mirror of
https://github.com/UiO-Gaming/mustafa.git
synced 2026-11-05 13:56:48 +01:00
replace hardcoded channel and role ids with config values
This commit is contained in:
1 parent
196cb8a65b
commit
4607aa7725
12 files changed
+59
-23
No files matched your search
+1
-2
@@ -24,7 +24,6 @@ class Aurora(commands.Cog):
|
||||
|
||||
self.notified = datetime(2000, 9, 11) # Used to prevent spamming aurora alerts
|
||||
self.aurora_alarm.start()
|
||||
self.AURORA_CHANNEL = 747542544291987599
|
||||
|
||||
def cog_unload(self):
|
||||
self.bot.logger.info("Unloading cog")
|
||||
@@ -91,7 +90,7 @@ class Aurora(commands.Cog):
|
||||
self.bot.logger.info("aurora_alarm: Fetch forecast")
|
||||
return
|
||||
|
||||
channel = self.bot.get_channel(self.AURORA_CHANNEL)
|
||||
channel = self.bot.get_channel(self.bot.channel_ids.get("aurora"))
|
||||
if not channel:
|
||||
self.bot.logger.warning("aurora_alarm: Failed to get aurora channel")
|
||||
return
|
||||
|
||||
@@ -78,7 +78,10 @@ class Birthday(commands.Cog):
|
||||
return
|
||||
|
||||
guild = self.bot.get_guild(self.bot.UIO_GAMING_GUILD_ID)
|
||||
channel = guild.get_channel(747542544291987597)
|
||||
channel = guild.get_channel(self.bot.channel_ids.get("general")) if guild else None
|
||||
if not channel:
|
||||
self.bot.logger.warning("Could not find the general channel. Check ids.guild and ids.channels.general")
|
||||
return
|
||||
for birthday in birthdays:
|
||||
try:
|
||||
user = await guild.fetch_member(birthday[0])
|
||||
@@ -118,7 +121,7 @@ class Birthday(commands.Cog):
|
||||
+ "bare har 1% sjanse å få!!!!\nhttps://youtu.be/mOyDlnvZwcg"
|
||||
)
|
||||
|
||||
if user.id == 170506717140877312:
|
||||
if user.id == self.bot.user_ids.get("dev"):
|
||||
message = (
|
||||
f"Ett steg nærmere døden i dag broder,,, Iskjhe bra,,, {user.mention}\n\n"
|
||||
+ "https://youtu.be/9Fr3oLZnmvc"
|
||||
|
||||
+4
-1
@@ -34,7 +34,10 @@ class BotInfo(commands.Cog):
|
||||
"""
|
||||
|
||||
# Dev user info
|
||||
dev = await self.bot.fetch_user(170506717140877312)
|
||||
if dev_id := self.bot.user_ids.get("dev"):
|
||||
dev = await self.bot.fetch_user(dev_id)
|
||||
else:
|
||||
dev = (await self.bot.application_info()).owner
|
||||
|
||||
# Memory usage
|
||||
process = Process(getpid())
|
||||
|
||||
@@ -77,7 +77,7 @@ class Gullkorn(commands.Cog):
|
||||
message (discord.Message): Message object to check for triggers to
|
||||
"""
|
||||
|
||||
if message.author.bot or message.channel.id != 865970753748074576 or not message.mentions:
|
||||
if message.author.bot or message.channel.id != self.bot.channel_ids.get("gullkorn") or not message.mentions:
|
||||
return
|
||||
|
||||
for user in message.mentions:
|
||||
|
||||
+1
-1
@@ -92,7 +92,7 @@ class Misc(commands.Cog):
|
||||
bruker = interaction.user
|
||||
|
||||
# Må jo gi meg selv en stor kuk
|
||||
if bruker.id == 170506717140877312:
|
||||
if bruker.id == self.bot.user_ids.get("dev"):
|
||||
dick_size = 69
|
||||
elif bruker.id == 327207142681608192:
|
||||
dick_size = 1
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import random
|
||||
from datetime import datetime
|
||||
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
from discord.ext import tasks
|
||||
|
||||
@@ -12,7 +13,6 @@ class RepeatedMessages(commands.Cog):
|
||||
|
||||
def __init__(self, bot: commands.Bot):
|
||||
self.bot = bot
|
||||
self.general_channel = 747542544291987597
|
||||
|
||||
# self.fredag.start()
|
||||
# self.mandag.start()
|
||||
@@ -23,6 +23,17 @@ class RepeatedMessages(commands.Cog):
|
||||
# self.mandag.cancel()
|
||||
self.new_year.cancel()
|
||||
|
||||
def get_general_channel(self) -> discord.TextChannel | None:
|
||||
"""
|
||||
Returns
|
||||
----------
|
||||
(discord.TextChannel | None): The channel to post repeated messages in. None if it can't be found
|
||||
"""
|
||||
|
||||
if not (channel := self.bot.get_channel(self.bot.channel_ids.get("general"))):
|
||||
self.bot.logger.warning("Could not find the general channel. Check ids.channels.general in the config")
|
||||
return channel
|
||||
|
||||
@tasks.loop(time=misc_utils.MIDNIGHT)
|
||||
@misc_utils.log_errors
|
||||
async def fredag(self):
|
||||
@@ -33,8 +44,8 @@ class RepeatedMessages(commands.Cog):
|
||||
if datetime.now().weekday() != 4:
|
||||
return
|
||||
|
||||
guild = self.bot.get_guild(self.bot.UIO_GAMING_GUILD_ID)
|
||||
channel = guild.get_channel(self.general_channel)
|
||||
if not (channel := self.get_general_channel()):
|
||||
return
|
||||
|
||||
videos = [
|
||||
"https://cdn.discordapp.com/attachments/750052141346979850/851216786259181578/video0.mp4",
|
||||
@@ -64,8 +75,8 @@ class RepeatedMessages(commands.Cog):
|
||||
"""
|
||||
if datetime.now().weekday() != 0:
|
||||
return
|
||||
guild = self.bot.get_guild(self.bot.UIO_GAMING_GUILD_ID)
|
||||
channel = guild.get_channel(self.general_channel)
|
||||
if not (channel := self.get_general_channel()):
|
||||
return
|
||||
await channel.send(
|
||||
"ENDELIG MANDAG!\n\n"
|
||||
+ "https://cdn.discordapp.com/attachments/678396498089738250/1168644637687283762/Snapchat-1787493720.mp4" # noqa: E501
|
||||
@@ -82,8 +93,8 @@ class RepeatedMessages(commands.Cog):
|
||||
if datetime.now().month != 1 or datetime.now().day != 1:
|
||||
return
|
||||
|
||||
guild = self.bot.get_guild(self.bot.UIO_GAMING_GUILD_ID)
|
||||
channel = guild.get_channel(self.general_channel)
|
||||
if not (channel := self.get_general_channel()):
|
||||
return
|
||||
await channel.send("GODT NYTTÅR!\n\nNå, meld dere inn i UiO Gaming igjen <:ThisIsAThreat:874998234072903710>")
|
||||
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ class SocialCredit(commands.Cog):
|
||||
+ "If it is, ignore this."
|
||||
)
|
||||
return
|
||||
if not (weeb_role := guild.get_role(803629993539403826)):
|
||||
if not (weeb_role := guild.get_role(self.bot.role_ids.get("weeb"))):
|
||||
self.bot.logger.warning(
|
||||
"Could not fetch UiO Gaming's weeb role."
|
||||
+ "If the bot does not have access to the UiO Gaming server, this function won't work. "
|
||||
@@ -288,7 +288,7 @@ class SocialCredit(commands.Cog):
|
||||
message (discord.Message): The message object
|
||||
"""
|
||||
|
||||
if message.channel.id == 754706204349038644:
|
||||
if message.channel.id == self.bot.channel_ids.get("politics"):
|
||||
await self.social_punishment(message.author.id, 25, "politics")
|
||||
|
||||
@roll(percent=25)
|
||||
@@ -301,7 +301,7 @@ class SocialCredit(commands.Cog):
|
||||
message (discord.Message): The message object
|
||||
"""
|
||||
|
||||
if message.channel.id == 811606213665357824:
|
||||
if message.channel.id == self.bot.channel_ids.get("member_chat"):
|
||||
await self.social_reward(message.author.id, 10, "member-chat")
|
||||
|
||||
@roll(percent=50)
|
||||
@@ -381,7 +381,7 @@ class SocialCredit(commands.Cog):
|
||||
"""
|
||||
|
||||
# This only works in the UiO Gaming server as well
|
||||
if message.channel.id == 865970753748074576 and message.mentions:
|
||||
if message.channel.id == self.bot.channel_ids.get("gullkorn") and message.mentions:
|
||||
for mention in message.mentions:
|
||||
await self.social_punishment(mention.id, 10, "gullkorn")
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class StarboardScraper(commands.Cog):
|
||||
"""
|
||||
|
||||
self.bot = bot
|
||||
self.starboard_channel_id = 757614289812193280
|
||||
self.starboard_channel_id = self.bot.channel_ids.get("starboard")
|
||||
|
||||
self.cursor = self.bot.db_connection.cursor()
|
||||
self.init_db()
|
||||
|
||||
@@ -417,7 +417,7 @@ class TempVoiceHelper:
|
||||
|
||||
# Get the UiO Gaming server's VC category. If the command is not invoked in that server it should still be fine
|
||||
# since the it will return None if not found.
|
||||
vc_category = interaction.guild.get_channel(747542544291987601)
|
||||
vc_category = interaction.guild.get_channel(self.bot.channel_ids.get("voice_category"))
|
||||
|
||||
try:
|
||||
channel = await interaction.guild.create_voice_channel(
|
||||
|
||||
@@ -498,7 +498,7 @@ class WordCloud(commands.Cog):
|
||||
|
||||
# Get member role for future channel permission checking
|
||||
# This shouldn't be hard coded but eh
|
||||
board_member_role = interaction.guild.get_role(779849617651138601)
|
||||
board_member_role = interaction.guild.get_role(self.bot.role_ids.get("board_member"))
|
||||
|
||||
# This is horrible but there's a lot of edge cases to handle so spare me pls
|
||||
all_messages = ""
|
||||
|
||||
@@ -5,6 +5,23 @@ dev_guild: 747542543750660178
|
||||
# IANA timezone name. Leave empty to use the system's timezone
|
||||
timezone: Europe/Oslo
|
||||
|
||||
# Discord IDs the bot's features rely on. Features whose ID is missing are skipped
|
||||
ids:
|
||||
guild: 747542543750660178
|
||||
channels:
|
||||
general: 747542544291987597
|
||||
aurora: 747542544291987599
|
||||
gullkorn: 865970753748074576
|
||||
politics: 754706204349038644
|
||||
member_chat: 811606213665357824
|
||||
starboard: 757614289812193280
|
||||
voice_category: 747542544291987601
|
||||
roles:
|
||||
weeb: 803629993539403826
|
||||
board_member: 779849617651138601
|
||||
users:
|
||||
dev: 170506717140877312
|
||||
|
||||
# Bot settings
|
||||
bot:
|
||||
token:
|
||||
|
||||
+5
-2
@@ -11,7 +11,6 @@ from discord.ext import commands
|
||||
|
||||
from logger import BotLogger
|
||||
|
||||
UIO_GAMING_GUILD_ID = 747542543750660178
|
||||
DATABASE_RELIANT_COGS = {
|
||||
"birthday.py",
|
||||
"gullkorn.py",
|
||||
@@ -67,7 +66,11 @@ class Bot(commands.Bot):
|
||||
self.mc_rcon_password = config["minecraft"]["rcon_password"]
|
||||
|
||||
# Fetch misc config values
|
||||
self.UIO_GAMING_GUILD_ID = UIO_GAMING_GUILD_ID
|
||||
ids = config.get("ids") or {}
|
||||
self.UIO_GAMING_GUILD_ID = ids.get("guild")
|
||||
self.channel_ids = ids.get("channels") or {}
|
||||
self.role_ids = ids.get("roles") or {}
|
||||
self.user_ids = ids.get("users") or {}
|
||||
self.guild_id = config.get("dev_guild", self.UIO_GAMING_GUILD_ID)
|
||||
self.config_mode = config.get("config_mode")
|
||||
self.presence = config["bot"].get("presence", {})
|
||||
|
||||
Reference in new issue
Block a user