-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from placeTW/confession
add confession functionality
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters