Adding verification channel register command.
This commit is contained in:
@@ -25,9 +25,9 @@ class PostHighscores(commands.Cog, name="Post Highscores"):
|
|||||||
?post-scores
|
?post-scores
|
||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
channel_id = highscores_data["channel_id"]
|
highscore_channel_id = highscores_data["highscore_channel_id"]
|
||||||
print(f"Printing out highscores information in channel {channel_id}")
|
print(f"Printing out highscores information in channel {highscore_channel_id}")
|
||||||
channel = self.bot.get_channel(channel_id)
|
channel = self.bot.get_channel(highscore_channel_id)
|
||||||
if channel is None:
|
if channel is None:
|
||||||
response = 'Registered Highscores channel does not exist or was never registered. \
|
response = 'Registered Highscores channel does not exist or was never registered. \
|
||||||
Register with "?register" command.'
|
Register with "?register" command.'
|
||||||
|
|||||||
@@ -13,18 +13,18 @@ class RegisterHighscoreChannel(commands.Cog, name="Register HighScore Channel"):
|
|||||||
def __init__(self, bot: commands.Bot):
|
def __init__(self, bot: commands.Bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
@commands.command(name="register")
|
@commands.command(name="register-highscore")
|
||||||
async def register_highscores(self, ctx: commands.Context):
|
async def register_highscores(self, ctx: commands.Context):
|
||||||
"""A command which registers current channel as channel to post highscores in.
|
"""A command which registers current channel as channel to post highscores in.
|
||||||
Usage:
|
Usage:
|
||||||
```
|
```
|
||||||
?register (in channel to post highscores in)
|
?register-highscore (in channel to post highscores in)
|
||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
print(f"Registering {ctx.channel.id}.")
|
print(f"Registering {ctx.channel.id} for highscores.")
|
||||||
# respond to the message
|
# respond to the message
|
||||||
await ctx.send(f"Registered <#{ctx.channel.id}> as channel to post highscores in.")
|
await ctx.send(f"Registered <#{ctx.channel.id}> as channel to post highscores in.")
|
||||||
highscores_data["channel_id"] = ctx.channel.id
|
highscores_data["highscore_channel_id"] = ctx.channel.id
|
||||||
data_storage.save_highscores_data(highscores_data)
|
data_storage.save_highscores_data(highscores_data)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
"""
|
||||||
|
Bot command to register the verification channel
|
||||||
|
"""
|
||||||
|
|
||||||
|
from nextcord.ext import commands
|
||||||
|
from highscores import highscores_data # pylint: disable=import-error
|
||||||
|
from utils import data_storage # pylint: disable=import-error
|
||||||
|
|
||||||
|
|
||||||
|
class RegisterVerificationChannel(commands.Cog, name="Register HighScore 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
|
||||||
|
data_storage.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 functon to bot"""
|
||||||
|
bot.add_cog(RegisterVerificationChannel(bot))
|
||||||
@@ -19,7 +19,7 @@ def open_highscores_data():
|
|||||||
data = json.load(file)
|
data = json.load(file)
|
||||||
else:
|
else:
|
||||||
# create the json object
|
# create the json object
|
||||||
data = {"channel_id": -1}
|
data = {"highscore_channel_id": -1, "verification_channel_id": -1}
|
||||||
config = open_highscores_config()
|
config = open_highscores_config()
|
||||||
for boss in config["bosses"]:
|
for boss in config["bosses"]:
|
||||||
data[boss["boss"]] = {"message_id": 0}
|
data[boss["boss"]] = {"message_id": 0}
|
||||||
|
|||||||
@@ -46,9 +46,9 @@ async def submit_score(self, ctx: commands.Context, boss_name: str, category: st
|
|||||||
highscores_data[boss_name]["categories"][category] = scores
|
highscores_data[boss_name]["categories"][category] = scores
|
||||||
|
|
||||||
# edit message
|
# edit message
|
||||||
channel_id = highscores_data["channel_id"]
|
highscore_channel_id = highscores_data["highscore_channel_id"]
|
||||||
print(f"Editting message {channel_id}")
|
print(f"Editting message {highscore_channel_id}")
|
||||||
channel = self.bot.get_channel(channel_id)
|
channel = self.bot.get_channel(highscore_channel_id)
|
||||||
if channel is None:
|
if channel is None:
|
||||||
response = 'Registered Highscores channel does not exist or was never registered. \
|
response = 'Registered Highscores channel does not exist or was never registered. \
|
||||||
Register with "?register" command.'
|
Register with "?register" command.'
|
||||||
|
|||||||
Reference in New Issue
Block a user