#Fix discord bot program bug

14 messages · Page 1 of 1 (latest)

tropic shale
#

How to fix?

tropic shale
#

Fix discord bot program bug

hardy swan
#

你为啥用手机编程

#

could you send entire code

tropic shale
hardy swan
#

can you send entire code

hardy swan
tropic shale
hardy swan
#

ok

tropic shale
# hardy swan could you send entire code

import discord
from discord import app_commands
from discord.ext import commands

intents = discord.Intents.default()
intents.message_content = True

class MyBot(commands.Bot):
def init(self):
super().init(command_prefix="!", intents=intents)

async def setup_hook(self):
    self.tree.add_command(ping)
    self.tree.add_command(hello)
    await self.tree.sync()

bot = MyBot()

@bot.event
async def on_ready():
print(f'Logged on as {bot.user}!')

@bot.event
async def on_message(message):
if message.author == bot.user:
return

@bot.command()
async def ping(ctx):
await ctx.send('pong')

@bot.tree.command(name="ping", description="Returns pong!")
async def ping(interaction: discord.Interaction):
await interaction.response.send_message("pong")

@bot.tree.command(name="hello", description="Says hello to the user.")
async def hello(interaction: discord.Interaction):
await interaction.response.send_message(f"Hello, {interaction.user.name}!")

bot.run('TOKEN')

hardy swan
#

why did you define ping twice

#

not really sure how discord py works but does it work locally?

#

or is there only a problem when you use replit