From 82e1141b2f05739810a64f26885261dd5aaa8ff6 Mon Sep 17 00:00:00 2001 From: Conatum Date: Tue, 26 Apr 2022 13:43:52 +0300 Subject: [PATCH] (client): Add `noop` interaction handling. --- bot/meta/client.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bot/meta/client.py b/bot/meta/client.py index 267ffe28..0ea0d4f1 100644 --- a/bot/meta/client.py +++ b/bot/meta/client.py @@ -2,10 +2,12 @@ from discord import Intents from cmdClient.cmdClient import cmdClient from . import patches +from .interactions import InteractionType from .config import conf from .sharding import shard_number, shard_count from LionContext import LionContext + # Initialise client owners = [int(owner) for owner in conf.bot.getlist('owners')] intents = Intents.all() @@ -19,3 +21,14 @@ client = cmdClient( baseContext=LionContext ) client.conf = conf + + +# TODO: Could include client id here, or app id, to avoid multiple handling. +NOOP_ID = 'NOOP' + + +@client.add_after_event('interaction_create') +async def handle_noop_interaction(client, interaction): + if interaction.interaction_type in (InteractionType.MESSAGE_COMPONENT, InteractionType.MODAL_SUBMIT): + if interaction.custom_id == NOOP_ID: + interaction.ack()