def unlink(self, ctx, text: discord.TextChannel, *, voice: discord.VoiceChannel):
"""Unlinks a voice channel and deletes the corresponding role."""
with ctx.session:
link = ctx.session.get(TextVoiceLink, text_id=text.id, voice_id=voice.id).one_or_none()
if link is None:
return await ctx.send('BAKA! Those channels are not linked!')
role_id, text_id, voice_id = link.role_id, link.text_id, link.voice_id
ctx.session.delete(link)
role = discord.utils.get(ctx.guild.roles, id=role_id)
if role is None:
await ctx.send(content='Unlinked {} from "{}" and deleted the "{}" role.'.format(text.mention, voice.name, role.name))
else:
await self._delete_role(ctx.guild, role, text, voice, 'Voice unlink requested by {}'.format(ctx.author))
await ctx.send(content='Unlinked {} from "{}" and deleted the "{}" role.'.format(text.mention, voice.name, role.name))
评论列表
文章目录