tux.cogs.guild.config
¶
Classes:
Name | Description |
---|---|
Config | |
Classes¶
Config(bot: Tux)
¶
Bases: GroupCog
Methods:
Name | Description |
---|---|
config_set_logs | Configure the guild logs. |
config_set_channels | Configure the guild channels. |
config_set_perms | Set the role for a permission level. |
config_set_roles | Configure the guild roles. |
config_get_roles | Get the basic roles for the guild. |
config_get_perms | Get the roles for each permission level. |
config_get_channels | Get the channels for each category. |
config_get_logs | Get the log channels for every category. |
config_set_prefix | Set the prefix for the guild. |
config_clear_prefix | Reset the prefix to the default value for this guild. |
Source code in tux/cogs/guild/config.py
Functions¶
config_set_logs(interaction: discord.Interaction, category: Literal['Public', 'Private']) -> None
async
¶
Configure the guild logs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
interaction | Interaction | The discord interaction object. | required |
category | Literal['Public', 'Private'] | The category of logs to configure. | required |
Source code in tux/cogs/guild/config.py
@logs.command(name="set")
@app_commands.guild_only()
@app_commands.checks.has_permissions(administrator=True)
async def config_set_logs(
self,
interaction: discord.Interaction,
category: Literal["Public", "Private"],
) -> None:
"""
Configure the guild logs.
Parameters
----------
interaction : discord.Interaction
The discord interaction object.
category : Literal["Public", "Private"]
The category of logs to configure.
"""
await interaction.response.defer(ephemeral=True)
if category == "Public":
view = ConfigSetPublicLogs()
elif category == "Private":
view = ConfigSetPrivateLogs()
await interaction.followup.send(view=view, ephemeral=True)
config_set_channels(interaction: discord.Interaction) -> None
async
¶
Configure the guild channels.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
interaction | Interaction | The discord interaction object. | required |
Source code in tux/cogs/guild/config.py
@channels.command(name="set")
@app_commands.guild_only()
@app_commands.checks.has_permissions(administrator=True)
async def config_set_channels(
self,
interaction: discord.Interaction,
) -> None:
"""
Configure the guild channels.
Parameters
----------
interaction : discord.Interaction
The discord interaction object.
"""
await interaction.response.defer(ephemeral=True)
view = ConfigSetChannels()
await interaction.followup.send(view=view, ephemeral=True)
config_set_perms(interaction: discord.Interaction, setting: discord.app_commands.Choice[str], role: discord.Role) -> None
async
¶
Set the role for a permission level.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
interaction | Interaction | The discord interaction object. | required |
setting | Choice[str] | The permission level to configure. | required |
role | Role | The role to set for the permission level. | required |
Source code in tux/cogs/guild/config.py
@perms.command(name="set")
@app_commands.guild_only()
@app_commands.checks.has_permissions(administrator=True)
@app_commands.describe(setting="Which permission level to configure")
@app_commands.choices(
setting=[
app_commands.Choice(name="Perm Level 0 (e.g. Member)", value="0"),
app_commands.Choice(name="Perm Level 1 (e.g. Support)", value="1"),
app_commands.Choice(name="Perm Level 2 (e.g. Junior Mod)", value="2"),
app_commands.Choice(name="Perm Level 3 (e.g. Mod)", value="3"),
app_commands.Choice(name="Perm Level 4 (e.g. Senior Mod)", value="4"),
app_commands.Choice(name="Perm Level 5 (e.g. Admin)", value="5"),
app_commands.Choice(name="Perm Level 6 (e.g. Head Admin)", value="6"),
app_commands.Choice(name="Perm Level 7 (e.g. Server Owner)", value="7"),
],
)
@app_commands.guild_only()
@app_commands.checks.has_permissions(administrator=True)
async def config_set_perms(
self,
interaction: discord.Interaction,
setting: discord.app_commands.Choice[str],
role: discord.Role,
) -> None:
"""
Set the role for a permission level.
Parameters
----------
interaction : discord.Interaction
The discord interaction object.
setting : discord.app_commands.Choice[str]
The permission level to configure.
role : discord.Role
The role to set for the permission level.
"""
assert interaction.guild
await interaction.response.defer(ephemeral=True)
await self.db.update_perm_level_role(
interaction.guild.id,
setting.value,
role.id,
)
await interaction.followup.send(
f"Perm level {setting.value} role set to {role.mention}.",
ephemeral=True,
)
config_set_roles(interaction: discord.Interaction, setting: discord.app_commands.Choice[str], role: discord.Role) -> None
async
¶
Configure the guild roles.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
interaction | Interaction | The discord interaction object. | required |
setting | Choice[str] | The role to configure. | required |
role | Role | The role to set. | required |
Source code in tux/cogs/guild/config.py
@roles.command(name="set")
@app_commands.guild_only()
@app_commands.checks.has_permissions(administrator=True)
@app_commands.describe(setting="Which role to configure")
@app_commands.choices(
setting=[
app_commands.Choice(name="Jail", value="jail_role_id"),
],
)
async def config_set_roles(
self,
interaction: discord.Interaction,
setting: discord.app_commands.Choice[str],
role: discord.Role,
) -> None:
"""
Configure the guild roles.
Parameters
----------
interaction : discord.Interaction
The discord interaction object.
setting : discord.app_commands.Choice[str]
The role to configure.
role : discord.Role
The role to set.
"""
assert interaction.guild
await interaction.response.defer(ephemeral=True)
if setting.value == "jail_role_id":
await self.db.update_jail_role_id(interaction.guild.id, role.id)
await interaction.followup.send(
f"{setting.value} role set to {role.mention}.",
ephemeral=True,
)
config_get_roles(interaction: discord.Interaction) -> None
async
¶
Get the basic roles for the guild.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
interaction | Interaction | The discord interaction object. | required |
Source code in tux/cogs/guild/config.py
@roles.command(name="get")
@app_commands.guild_only()
@app_commands.checks.has_permissions(administrator=True)
async def config_get_roles(
self,
interaction: discord.Interaction,
) -> None:
"""
Get the basic roles for the guild.
Parameters
----------
interaction : discord.Interaction
The discord interaction object.
"""
assert interaction.guild
await interaction.response.defer(ephemeral=True)
embed = EmbedCreator.create_embed(
title="Config - Roles",
embed_type=EmbedType.INFO,
custom_color=discord.Color.blue(),
message_timestamp=discord.utils.utcnow(),
)
jail_role_id = await self.db.get_jail_role_id(interaction.guild.id)
jail_role = f"<@&{jail_role_id}>" if jail_role_id else "Not set"
embed.add_field(name="Jail Role", value=jail_role, inline=False)
await interaction.followup.send(embed=embed, ephemeral=True)
config_get_perms(interaction: discord.Interaction) -> None
async
¶
Get the roles for each permission level.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
interaction | Interaction | The discord interaction object. | required |
Source code in tux/cogs/guild/config.py
@perms.command(name="get")
@app_commands.guild_only()
@app_commands.checks.has_permissions(administrator=True)
async def config_get_perms(
self,
interaction: discord.Interaction,
) -> None:
"""
Get the roles for each permission level.
Parameters
----------
interaction : discord.Interaction
The discord interaction object.
"""
assert interaction.guild
await interaction.response.defer(ephemeral=True)
embed = EmbedCreator.create_embed(
embed_type=EmbedType.INFO,
custom_color=discord.Color.blue(),
title="Config - Permission Level Roles",
message_timestamp=discord.utils.utcnow(),
)
for i in range(8):
perm_level: str = f"perm_level_{i}_role_id"
role_id = await self.db.get_perm_level_role(interaction.guild.id, perm_level)
role = f"<@&{role_id}>" if role_id else "Not set"
embed.add_field(name=f"Perm Level {i}", value=role, inline=True)
await interaction.followup.send(embed=embed, ephemeral=True)
config_get_channels(interaction: discord.Interaction) -> None
async
¶
Get the channels for each category.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
interaction | Interaction | The discord interaction object. | required |
Source code in tux/cogs/guild/config.py
@channels.command(name="get")
@app_commands.guild_only()
@app_commands.checks.has_permissions(administrator=True)
async def config_get_channels(
self,
interaction: discord.Interaction,
) -> None:
"""
Get the channels for each category.
Parameters
----------
interaction : discord.Interaction
The discord interaction object.
"""
assert interaction.guild
await interaction.response.defer(ephemeral=True)
embed = EmbedCreator.create_embed(
title="Config - Channels",
embed_type=EmbedType.INFO,
custom_color=discord.Color.blue(),
message_timestamp=discord.utils.utcnow(),
)
jail_channel_id = await self.db.get_jail_channel_id(interaction.guild.id)
jail_channel = f"<#{jail_channel_id}>" if jail_channel_id else "Not set"
embed.add_field(name="Jail Channel", value=jail_channel, inline=False)
starboard_channel_id = await self.db.get_starboard_channel_id(interaction.guild.id)
starboard_channel = f"<#{starboard_channel_id}>" if starboard_channel_id else "Not set"
embed.add_field(name="Starboard Channel", value=starboard_channel, inline=False)
general_channel_id = await self.db.get_general_channel_id(interaction.guild.id)
general_channel = f"<#{general_channel_id}>" if general_channel_id else "Not set"
embed.add_field(name="General Channel", value=general_channel, inline=False)
await interaction.followup.send(embed=embed, ephemeral=True)
config_get_logs(interaction: discord.Interaction) -> None
async
¶
Get the log channels for every category.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
interaction | Interaction | The discord interaction object. | required |
Source code in tux/cogs/guild/config.py
@logs.command(name="get")
@app_commands.guild_only()
@app_commands.checks.has_permissions(administrator=True)
async def config_get_logs(
self,
interaction: discord.Interaction,
) -> None:
"""
Get the log channels for every category.
Parameters
----------
interaction : discord.Interaction
The discord interaction object.
"""
assert interaction.guild
await interaction.response.defer(ephemeral=True)
embed = EmbedCreator.create_embed(
title="Config - Logs",
embed_type=EmbedType.INFO,
custom_color=discord.Color.blue(),
message_timestamp=discord.utils.utcnow(),
)
join_log_id = await self.db.get_join_log_id(interaction.guild.id)
join_log = f"<#{join_log_id}>" if join_log_id else "Not set"
embed.add_field(name="Join Log", value=join_log, inline=True)
audit_log_id = await self.db.get_audit_log_id(interaction.guild.id)
audit_log = f"<#{audit_log_id}>" if audit_log_id else "Not set"
embed.add_field(name="Audit Log", value=audit_log, inline=True)
mod_log_id = await self.db.get_mod_log_id(interaction.guild.id)
mod_log = f"<#{mod_log_id}>" if mod_log_id else "Not set"
embed.add_field(name="Mod Log", value=mod_log, inline=True)
private_log_id = await self.db.get_private_log_id(interaction.guild.id)
private_log = f"<#{private_log_id}>" if private_log_id else "Not set"
embed.add_field(name="Private Log", value=private_log, inline=True)
report_log_id = await self.db.get_report_log_id(interaction.guild.id)
report_log = f"<#{report_log_id}>" if report_log_id else "Not set"
embed.add_field(name="Report Log", value=report_log, inline=True)
dev_log_id = await self.db.get_dev_log_id(interaction.guild.id)
dev_log = f"<#{dev_log_id}>" if dev_log_id else "Not set"
embed.add_field(name="Dev Log", value=dev_log, inline=True)
await interaction.followup.send(embed=embed, ephemeral=True)
config_set_prefix(interaction: discord.Interaction, prefix: app_commands.Range[str, 1, 10]) -> None
async
¶
Set the prefix for the guild.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
interaction | Interaction | The discord interaction object. | required |
prefix | str | The prefix to set for the guild. | required |
Source code in tux/cogs/guild/config.py
@prefix.command(name="set")
@app_commands.guild_only()
@app_commands.checks.has_permissions(administrator=True)
async def config_set_prefix(
self,
interaction: discord.Interaction,
prefix: app_commands.Range[str, 1, 10],
) -> None:
"""
Set the prefix for the guild.
Parameters
----------
interaction : discord.Interaction
The discord interaction object.
prefix : str
The prefix to set for the guild.
"""
assert interaction.guild
await interaction.response.defer(ephemeral=True)
await self.db.update_guild_prefix(interaction.guild.id, prefix)
await interaction.followup.send(
embed=EmbedCreator.create_embed(
bot=self.bot,
user_name=interaction.user.name,
user_display_avatar=interaction.user.display_avatar.url,
embed_type=EmbedCreator.SUCCESS,
title="Guild Config",
description=f"The prefix was updated to `{prefix}`",
),
)
config_clear_prefix(interaction: discord.Interaction) -> None
async
¶
Reset the prefix to the default value for this guild.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
interaction | Interaction | The discord interaction object. | required |
Source code in tux/cogs/guild/config.py
@prefix.command(name="clear")
@app_commands.guild_only()
@app_commands.checks.has_permissions(administrator=True)
async def config_clear_prefix(
self,
interaction: discord.Interaction,
) -> None:
"""
Reset the prefix to the default value for this guild.
Parameters
----------
interaction : discord.Interaction
The discord interaction object.
"""
assert interaction.guild
await interaction.response.defer(ephemeral=True)
await self.db.delete_guild_prefix(interaction.guild.id)
await interaction.followup.send(
embed=EmbedCreator.create_embed(
bot=self.bot,
user_name=interaction.user.name,
user_display_avatar=interaction.user.display_avatar.url,
embed_type=EmbedCreator.SUCCESS,
title="Guild Config",
description=f"The prefix was reset to `{CONFIG.DEFAULT_PREFIX}`",
),
)