问题描述
我已经在网上搜索了很多关于此的内容.在那里我遇到了 API 参考(https://discordpy.readthedocs.io/en/rewrite/api.html#discord.TextChannel) 哪一种帮助我找到了我需要使用的命令.所以我的结论是使用这个代码:
i've already searched a lot about this online. There I came across the API Refrence (https://discordpy.readthedocs.io/en/rewrite/api.html#discord.TextChannel) which kind of helped me finding what command I need to use. So my conculsion would be to use this code:
channel = client.get_channel(475772135730708480)
@client.command()
async def emoivb(ctx):
await discord.VoiceChannel.edit(channel, name = "test")
问题是它不能解决这个错误:
the problem is that it doesnt work with this error:
File "C:/Users/MyUser/Desktop/discordbot.py", line 25, in emoivb
await discord.VoiceChannel.edit(channel, name = "test")
所以这个错误根本没有帮助我......但我确定我只是没有正确理解 API 引用并且没有使用应该使用的命令.我对 python 编码很陌生,所以这是最有可能发生的事情.如果有人有更多的python知识并且能够理解我做错了什么,我将非常感谢您的帮助!:)
So this error doesnt help me at all... but im sure I just didnt understand the API refrence correctly and didnt use the command as it is supposed to be used. Im pretty new to python coding so that is the most likely thing to have happended.If anyone has some more python knowledge and is able to understand what I did wrong I would really appreciate your help! :)
推荐答案
更简单的方法是在命令中指定目标通道和名称,例如
The easier way would be to specify the target channel and name in the command, something like
@client.command()
async def emoivb(ctx, channel: discord.VoiceChannel, *, new_name):
await channel.edit(name=new_name)
但这并不完美:对于带有空格的名称,您必须将现有频道名称括在引号中
This isn't perfect though: For names with spaces you'll have to enclose the existing channel name in quotes
!rename "Old Channel" New Channel
这是因为 Discord 不支持提及语音频道.
This is because Discord doesn't support mentioning voice channels.
这篇关于如何使用 discord.py v.1.0.0a 更改频道名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!