不和谐机器人创建“通道”变量

2024-06-26 13:45:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我发现了python discord bot模块,这是练习python的一个非常好的练习。 因此,使用discord模块,我尝试创建一个频道,同时将其放入一个变量中(我不想在创建后在列表中搜索该频道)

下面是我要执行的代码:

import discord  
from discord.ext import commands 

client = commands.Bot(command_prefix = "?")

@client.event 
async def on_ready():
    server = client.get_server(os.environ['DISCORD_SERVER_ID]) 
    cCurrent = client.create_channel(server, str("%s 0" %(pokeName)))
[...]
    await client.send_message(cCurrent, embed=raid.embed())

执行此代码时,出现错误:

^{pr2}$

所以我假设client.create_channel还没有执行,使用python是正常的吗?在

如何同时在客户机和变量中创建新的channel对象?在


Tags: 模块代码fromimportclient列表serverbot