1
Fork 0
mirror of https://github.com/wlinator/luminara.git synced 2024-10-02 18:23:12 +00:00

chore: Update prefix retrieval logic to handle guild and bot DM contexts

This commit is contained in:
wlinator 2024-08-12 06:27:52 -04:00
parent cf218c4e4d
commit d1aab80374
9 changed files with 39 additions and 11 deletions

View file

@ -56,8 +56,8 @@
"config_modlog_info_warning_name": "⚠️ Warning",
"config_modlog_info_warning_value": "Changing the mod-log channel in the future will make old cases uneditable in this channel.",
"config_modlog_permission_error": "I don't have perms to send messages in that channel. Please fix & try again.",
"config_prefix_get": "the current prefix for this server is `{0}`.",
"config_prefix_set": "the prefix has been set to `{0}`.",
"config_prefix_get": "the current prefix for this server is `{0}`",
"config_prefix_set": "the prefix has been set to `{0}`",
"config_prefix_too_long": "the prefix must be 25 characters or less.",
"config_show_author": "{0} Configuration",
"config_show_birthdays": "Birthdays",

View file

@ -1,5 +1,5 @@
import discord
from discord import guild_only
from discord.ext.commands import guild_only
from config.parser import JsonCache
from discord.commands import SlashCommandGroup
from discord.ext import bridge, commands

View file

@ -26,7 +26,7 @@ async def set_prefix(ctx, prefix):
async def get_prefix(ctx):
prefix = GuildConfig.get_prefix(ctx.guild.id)
prefix = GuildConfig.get_prefix_from_guild_id(ctx.guild.id) if ctx.guild else "."
embed = EmbedBuilder().create_info_embed(
ctx=ctx,
author_text=CONST.STRINGS["config_author"],

View file

@ -1,5 +1,5 @@
import discord
from discord import guild_only
from discord.ext.commands import guild_only
from discord.ext import bridge, commands
from modules.economy import balance, blackjack, daily, give, slots

View file

@ -1,5 +1,5 @@
import discord
from discord import guild_only
from discord.ext.commands import guild_only
from discord.ext import bridge, commands
from modules.levels import leaderboard, level

View file

@ -1,7 +1,7 @@
from datetime import datetime
import discord
from discord import guild_only
from discord.ext.commands import guild_only
from discord.commands import SlashCommandGroup
from discord.ext import bridge, commands, tasks
@ -36,6 +36,10 @@ class Misc(commands.Cog):
aliases=["p", "status"],
description="Simple status check.",
help="Simple status check.",
contexts={
discord.InteractionContextType.guild,
discord.InteractionContextType.bot_dm,
},
)
async def ping(self, ctx) -> None:
await ping.ping(self, ctx)
@ -44,6 +48,10 @@ class Misc(commands.Cog):
name="uptime",
description="See Lumi's uptime since the last update.",
help="See how long Lumi has been online since his last update.",
contexts={
discord.InteractionContextType.guild,
discord.InteractionContextType.bot_dm,
},
)
async def uptime(self, ctx) -> None:
await ping.uptime(self, ctx, self.start_time)
@ -52,6 +60,10 @@ class Misc(commands.Cog):
name="invite",
description="Generate an invite link.",
help="Generate a link to invite Lumi to your own server!",
contexts={
discord.InteractionContextType.guild,
discord.InteractionContextType.bot_dm,
},
)
async def invite_command(self, ctx) -> None:
await invite.cmd(ctx)
@ -60,9 +72,11 @@ class Misc(commands.Cog):
name="prefix",
description="See the server's current prefix.",
help="See the server's current prefix.",
contexts={discord.InteractionContextType.guild},
contexts={
discord.InteractionContextType.guild,
discord.InteractionContextType.bot_dm,
},
)
@guild_only()
async def prefix_command(self, ctx) -> None:
await c_prefix.get_prefix(ctx)
@ -71,6 +85,10 @@ class Misc(commands.Cog):
aliases=["stats"],
description="Shows basic Lumi stats.",
help="Shows basic Lumi stats.",
contexts={
discord.InteractionContextType.guild,
discord.InteractionContextType.bot_dm,
},
)
async def info_command(self, ctx) -> None:
unix_timestamp: int = int(round(self.start_time.timestamp()))

View file

@ -1,5 +1,5 @@
import discord
from discord import guild_only
from discord.ext.commands import guild_only
from discord.ext import bridge, commands
from modules.moderation import ban, cases, warn, timeout, kick, softban

View file

@ -1,5 +1,5 @@
import discord
from discord import guild_only
from discord.ext.commands import guild_only
from discord.commands import SlashCommandGroup
from discord.ext import commands

View file

@ -120,6 +120,16 @@ class GuildConfig:
return prefix or "."
@staticmethod
def get_prefix_from_guild_id(guild_id):
query = """
SELECT prefix
FROM guild_config
WHERE guild_id = %s
"""
return database.select_query_one(query, (guild_id,)) or "."
@staticmethod
def set_prefix(guild_id, prefix):
"""