tarto-dev / tagsy-discord

Tagsy, your friendly Discord bot, designed to enhance server interaction with its intuitive tagging system
MIT License
2 stars 1 forks source link

Add contextual commands #12

Closed tarto-dev closed 8 months ago

tarto-dev commented 8 months ago

Check API to implements contextual commands such as add and update on existing messages sent by other discord users.

Add authored by and a direct link to post aswel if allowed by API.

tarto-dev commented 8 months ago

An implements with #10 would be nice to improve useability

tarto-dev commented 8 months ago

Sample code who should do the trick (not tested so far because #10 trends to fail and remove bot listener)

from disnake.ext import commands
import disnake

class ContextMenuCommands(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.message_command(name="Add as Tag")
    async def add_as_tag(self, inter: disnake.MessageCommandInteraction):
        selected_message_content = inter.target.content
        modal = AddTagModal(server_id=inter.guild_id, prefill_message=selected_message_content)
        await inter.response.send_modal(modal)