GalaxyCogs/podcast/podcast.py
cswimr 99e7d90185
All checks were successful
Actions / Lint Code (Pylint) (push) Successful in 45s
changed all instances of SeaswimmerTheFsh to cswimr
2024-09-16 09:20:13 -04:00

55 lines
2.3 KiB
Python

from redbot.core import Config, checks, commands
class Podcast(commands.Cog):
"""Provides a questions submission system for podcasts.
Developed by cswimr."""
def __init__(self, bot):
self.bot = bot
self.config = Config.get_conf(self, identifier=27548165)
self.config.register_global(
global_submission_channel = 0,
global_blacklisted_users = {}
)
self.config.register_guild(
submission_channel = 0,
blacklisted_users = {},
global_mode = True
)
@commands.command()
async def podcast(self, ctx: commands.Context, question: str):
"""Submits a question to the Podcast."""
prefix = await self.bot.get_valid_prefixes()
if await self.config.guild(ctx.guild).global_mode(True):
submission_channel = ctx.bot.get_channel(await self.config.global_submission_channel())
blacklisted_users = await self.config.global_blacklisted_users()
elif await self.config.guild(ctx.guild).global_mode(False):
submission_channel = ctx.bot.get_channel(await self.config.guild(ctx.guild).submission_channel())
blacklisted_users = await self.config.guild(ctx.guild).blacklisted_users()
else:
return
if ctx.author.id in blacklisted_users:
await ctx.author.send(content=f"You are blacklisted from ``{prefix}podcast``!")
else:
await submission_channel.send(content=f"{question}")
await ctx.send(content="Question submitted!")
@commands.group(autohelp=True)
@checks.admin_or_permissions(manage_guild=True)
@commands.guild_only()
async def podcastset(self, ctx):
"""Commands to configure the Podcast cog."""
@podcastset.command(name="global")
async def set_global_mode(self, ctx, enabled: bool):
"""Enables or disables global mode."""
if enabled is True:
await self.config.guild(ctx.guild).global_mode.set(True)
await ctx.send(content="``global_mode`` has been enabled.")
elif enabled is False:
await self.config.guild(ctx.guild).global_mode.set(False)
await ctx.send(content="``global_mode`` has been disabled.")
else:
await ctx.send(content="Please specify an argument!")