Renamed python files to more describe their contents. Intend on having more than 1 class per file.
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
"""
|
||||
Commands for managing the Guild's settings.
|
||||
"""
|
||||
|
||||
from nextcord.ext import commands
|
||||
import nextcord
|
||||
|
||||
from highscores import highscores_data # pylint: disable=import-error
|
||||
|
||||
|
||||
class Register(commands.Cog, name="Register"):
|
||||
"""
|
||||
Class holds the Register group command. Registers various channels.
|
||||
"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
"""
|
||||
Default constructor for Register class. Does nothing.
|
||||
"""
|
||||
|
||||
@nextcord.slash_command(default_member_permissions=nextcord.Permissions(administrator=True))
|
||||
async def register(self):
|
||||
"""
|
||||
Parent slash command, never called.
|
||||
"""
|
||||
|
||||
@register.subcommand(description="Registers the channel for perminent highscores messages.")
|
||||
async def highscore(
|
||||
self,
|
||||
interaction: nextcord.Interaction,
|
||||
channel: nextcord.abc.GuildChannel = nextcord.SlashOption(
|
||||
description="Channel to register",
|
||||
required=False,
|
||||
channel_types=[nextcord.ChannelType.text],
|
||||
default=None,
|
||||
),
|
||||
) -> None:
|
||||
"""
|
||||
Command function to register the highscore printing channel.
|
||||
|
||||
Args:
|
||||
interaction (nextcord.Interaction): Interaction that invoked the command
|
||||
channel (nextcord.abc.GuildChannel, optional): Channel to register
|
||||
Is a SlashOption. Limited to text channels, Defaults to None.
|
||||
"""
|
||||
if not channel:
|
||||
channel = interaction.channel
|
||||
channel_id = channel.id
|
||||
guild = highscores_data.get_guild(interaction.guild_id)
|
||||
await interaction.send(f"Registered <#{channel_id}>.", ephemeral=True)
|
||||
guild.highscore_channel = channel_id
|
||||
highscores_data.save_guild_data(guild)
|
||||
|
||||
@register.subcommand(description="Registers the channel for submission messages.")
|
||||
async def submission(
|
||||
self,
|
||||
interaction: nextcord.Interaction,
|
||||
channel: nextcord.abc.GuildChannel = nextcord.SlashOption(
|
||||
description="Channel to register",
|
||||
required=False,
|
||||
channel_types=[nextcord.ChannelType.text],
|
||||
default=None,
|
||||
),
|
||||
) -> None:
|
||||
"""
|
||||
Command function to register the submission message channel.
|
||||
|
||||
Args:
|
||||
interaction (nextcord.Interaction): Interaction that invoked the command
|
||||
channel (nextcord.abc.GuildChannel, optional): Channel to register
|
||||
Is a SlashOption. Limited to text channels, Defaults to None.
|
||||
"""
|
||||
if not channel:
|
||||
channel = interaction.channel
|
||||
channel_id = channel.id
|
||||
guild = highscores_data.get_guild(interaction.guild_id)
|
||||
await interaction.send(f"Registered <#{channel_id}>.", ephemeral=True)
|
||||
guild.submission_channel = channel_id
|
||||
highscores_data.save_guild_data(guild)
|
||||
|
||||
@register.subcommand(description="Registers the channel for verification messages.")
|
||||
async def verify(
|
||||
self,
|
||||
interaction: nextcord.Interaction,
|
||||
channel: nextcord.abc.GuildChannel = nextcord.SlashOption(
|
||||
description="Channel to register",
|
||||
required=False,
|
||||
channel_types=[nextcord.ChannelType.text],
|
||||
default=None,
|
||||
),
|
||||
) -> None:
|
||||
"""
|
||||
Command function to register the verification message channel.
|
||||
|
||||
Args:
|
||||
interaction (nextcord.Interaction): Interaction that invoked the command
|
||||
channel (nextcord.abc.GuildChannel, optional): Channel to register
|
||||
Is a SlashOption. Limited to text channels, Defaults to None.
|
||||
"""
|
||||
if not channel:
|
||||
channel = interaction.channel
|
||||
channel_id = channel.id
|
||||
guild = highscores_data.get_guild(interaction.guild_id)
|
||||
await interaction.send(f"Registered <#{channel_id}>.", ephemeral=True)
|
||||
guild.verification_channel = channel_id
|
||||
highscores_data.save_guild_data(guild)
|
||||
Reference in New Issue
Block a user