![]() In discord there is generally no easy way to react to this content or gauge how relevant it is to the server. In a given server, participants will often post content, whether it be funny images or New York Times articles. Now your bot will be able to send a custom emoji! Reacting to images/embeds Let’s implement it: import random async def on_message(message): if : # if the message was written by the bot, ignore it return bot_reactions = # new start bot_reactions.append() # end if (random.randint(0, 100) > 97): await message.add_reaction(random.choice(bot_reactions)) await bot.process_commands(message) # run all bot commands # if you do not include the above command, the bot will not # run any of your defined commands Click on Open LinkĪs long as the bot is in the same server and now that we have the ID, we can reference that emoji in our code with the syntax Let’s create a discord bot that sends random emoji reactions to certain messages: import random async def on_message(message): if : # if the message was written by the bot, ignore it return bot_reactions = if (random.randint(0, 100) > 97): await message.add_reaction(random.choice(bot_reactions)) await bot.process_commands(message) # run all bot commands Implementing Custom ReactionsĪfter adding a custom reaction to your server, send it in a message and then right click on it. Go to your bot.py file and define a new bot event like this: async def on_message(message): # define some action to do when receiving a message. ![]() To implement this, we need to define a bot event. ![]() Every discord server can have up to 50 free custom reactions. In discord, ‘reactions’ are a type of picture or emoji which users can add to messages. We will be implementing bot features which can add default and custom reactions to messages.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |