From 50afe4ab59cad7e0e4c762cc1edc7fe4177e0353 Mon Sep 17 00:00:00 2001 From: Aaron Riedel Date: Mon, 7 Mar 2022 03:47:53 +0000 Subject: [PATCH] adding context menu for emoji text --- bot.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/bot.py b/bot.py index b109c52..117762a 100644 --- a/bot.py +++ b/bot.py @@ -9,6 +9,7 @@ from os import environ from discord.ext import commands from discord.commands import Option from discord.commands import permissions +from discord.ui import InputText, Modal def left(s, amount): return s[:amount] @@ -54,6 +55,7 @@ def is_gm(): return commands.check(predicate) emojinumbers = ["0\u20E3", "1\u20E3" , "2\u20E3" , "3\u20E3" , "4\u20E3" , "5\u20E3" , "6\u20E3" , "7\u20E3" , "8\u20E3" , "9\u20E3"] +alphabet = {"a" : "🇦","b" : "🇧","c" : "🇨","d" : "🇩","e" : "🇪","f" : "🇫","g" : "🇬","h" : "🇭","i" : "🇮","j" : "🇯","k" : "🇰","l" : "🇱","m" : "🇲","n" : "🇳","o" : "🇴","p" : "🇵","q" : "🇶","r" : "🇷","s" : "🇸","t" : "🇹","u" : "🇺","v" : "🇻","w" : "🇼","x" : "🇽","y" : "🇾","z" : "🇿"} bot.help_command = commands.DefaultHelpCommand(dm_help=False, no_category="Befehle die du nutzen kannst") @@ -154,6 +156,29 @@ async def gmroll(ctx, em = discord.Embed(title=rolle, description=rolltotal, colour=0x009933) await ctx.response.send_message(embed=em, ephemeral=True) +class MyModal(Modal): + def __init__(self) -> None: + self.message_id = 0 + super().__init__("Emojitext") + self.add_item(InputText(label="Dein Text:", placeholder="Jeder Buchstabe nur einmal!")) + def set_message_id(self, message_id): + self.message_id = message_id + async def callback(self, interaction: discord.Interaction): + await interaction.response.send_message(content="Füge Reaktionen hinzu...", ephemeral=True) + emojitext = self.children[0].value.lower() + original_message = await interaction.channel.fetch_message(self.message_id) + for x in list(emojitext): + await original_message.add_reaction(alphabet[x]) + + +@bot.message_command(name="Emoji Text", guild_ids=[261575556708040705]) +@permissions.has_role(member_role) +async def emoji_text(ctx, message: discord.Message): + modal = MyModal() + modal.title = "Emoji Bot" + modal.set_message_id(message.id) + await ctx.interaction.response.send_modal(modal) + @bot.command(help="veraltet", usage="", hidden=True) @is_member() async def yesno(ctx):