discord

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

Check if command is ran in certain channel

时光怂恿深爱的人放手 提交于 2021-02-11 06:48:46
问题 I currently have this as my command: bot.on('message', function (message) { if (message.content == '!register') { message.member.send("Registered!"); let memberRole = message.member.guild.roles.find("name", "Verified"); message.member.addRole(memberRole); } }); I want it so this command can only be ran in a text channel called registration (I have the channel id if needed). 回答1: Here is the code if you only have one textchannel called registration : bot.on('message', function (message) { if

Check if command is ran in certain channel

做~自己de王妃 提交于 2021-02-11 06:48:19
问题 I currently have this as my command: bot.on('message', function (message) { if (message.content == '!register') { message.member.send("Registered!"); let memberRole = message.member.guild.roles.find("name", "Verified"); message.member.addRole(memberRole); } }); I want it so this command can only be ran in a text channel called registration (I have the channel id if needed). 回答1: Here is the code if you only have one textchannel called registration : bot.on('message', function (message) { if

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

Heroku build failing on dependency install

雨燕双飞 提交于 2021-02-10 19:51:52
问题 Node Canvas isn't installing on Heroku build, even though it works just fine on my own PC. I'm on nodejs version 12.16.3. I can't find a solution for this anywhere. Canvas is a must, and I've never seen this error before until Heroku. Is this a problem with Heroku or a problem with my package/package-lock files? My Discord is Tom Becker#0590 in case you need it. Here's my build log: -----> Node.js app detected -----> Creating runtime environment NPM_CONFIG_LOGLEVEL=error NODE_ENV=production

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')