J3htro
J3htro

Reputation: 290

Discord bot commands execute multiple times

It worked at first, but then somewhy it started to give the answers 4-5 times at once, any idea why?

import discord
from discord.ext import commands

client = commands.Bot(command_prefix = '.')

@client.event
async def once_ready():
    print('Bot is ready.')

@client.event
async def on_member_join(member):
    print(f'{member} has joined the server.')

@client.event
async def on_member_remove(member):
    print(f'{member} has left the server.')

@client.command()
async def ping(ctx):
    await ctx.send('Pong!')

client.run('my token here')

Upvotes: 1

Views: 1597

Answers (1)

J3htro
J3htro

Reputation: 290

So, the problem was that I couldn't shut down the already running bots in Atom.

  • If you add the code that I wrote down there (that only the owner can use) will shut down the already running bots (write /shutdown in discord server or whatever your prefix is).

However, you may need a PC restart after saving the bot with this code.

@client.command()
@commands.is_owner()
async def shutdown(ctx):
    await ctx.bot.logout()
  • So every time if you want to edit your command, you write /shutdown and edit it, after that, you can start it again.

I hope this works for you and that I could help if you had the same problem.

Upvotes: 1

Related Questions