FIXED THINGS

This commit is contained in:
Paillat
2023-05-05 13:28:27 +02:00
parent bee3680e63
commit 88e9acba80
2 changed files with 11 additions and 9 deletions

View File

@@ -194,15 +194,17 @@ class Setup(discord.Cog):
async def add_channel( async def add_channel(
self, ctx: discord.ApplicationContext, channel: discord.TextChannel = None self, ctx: discord.ApplicationContext, channel: discord.TextChannel = None
): ):
# check if the guild is in the database
curs_data.execute("SELECT * FROM data WHERE guild_id = ?", (ctx.guild.id,)) curs_data.execute("SELECT * FROM data WHERE guild_id = ?", (ctx.guild.id,))
if curs_data.fetchone() is None: if curs_data.fetchone() is None:
await ctx.respond("This server is not setup", ephemeral=True) await ctx.respond("This server is not setup", ephemeral=True)
return return
con_premium.execute( try:
curs_premium.execute(
"SELECT premium FROM data WHERE guild_id = ?", (ctx.guild.id,) "SELECT premium FROM data WHERE guild_id = ?", (ctx.guild.id,)
) )
premium = curs_premium.fetchone()[0] premium = curs_premium.fetchone()[0]
except:
premium = False
if not premium: if not premium:
await ctx.respond("This server is not premium", ephemeral=True) await ctx.respond("This server is not premium", ephemeral=True)
return return
@@ -217,10 +219,10 @@ class Setup(discord.Cog):
"This channel is already set as the main channel", ephemeral=True "This channel is already set as the main channel", ephemeral=True
) )
return return
con_premium.execute( curs_premium.execute(
"SELECT * FROM channels WHERE guild_id = ?", (ctx.guild.id,) "SELECT * FROM channels WHERE guild_id = ?", (ctx.guild.id,)
) )
guild_channels = con_premium.fetchone() guild_channels = curs_premium.fetchone()
if guild_channels is None: if guild_channels is None:
# if the channel is not in the list, add it # if the channel is not in the list, add it
con_premium.execute( con_premium.execute(
@@ -236,7 +238,7 @@ class Setup(discord.Cog):
return return
for i in range(5): for i in range(5):
if channels[i] == None: if channels[i] == None:
con_premium.execute( curs_premium.execute(
f"UPDATE channels SET channel{i} = ? WHERE guild_id = ?", f"UPDATE channels SET channel{i} = ? WHERE guild_id = ?",
(channel.id, ctx.guild.id), (channel.id, ctx.guild.id),
) )

View File

@@ -58,7 +58,7 @@ def get_guild_data(message):
guild_data = {} guild_data = {}
guid = mg_to_guid(message) guid = mg_to_guid(message)
try: try:
con_premium.execute( curs_premium.execute(
"SELECT * FROM data WHERE guild_id = ?", (guid,) "SELECT * FROM data WHERE guild_id = ?", (guid,)
) # get the data of the guild ) # get the data of the guild
except: except: