首页 > 解决方案 > 如何在 pythons 中为不和谐的机器人使用 client.delete_channel() 命令

问题描述

我需要知道如何在 discord.py 中使用 delete_channel 命令可能有人请发布代码示例

标签: pythondiscord.py

解决方案


以下是使用命令删除频道的方法

from discord.ext.commands import Bot
import discord

bot=Bot(command_prefix='.')

这是在async版本中,可能是您正在使用的版本


@bot.command(pass_context=True)
async def del_chan(msg,channel:discord.Channel):
    await bot.delete_channel(channel)

这是在rewrite

@bot.command()
async def del_channel(msg,chan:discord.TextChannel):
    await chan.delete()

要使用您会执行的命令.del_chan #channel_name, .del_chan channel_name, .del_channel #channel_name, 或.del_channel channel_name


推荐阅读