Skip to content

Commit f7095ac

Browse files
committed
Merge branch 'main' of github.com:allthingslinux/tux
2 parents 54469b3 + 96b04b1 commit f7095ac

File tree

1 file changed

+171
-0
lines changed

1 file changed

+171
-0
lines changed

tux/cogs/guild/config.py

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
import discord
2+
from discord.ext import commands
3+
4+
from tux.database.controllers import DatabaseController
5+
6+
7+
class Config(commands.Cog):
8+
def __init__(self, bot: commands.Bot) -> None:
9+
self.bot = bot
10+
self.db = DatabaseController().guild_config
11+
12+
@commands.hybrid_group(name="config", description="Guild configuration commands.", alias="cfg")
13+
async def config(self, ctx: commands.Context[commands.Bot]) -> None:
14+
if ctx.invoked_subcommand is None:
15+
await ctx.send_help("config")
16+
17+
@commands.has_permissions(administrator=True)
18+
@config.command(name="set_dev_role", description="Set the dev role for the guild.")
19+
async def set_dev_role(self, ctx: commands.Context[commands.Bot], role: discord.Role) -> None:
20+
if ctx.guild is None:
21+
return
22+
await self.db.update_guild_dev_role_id(ctx.guild.id, role.id)
23+
await ctx.reply(f"Dev role set to {role.mention}.", ephemeral=True)
24+
25+
@commands.has_permissions(administrator=True)
26+
@config.command(name="set_admin_role", description="Set the admin role for the guild.")
27+
async def set_admin_role(self, ctx: commands.Context[commands.Bot], role: discord.Role) -> None:
28+
if ctx.guild is None:
29+
return
30+
await self.db.update_guild_admin_role_id(ctx.guild.id, role.id)
31+
await ctx.reply(f"Admin role set to {role.mention}.", ephemeral=True)
32+
33+
@commands.has_permissions(administrator=True)
34+
@config.command(name="set_senior_role", description="Set the senior role for the guild.")
35+
async def set_senior_role(self, ctx: commands.Context[commands.Bot], role: discord.Role) -> None:
36+
if ctx.guild is None:
37+
return
38+
await self.db.update_guild_senior_role_id(ctx.guild.id, role.id)
39+
await ctx.reply(f"Senior role set to {role.mention}.", ephemeral=True)
40+
41+
@commands.has_permissions(administrator=True)
42+
@config.command(name="set_staff_role", description="Set the base staff role for the guild.")
43+
async def set_staff_role(self, ctx: commands.Context[commands.Bot], role: discord.Role) -> None:
44+
if ctx.guild is None:
45+
return
46+
await self.db.update_guild_base_staff_role_id(ctx.guild.id, role.id)
47+
await ctx.reply(f"Staff role set to {role.mention}.", ephemeral=True)
48+
49+
@commands.has_permissions(administrator=True)
50+
@config.command(name="set_member_role", description="Set the base member role for the guild.")
51+
async def set_member_role(self, ctx: commands.Context[commands.Bot], role: discord.Role) -> None:
52+
if ctx.guild is None:
53+
return
54+
await self.db.update_guild_base_member_role_id(ctx.guild.id, role.id)
55+
await ctx.reply(f"Member role set to {role.mention}.", ephemeral=True)
56+
57+
@commands.has_permissions(administrator=True)
58+
@config.command(name="set_junior_role", description="Set the junior role for the guild.")
59+
async def set_junior_role(self, ctx: commands.Context[commands.Bot], role: discord.Role) -> None:
60+
if ctx.guild is None:
61+
return
62+
await self.db.update_guild_junior_role_id(ctx.guild.id, role.id)
63+
await ctx.reply(f"Junior role set to {role.mention}.", ephemeral=True)
64+
65+
@commands.has_permissions(administrator=True)
66+
@config.command(name="set_jail_role", description="Set the jail role for the guild.")
67+
async def set_jail_role(self, ctx: commands.Context[commands.Bot], role: discord.Role) -> None:
68+
if ctx.guild is None:
69+
return
70+
await self.db.update_guild_jail_role_id(ctx.guild.id, role.id)
71+
await ctx.reply(f"Jail role set to {role.mention}.", ephemeral=True)
72+
73+
@commands.has_permissions(administrator=True)
74+
@config.command(name="set_quarantine_role", description="Set the quarantine role for the guild.")
75+
async def set_quarantine_role(self, ctx: commands.Context[commands.Bot], role: discord.Role) -> None:
76+
if ctx.guild is None:
77+
return
78+
await self.db.update_guild_quarantine_role_id(ctx.guild.id, role.id)
79+
await ctx.reply(f"Quarantine role set to {role.mention}.", ephemeral=True)
80+
81+
@commands.has_permissions(administrator=True)
82+
@config.command(name="set_mod_role", description="Set the moderator role for the guild.")
83+
async def set_mod_role(self, ctx: commands.Context[commands.Bot], role: discord.Role) -> None:
84+
if ctx.guild is None:
85+
return
86+
await self.db.update_guild_mod_role_id(ctx.guild.id, role.id)
87+
await ctx.reply(f"Moderator role set to {role.mention}.", ephemeral=True)
88+
89+
@commands.has_permissions(administrator=True)
90+
@config.command(name="set_mod_log", description="Set the mod log channel for the guild.")
91+
async def set_mod_log(self, ctx: commands.Context[commands.Bot], channel: discord.TextChannel) -> None:
92+
if ctx.guild is None:
93+
return
94+
await self.db.update_guild_mod_log_channel_id(ctx.guild.id, channel.id)
95+
await ctx.reply(f"Mod log channel set to {channel.mention}.", ephemeral=True)
96+
97+
@commands.has_permissions(administrator=True)
98+
@config.command(name="set_audit_log", description="Set the audit log channel for the guild.")
99+
async def set_audit_log(self, ctx: commands.Context[commands.Bot], channel: discord.TextChannel) -> None:
100+
if ctx.guild is None:
101+
return
102+
await self.db.update_guild_audit_log_channel_id(ctx.guild.id, channel.id)
103+
await ctx.reply(f"Audit log channel set to {channel.mention}.", ephemeral=True)
104+
105+
@commands.has_permissions(administrator=True)
106+
@config.command(name="set_join_log", description="Set the join log channel for the guild.")
107+
async def set_join_log(self, ctx: commands.Context[commands.Bot], channel: discord.TextChannel) -> None:
108+
if ctx.guild is None:
109+
return
110+
await self.db.update_guild_join_log_channel_id(ctx.guild.id, channel.id)
111+
await ctx.reply(f"Join log channel set to {channel.mention}.", ephemeral=True)
112+
113+
@commands.has_permissions(administrator=True)
114+
@config.command(name="set_private_log", description="Set the private log channel for the guild.")
115+
async def set_private_log(self, ctx: commands.Context[commands.Bot], channel: discord.TextChannel) -> None:
116+
if ctx.guild is None:
117+
return
118+
await self.db.update_guild_private_log_channel_id(ctx.guild.id, channel.id)
119+
await ctx.reply(f"Private log channel set to {channel.mention}.", ephemeral=True)
120+
121+
@commands.has_permissions(administrator=True)
122+
@config.command(name="set_report_log", description="Set the report log channel for the guild.")
123+
async def set_report_log(self, ctx: commands.Context[commands.Bot], channel: discord.TextChannel) -> None:
124+
if ctx.guild is None:
125+
return
126+
await self.db.update_guild_report_log_channel_id(ctx.guild.id, channel.id)
127+
await ctx.reply(f"Report log channel set to {channel.mention}.", ephemeral=True)
128+
129+
@commands.has_permissions(administrator=True)
130+
@config.command(name="set_dev_log", description="Set the dev log channel for the guild.")
131+
async def set_dev_log(self, ctx: commands.Context[commands.Bot], channel: discord.TextChannel) -> None:
132+
if ctx.guild is None:
133+
return
134+
await self.db.update_guild_dev_log_channel_id(ctx.guild.id, channel.id)
135+
await ctx.reply(f"Dev log channel set to {channel.mention}.", ephemeral=True)
136+
137+
@commands.has_permissions(administrator=True)
138+
@config.command(name="set_jail_channel", description="Set the jail channel for the guild.")
139+
async def set_jail_channel(self, ctx: commands.Context[commands.Bot], channel: discord.TextChannel) -> None:
140+
if ctx.guild is None:
141+
return
142+
await self.db.update_guild_jail_channel_id(ctx.guild.id, channel.id)
143+
await ctx.reply(f"Jail channel set to {channel.mention}.", ephemeral=True)
144+
145+
@commands.has_permissions(administrator=True)
146+
@config.command(name="set_starboard_channel", description="Set the starboard channel for the guild.")
147+
async def set_starboard_channel(self, ctx: commands.Context[commands.Bot], channel: discord.TextChannel) -> None:
148+
if ctx.guild is None:
149+
return
150+
await self.db.update_guild_starboard_channel_id(ctx.guild.id, channel.id)
151+
await ctx.reply(f"Starboard channel set to {channel.mention}.", ephemeral=True)
152+
153+
@commands.has_permissions(administrator=True)
154+
@config.command(name="set_mod_channel", description="Set the mod channel for the guild.")
155+
async def set_mod_channel(self, ctx: commands.Context[commands.Bot], channel: discord.TextChannel) -> None:
156+
if ctx.guild is None:
157+
return
158+
await self.db.update_guild_mod_channel_id(ctx.guild.id, channel.id)
159+
await ctx.reply(f"Mod channel set to {channel.mention}.", ephemeral=True)
160+
161+
@commands.has_permissions(administrator=True)
162+
@config.command(name="set_bot_channel", description="Set the bot channel for the guild.")
163+
async def set_bot_channel(self, ctx: commands.Context[commands.Bot], channel: discord.TextChannel) -> None:
164+
if ctx.guild is None:
165+
return
166+
await self.db.update_guild_bot_channel_id(ctx.guild.id, channel.id)
167+
await ctx.reply(f"Bot channel set to {channel.mention}.", ephemeral=True)
168+
169+
170+
async def setup(bot: commands.Bot) -> None:
171+
await bot.add_cog(Config(bot))

0 commit comments

Comments
 (0)