Replace rest of bot.config references. Clear record.py of old config usage.
This commit is contained in:
@@ -9,13 +9,12 @@ from git import Repo
|
||||
from nextcord.ext import commands
|
||||
|
||||
from classes.gitea_webhook import GiteaWebhook
|
||||
from DakinySettings import settings
|
||||
from utils import REPO_DIR, edit_clan_council_info, update_clan_messages
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import nextcord
|
||||
|
||||
from DakinySettings import DakinySettings
|
||||
|
||||
app = FastAPI()
|
||||
REPO_URL = "https://gitea.cheezers.org/imcompiling/dakiny-messages.git"
|
||||
|
||||
@@ -30,7 +29,6 @@ class ClanMessages(commands.Cog, name="Clan Messages"):
|
||||
|
||||
def __init__(self, bot: commands.Bot):
|
||||
self.bot = bot
|
||||
self.config: DakinySettings = self.bot.config
|
||||
self.repo_setup()
|
||||
|
||||
@commands.Cog.listener()
|
||||
@@ -58,13 +56,13 @@ class ClanMessages(commands.Cog, name="Clan Messages"):
|
||||
channel_updates = {file.split("/")[1] for file in modified_files if file.split("/")[1] not in template_updates}
|
||||
|
||||
self.origin.pull()
|
||||
guild: nextcord.Guild = self.bot.get_guild(self.config.params.guild_id)
|
||||
guild: nextcord.Guild = self.bot.get_guild(settings.params.guild_id)
|
||||
|
||||
await update_clan_messages(guild, channel_updates)
|
||||
|
||||
# if the council members template has changed, update the message
|
||||
if "council_members.txt" in template_updates:
|
||||
await edit_clan_council_info(self.bot.get_guild(self.config.params.guild_id))
|
||||
await edit_clan_council_info(self.bot.get_guild(settings.params.guild_id))
|
||||
|
||||
return {"message": "Successfully updated all discord messages."}
|
||||
|
||||
@@ -78,7 +76,7 @@ class ClanMessages(commands.Cog, name="Clan Messages"):
|
||||
|
||||
self.origin = self.repo.remote("origin")
|
||||
|
||||
if self.config.params.git_branch == "test":
|
||||
if settings.params.git_branch == "test":
|
||||
self.repo.create_head("test", self.origin.refs.test).set_tracking_branch(self.origin.refs.test).checkout()
|
||||
else:
|
||||
self.repo.create_head("main", self.origin.refs.main).set_tracking_branch(self.origin.refs.main).checkout()
|
||||
|
||||
+14
-17
@@ -4,7 +4,7 @@ import nextcord
|
||||
from discord import TextInputStyle
|
||||
from nextcord.ext import commands
|
||||
|
||||
from DakinySettings import DakinySettings
|
||||
from DakinySettings import settings
|
||||
from utils import GUILDS, MAX_DISCORD_MESSAGE_LENGTH, record_event_points
|
||||
|
||||
|
||||
@@ -42,9 +42,9 @@ class RecordCog(commands.Cog, name="Record Commands"):
|
||||
host (nextcord.Member, optional): Alternative host to user using command.
|
||||
"""
|
||||
# check role
|
||||
if interaction.guild.get_role(self.bot.config.params.event_host_role_id) not in interaction.user.roles:
|
||||
if interaction.guild.get_role(settings.role_ids.event_host) not in interaction.user.roles:
|
||||
await interaction.response.send_message(
|
||||
f"You must have the <@&{self.bot.config.params.event_host_role_id}> role to record an event.",
|
||||
f"You must have the <@&{settings.role_ids.event_host}> role to record an event.",
|
||||
ephemeral=True,
|
||||
)
|
||||
return
|
||||
@@ -59,7 +59,7 @@ class RecordCog(commands.Cog, name="Record Commands"):
|
||||
|
||||
await interaction.response.send_message(
|
||||
"Fill out event details and select all members who participated!",
|
||||
view=EventView(name, self.bot.config, host.id),
|
||||
view=EventView(name, host.id),
|
||||
ephemeral=True,
|
||||
embed=embed,
|
||||
)
|
||||
@@ -105,9 +105,9 @@ class RecordCog(commands.Cog, name="Record Commands"):
|
||||
non_discord_recipient (str): Non Discord member to give point to.
|
||||
"""
|
||||
# role check
|
||||
if interaction.guild.get_role(self.bot.config.params.clan_member_role_id) not in interaction.user.roles:
|
||||
if interaction.guild.get_role(settings.role_ids.clan_member) not in interaction.user.roles:
|
||||
await interaction.response.send_message(
|
||||
f"You must have the <@&{self.bot.config.params.clan_member_role_id}> role to record points.",
|
||||
f"You must have the <@&{settings.role_ids.clan_member}> role to record points.",
|
||||
ephemeral=True,
|
||||
)
|
||||
return
|
||||
@@ -119,14 +119,14 @@ class RecordCog(commands.Cog, name="Record Commands"):
|
||||
elif recipient is not None: # noqa: RET505
|
||||
record_event_points(
|
||||
[str(recipient.id)],
|
||||
self.bot.config.params.event_participate_points,
|
||||
settings.event_settings.participate_points,
|
||||
is_member=True,
|
||||
)
|
||||
recipient_str = f"<@{recipient.id}>"
|
||||
elif non_discord_recipient is not None:
|
||||
record_event_points(
|
||||
[non_discord_recipient],
|
||||
self.bot.config.params.event_participate_points,
|
||||
settings.event_settings.participate_points,
|
||||
is_member=False,
|
||||
)
|
||||
recipient_str = f'"{non_discord_recipient}"'
|
||||
@@ -134,9 +134,7 @@ class RecordCog(commands.Cog, name="Record Commands"):
|
||||
await interaction.response.send_message("You must provide a recipient.", ephemeral=True)
|
||||
return
|
||||
|
||||
event_channel: nextcord.TextChannel = interaction.guild.get_channel(
|
||||
self.bot.config.params.event_post_channel_id
|
||||
)
|
||||
event_channel: nextcord.TextChannel = interaction.guild.get_channel(settings.channel_ids.event_post)
|
||||
|
||||
msg = f"<@{interaction.user.id}> has given {recipient_str} points for the {activity} activity. Justification: {justification}" # noqa: E501
|
||||
if not msg.endswith("."):
|
||||
@@ -153,11 +151,10 @@ class EventView(nextcord.ui.View):
|
||||
Also contains a UserSelect object to pick discord members.
|
||||
"""
|
||||
|
||||
def __init__(self, name: str, config: DakinySettings, host_id: int):
|
||||
def __init__(self, name: str, host_id: int):
|
||||
super().__init__()
|
||||
|
||||
self.name: str = name
|
||||
self.config: DakinySettings = config
|
||||
self.host_id: int = host_id
|
||||
|
||||
self.event_participants = ParticipantSelect()
|
||||
@@ -188,7 +185,7 @@ class EventView(nextcord.ui.View):
|
||||
discord_users_list: list[str] = [str(user.id) for user in discord_users if user.id is not self.host_id]
|
||||
record_event_points(
|
||||
discord_users_list,
|
||||
self.config.params.event_participate_points,
|
||||
settings.event_settings.participate_points,
|
||||
is_member=True,
|
||||
)
|
||||
|
||||
@@ -197,13 +194,13 @@ class EventView(nextcord.ui.View):
|
||||
non_discord_users_list: list[str] = non_discord_users.split("\n")
|
||||
record_event_points(
|
||||
non_discord_users_list,
|
||||
self.config.params.event_participate_points,
|
||||
settings.event_settings.participate_points,
|
||||
is_member=False,
|
||||
)
|
||||
|
||||
record_event_points([self.host_id], self.config.params.event_host_points, is_member=True)
|
||||
record_event_points([self.host_id], settings.event_settings.host_points, is_member=True)
|
||||
|
||||
event_channel: nextcord.TextChannel = interaction.guild.get_channel(self.config.params.event_post_channel_id)
|
||||
event_channel: nextcord.TextChannel = interaction.guild.get_channel(settings.channel_ids.event_post)
|
||||
await event_channel.send(embed=interaction.message.embeds[0])
|
||||
await interaction.response.edit_message(content="Event has been submitted.", view=None, embed=None)
|
||||
|
||||
|
||||
@@ -6,11 +6,9 @@ import nextcord
|
||||
from nextcord.ext import commands
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from DakinySettings import settings
|
||||
from database_setup.sql_data_classes import Presences, engine
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from DakinySettings import DakinySettings
|
||||
|
||||
|
||||
class RequestCog(commands.Cog, name="Request Commands"):
|
||||
"""Class holds request commands."""
|
||||
@@ -41,10 +39,9 @@ class RequestCog(commands.Cog, name="Request Commands"):
|
||||
interaction (nextcord.Interaction): Interaction that invoked the command.
|
||||
presence (str): The presence to add.
|
||||
"""
|
||||
config: DakinySettings = self.bot.config
|
||||
content = f'<@{interaction.user.id}> would like to add presence "{presence}."'
|
||||
view = PresenceChange(presence)
|
||||
await self.bot.get_channel(config.params.admin_channel_id).send(content=content, view=view)
|
||||
await self.bot.get_channel(settings.channel_ids.admin).send(content=content, view=view)
|
||||
await interaction.response.send_message("Request sent to admins.", ephemeral=True)
|
||||
|
||||
@request.subcommand(description="Request to change your Dakiny nickname")
|
||||
@@ -65,10 +62,9 @@ class RequestCog(commands.Cog, name="Request Commands"):
|
||||
interaction (nextcord.Interaction): Interaction that invoked the command.
|
||||
new_nickname(str): The username to change to.
|
||||
"""
|
||||
config: DakinySettings = self.bot.config
|
||||
content = f'<@{interaction.user.id}> would like to change their username to "{new_nickname}."'
|
||||
view = UsernameRequest(interaction.user.id, new_nickname)
|
||||
await self.bot.get_channel(config.params.admin_channel_id).send(content=content, view=view)
|
||||
await self.bot.get_channel(settings.channel_ids.admin).send(content=content, view=view)
|
||||
await interaction.response.send_message("Request sent to admins.", ephemeral=True)
|
||||
|
||||
|
||||
|
||||
@@ -106,8 +106,8 @@ class DailyLoop(commands.Cog, name="Daily Loop"):
|
||||
Sends a message saying happy cakeday.
|
||||
"""
|
||||
today = datetime.now(tz=UTC).date()
|
||||
guild: nextcord.Guild = self.bot.get_guild(self.bot.config.params.guild_id)
|
||||
announce_channel: nextcord.TextChannel = guild.get_channel(self.bot.config.params.general_channel_id)
|
||||
guild: nextcord.Guild = self.bot.get_guild(settings.params.guild_id)
|
||||
announce_channel: nextcord.TextChannel = guild.get_channel(settings.channel_ids.general)
|
||||
|
||||
cakedays: list[nextcord.Member] = [
|
||||
human for human in guild.humans if human.joined_at.month == today.month and human.joined_at.day == today.day
|
||||
|
||||
Reference in New Issue
Block a user