def _purge_casino(self, ctx):
"""Removes all servers that the bot is no longer on.
If your JSON file is getting rather large, utilize this
command. It is possible that if your bot is on a ton of
servers, there are many that it is no longer running on.
This will remove them from the JSON file.
"""
author = ctx.message.author
servers = super().get_all_servers()
purge_list = [x for x in servers if self.bot.get_server(x) is None]
if not purge_list:
return await self.bot.say("There are no servers for me to purge at this time.")
await self.bot.say(_("I found {} server(s) I am no longer on. Would you like for me to "
"delete their casino data?").format(len(purge_list)))
response = await self.bot.wait_for_message(timeout=15, author=author)
if response is None:
return await self.bot.say(_("You took too long to answer. Canceling purge."))
if response.content.title() == _("Yes"):
for x in purge_list:
servers.pop(x)
super().save_system()
await self.bot.say(_("{} server entries have been erased.").format(len(purge_list)))
else:
return await self.bot.say(_("Incorrect response. This is a yes or no question."))
评论列表
文章目录