Add UpdateUsernameVerify view to MessageManagementCog.
This commit is contained in:
@@ -1,18 +1,23 @@
|
|||||||
"""
|
"""
|
||||||
Cog loader. Adds all command classes as cogs to the bot.
|
Cog loader. Adds all command cogs to the bot.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from nextcord.ext import commands
|
from nextcord.ext import commands
|
||||||
|
|
||||||
# Command classes
|
# Command classes
|
||||||
from .message_management import MessageManagement
|
from .message_management import MessageManagementCog
|
||||||
from .settings_management import SettingsManagement
|
from .settings_management import SettingsManagementCog
|
||||||
from .data_management import DataManagement
|
from .data_management import DataManagementCog
|
||||||
|
|
||||||
|
# Views for commands
|
||||||
|
from .views.update_username_verify import UpdateUsernameVerifyView
|
||||||
|
|
||||||
# This function will be called when this extension is loaded.
|
# This function will be called when this extension is loaded.
|
||||||
# It is necessary to add these functions to the bot.
|
# It is necessary to add these functions to the bot.
|
||||||
def setup(bot: commands.Bot):
|
def setup(bot: commands.Bot):
|
||||||
"""Adds all command classes to bot."""
|
"""
|
||||||
bot.add_cog(DataManagement())
|
Adds all command classes to bot.
|
||||||
bot.add_cog(MessageManagement(bot))
|
"""
|
||||||
bot.add_cog(SettingsManagement())
|
bot.add_cog(DataManagementCog(bot))
|
||||||
|
bot.add_cog(MessageManagementCog(bot))
|
||||||
|
bot.add_cog(SettingsManagementCog())
|
||||||
|
|||||||
@@ -6,17 +6,26 @@ from nextcord.ext import commands
|
|||||||
import nextcord
|
import nextcord
|
||||||
|
|
||||||
from highscores import highscores_data # pylint: disable=import-error
|
from highscores import highscores_data # pylint: disable=import-error
|
||||||
|
from .views.update_username_verify import UpdateUsernameVerifyView
|
||||||
|
|
||||||
|
|
||||||
class DataManagement(commands.Cog, name="Table Management"):
|
class DataManagementCog(commands.Cog, name="Table Management"):
|
||||||
"""
|
"""
|
||||||
Class holds commands for managing the data storage of the highscores.
|
Class holds commands for managing the data storage of the highscores.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, bot: commands.Bot):
|
||||||
"""
|
"""
|
||||||
Default constructor for DataManagement class. Does nothing.
|
Default constructor for DataManagement class. Sets internal bot variable.
|
||||||
"""
|
"""
|
||||||
|
self._bot: commands.Bot = bot
|
||||||
|
|
||||||
|
@commands.Cog.listener()
|
||||||
|
async def on_ready(self):
|
||||||
|
"""
|
||||||
|
Called when cog is loaded. Adds views required for DataManagement commands.
|
||||||
|
"""
|
||||||
|
self._bot.add_view(UpdateUsernameVerifyView())
|
||||||
|
|
||||||
@nextcord.slash_command(
|
@nextcord.slash_command(
|
||||||
description="Deletes all scores for this guild. Used for testing.",
|
description="Deletes all scores for this guild. Used for testing.",
|
||||||
@@ -70,6 +79,8 @@ class DataManagement(commands.Cog, name="Table Management"):
|
|||||||
embed.add_field(name="Old Username", value=old_username)
|
embed.add_field(name="Old Username", value=old_username)
|
||||||
embed.add_field(name="New Username", value=new_username)
|
embed.add_field(name="New Username", value=new_username)
|
||||||
await verify_channel.send(
|
await verify_channel.send(
|
||||||
content=f"Username change request from <@{interaction.user.id}>.", embed=embed
|
content=f"Username change request from <@{interaction.user.id}>.",
|
||||||
|
embed=embed,
|
||||||
|
view=UpdateUsernameVerifyView(),
|
||||||
)
|
)
|
||||||
await interaction.send("Request sent to admins for verification.", ephemeral=True)
|
await interaction.send("Request sent to admins for verification.", ephemeral=True)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from highscores import highscores_data # pylint: disable=import-error
|
|||||||
from utilities.utils import send_highscore_message # pylint: disable=import-error
|
from utilities.utils import send_highscore_message # pylint: disable=import-error
|
||||||
|
|
||||||
|
|
||||||
class MessageManagement(commands.Cog, name="Message Management"):
|
class MessageManagementCog(commands.Cog, name="Message Management"):
|
||||||
"""
|
"""
|
||||||
Class holds commands for managing the messages that display highscores.
|
Class holds commands for managing the messages that display highscores.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import nextcord
|
|||||||
from highscores import highscores_data # pylint: disable=import-error
|
from highscores import highscores_data # pylint: disable=import-error
|
||||||
|
|
||||||
|
|
||||||
class SettingsManagement(commands.Cog, name="Settings Management"):
|
class SettingsManagementCog(commands.Cog, name="Settings Management"):
|
||||||
"""
|
"""
|
||||||
Class holds commands for managing Guild's settings.
|
Class holds commands for managing Guild's settings.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ class UpdateUsernameVerifyView(nextcord.ui.View):
|
|||||||
interaction (nextcord.Interaction): Interaction with the button
|
interaction (nextcord.Interaction): Interaction with the button
|
||||||
"""
|
"""
|
||||||
embed_content = interaction.message.embeds[0].to_dict()
|
embed_content = interaction.message.embeds[0].to_dict()
|
||||||
old_username: str = embed_content["Old Username"]
|
old_username: str = embed_content[0].value()
|
||||||
new_username: str = embed_content["New Username"]
|
new_username: str = embed_content[1].value()
|
||||||
|
|
||||||
guild = highscores_data.get_guild(interaction.guild_id)
|
guild = highscores_data.get_guild(interaction.guild_id)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user