diff --git a/commands/confessions/confession.py b/commands/confessions/confession.py new file mode 100644 index 0000000..b32195f --- /dev/null +++ b/commands/confessions/confession.py @@ -0,0 +1,49 @@ +import discord + + +TW_SERVER_CONFESSIONS_CHANNEL_ID = 1161839912509775902 +BALTICS_SERVER_CONFESSIONS_CHANNEL_ID = 1161419086987800737 +TW_SERVER_CONFESSIONS_CHANNEL_OBJ = discord.Object( + id=TW_SERVER_CONFESSIONS_CHANNEL_ID +) +BALTICS_SERVER_CONFESSIONS_CHANNEL_OBJ = discord.Object( + id=BALTICS_SERVER_CONFESSIONS_CHANNEL_ID +) + + +def register_commands( + tree: discord.app_commands.CommandTree, + client: discord.Client, + guilds: list, +): + @tree.command( + name="confess", + description="Make an anonymous confession", + guilds=[ # TW and Baltics server + discord.Object(id=guilds[0]), + discord.Object(id=guilds[1]), + ], + ) + async def confess(interaction: discord.Interaction, confession: str): + """Write an anonymous confession. + + Args: + interaction (discord.Interaction): required by discord.py + confession (str): The confession to make. + """ + server = ( + "TW" if (interaction.guild_id == int(guilds[0])) else "BALTICS" + ) + confession_channel_id = ( + TW_SERVER_CONFESSIONS_CHANNEL_ID + if server == "TW" + else BALTICS_SERVER_CONFESSIONS_CHANNEL_ID + ) + confession_channel = client.get_channel(confession_channel_id) + embed = discord.Embed() + embed.add_field(name="Confession", value=confession, inline=False) + await confession_channel.send(embed=embed) + await interaction.response.send_message( + f"Your confession has been sent to <#{confession_channel_id}>.", + ephemeral=True, + ) diff --git a/main.py b/main.py index 714417f..e5ee42a 100644 --- a/main.py +++ b/main.py @@ -26,6 +26,7 @@ from commands.restart import restart from commands.gothefucktosleep import gothefucktosleep from commands.boba import boba +from commands.confessions import confession from presence import watching import bot import sys @@ -95,6 +96,11 @@ async def test_slash_command(interaction: discord.Interaction): gothefucktosleep.register_commands(tree, guild) boba.register_commands(tree, guild) +# * register commands to the specific servers onlu +# at this point, the first two servers are specifically TW and Baltics server +# TODO: make GUILDS a dict probably +confession.register_commands(tree, client, GUILDS[:2]) + # sync the slash commands servers @client.event @@ -132,4 +138,5 @@ async def on_message(message: discord.Message): await meow_meow(message) + client.run(TOKEN)