Discord.py 代码无效!我怎样才能解决这个问题?
Discord.py code doesn't work! How can i fix this?
为什么这不起作用?当我 运行 代码并尝试 !test 时,它甚至不会向终端发送错误。我该如何解决这个问题?
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix="!")
bot.command()
async def test(ctx):
ctx.send("test")
bot.run(token)
您缺少装饰器符号
@bot.command()
此外,您的 test
函数中的发送消息指令需要等待
@bot.command()
async def test(ctx):
await ctx.send("test")
为什么这不起作用?当我 运行 代码并尝试 !test 时,它甚至不会向终端发送错误。我该如何解决这个问题?
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix="!")
bot.command()
async def test(ctx):
ctx.send("test")
bot.run(token)
您缺少装饰器符号
@bot.command()
此外,您的 test
函数中的发送消息指令需要等待
@bot.command()
async def test(ctx):
await ctx.send("test")