python - 日志命令列表 .append() 在 discord.py 中不起作用
问题描述
我正在使用 discord.py 制作 Discord Bot。
由于某种原因.append()
不适用于 log 变量。
它给了我这个错误:
AttributeError: 'Command' object has no attribute 'append'
我在没有 discord.py 的普通脚本上对其进行了测试,并且成功了。
但是由于某种原因,如果我将脚本放在机器人上,它会说
命令代码:
global log
log = ["Spam Log :"]
@client.command()
async def spam(ctx, speed=None, *text):
global log
log.append(f"{text} - Spammed By {ctx.author} at {speed} speed.")
if speed == None:
await ctx.send("Please put a speed and text")
return
try:
if str(ctx.guild.id) == "854947008304119809" and str(ctx.channel.id) == "868123051030638652":
import asyncio
global spamming
spamming = True
while spamming == True:
await ctx.send(" ".join(text[:]))
await asyncio.sleep(int(speed))
else:
await ctx.send("Please do it on <#868123051030638652>.")
except:
text = "An error accured, please try again with valid numbers."
await ctx.send(text)
```
解决方案
推荐阅读
- wordpress - 谷歌在网站上说恶意软件,我已经搜索并运行扫描但找不到它
- mysql - 无法在 XAMPP、Windows 10 上启动 MySql 服务
- java - Android Studio 应用程序无法使用 MySQL 登录
- javascript - 添加JS代码后按钮提交两次防止多次点击
- php - 使草稿帖子仅对管理员可见
- python - 我无法安装 scikit_learn 库
- javascript - 识别用户的内部 IP 地址
- python - python中绑定方法和实例方法的区别
- vee-validate - VeeValidate 3.1 如何在外部文件和每个组件中添加规则
- reactjs - 在终端中启动 npx create-react-app 后,我在终端中收到此错误