experimental: add emoji text with modal and context menu

This commit is contained in:
Aaron Riedel 2022-01-31 21:09:58 +01:00
parent 3639de8217
commit 4e4cf48e60

18
bot.py
View file

@ -9,6 +9,7 @@ from os import environ
from discord.ext import commands from discord.ext import commands
from discord.commands import Option from discord.commands import Option
from discord.commands import permissions from discord.commands import permissions
from discord.ui import InputText, Modal
def left(s, amount): def left(s, amount):
return s[:amount] return s[:amount]
@ -152,11 +153,22 @@ async def gmroll(ctx,
em = discord.Embed(title=rolle, description=rolltotal, colour=0x009933) em = discord.Embed(title=rolle, description=rolltotal, colour=0x009933)
await ctx.response.send_message(embed=em, ephemeral=True) await ctx.response.send_message(embed=em, ephemeral=True)
class MyModal(Modal):
def __init__(self) -> None:
super().__init__("Emojitext")
self.add_item(InputText(label="Dein Text:", placeholder="Jeder Buchstabe nur einmal!"))
async def callback(self, interaction: discord.Interaction):
emojitext = self.children[0].value.lower.strip
for x in list(emojitext):
await interaction.message.add_reaction(alphabet[x])
await interaction.response.send_message(content="done", ephemeral=True)
@bot.message_command(name="Emoji Text", guild_ids=[261575556708040705]) @bot.message_command(name="Emoji Text", guild_ids=[261575556708040705])
@permissions.has_role(member_role)
async def emoji_text(ctx, message: discord.Message): async def emoji_text(ctx, message: discord.Message):
emojitext = "shiba" modal = MyModal()
for x in list(emojitext): await ctx.interaction.response.send_modal(modal)
await message.add_reaction(alphabet[x])
@bot.command(help="veraltet", usage="", hidden=True) @bot.command(help="veraltet", usage="", hidden=True)
@is_member() @is_member()