I tried using the following code but it didn’t work. Edit: For anyone that had a similar problem, while not mentioned in the docs, discord.Member can take user ids aside from @username so there isn’t any need for a complicated way. Answer I’m presuming you’re Tagging the user with @UserNameHere in discord. It’s much easier to take that input as
Tag: discord
How to receive and send message to specific channel in Discord.py?
Yesterday I was working on something simple where a bot on command of !name Barty would print back Hello Barty However the problem I am facing at this moment is that the bot would response to any channel where I do use the !name XXXX and what I am trying to do is that I want only to react to
Which method is the best for starting the bot in discord.py? login() and connect() vs start() vs run()
So, to connect the bot to discord.py, there are several methods: discord.Client().login() + discord.Client().connect() discord.Client().start() discord.Client().run() What is the difference between them and which one is the best for running the bot? Answer I believe the official documentation is very clear: start() is shorthand coroutine for login() + connect(). run() is a blocking call which means that This function must
Discord.py how do I send a DM to anyone I want through a command
Someone asked me to make a bot for him that sends a DM to anyone he specifies through a command, like *send_dm @Jess#6461 hello. I’ve searched alot and I came across this code: but then I got the error: discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: ‘Bot’ object has no attribute ‘send_message’ I want to type for example : *send_dm @Jess#6461
Discord.py (rewrite): Error Handling “Improper Token” In Function
I feel like I’m missing a simple way to solve this problem, but I can’t seem to find a way to handle the discord.errors.LoginFailure: Improper token has been passed. error. What I’m trying to do is run a function that essentially runs a bot and repeats itself if it comes across any errors (with try: and except:) and if it
How to Make a Discord Bot Asynchronously Wait for Reactions on Multiple Messages?
tl;dr How can my bot asynchronously wait for reactions on multiple messages? I’m adding a rock-paper-scissors (rps) command to my Discord bot. Users can invoke the command can be invoked by entering .rps along with an optional parameter, specifying a user to play with. When invoked, the bot will direct-message (DM) the user who invoked it and the target user
Print online users to console, Discord.py
When I execute the command using my current code, I get the error NameError: name ‘offline’ is not defined. I can’t find the correct variables to make it work properly. Answer According to the API reference, you could use PS. I know nothing about this library, yet I tried searching the docs. Give it a try from now on :)
How to make a command case insensitive in discord.py
How would one make a command case-insensitive without adding many aliases for different capitalizations like this: Answer On the rewrite branch, commands.Bot accepts a case_insensitive parameter Note that there is a performance loss when using this feature.
Finding author of a message
If someone writes “?name (arg)” I want my bot to say the author of the message + “, your name is” + arg. I can’t find of the author of the message though. Answer To get the name of the author of the message, you will need to use context
Deleting User Messages in Discord.py
Is there any way to delete a message sent by anyone other than the bot itself, the documentation seems to indicate that it is possible Your own messages could be deleted without any proper permissions. However to delete other people’s messages, you need the proper permissions to do so. But I can’t find a way to target the message to