bereal-discord/bot/commands/SubscribeCommand.py

33 lines
1.2 KiB
Python

from database.controller import Database
import discord
from discord import app_commands
from discord.ext import commands
class SubscribeCommand(commands.Cog):
def __init__(self, app: commands.Bot) -> None:
self.app = app
@app_commands.command(
name="subscribe", description="Subscribe to BeReal. notifications."
)
async def subscribe(self, interaction: discord.Interaction) -> None:
result = self.app.db.add_subscriber(interaction.user.id)
if result:
await interaction.response.send_message(
":information_source: You have been subscribed to **BeReal. notifications**\n\
:arrow_right: You will receive every day notifications whenever it's\
time to BeReal.\n:warning: You may unsubscribe at any time using `/unsubscribe`.",
ephemeral=True,
)
else:
await interaction.response.send_message(
":information_source: You are already subscribed to **BeReal. notifications**\
\n:warning: You may unsubscribe at any time using `/unsubscribe`.",
ephemeral=True,
)
async def setup(app: commands.Bot) -> None:
await app.add_cog(SubscribeCommand(app))