创建一个非常简单的不和谐机器人的最佳方法=
Best way to create a very simple discord bot=
嘿,我真的很想知道是否可以通过一种简单的方式制造不和谐?
我实际上得到了这个脚本,但是在我 运行 它
之后它崩溃了几次
import discord
client = discord.Client()
@client.event
async def on_ready():
print("The bot is ready!")
await client.change_presence(game=discord.Game(name="Making a bot"))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content == "Hello":
await client.send_message(message.channel, "World")
client.run('***************************************************************')
我收到这个错误:
The bot is ready!Ignoring exception in on_ready
Traceback (most recent call last):
File "C:\Users\Sigmanificient\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\client.py", line 270, in _run_event
await coro(*args, **kwargs)
File "C:\Users\SigmanificientD Objects\PyNG\discord_bot.py", line 7, in on_ready
await client.change_presence(game=discord.Game(name="Making a bot"))
TypeError: change_presence() got an unexpected keyword argument 'game'
我会为不同的消息制作多个遮阳篷。
我相信游戏关键字已更改为 activity
await client.change_presence(activity=discord.Game(name="Making a bot"))
您可能需要大写 activity
无论您从何处获取该代码,请确保您使用的 discord.py 版本与它们相同。否则你会得到错误。我最近不得不对我的一个机器人进行重大重写,因为它使用的是旧代码。
在这种情况下,Client.change_presence 中的游戏关键字参数已重命名为 activity,因此您要查找的内容类似于:
await client.change_presence(activity=discord.Game(name="with the API"))
嘿,我真的很想知道是否可以通过一种简单的方式制造不和谐?
我实际上得到了这个脚本,但是在我 运行 它
之后它崩溃了几次import discord
client = discord.Client()
@client.event
async def on_ready():
print("The bot is ready!")
await client.change_presence(game=discord.Game(name="Making a bot"))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content == "Hello":
await client.send_message(message.channel, "World")
client.run('***************************************************************')
我收到这个错误:
The bot is ready!Ignoring exception in on_ready
Traceback (most recent call last):
File "C:\Users\Sigmanificient\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\client.py", line 270, in _run_event
await coro(*args, **kwargs)
File "C:\Users\SigmanificientD Objects\PyNG\discord_bot.py", line 7, in on_ready
await client.change_presence(game=discord.Game(name="Making a bot"))
TypeError: change_presence() got an unexpected keyword argument 'game'
我会为不同的消息制作多个遮阳篷。
我相信游戏关键字已更改为 activity
await client.change_presence(activity=discord.Game(name="Making a bot"))
您可能需要大写 activity
无论您从何处获取该代码,请确保您使用的 discord.py 版本与它们相同。否则你会得到错误。我最近不得不对我的一个机器人进行重大重写,因为它使用的是旧代码。
在这种情况下,Client.change_presence 中的游戏关键字参数已重命名为 activity,因此您要查找的内容类似于:
await client.change_presence(activity=discord.Game(name="with the API"))