bereal-discord/bot/commands/UnsubscribeCommand.py

32 lines
1.2 KiB
Python
Raw Permalink Normal View History

2024-03-02 20:41:56 +00:00
import discord
from discord import app_commands
from discord.ext import commands
class UnsubscribeCommand(commands.Cog):
def __init__(self, app: commands.Bot) -> None:
self.app = app
@app_commands.command(
name="unsubscribe", description="Unsubscribe to BeReal. notifications."
)
async def unsubscribe(self, interaction: discord.Interaction) -> None:
result = self.app.db.remove_subscriber(interaction.user.id)
if result:
await interaction.response.send_message(
":information_source: You have been unsubscribed to **BeReal. notifications**\n\
:arrow_right: You will **no longer receive** every day notifications whenever it's\
time to BeReal.\n:warning: You may re-subscribe at any time using `/subscribe`.",
ephemeral=True,
)
else:
await interaction.response.send_message(
":information_source: You are already not subscribed to **BeReal. notifications**\
\n:warning: You may subscribe at any time using `/subscribe`.",
ephemeral=True,
)
async def setup(app: commands.Bot) -> None:
await app.add_cog(UnsubscribeCommand(app))