Added possibility to cancel a running vote
This commit is contained in:
parent
daa2a094f2
commit
45afcee8fb
|
|
@ -425,6 +425,15 @@ class Game:
|
||||||
if not passed:
|
if not passed:
|
||||||
await self.increase_chaos()
|
await self.increase_chaos()
|
||||||
|
|
||||||
|
@vote_running
|
||||||
|
@save_on_success
|
||||||
|
async def cancel_vote(self):
|
||||||
|
logger.debug(f"[{self.guild.name}] Cancelling the vote")
|
||||||
|
vote_message_id = self.config["vote"]["message"]
|
||||||
|
self.config["vote"] = None
|
||||||
|
if vote_message_id is not None:
|
||||||
|
await (await self.get_votes_channel().fetch_message(vote_message_id)).edit(content = "~~The vote has been canceled~~")
|
||||||
|
|
||||||
@game_started
|
@game_started
|
||||||
@save_on_success
|
@save_on_success
|
||||||
async def increase_chaos(self):
|
async def increase_chaos(self):
|
||||||
|
|
|
||||||
18
SecretBot.py
18
SecretBot.py
|
|
@ -244,6 +244,24 @@ class SecretBot(commands.Cog):
|
||||||
await game.stop_vote()
|
await game.stop_vote()
|
||||||
await ctx.message.delete()
|
await ctx.message.delete()
|
||||||
|
|
||||||
|
@commands.command("CancelVote", help = "Cancel the current vote, applying no consequences")
|
||||||
|
async def cancel_vote_with_confirmation(self, ctx: commands.Context):
|
||||||
|
game = await self.get_running_game_or_error_message(ctx)
|
||||||
|
await self.check_is_administrator_or_gm(ctx)
|
||||||
|
if game.is_vote_running():
|
||||||
|
await self.confirm_action("Do you really want to cancel the vote (applying no consequences)?", ctx.channel, self.cancel_vote(ctx), ctx.message)
|
||||||
|
else:
|
||||||
|
await ctx.reply(":x: No vote is running")
|
||||||
|
|
||||||
|
async def cancel_vote(self, ctx: commands.Context):
|
||||||
|
game = await self.get_running_game_or_error_message(ctx)
|
||||||
|
await self.check_is_administrator_or_gm(ctx)
|
||||||
|
if game.is_vote_running():
|
||||||
|
await game.cancel_vote()
|
||||||
|
await ctx.reply(":white_check_mark: The current vote has been canceled.")
|
||||||
|
else:
|
||||||
|
await ctx.reply(":x: Not vote is running")
|
||||||
|
|
||||||
@commands.command("AutoEndVote", help = "Set whether votes of the current game should end automatically when everybody has voted", usage = "true|false|get")
|
@commands.command("AutoEndVote", help = "Set whether votes of the current game should end automatically when everybody has voted", usage = "true|false|get")
|
||||||
async def auto_end_vote(self, ctx: commands.Context, value):
|
async def auto_end_vote(self, ctx: commands.Context, value):
|
||||||
game = await self.get_running_game_or_error_message(ctx)
|
game = await self.get_running_game_or_error_message(ctx)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue