discord

Cannot catch UnhandledPromiseRejectionWarning in promise

a 夏天 提交于 2020-01-15 09:17:10
问题 so I'm trying to catch UnhandledPromiseRejectionWarning in my promise, but for some reason it's not working. It ignores my code and just outputs the error to console. Error: UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Forbidden (Cannot send messages to this user) code: e.message.author.openDM().then((message) => { message.sendMessage(`test`); }).catch((error) => { e.message.channel.sendMessage(error + "test"); }); This is a discord bot, using

Remove 'command not found' error discord.py

北战南征 提交于 2020-01-13 20:33:08
问题 In a discord.py rewrite bot, if someone types the bots prefix and then any text after it, if the text is not found as a command you will get Ignoring exception in command None: discord.ext.commands.errors.CommandNotFound: Command "sd" is not found Is there anyway to stop the bot from logging this? 回答1: Write an on_command_error error handler that checks if the error is an instance of CommandNotFound , and ignores it if it is from discord.ext.commands import CommandNotFound @bot.event async

Did Discord.py change its API?

北战南征 提交于 2020-01-11 14:49:08
问题 For some reason the code that I have for a Discord bot worked perfectly fine just a few months ago, but now I am getting something saying that 'Bot' has no attribute to certain commands like 'say' discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Bot' object has no attribute 'say' 回答1: Yes. discord.py version 1.0, the "rewrite" version, was officially released on April 8th, and has supplanted the older "async" version 0.16. You should review the

Is it possible to check if user have PM's enabled?

白昼怎懂夜的黑 提交于 2020-01-11 14:07:13
问题 I'd like to know if there is a way to check if a User have Private Messages Enabled. This Feature is for an Support Bot. Currently I use the GuildMessageRecievedEvent and send a Private Message to the User. 回答1: No, there is not. You can only send a message and handle the failure: user.openPrivateChannel().submit() .thenCompose(channel -> channel.sendMessage(x).submit()) .whenComplete((message, error) -> { if (error != null) failed(); else success(); }); This is also shown as an example in

Is it possible to check if user have PM's enabled?

做~自己de王妃 提交于 2020-01-11 14:05:53
问题 I'd like to know if there is a way to check if a User have Private Messages Enabled. This Feature is for an Support Bot. Currently I use the GuildMessageRecievedEvent and send a Private Message to the User. 回答1: No, there is not. You can only send a message and handle the failure: user.openPrivateChannel().submit() .thenCompose(channel -> channel.sendMessage(x).submit()) .whenComplete((message, error) -> { if (error != null) failed(); else success(); }); This is also shown as an example in

how do you convert a python code that requires user input to work in a discord bot?

折月煮酒 提交于 2020-01-11 07:47:08
问题 So I have a piece of code and it requires user input multiple times (and what is inputed is not alway the same). Instead of passing the code to everyone in my discord I would like to make it directly into a discord bot so everyone can use it. How do I all the bot to take in a user msg after a code is given here is an example of kinda what I want: -.botcalc --this is discord bot, enter first number: -1 --enter second number: -2 --1+2 = 3 回答1: Using wait_for async def botcalc(self, ctx): author

Send message and shortly delete it

为君一笑 提交于 2020-01-11 07:01:05
问题 I'm trying to make a Discord bot delete its "system messages" after, say, 10 seconds, because I've been seeing a lot of "Invalid command" errors and "Done!" notifications, and I'd like to clear them out for actual messages. This is different from deleting messages where the user has a command; I already have that capability. 回答1: I recommend you send the message, wait for the response and delete the returned message after that time. Here's how it'd work: message.reply('Invalid command') .then

Send message and shortly delete it

牧云@^-^@ 提交于 2020-01-11 06:59:09
问题 I'm trying to make a Discord bot delete its "system messages" after, say, 10 seconds, because I've been seeing a lot of "Invalid command" errors and "Done!" notifications, and I'd like to clear them out for actual messages. This is different from deleting messages where the user has a command; I already have that capability. 回答1: I recommend you send the message, wait for the response and delete the returned message after that time. Here's how it'd work: message.reply('Invalid command') .then

Why doesn't multiple on_message events work?

三世轮回 提交于 2020-01-08 18:01:47
问题 Why can't I have multiple on_message events? import discord client = discord.Client() @client.event async def on_ready(): print('in on_ready') @client.event async def on_message(message): print("in on_message #1") @client.event async def on_message(message): print("in on_message #2") @client.event async def on_message(message): print("in on_message #3") client.run("TOKEN") For example, if I typed anything in discord, it's always only the last on_message that gets triggered. How can I get all

How do I create a new private text channel and add 2 people to it?

一笑奈何 提交于 2020-01-06 05:54:24
问题 I'm creating a discord bot where a user will message the bot and the bot will create a new PRIVATE text channel; preferably on the same server as the bot the bot will add only the messaging user and an admin to the channel I have been able to make a new channel using this question as a guide. I have not been able to make a private text channel or find a command that will allow me to do so. Does anyone know how to create a private text channel in discord.py and add 2 people (messaging user and