def leave(self, ctx, guild=None):
"""
Leaves a specified guild
"""
guild_names = list("{} - ID: {}".format(g.name, g.id) for g in self.bot.guilds)
if guild is None:
guild = await reaction_menu.start_reaction_menu(
self.bot, guild_names, ctx.author, ctx.channel, count=1,
timeout=60, per_page=10, header=header, return_from=self.bot.guilds, allow_none=True)
guild = guild[0]
else:
guild = discord.utils.find(lambda s: s.name == guild or str(s.id) == guild, self.bot.guilds)
if guild is None:
await ctx.send("Unable to locate guild")
return
try:
await guild.leave()
await ctx.send("`Successfully left the guild`")
except discord.HTTPException:
await ctx.send("`Leaving the guild failed!`")
评论列表
文章目录