From c35e4a8c44a7db98d6bffbe8ae8b418750e9fbe9 Mon Sep 17 00:00:00 2001 From: FuseFairy Date: Sun, 21 Apr 2024 20:35:57 +0800 Subject: [PATCH] first commit --- src/check_channel.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/check_channel.py diff --git a/src/check_channel.py b/src/check_channel.py new file mode 100644 index 0000000..456abff --- /dev/null +++ b/src/check_channel.py @@ -0,0 +1,13 @@ +import discord +import os +from dotenv import load_dotenv + +load_dotenv() + +async def check_channel(interaction: discord.Interaction, channel): + allowed_channel_ids = os.getenv(channel, "").split(",") + if str(interaction.channel.id) not in allowed_channel_ids and allowed_channel_ids[0] != "": + allowed_channels_mention = ", ".join(f"<#{id_}>" for id_ in allowed_channel_ids) + await interaction.followup.send(f"> **Command can only be used on: {allowed_channels_mention}**") + return False + return True \ No newline at end of file