combining commands and events

To further develop this you need to fully understand what you’ve done and have a plan for what you want to do. I will first direct you to the discord python documentation Where you can see everything has to offer. This should probably be your first stop when you have questions.

I see you have import discord and from discord.ext import commands… has two ways to approach a bot, which you have:

client = discord.Client() hails from import discord, and bot = commands.Bot() hails from import discord.ext.

You need to choose whether to use discord.Client() or discord.Bot() because the use cases are entirely different. I suggest the latter, as it will allow your bot to do more, in a cleaner fashion.

Your next step would be to change any @ decorators to whichever variable you choose and keep that consistent throughout your code. Then, you need to remove whichever .run(TOKEN) you won’t use. So, if I were you, I would read the documentation which I linked to you so you understand more than a YouTube tutorial would teach.

As for a revision to your code, it would look like this:

import os
import discord
from dotenv import load_dotenv
from discord.ext import commands

TOKEN = os.getenv('DISCORD_TOKEN')
GUILD = os.getenv('DISCORD_GUILD')

bot = commands.Bot(command_prefix='$')

@bot.command(name='repeat', help='help me to understand bots')
async def test(ctx, *args):
    for arg in args:
        await ctx.send(arg)

async def on_raw_reaction_add(payload):
    print("someone reacted to something")

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top