Finish up smells in the commands directory.
Add a discord max message length constant. Move boolean argument to not be positional.
This commit is contained in:
+26
-30
@@ -1,31 +1,27 @@
|
||||
"""
|
||||
Contains commands and views for request commands.
|
||||
"""
|
||||
"""Contains commands and views for request commands."""
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import nextcord
|
||||
from nextcord.ext import commands
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from config import DakinyConfig
|
||||
from database_setup.sql_data_classes import Presences, engine
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from config import DakinyConfig
|
||||
|
||||
|
||||
class RequestCog(commands.Cog, name="Request Commands"):
|
||||
"""
|
||||
Class holds request commands.
|
||||
"""
|
||||
"""Class holds request commands."""
|
||||
|
||||
def __init__(self, bot) -> None:
|
||||
"""
|
||||
Default constructor for RequestCog class. Does nothing.
|
||||
"""
|
||||
def __init__(self, bot: commands.Bot) -> None:
|
||||
"""Default constructor for RequestCog class. Does nothing."""
|
||||
self.bot: commands.Bot = bot
|
||||
|
||||
@nextcord.slash_command()
|
||||
async def request(self, interaction: nextcord.Interaction):
|
||||
"""
|
||||
Parent slash command for request. Never called.
|
||||
"""
|
||||
async def request(self, interaction: nextcord.Interaction) -> None:
|
||||
"""Parent slash command for request. Never called."""
|
||||
|
||||
@request.subcommand(description="Request to add a presence to the bot's presence list.")
|
||||
async def add_presence(
|
||||
@@ -37,7 +33,7 @@ class RequestCog(commands.Cog, name="Request Commands"):
|
||||
max_length=100,
|
||||
description="The presence you want to add.",
|
||||
),
|
||||
):
|
||||
) -> None:
|
||||
"""
|
||||
Sends a message to admins to request to add a presence.
|
||||
|
||||
@@ -61,13 +57,13 @@ class RequestCog(commands.Cog, name="Request Commands"):
|
||||
max_length=32,
|
||||
description="Your requested new nickname.",
|
||||
),
|
||||
):
|
||||
) -> None:
|
||||
"""
|
||||
Sends a message to admins to request a nickname change.
|
||||
|
||||
Args:
|
||||
interaction (nextcord.Interaction): Interaction that invoked the command.
|
||||
new_username(str): The username to change to.
|
||||
new_nickname(str): The username to change to.
|
||||
"""
|
||||
config: DakinyConfig = self.bot.config
|
||||
content = f'<@{interaction.user.id}> would like to change their username to "{new_nickname}."'
|
||||
@@ -77,9 +73,7 @@ class RequestCog(commands.Cog, name="Request Commands"):
|
||||
|
||||
|
||||
class UsernameRequest(nextcord.ui.View):
|
||||
"""
|
||||
View provides approve and deny buttons and action for a username change request.
|
||||
"""
|
||||
"""View provides approve and deny buttons and action for a username change request."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@@ -91,9 +85,11 @@ class UsernameRequest(nextcord.ui.View):
|
||||
self.new_nickname = new_nickname
|
||||
|
||||
@nextcord.ui.button(label="Approve", style=nextcord.ButtonStyle.green)
|
||||
async def approve(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
|
||||
async def approve(self, button: nextcord.ui.Button, interaction: nextcord.Interaction) -> None: # noqa: ARG002
|
||||
"""
|
||||
Approve button for a nickname change request. Changes the target's nickname to self.new_nickname.
|
||||
Approve button for a nickname change request.
|
||||
|
||||
Changes the target's nickname to self.new_nickname.
|
||||
Catches an error if the target as a higher role than the bot.
|
||||
Removes the view from the interaction message.
|
||||
|
||||
@@ -124,7 +120,7 @@ class UsernameRequest(nextcord.ui.View):
|
||||
)
|
||||
|
||||
@nextcord.ui.button(label="Deny", style=nextcord.ButtonStyle.red)
|
||||
async def deny(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
|
||||
async def deny(self, button: nextcord.ui.Button, interaction: nextcord.Interaction) -> None: # noqa: ARG002
|
||||
"""
|
||||
Deny button for a nickname request. Just removes the view and logs who denied the request.
|
||||
|
||||
@@ -137,9 +133,7 @@ class UsernameRequest(nextcord.ui.View):
|
||||
|
||||
|
||||
class PresenceChange(nextcord.ui.View):
|
||||
"""
|
||||
View provides approve and deny buttons and action for a username change request.
|
||||
"""
|
||||
"""View provides approve and deny buttons and action for a username change request."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@@ -149,9 +143,11 @@ class PresenceChange(nextcord.ui.View):
|
||||
self.presence = presence
|
||||
|
||||
@nextcord.ui.button(label="Approve", style=nextcord.ButtonStyle.green)
|
||||
async def approve(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
|
||||
async def approve(self, button: nextcord.ui.Button, interaction: nextcord.Interaction) -> None: # noqa: ARG002
|
||||
"""
|
||||
Approve button for a presence add request. Adds the presence to the database.
|
||||
Approve button for a presence add request.
|
||||
|
||||
Adds the presence to the database.
|
||||
Removes the view from the interaction message.
|
||||
|
||||
Args:
|
||||
@@ -166,7 +162,7 @@ class PresenceChange(nextcord.ui.View):
|
||||
await interaction.response.edit_message(content=content, view=None)
|
||||
|
||||
@nextcord.ui.button(label="Deny", style=nextcord.ButtonStyle.red)
|
||||
async def deny(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
|
||||
async def deny(self, button: nextcord.ui.Button, interaction: nextcord.Interaction) -> None: # noqa: ARG002
|
||||
"""
|
||||
Deny button for a presence add request. Just removes the view and logs who denied the request.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user