【问题标题】:Discord bot is not running for some reason CLOSEDDiscord 机器人由于某种原因没有运行
【发布时间】:2021-09-07 23:51:53
【问题描述】:

我的机器人需要帮助,我之前都编写过代码,但后来发生了一些事情,我制作了一个新的,但当我运行代码时它无法正常工作,但机器人不在线或不响应命令

import discord 
from keep_alive import keep_alive 

client = discord.Client() 

@client.event async def on_ready(): print('we have logged in as {0.user}').format.client

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

if message.content.startswith('$cmds'): 

await message.channel.send("Hello! how are you, my current commands are $cmds and $ping more coming soon!") keep_alive() client.run(os.getenv("Token"))

enter image description here

[在此处输入图片描述][2]

[2]:https://i.stack.imgur.com/URmvr.jpg![enter此处的图片描述](https://i.stack.imgur.com/ei20c.jpg)

【问题讨论】:

  • 你能把你的代码和错误发在这里吗?
  • 没有它说它已经全部登录但它没有
  • 请在此处发送代码,编辑您的问题并粘贴您的代码
  • 好的,现在就在那里

标签: python discord bots helper


【解决方案1】:

建议你使用命令框架:-

import discord
from discord.ext import commands

@client.command()
async def cmds(ctx):
  await ctx.send("Hello! how are you, my current commands are $cmds and $ping more coming soon!")

【讨论】:

  • 你能帮我完成整个代码吗?请喜欢up time bot命令和东西吗?
  • 呃,我不能。您可以浏览docs或观看一些 yt 教程
  • 它只是在我运行代码时这样说(查看原始问题)
  • 表示你的token错误,从discord developer portal插入正确的token
猜你喜欢
  • 1970-01-01
  • 2021-04-13
  • 2021-12-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-12-27
相关资源
最近更新 更多