【发布时间】:2020-09-27 07:14:57
【问题描述】:
所以我在这里做一个小项目,而且我非常想拥有其中一个“请输入此服务器中频道的名称”功能。
差不多,机器人会询问频道名称,我输入例如“#changelog” - 然后它会询问它应该在该频道中写入什么等等。 所以需要获取频道ID(我猜),但我不希望用户写ID,而只写#server-name。然后每当我这样做时,机器人就会在该频道中写入。
这是我当前的代码!
class Changelog(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_ready(self):
print('Changelog is loaded')
@commands.command()
async def clhook(self, ctx):
await ctx.send('Write text-channel: ')
text_channel = await self.client.wait_for("message", check=lambda message: message.author == ctx.author, timeout=300)
clhook = self.client.get_channel(text_channel)
def setup(client):
client.add_cog(Changelog(client))
编辑: 频道 ID 将“永远”保存,这意味着我不必重写消息应该去哪里的频道名称!
【问题讨论】:
标签: discord.py discord.py-rewrite