python - 每当我尝试它们时,我的不和谐机器人命令都不起作用(无论有没有语法)机器人不说话
问题描述
这是我的代码,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)
解决方案
删除第 11 行并添加
client.run(os.getenv('TOKEN'))
到最后。
推荐阅读
- sql - IBM Informix Server - 列出具有 DBSECADM 角色的用户
- reactjs - 是否可以通过 API 调用来初始化 React 应用程序中的 Global Store?
- gcc - LLVM/Clang 是否由 GCC 引导/编译?
- c# - 在 C# 中使用 Selenium 下载图像
- python - 解释 HDBSCAN 聚类的行为
- python - 将数字作为一个整体循环,将字符串作为单数循环
- python - 在输入的字符串处拆分句子并使用第二个拆分部分
- bash - 处理 Terraform 模板文件和 Bash 脚本的解析错误
- sql-server - XML 查询非常慢,当 XML 类型的 .value 方法包含属性过滤器时
- c# - CSOM ListCollectionItems 计数基于文件夹路径性能问题