Discord.py get user object from id/tag
If you know the user id, I suggest using bot.get_user(user_id) instead.
If you know the user id, I suggest using bot.get_user(user_id) instead.
Note: I will include a version for pycord at the end because I think it’s much simpler, also it was the original answer. discord.py version First make sure that you have the newest version of discord.py installed. In your code, you first import the library: import discord from discord import app_commands and then you define … Read more
What you can do is use an async/await function and a loop to make sequntial requests async function lots_of_messages_getter(channel, limit = 500) { const sum_messages = []; let last_id; while (true) { const options = { limit: 100 }; if (last_id) { options.before = last_id; } const messages = await channel.fetchMessages(options); sum_messages.push(…messages.array()); last_id = messages.last().id; … Read more
Yup, it should be possible. You need the bot/user account to have the Manage Messages permission. @client.event async def on_message(message): await message.delete() So, the event would occur something like User sends message Bot detects that the user has sent a message Bot deletes the message that the user sent Hopefully from this you should be … Read more
I know your problem is already solved, but I will post an answer so that people who have this same problem will be able to find the solution easily. To send an image or GIF, here are two options (adapted from here): Opening the file and sending it directly to the channel: with open(‘my_image.png’, ‘rb’) … Read more
Updated answer for 2021 (discord.py 1.x – 2.x): discord.py currently supports Python 3.5 and up. If you receive a SyntaxError, it means you’re using an older version of Python and isn’t supported by discord.py. First, install a later version of Python (3.8.x is preferred as of this message), and run python3.8 bot.py or py -3.8 … Read more
You need to enable the GUILD_MESSAGES intent: const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] }); This will enable you to receive the MESSAGE_CREATE event for messages sent in guilds. A full list of intents can be found on the Discord developer docs. Additionally, if you are using Discord.js v13, the message event has been … Read more
create_ytdl_player was the old way of creating a player. With discord.py@rewrite (> v.1.0), playing music is a bit more complicated. There are two ways to play music. For both ways, using FFmpeg will be necessary, so you’ll have to install it. Here are two of ways to play videos (with youtube-dl and ffmpeg): From file … Read more
From https://github.com/Rapptz/discord.py/issues/390: It’s <:emoji_name:emoji_id> for custom emojis. You can also find the discord.Emoji instance through Server.emojis and then cast it to str.
Other than avoiding the error, there’s a way to get around it. If discord.errors.HTTPException: 429 appears in the console on replit, just use the command kill 1 in the shell. This command completely exits the script, and when you click run again it will run from a different IP Address, bypassing the Discord rate limit. … Read more