Skip to content
Snippets Groups Projects
Commit 09e852ba authored by dnns01's avatar dnns01
Browse files

fix $11x - Allow mods to edit polls

parent 95060ed1
Branches
No related tags found
No related merge requests found
...@@ -3,6 +3,8 @@ import os ...@@ -3,6 +3,8 @@ import os
import discord import discord
from discord.ext import commands from discord.ext import commands
import utils
OPTIONS = ["🇦", "🇧", "🇨", "🇩", "🇪", "🇫", "🇬", "🇭", "🇮", "🇯", "🇰", "🇱", "🇲", "🇳", "🇴", "🇵", "🇶", "🇷"] OPTIONS = ["🇦", "🇧", "🇨", "🇩", "🇪", "🇫", "🇬", "🇭", "🇮", "🇯", "🇰", "🇱", "🇲", "🇳", "🇴", "🇵", "🇶", "🇷"]
...@@ -21,6 +23,19 @@ class PollCog(commands.Cog): ...@@ -21,6 +23,19 @@ class PollCog(commands.Cog):
await channel.send(msg) await channel.send(msg)
@commands.command(name="edit-poll")
@commands.check(utils.is_mod)
async def cmd_edit_poll(self, ctx, message_id, question, *answers):
message = await ctx.fetch_message(message_id)
if message:
if message.embeds[0].title == "Umfrage":
old_poll = Poll(self.bot, message=message)
new_poll = Poll(self.bot, question=question, answers=answers, author=old_poll.author)
await new_poll.send_poll(ctx.channel, message=message)
else:
ctx.send("Fehler! Umfrage nicht gefunden!")
pass
@commands.command(name="poll") @commands.command(name="poll")
async def cmd_poll(self, ctx, question, *answers): async def cmd_poll(self, ctx, question, *answers):
""" Create poll """ """ Create poll """
...@@ -61,7 +76,7 @@ class Poll: ...@@ -61,7 +76,7 @@ class Poll:
for i in range(2, len(embed.fields)): for i in range(2, len(embed.fields)):
self.answers.append(embed.fields[i].value) self.answers.append(embed.fields[i].value)
async def send_poll(self, channel, result=False): async def send_poll(self, channel, result=False, message=None):
option_ctr = 0 option_ctr = 0
title = "Umfrage" title = "Umfrage"
...@@ -103,12 +118,21 @@ class Poll: ...@@ -103,12 +118,21 @@ class Poll:
embed.add_field(name=name, value=value, inline=False) embed.add_field(name=name, value=value, inline=False)
option_ctr += 1 option_ctr += 1
message = await channel.send("", embed=embed) if message:
await message.edit(embed=embed)
else:
message = await channel.send("", embed=embed)
await message.clear_reaction("🗑️")
await message.clear_reaction("🛑")
if not result: if not result:
for i in range(0, len(self.answers)): for i in range(0, len(self.answers)):
await message.add_reaction(OPTIONS[i]) await message.add_reaction(OPTIONS[i])
for i in range(len(self.answers), len(OPTIONS)):
await message.clear_reaction(OPTIONS[i])
await message.add_reaction("🗑️") await message.add_reaction("🗑️")
await message.add_reaction("🛑") await message.add_reaction("🛑")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment