Skip to content
Advertisement

Tag: discord

How to get a user’s avatar with their id in discord.py?

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

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

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

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

Advertisement