问题描述
@bot.command(pass_context=True)
async def move(ctx,member: discord.Member,channel: discord.VoiceChannel):
await member.edit(voice_channel=channel)
我试图使如果未设置频道,然后使其变为687744572042117117243 有什么想法吗?
解决方法
有2种方法:
- 将其设置为“无”,然后签入命令。
- 直接在参数中设置频道
第一种方式:
@bot.command()
async def move(ctx,member: discord.Member,channel: discord.VoiceChannel=None):
channel = channel if channel else bot.get_channel(687744572042117243)
await member.edit(voice_channel=channel)
第二种方式:
@bot.command()
async def move(ctx,channel: discord.VoiceChannel=bot.get_channel(687744572042117243)):
await member.edit(voice_channel=channel)