Compare commits
5
Commits
da7e529502
...
v1.7.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9bfbafe15b | ||
|
|
b42f04aada | ||
|
|
2ba56ead82 | ||
|
|
be824de52e | ||
|
|
d3084c4ddb |
+13
-13
@@ -12,28 +12,37 @@ class ChannelIds:
|
||||
"""Class holds all channel ids needed by bot."""
|
||||
|
||||
admin: int # might want to rename this...
|
||||
announcement_category: int
|
||||
announcement: int
|
||||
clan_info: int
|
||||
event_post: int
|
||||
general: int
|
||||
voting_parent: int
|
||||
voting: int
|
||||
|
||||
|
||||
@dataclass
|
||||
class Election:
|
||||
"""Class defines relevant election dates."""
|
||||
|
||||
name: str
|
||||
election_start: str
|
||||
highcouncil_election_announce: str
|
||||
highcouncil_election_end: str
|
||||
highcouncil_election_start: str
|
||||
name: str
|
||||
term_end: str
|
||||
term_start: str
|
||||
voting_end: str
|
||||
voting_start: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class EventSettings:
|
||||
"""Class defines settings editable by Clan Council."""
|
||||
|
||||
host_points: int
|
||||
participate_points: int
|
||||
weekly_limit: int
|
||||
|
||||
|
||||
@dataclass
|
||||
class Params:
|
||||
"""Class defines start parameters that shouldn't be changed."""
|
||||
@@ -47,22 +56,13 @@ class Params:
|
||||
class RoleIds:
|
||||
"""Class holds all role ids needed by bot."""
|
||||
|
||||
clan_council_elect: int
|
||||
clan_council: int
|
||||
clan_council_elect: int
|
||||
clan_member: int
|
||||
event_host: int
|
||||
high_council: int
|
||||
|
||||
|
||||
@dataclass
|
||||
class EventSettings:
|
||||
"""Class defines settings editable by Clan Council."""
|
||||
|
||||
host_points: int
|
||||
participate_points: int
|
||||
weekly_limit: int
|
||||
|
||||
|
||||
@dataclass
|
||||
class DakinySettings(YAMLWizard):
|
||||
"""Class defines all configs required for Dakiny Bot."""
|
||||
|
||||
+1
-1
@@ -160,7 +160,7 @@ class Election:
|
||||
async def election_start_action(self) -> None:
|
||||
"""Performs required actions for when the election cycle starts."""
|
||||
# create new channel for election
|
||||
parent: nextcord.TextChannel = self.guild.get_channel(settings.channel_ids.voting_parent)
|
||||
parent: nextcord.TextChannel = self.guild.get_channel(settings.channel_ids.voting)
|
||||
quarter_name: str = get_election_name()
|
||||
|
||||
thread_msg: nextcord.Message = await parent.send(content=quarter_name)
|
||||
|
||||
@@ -7,6 +7,7 @@ from cogs.commands.refresh import RefreshCog
|
||||
from cogs.commands.remove import RemoveCog
|
||||
from cogs.commands.request import RequestCog
|
||||
from cogs.commands.set import SetCog
|
||||
from cogs.commands.settings import SettingsCog
|
||||
from cogs.commands.test import TestCog
|
||||
from cogs.commands.time import TimeCog
|
||||
from cogs.commands.view import ViewCog
|
||||
@@ -21,6 +22,7 @@ def setup(bot: commands.Bot) -> None:
|
||||
bot.add_cog(RemoveCog())
|
||||
bot.add_cog(RequestCog(bot))
|
||||
bot.add_cog(SetCog())
|
||||
bot.add_cog(SettingsCog())
|
||||
bot.add_cog(TestCog(bot))
|
||||
bot.add_cog(TimeCog())
|
||||
bot.add_cog(ViewCog())
|
||||
|
||||
@@ -0,0 +1,301 @@
|
||||
"""Contains commands and views for settings commands."""
|
||||
|
||||
import nextcord
|
||||
from nextcord.ext import commands
|
||||
|
||||
from DakinySettings import settings
|
||||
from utils import GUILDS
|
||||
|
||||
|
||||
class SettingsCog(commands.Cog, name="Settings Commands"):
|
||||
"""Class holds settings commands."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
"""Default constructor for SettingsCog class. Does nothing."""
|
||||
|
||||
@nextcord.slash_command(guild_ids=GUILDS, default_member_permissions=nextcord.Permissions(administrator=True))
|
||||
async def settings(self, interaction: nextcord.Interaction) -> None:
|
||||
"""Parent slash command for settings. Never called."""
|
||||
|
||||
@settings.subcommand()
|
||||
async def channel_ids(self, interaction: nextcord.Interaction) -> None:
|
||||
"""Subcommand parent. Never called."""
|
||||
|
||||
@channel_ids.subcommand(description="Sets channel that bot sends verification requests to admins.")
|
||||
async def admin(
|
||||
self,
|
||||
interaction: nextcord.Interaction,
|
||||
channel: nextcord.TextChannel = nextcord.SlashOption(
|
||||
required=False, description="Channel to set to. If left blank, uses current channel."
|
||||
),
|
||||
) -> None:
|
||||
"""
|
||||
Sets DakinySettings channel_ids.admin value to given channel id or current channel id.
|
||||
|
||||
Args:
|
||||
interaction (nextcord.Interaction): Discord interaction of command.
|
||||
channel (nextcord.TextChannel, optional): Channel to set in settings.
|
||||
"""
|
||||
channel_id = interaction.channel_id if channel is None else channel.id
|
||||
settings.channel_ids.admin = channel_id
|
||||
settings.save()
|
||||
await interaction.response.send_message(f"Admin verification channel set to <#{channel_id}>.", ephemeral=True)
|
||||
|
||||
@channel_ids.subcommand(description="Sets announcement channel.")
|
||||
async def announcement(
|
||||
self,
|
||||
interaction: nextcord.Interaction,
|
||||
channel: nextcord.TextChannel = nextcord.SlashOption(
|
||||
required=False, description="Channel to set to. If left blank, uses current channel."
|
||||
),
|
||||
) -> None:
|
||||
"""
|
||||
Sets DakinySettings channel_ids.announcement value to given channel id or current channel id.
|
||||
|
||||
Args:
|
||||
interaction (nextcord.Interaction): Discord interaction of command.
|
||||
channel (nextcord.TextChannel, optional): Channel to set in settings.
|
||||
"""
|
||||
channel_id = interaction.channel_id if channel is None else channel.id
|
||||
settings.channel_ids.announcement = channel_id
|
||||
settings.save()
|
||||
await interaction.response.send_message(f"Announcement channel set to <#{channel_id}>.", ephemeral=True)
|
||||
|
||||
@channel_ids.subcommand(description="Sets clan info channel. Channel used for tracking current council.")
|
||||
async def clan_info(
|
||||
self,
|
||||
interaction: nextcord.Interaction,
|
||||
channel: nextcord.TextChannel = nextcord.SlashOption(
|
||||
required=False, description="Channel to set to. If left blank, uses current channel."
|
||||
),
|
||||
) -> None:
|
||||
"""
|
||||
Sets DakinySettings channel_ids.clan_info value to given channel id or current channel id.
|
||||
|
||||
Args:
|
||||
interaction (nextcord.Interaction): Discord interaction of command.
|
||||
channel (nextcord.TextChannel, optional): Channel to set in settings.
|
||||
"""
|
||||
channel_id = interaction.channel_id if channel is None else channel.id
|
||||
settings.channel_ids.clan_info = channel_id
|
||||
settings.save()
|
||||
await interaction.response.send_message(f"Clan information channel set to <#{channel_id}>.", ephemeral=True)
|
||||
|
||||
@channel_ids.subcommand(
|
||||
description="Sets event post channel. Channel is where event tracking information is posted."
|
||||
)
|
||||
async def event_post(
|
||||
self,
|
||||
interaction: nextcord.Interaction,
|
||||
channel: nextcord.TextChannel = nextcord.SlashOption(
|
||||
required=False, description="Channel to set to. If left blank, uses current channel."
|
||||
),
|
||||
) -> None:
|
||||
"""
|
||||
Sets DakinySettings channel_ids.event_post value to given channel id or current channel id.
|
||||
|
||||
Args:
|
||||
interaction (nextcord.Interaction): Discord interaction of command.
|
||||
channel (nextcord.TextChannel, optional): Channel to set in settings.
|
||||
"""
|
||||
channel_id = interaction.channel_id if channel is None else channel.id
|
||||
settings.channel_ids.event_post = channel_id
|
||||
settings.save()
|
||||
await interaction.response.send_message(f"Event posting channel set to <#{channel_id}>.", ephemeral=True)
|
||||
|
||||
@channel_ids.subcommand(description="Sets general channel.")
|
||||
async def general(
|
||||
self,
|
||||
interaction: nextcord.Interaction,
|
||||
channel: nextcord.TextChannel = nextcord.SlashOption(
|
||||
required=False, description="Channel to set to. If left blank, uses current channel."
|
||||
),
|
||||
) -> None:
|
||||
"""
|
||||
Sets DakinySettings channel_ids.general value to given channel id or current channel id.
|
||||
|
||||
Args:
|
||||
interaction (nextcord.Interaction): Discord interaction of command.
|
||||
channel (nextcord.TextChannel, optional): Channel to set in settings.
|
||||
"""
|
||||
channel_id = interaction.channel_id if channel is None else channel.id
|
||||
settings.channel_ids.general = channel_id
|
||||
settings.save()
|
||||
await interaction.response.send_message(f"General channel set to <#{channel_id}>.", ephemeral=True)
|
||||
|
||||
@channel_ids.subcommand(description="Sets voting channel. Channel used as parent for voting threads.")
|
||||
async def voting(
|
||||
self,
|
||||
interaction: nextcord.Interaction,
|
||||
channel: nextcord.TextChannel = nextcord.SlashOption(
|
||||
required=False, description="Channel to set to. If left blank, uses current channel."
|
||||
),
|
||||
) -> None:
|
||||
"""
|
||||
Sets DakinySettings channel_ids.voting value to given channel id or current channel id.
|
||||
|
||||
Args:
|
||||
interaction (nextcord.Interaction): Discord interaction of command.
|
||||
channel (nextcord.TextChannel, optional): Channel to set in settings.
|
||||
"""
|
||||
channel_id = interaction.channel_id if channel is None else channel.id
|
||||
settings.channel_ids.voting = channel_id
|
||||
settings.save()
|
||||
await interaction.response.send_message(f"Voting channel set to <#{channel_id}>.", ephemeral=True)
|
||||
|
||||
@settings.subcommand()
|
||||
async def event_settings(self, interaction: nextcord.Interaction) -> None:
|
||||
"""Subcommand parent. Never called."""
|
||||
|
||||
@event_settings.subcommand(description="Sets Event Host Points value.")
|
||||
async def host_points(
|
||||
self,
|
||||
interaction: nextcord.Interaction,
|
||||
points: int = nextcord.SlashOption(
|
||||
required=True, description="Number of Event Points a host earns when hosting event.", min_value=0
|
||||
),
|
||||
) -> None:
|
||||
"""
|
||||
Sets DakinySettings event_settings.host_points to the given number of points.
|
||||
|
||||
Args:
|
||||
interaction (nextcord.Interaction): Discord interaction of command.
|
||||
points (nextcord.TextChannel): Number of points to set.
|
||||
"""
|
||||
settings.event_settings.host_points = points
|
||||
settings.save()
|
||||
await interaction.response.send_message(f"Event Host Points set to {points}.", ephemeral=True)
|
||||
|
||||
@event_settings.subcommand(description="Sets Event Participation Points value.")
|
||||
async def participate_points(
|
||||
self,
|
||||
interaction: nextcord.Interaction,
|
||||
points: int = nextcord.SlashOption(
|
||||
required=True,
|
||||
description="Number of Event Points a participant earns when attending an event.",
|
||||
min_value=0,
|
||||
),
|
||||
) -> None:
|
||||
"""
|
||||
Sets DakinySettings event_settings.participate_points to the given number of points.
|
||||
|
||||
Args:
|
||||
interaction (nextcord.Interaction): Discord interaction of command.
|
||||
points (nextcord.TextChannel): Number of points to set.
|
||||
"""
|
||||
settings.event_settings.participate_points = points
|
||||
settings.save()
|
||||
await interaction.response.send_message(f"Event Participation Points set to {points}.", ephemeral=True)
|
||||
|
||||
@event_settings.subcommand(description="Sets Event Weekly Limit value.")
|
||||
async def weekly_limit(
|
||||
self,
|
||||
interaction: nextcord.Interaction,
|
||||
points: int = nextcord.SlashOption(
|
||||
required=True, description="Number of Event Points a clan member can earn in a week.", min_value=0
|
||||
),
|
||||
) -> None:
|
||||
"""
|
||||
Sets DakinySettings event_settings.weekly_limit to the given number of points.
|
||||
|
||||
Args:
|
||||
interaction (nextcord.Interaction): Discord interaction of command.
|
||||
points (nextcord.TextChannel): Number of points to set.
|
||||
"""
|
||||
settings.event_settings.weekly_limit = points
|
||||
settings.save()
|
||||
await interaction.response.send_message(f"Event Weekly Limit set to {points}.", ephemeral=True)
|
||||
|
||||
@settings.subcommand()
|
||||
async def role_ids(self, interaction: nextcord.Interaction) -> None:
|
||||
"""Subcommand parent. Never called."""
|
||||
|
||||
@role_ids.subcommand(description="Sets Clan Council role id.")
|
||||
async def clan_council(
|
||||
self,
|
||||
interaction: nextcord.Interaction,
|
||||
role: nextcord.Role = nextcord.SlashOption(required=True, description="Role to set."),
|
||||
) -> None:
|
||||
"""
|
||||
Sets DakinySettings role_ids.clan_council to the given role id.
|
||||
|
||||
Args:
|
||||
interaction (nextcord.Interaction): Discord interaction of command.
|
||||
role (nextcord.TextChannel): Role to set in settings.
|
||||
"""
|
||||
role_id = role.id
|
||||
settings.role_ids.clan_council = role_id
|
||||
settings.save()
|
||||
await interaction.response.send_message(f"Clan Council role set to <@&{role_id}>.", ephemeral=True)
|
||||
|
||||
@role_ids.subcommand(description="Sets Clan Council Elect role id.")
|
||||
async def clan_council_elect(
|
||||
self,
|
||||
interaction: nextcord.Interaction,
|
||||
role: nextcord.Role = nextcord.SlashOption(required=True, description="Role to set."),
|
||||
) -> None:
|
||||
"""
|
||||
Sets DakinySettings role_ids.clan_council_elect to the given role id.
|
||||
|
||||
Args:
|
||||
interaction (nextcord.Interaction): Discord interaction of command.
|
||||
role (nextcord.TextChannel): Role to set in settings.
|
||||
"""
|
||||
role_id = role.id
|
||||
settings.role_ids.clan_council_elect = role_id
|
||||
settings.save()
|
||||
await interaction.response.send_message(f"Clan Council Elect role set to <@&{role_id}>.", ephemeral=True)
|
||||
|
||||
@role_ids.subcommand(description="Sets Clan Member role id.")
|
||||
async def clan_member(
|
||||
self,
|
||||
interaction: nextcord.Interaction,
|
||||
role: nextcord.Role = nextcord.SlashOption(required=True, description="Role to set."),
|
||||
) -> None:
|
||||
"""
|
||||
Sets DakinySettings role_ids.clan_member to the given role id.
|
||||
|
||||
Args:
|
||||
interaction (nextcord.Interaction): Discord interaction of command.
|
||||
role (nextcord.TextChannel): Role to set in settings.
|
||||
"""
|
||||
role_id = role.id
|
||||
settings.role_ids.clan_member = role_id
|
||||
settings.save()
|
||||
await interaction.response.send_message(f"Clan Member role set to <@&{role_id}>.", ephemeral=True)
|
||||
|
||||
@role_ids.subcommand(description="Sets Event Host role id.")
|
||||
async def event_host(
|
||||
self,
|
||||
interaction: nextcord.Interaction,
|
||||
role: nextcord.Role = nextcord.SlashOption(required=True, description="Role to set."),
|
||||
) -> None:
|
||||
"""
|
||||
Sets DakinySettings role_ids.event_host to the given role id.
|
||||
|
||||
Args:
|
||||
interaction (nextcord.Interaction): Discord interaction of command.
|
||||
role (nextcord.TextChannel): Role to set in settings.
|
||||
"""
|
||||
role_id = role.id
|
||||
settings.role_ids.event_host = role_id
|
||||
settings.save()
|
||||
await interaction.response.send_message(f"Event Host role set to <@&{role_id}>.", ephemeral=True)
|
||||
|
||||
@role_ids.subcommand(description="Sets High Council role id.")
|
||||
async def high_council(
|
||||
self,
|
||||
interaction: nextcord.Interaction,
|
||||
role: nextcord.Role = nextcord.SlashOption(required=True, description="Role to set."),
|
||||
) -> None:
|
||||
"""
|
||||
Sets DakinySettings role_ids.high_council to the given role id.
|
||||
|
||||
Args:
|
||||
interaction (nextcord.Interaction): Discord interaction of command.
|
||||
role (nextcord.TextChannel): Role to set in settings.
|
||||
"""
|
||||
role_id = role.id
|
||||
settings.role_ids.high_council = role_id
|
||||
settings.save()
|
||||
await interaction.response.send_message(f"High Council role set to <@&{role_id}>.", ephemeral=True)
|
||||
Reference in New Issue
Block a user