diff --git a/commands.py b/commands.py index 08e9878..5f99c0f 100644 --- a/commands.py +++ b/commands.py @@ -23,13 +23,51 @@ else: with open("cogs/essentials/config.toml", "r") as f: esconf = toml.load(f) - - class EssentialCommands(commands.Cog): def __init__(self, bot): self.bot = bot self.rep_file = "cogs/essentials/reputation" + #Here it inits a new guild specific config in storage.db like all the commands enabled, events, or some specific storage like reputation. + def sql_guild_init(self, serverid): + # Define the SQL statement to create a table + conn = self.bot.api.db_api.connection + cursor = self.bot.api.db_api.cursor + sql = """ + CREATE TABLE essentials_server_serverid ( + command_ping TEXT (1, 1) DEFAULT (TRUE), + command_say TEXT (1, 1) DEFAULT (TRUE), + command_serverinfo TEXT (1, 1) DEFAULT (TRUE), + command_avatar TEXT (1, 1) DEFAULT (TRUE), + command_whois TEXT (1, 1) DEFAULT (TRUE), + command_embed TEXT (1, 1) DEFAULT (TRUE), + command_clean TEXT (1, 1) DEFAULT (TRUE), + command_lock TEXT (1, 1) DEFAULT (TRUE), + command_unlock TEXT (1, 1) DEFAULT (TRUE), + command_lockdown TEXT (1, 1) DEFAULT (FALSE), + command_unlockdown TEXT (1, 1) DEFAULT (FALSE), + event_goodbye_enabled TEXT (1, 1) DEFAULT (TRUE), + event_goodbye_title TEXT (1, 1) DEFAULT 'Goodbye', + event_goodbye_message TEXT (1, 1) DEFAULT '{member.display_name} has left the server.', + event_goodbye_channelid TEXT (1, 1) DEFAULT 'INSERT THE CHANNEL ID OF THE CHANNEL TO SEND THE GOODBYE MEESAGE HERE', + event_welcome_enabled TEXT (1, 1) DEFAULT (TRUE), + event_welcome_title TEXT (1, 1) DEFAULT 'Welcome', + event_welcome_message TEXT (1, 1) DEFAULT 'Welcome to the server {member.mention} :wave:', + event_welcome_channelid TEXT (1, 1) DEFAULT 'INSERT THE CHANNEL ID OF THE GOODBYE CHANNEL CAN BE THE SAME AS THE WELCOME CHANNEL' + );""" + + sql = sql.replace("serverid", str(serverid)) + #return sql + + # Execute the SQL statement + cursor.execute(sql) + + # Commit the transaction + conn.commit() + + def sql_init(self): + pass + @discord.Cog.listener() async def on_member_join(self, member): @@ -110,7 +148,7 @@ class EssentialCommands(commands.Cog): embed = discord.Embed(description=f"You have given {reputation_type} reputation to {user.mention} with the comment: {comment}", title="You have given reputation.") await message.channel.send(embed=embed) - @commands.slash_command() + @commands.slash_command(guild_ids=guild_ids) async def reputation(self, ctx, user: discord.User): # load the reputation data from the TOML file try: @@ -158,6 +196,10 @@ class EssentialCommands(commands.Cog): await ctx.respond('Pong!') @commands.slash_command(guild_ids=guild_ids) + async def getalltables(self, ctx): + tables = self.sql_guild_init(ctx.guild.id) + await ctx.respond(tables) + @commands.slash_command(guild_ids=guild_ids) @option('msg', description="The message to say.") async def say(self, ctx, message): if not esconf["commands"]["say"]: