更改不和谐语音通道的名称

时间:2021-01-25 23:59:30

标签: python discord.py

我正在尝试更改我的 Discord 服务器的名称,但我不确定如何执行此类操作。

这是我目前的完整代码:

import discord
import os
from dotenv import load_dotenv
from discord.ext import commands
import asyncio
from string import digits, ascii_letters

load_dotenv()
DISCORD_TOKEN = os.getenv("DISCORD_TOKEN")
bot = commands.Bot(command_prefix="$")


@bot.event
async def on_ready():
    print("It's ready")


@bot.command()
async def change(ctx):
    channel = 203487901092817113
    ctx.message.channel.edit(name="hello")


bot.run(DISCORD_TOKEN)

2 个答案:

答案 0 :(得分:1)

可以使用 guild.create_voice_channel

创建语音频道
await guild.create_voice_channel("voice channel",overwrites=None, category="category",reason=None)
voice_channel= client.get_channel(11123323002020)
await voice_channel.edit(name=f"This is a voice")

编辑与消息通道完全一样,只是获取语音通道的id,然后运行命令,获取/找到指定的通道并进行编辑。

频道编辑的速率限制为每 5 分钟 2 个请求

答案 1 :(得分:0)

您需要一个 await 关键字。

await ctx.message.channel.edit(name="hello")