29 lines
1.1 KiB
Python
29 lines
1.1 KiB
Python
import discord
|
|
from discord import app_commands
|
|
from discord.ext import commands
|
|
|
|
|
|
class SubscribeCog(commands.Cog):
|
|
def __init__(self, bot: commands.Bot, config):
|
|
self.bot = bot
|
|
self.config = config
|
|
|
|
@app_commands.command(name="subscribe", description="Get pinged when new items land in #inbox")
|
|
async def subscribe(self, interaction: discord.Interaction):
|
|
role = interaction.guild.get_role(self.config.triage_role_id)
|
|
await interaction.user.add_roles(role)
|
|
await interaction.response.send_message(
|
|
"You're subscribed to Chorus inbox pings.", ephemeral=True
|
|
)
|
|
|
|
@app_commands.command(name="unsubscribe", description="Stop getting pinged for new items")
|
|
async def unsubscribe(self, interaction: discord.Interaction):
|
|
role = interaction.guild.get_role(self.config.triage_role_id)
|
|
await interaction.user.remove_roles(role)
|
|
await interaction.response.send_message(
|
|
"You're unsubscribed from Chorus inbox pings.", ephemeral=True
|
|
)
|
|
|
|
|
|
async def setup(bot: commands.Bot, config):
|
|
await bot.add_cog(SubscribeCog(bot, config))
|