Skip to content

Commit

Permalink
Merge pull request #40 from placeTW/confession
Browse files Browse the repository at this point in the history
add confession functionality
  • Loading branch information
howardt12345 authored Oct 12, 2023
2 parents b4f8859 + 115228b commit 0102b0a
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
49 changes: 49 additions & 0 deletions commands/confessions/confession.py
Original file line number Diff line number Diff line change
@@ -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,
)
7 changes: 7 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -132,4 +138,5 @@ async def on_message(message: discord.Message):

await meow_meow(message)


client.run(TOKEN)

0 comments on commit 0102b0a

Please sign in to comment.