首页 > 解决方案 > 每当我尝试它们时,我的不和谐机器人命令都不起作用(无论有没有语法)机器人不说话

问题描述

这是我的代码,IDE 没有给出错误,但如果你能提供帮助,我的机器人仍然不会说话;-;

import discord
import requests
import random
import os
import flask
from discord.ext import commands
client = commands.Bot(command_prefix= '.')
client = discord.Client()
@client.event
async def on_ready():
  print('Bot ready to launch as {0.user}'.format(client))
client.run(os.getenv('TOKEN'))
@client.command()
async def ping(ctx):
    await ctx.send(':ping_pong: PONG!')
@client.command(name='test', aliases=['testcommand','testing'])
async def test(ctx, arg):
    return ctx.send(arg)
    
@client.command(name='purge')
async def clear(ctx, amount:int):
      await ctx.channel.purge(limit=amount)

标签: pythonbotsdiscord.py

解决方案


删除第 11 行并添加

client.run(os.getenv('TOKEN'))

到最后。


推荐阅读