discord.py

How to get how many messages has been sent in a channel

六月ゝ 毕业季﹏ 提交于 2021-02-11 08:57:47
问题 I am trying to get the number of how many messages have been sent in a channel, and using the logs_from() function wont work because that only accepts a fixed amount of messages to retrieve, how do I do this? 回答1: In the discord.py-rewrite branch, there is a TextChannel.history AsyncIterator . If you pass limit=None , it will return all the messages from the channel @bot.command() async def message_count(ctx, channel: discord.TextChannel=None): channel = channel or ctx.channel count = 0 async

Get Discord user ID from username

我们两清 提交于 2021-02-11 06:27:28
问题 If I have a user's Discord name and discriminator as a string (e.g ExampleUser#1234 ) how can I get their user ID from it? I've found get_user(id) , but that returns a user object from an ID. I'm using Python and Discord.py. 回答1: In one line just do discord.utils.get(client.get_all_members(), name="ExampleUser", discriminator="1234").id notice the .id at the end, that gives you the ID of that person. Also for the discriminator part don't include the hash(#) 回答2: As stated in this excellent

discord.py-rewrite Blacklist certain people from using the bot

梦想与她 提交于 2021-02-11 05:12:57
问题 I am making a bot similar to "Discord Deliver" and "Discord Byte" where people can order virtual food, and I want to be able to black list certain people from using the bot. Is there any way of doing this? For all my commands i use @bot.command ; I am specifying this as some people use on_message . Sorry that I don't have anything I've tried, I am relatively new to discord.py-rewrite. 回答1: You can make a set containing their names and exit the function if the command's author's name is in

discord.py-rewrite Blacklist certain people from using the bot

好久不见. 提交于 2021-02-11 05:10:29
问题 I am making a bot similar to "Discord Deliver" and "Discord Byte" where people can order virtual food, and I want to be able to black list certain people from using the bot. Is there any way of doing this? For all my commands i use @bot.command ; I am specifying this as some people use on_message . Sorry that I don't have anything I've tried, I am relatively new to discord.py-rewrite. 回答1: You can make a set containing their names and exit the function if the command's author's name is in

discord.py-rewrite Blacklist certain people from using the bot

。_饼干妹妹 提交于 2021-02-11 05:10:00
问题 I am making a bot similar to "Discord Deliver" and "Discord Byte" where people can order virtual food, and I want to be able to black list certain people from using the bot. Is there any way of doing this? For all my commands i use @bot.command ; I am specifying this as some people use on_message . Sorry that I don't have anything I've tried, I am relatively new to discord.py-rewrite. 回答1: You can make a set containing their names and exit the function if the command's author's name is in

Check reaction user not work for specific user?

风流意气都作罢 提交于 2021-02-11 04:55:28
问题 I'm trying to make the bot reaction only change for the specific user that do !pages command, I tried message.author and reaction.message.author == message.author but it didn't work! The issue is that when someone used this command, it will also worked for others which is not what I expected.. Here's the code from discord.ext import commands bot = commands.Bot(command_prefix='!') left = '⏪' right = '⏩' messages = ("1", "2", "3") def predicate(message, l, r): def check(reaction, user): if

Python message.content discord bot

隐身守侯 提交于 2021-02-10 18:43:50
问题 I would like a help, I am trying to make my bot in discord to respond automatically when someone writes some word, the problem is that the command only works if the word is the first thing to be written in the sentence. I wish my bot could respond to the message even when the word is in the middle of some sentence. What should I do? 回答1: Bot = commands.Bot(command_prefix="") @Bot.event async def on_message(message): if "not" in message.content: await Bot.send_message(message.channel, 'yes')

Python message.content discord bot

大憨熊 提交于 2021-02-10 18:41:53
问题 I would like a help, I am trying to make my bot in discord to respond automatically when someone writes some word, the problem is that the command only works if the word is the first thing to be written in the sentence. I wish my bot could respond to the message even when the word is in the middle of some sentence. What should I do? 回答1: Bot = commands.Bot(command_prefix="") @Bot.event async def on_message(message): if "not" in message.content: await Bot.send_message(message.channel, 'yes')

How do I prevent a user from sending more than one message in a channel?

别来无恙 提交于 2021-02-10 17:03:35
问题 User 1: Hello! User 1: How are you? User 2: I'm good. User 2: hbu User 3: hey guys! User 1: i'm doing fine I'm trying to delete the second message from User 1 and User 2, so that any user can only send a single message. I was told to use channel.history , but I can't think of a way to compare the author's of the messages to make sure they aren't the same person. This is what I want: I want to prevent double posting: User 1: Hello! How are you? User 2: I'm good, hbu. User 3: hey guys! User 1:

How do I prevent a user from sending more than one message in a channel?

隐身守侯 提交于 2021-02-10 17:03:34
问题 User 1: Hello! User 1: How are you? User 2: I'm good. User 2: hbu User 3: hey guys! User 1: i'm doing fine I'm trying to delete the second message from User 1 and User 2, so that any user can only send a single message. I was told to use channel.history , but I can't think of a way to compare the author's of the messages to make sure they aren't the same person. This is what I want: I want to prevent double posting: User 1: Hello! How are you? User 2: I'm good, hbu. User 3: hey guys! User 1: