Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae1d820297 |
@@ -0,0 +1,67 @@
|
|||||||
|
"""
|
||||||
|
Bot command for registering various channels to the bot.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from nextcord import Embed
|
||||||
|
from nextcord.ext import commands
|
||||||
|
|
||||||
|
from highscores import highscores_data # pylint: disable=import-error
|
||||||
|
from utilities.data_storage import save_highscores_data # pylint: disable=import-error
|
||||||
|
|
||||||
|
|
||||||
|
class RegisterVerificationChannel(commands.Cog, name="Register"):
|
||||||
|
"""Bot command for registering various channels to the bot."""
|
||||||
|
|
||||||
|
def __init__(self, bot: commands.Bot):
|
||||||
|
self.bot = bot
|
||||||
|
|
||||||
|
@commands.command(name="register")
|
||||||
|
@commands.has_permissions(administrator=True)
|
||||||
|
async def register_highscores(self, ctx: commands.Context, registration_type: str):
|
||||||
|
"""A command which registers current channel as for various uses.
|
||||||
|
Usage:
|
||||||
|
```
|
||||||
|
?register verify (Use in channel you want to verify submissions in.)
|
||||||
|
?register highscore (Use in channel you want to show highscore messages in.)
|
||||||
|
?register submission (Use in channel you want submission messages to be send it.)
|
||||||
|
?register help (Shows help message.)
|
||||||
|
```
|
||||||
|
"""
|
||||||
|
# respond to the message
|
||||||
|
channel_id = ctx.channel.id
|
||||||
|
|
||||||
|
if registration_type == "verify":
|
||||||
|
await ctx.send(f"Registered <#{channel_id}> as channel to post verifications in.")
|
||||||
|
highscores_data["verification_channel_id"] = channel_id
|
||||||
|
elif registration_type == "highscore":
|
||||||
|
await ctx.send(f"Registered <#{channel_id}> as channel to post highscores in.")
|
||||||
|
highscores_data["highscore_channel_id"] = channel_id
|
||||||
|
elif registration_type == "submission":
|
||||||
|
await ctx.send(f"Registered <#{channel_id}> as channel to post submissions in.")
|
||||||
|
highscores_data["submission_channel_id"] = channel_id
|
||||||
|
else:
|
||||||
|
embed = Embed(
|
||||||
|
title="Register command help", description="How to use the register command."
|
||||||
|
)
|
||||||
|
embed.add_field(
|
||||||
|
name="?register verify", value="Use in channel you want to verify submissions in."
|
||||||
|
)
|
||||||
|
embed.add_field(
|
||||||
|
name="?register highscore",
|
||||||
|
value="Use in channel you want to show highscore messages in.",
|
||||||
|
)
|
||||||
|
embed.add_field(
|
||||||
|
name="?register submission",
|
||||||
|
value="Use in channel you want submission messages to be send it.",
|
||||||
|
)
|
||||||
|
embed.add_field(name="?register help", value="Use to show this message.")
|
||||||
|
await ctx.reply(embed=embed)
|
||||||
|
|
||||||
|
save_highscores_data(highscores_data)
|
||||||
|
|
||||||
|
|
||||||
|
# This function will be called when this extension is loaded.
|
||||||
|
# It is necessary to add these functions to the bot.
|
||||||
|
def setup(bot: commands.Bot):
|
||||||
|
"""Adds function to bot"""
|
||||||
|
bot.add_cog(RegisterVerificationChannel(bot))
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
"""
|
|
||||||
Bot command to register the highscores channel
|
|
||||||
"""
|
|
||||||
|
|
||||||
from nextcord.ext import commands
|
|
||||||
from highscores import highscores_data # pylint: disable=import-error
|
|
||||||
from utilities.data_storage import save_highscores_data # pylint: disable=import-error
|
|
||||||
|
|
||||||
|
|
||||||
class RegisterHighscoreChannel(commands.Cog, name="Register HighScore Channel"):
|
|
||||||
"""Registers Highscore channel"""
|
|
||||||
|
|
||||||
def __init__(self, bot: commands.Bot):
|
|
||||||
self.bot = bot
|
|
||||||
|
|
||||||
@commands.command(name="register-highscore")
|
|
||||||
async def register_highscores(self, ctx: commands.Context):
|
|
||||||
"""A command which registers current channel as channel to post highscores in.
|
|
||||||
Usage:
|
|
||||||
```
|
|
||||||
?register-highscore (in channel to post highscores in)
|
|
||||||
```
|
|
||||||
"""
|
|
||||||
print(f"Registering {ctx.channel.id} for highscores.")
|
|
||||||
# respond to the message
|
|
||||||
await ctx.send(f"Registered <#{ctx.channel.id}> as channel to post highscores in.")
|
|
||||||
highscores_data["highscore_channel_id"] = ctx.channel.id
|
|
||||||
save_highscores_data(highscores_data)
|
|
||||||
|
|
||||||
|
|
||||||
# This function will be called when this extension is loaded.
|
|
||||||
# It is necessary to add these functions to the bot.
|
|
||||||
def setup(bot: commands.Bot):
|
|
||||||
"""Adds function to bot"""
|
|
||||||
bot.add_cog(RegisterHighscoreChannel(bot))
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
"""
|
|
||||||
Bot command to register the verification channel
|
|
||||||
"""
|
|
||||||
|
|
||||||
from nextcord.ext import commands
|
|
||||||
from highscores import highscores_data # pylint: disable=import-error
|
|
||||||
from utilities.data_storage import save_highscores_data # pylint: disable=import-error
|
|
||||||
|
|
||||||
|
|
||||||
class RegisterVerificationChannel(commands.Cog, name="Register Verify Channel"):
|
|
||||||
"""Registers Verification channel"""
|
|
||||||
|
|
||||||
def __init__(self, bot: commands.Bot):
|
|
||||||
self.bot = bot
|
|
||||||
|
|
||||||
@commands.command(name="register-verify")
|
|
||||||
async def register_highscores(self, ctx: commands.Context):
|
|
||||||
"""A command which registers current channel as channel to post verifications in.
|
|
||||||
Usage:
|
|
||||||
```
|
|
||||||
?register-verify (in channel to post highscores in)
|
|
||||||
```
|
|
||||||
"""
|
|
||||||
print(f"Registering {ctx.channel.id} for verification.")
|
|
||||||
# respond to the message
|
|
||||||
await ctx.send(f"Registered <#{ctx.channel.id}> as channel to post verifications in.")
|
|
||||||
highscores_data["verification_channel_id"] = ctx.channel.id
|
|
||||||
save_highscores_data(highscores_data)
|
|
||||||
|
|
||||||
|
|
||||||
# This function will be called when this extension is loaded.
|
|
||||||
# It is necessary to add these functions to the bot.
|
|
||||||
def setup(bot: commands.Bot):
|
|
||||||
"""Adds function to bot"""
|
|
||||||
bot.add_cog(RegisterVerificationChannel(bot))
|
|
||||||
@@ -27,7 +27,8 @@ class SubmissionButton(nextcord.ui.View):
|
|||||||
embed = nextcord.Embed(title="Highscores Submission")
|
embed = nextcord.Embed(title="Highscores Submission")
|
||||||
embed.add_field(name="Boss", value=boss_name, inline=False)
|
embed.add_field(name="Boss", value=boss_name, inline=False)
|
||||||
embed.add_field(name="User", value=interaction.user.display_name, inline=False)
|
embed.add_field(name="User", value=interaction.user.display_name, inline=False)
|
||||||
submission_message = await interaction.channel.send( # TODO change channel
|
channel = self._bot.get_channel(highscores_data["submission_channel_id"])
|
||||||
|
submission_message = await channel.send(
|
||||||
f"<@{interaction.user.id}>",
|
f"<@{interaction.user.id}>",
|
||||||
view=SubmissionDropdownView(
|
view=SubmissionDropdownView(
|
||||||
self._bot, interaction, await self._category_select_options(boss_name)
|
self._bot, interaction, await self._category_select_options(boss_name)
|
||||||
|
|||||||
Reference in New Issue
Block a user