【发布时间】:2020-05-18 01:28:31
【问题描述】:
我正在发出一个命令,用户可以在其中创建和删除私人语音频道。对于我想要添加或删除频道的部分,它希望我添加一个变量。我需要它来删除用户所在的语音频道。比你提前
代码:
client.command()
async def room(ctx, activity=None, *, member : discord.Member = None):
if activity == "STREAMING".lower():
guild = ctx.guild
user = ctx.author
await guild.create_voice_channel(f"Streaming Room - {user}")
await ctx.send("Created streaming room!")
elif activity == "RECORDING".lower():
guild = ctx.guild
user = ctx.author
channel = await guild.create_voice_channel(f"Recording Room - {user}")
everyone = ctx.message.author.guild.default_role
disallow = discord.PermissionOverwrite()
disallow.read_messages = False
disallow.send_messages = False
await channel.set_permissions(everyone, overwrite=disallow)
await ctx.send("Created recording room!")
elif activity == 'ADD'.lower():
await ctx.send(f"{member.mention} has been added to your room")
allow = discord.PermissionOverwrite()
allow.connect = True
allow.speak = True
await channel.set_permissions(member, overwrite=allow)
else:
await ctx.send('Please specify what activity you would like to be doing [streaming, recording]')
【问题讨论】:
标签: python discord discord.py discord.py-rewrite