2024-09-16 09:20:13 -04:00
|
|
|
from redbot.core import Config, checks, commands
|
|
|
|
|
2023-03-04 15:36:46 -05:00
|
|
|
|
|
|
|
class Podcast(commands.Cog):
|
|
|
|
"""Provides a questions submission system for podcasts.
|
2024-09-16 09:20:13 -04:00
|
|
|
Developed by cswimr."""
|
2023-03-04 15:36:46 -05:00
|
|
|
|
|
|
|
def __init__(self, bot):
|
|
|
|
self.bot = bot
|
|
|
|
self.config = Config.get_conf(self, identifier=27548165)
|
2023-03-04 16:14:20 -05:00
|
|
|
self.config.register_global(
|
|
|
|
global_submission_channel = 0,
|
|
|
|
global_blacklisted_users = {}
|
|
|
|
)
|
2023-03-04 15:36:46 -05:00
|
|
|
self.config.register_guild(
|
2023-03-04 16:14:20 -05:00
|
|
|
submission_channel = 0,
|
|
|
|
blacklisted_users = {},
|
|
|
|
global_mode = True
|
|
|
|
)
|
|
|
|
|
|
|
|
@commands.command()
|
2023-09-24 20:36:48 -04:00
|
|
|
async def podcast(self, ctx: commands.Context, question: str):
|
2023-03-04 16:14:20 -05:00
|
|
|
"""Submits a question to the Podcast."""
|
2023-03-04 16:59:27 -05:00
|
|
|
prefix = await self.bot.get_valid_prefixes()
|
2023-03-04 16:14:20 -05:00
|
|
|
if await self.config.guild(ctx.guild).global_mode(True):
|
2023-09-24 20:36:48 -04:00
|
|
|
submission_channel = ctx.bot.get_channel(await self.config.global_submission_channel())
|
2023-03-04 16:14:20 -05:00
|
|
|
blacklisted_users = await self.config.global_blacklisted_users()
|
|
|
|
elif await self.config.guild(ctx.guild).global_mode(False):
|
2023-09-24 20:36:48 -04:00
|
|
|
submission_channel = ctx.bot.get_channel(await self.config.guild(ctx.guild).submission_channel())
|
2023-03-04 16:14:20 -05:00
|
|
|
blacklisted_users = await self.config.guild(ctx.guild).blacklisted_users()
|
|
|
|
else:
|
|
|
|
return
|
2023-03-04 16:59:27 -05:00
|
|
|
if ctx.author.id in blacklisted_users:
|
2023-03-05 00:11:32 -05:00
|
|
|
await ctx.author.send(content=f"You are blacklisted from ``{prefix}podcast``!")
|
2023-03-04 16:59:27 -05:00
|
|
|
else:
|
|
|
|
await submission_channel.send(content=f"{question}")
|
|
|
|
await ctx.send(content="Question submitted!")
|
2023-03-04 16:14:20 -05:00
|
|
|
|
2023-03-05 00:16:15 -05:00
|
|
|
@commands.group(autohelp=True)
|
2023-03-05 00:21:04 -05:00
|
|
|
@checks.admin_or_permissions(manage_guild=True)
|
2023-03-05 00:16:15 -05:00
|
|
|
@commands.guild_only()
|
2023-03-05 00:16:41 -05:00
|
|
|
async def podcastset(self, ctx):
|
2023-03-05 00:16:15 -05:00
|
|
|
"""Commands to configure the Podcast cog."""
|
2023-03-04 16:59:27 -05:00
|
|
|
|
2023-03-05 00:16:15 -05:00
|
|
|
@podcastset.command(name="global")
|
2023-03-05 22:53:54 -05:00
|
|
|
async def set_global_mode(self, ctx, enabled: bool):
|
2023-03-05 00:16:15 -05:00
|
|
|
"""Enables or disables global mode."""
|
2023-09-24 20:36:48 -04:00
|
|
|
if enabled is True:
|
2023-03-05 00:16:15 -05:00
|
|
|
await self.config.guild(ctx.guild).global_mode.set(True)
|
2023-03-05 22:53:54 -05:00
|
|
|
await ctx.send(content="``global_mode`` has been enabled.")
|
2023-09-24 20:36:48 -04:00
|
|
|
elif enabled is False:
|
2023-03-05 00:16:15 -05:00
|
|
|
await self.config.guild(ctx.guild).global_mode.set(False)
|
2023-03-05 22:53:54 -05:00
|
|
|
await ctx.send(content="``global_mode`` has been disabled.")
|
2023-03-05 00:16:15 -05:00
|
|
|
else:
|
2023-09-24 20:36:48 -04:00
|
|
|
await ctx.send(content="Please specify an argument!")
|