mirror of
https://github.com/Paillat-dev/Botator.git
synced 2026-01-02 01:06:19 +00:00
refactor(help.py, settings.py): remove debug import and debug statements
feat(settings.py): add ctx_to_guid function to convert context to guild id for database queries feat(settings.py): add support for changing the model used by the bot fix(settings.py): fix images command not updating the database correctly feat(cogs/setup.py): add dms_only check to setup_dms command refactor(cogs/setup.py): move ctx_to_guid function to config.py refactor(cogs/setup.py): move mg_to_guid function to config.py feat(makeprompt.py): add support for DMs conversations fix(makeprompt.py): fix images setting retrieval from database fix(makeprompt.py): fix guild_id to guid conversion in database queries refactor(makeprompt.py): extract historicator function to get the channel or user of a message refactor(makeprompt.py): remove debug statements and unused variables
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
import discord
|
||||
from config import debug
|
||||
|
||||
|
||||
class Help(discord.Cog):
|
||||
def __init__(self, bot: discord.Bot) -> None:
|
||||
@@ -9,9 +7,6 @@ class Help(discord.Cog):
|
||||
|
||||
@discord.slash_command(name="help", description="Show all the commands")
|
||||
async def help(self, ctx: discord.ApplicationContext):
|
||||
debug(
|
||||
f"The user {ctx.author} ran the help command in the channel {ctx.channel} of the guild {ctx.guild}, named {ctx.guild.name}"
|
||||
)
|
||||
embed = discord.Embed(
|
||||
title="Help", description="Here is the help page", color=0x00FF00
|
||||
)
|
||||
@@ -71,9 +66,6 @@ class Help(discord.Cog):
|
||||
name="advanced_help", description="Show the advanced settings meanings"
|
||||
)
|
||||
async def advanced_help(self, ctx: discord.ApplicationContext):
|
||||
debug(
|
||||
f"The user {ctx.author} ran the advanced_help command in the channel {ctx.channel} of the guild {ctx.guild}, named {ctx.guild.name}"
|
||||
)
|
||||
embed = discord.Embed(
|
||||
title="Advanced Help",
|
||||
description="Here is the advanced help page",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import discord
|
||||
from config import debug, con_data, curs_data, moderate
|
||||
from config import debug, con_data, curs_data, moderate, ctx_to_guid
|
||||
from discord import default_permissions
|
||||
|
||||
models = ["davinci", "gpt-3.5-turbo", "gpt-4"]
|
||||
@@ -31,10 +31,7 @@ class Settings(discord.Cog):
|
||||
presence_penalty: float = None,
|
||||
prompt_size: int = None,
|
||||
):
|
||||
debug(
|
||||
f"The user {ctx.author} ran the advanced command in the channel {ctx.channel} of the guild {ctx.guild}, named {ctx.guild.name}"
|
||||
)
|
||||
curs_data.execute("SELECT * FROM data WHERE guild_id = ?", (ctx.guild.id,))
|
||||
curs_data.execute("SELECT * FROM data WHERE guild_id = ?", (ctx_to_guid(ctx),))
|
||||
if curs_data.fetchone() is None:
|
||||
await ctx.respond("This server is not setup", ephemeral=True)
|
||||
return
|
||||
@@ -69,26 +66,26 @@ class Settings(discord.Cog):
|
||||
if max_tokens is None:
|
||||
if (
|
||||
curs_data.execute(
|
||||
"SELECT max_tokens FROM data WHERE guild_id = ?", (ctx.guild.id,)
|
||||
"SELECT max_tokens FROM data WHERE guild_id = ?", (ctx_to_guid(ctx),)
|
||||
).fetchone()[0]
|
||||
is not None
|
||||
and max_tokens is None
|
||||
):
|
||||
max_tokens = curs_data.execute(
|
||||
"SELECT max_tokens FROM data WHERE guild_id = ?", (ctx.guild.id,)
|
||||
"SELECT max_tokens FROM data WHERE guild_id = ?", (ctx_to_guid(ctx),)
|
||||
).fetchone()[0]
|
||||
else:
|
||||
max_tokens = 64
|
||||
if temperature is None:
|
||||
if (
|
||||
curs_data.execute(
|
||||
"SELECT temperature FROM data WHERE guild_id = ?", (ctx.guild.id,)
|
||||
"SELECT temperature FROM data WHERE guild_id = ?", (ctx_to_guid(ctx),)
|
||||
).fetchone()[0]
|
||||
is not None
|
||||
and temperature is None
|
||||
):
|
||||
temperature = curs_data.execute(
|
||||
"SELECT temperature FROM data WHERE guild_id = ?", (ctx.guild.id,)
|
||||
"SELECT temperature FROM data WHERE guild_id = ?", (ctx_to_guid(ctx),)
|
||||
).fetchone()[0]
|
||||
else:
|
||||
temperature = 0.9
|
||||
@@ -96,14 +93,14 @@ class Settings(discord.Cog):
|
||||
if (
|
||||
curs_data.execute(
|
||||
"SELECT frequency_penalty FROM data WHERE guild_id = ?",
|
||||
(ctx.guild.id,),
|
||||
(ctx_to_guid(ctx),),
|
||||
).fetchone()[0]
|
||||
is not None
|
||||
and frequency_penalty is None
|
||||
):
|
||||
frequency_penalty = curs_data.execute(
|
||||
"SELECT frequency_penalty FROM data WHERE guild_id = ?",
|
||||
(ctx.guild.id,),
|
||||
(ctx_to_guid(ctx),),
|
||||
).fetchone()[0]
|
||||
else:
|
||||
frequency_penalty = 0.0
|
||||
@@ -111,27 +108,27 @@ class Settings(discord.Cog):
|
||||
if (
|
||||
curs_data.execute(
|
||||
"SELECT presence_penalty FROM data WHERE guild_id = ?",
|
||||
(ctx.guild.id,),
|
||||
(ctx_to_guid(ctx),),
|
||||
).fetchone()[0]
|
||||
is not None
|
||||
and presence_penalty is None
|
||||
):
|
||||
presence_penalty = curs_data.execute(
|
||||
"SELECT presence_penalty FROM data WHERE guild_id = ?",
|
||||
(ctx.guild.id,),
|
||||
(ctx_to_guid(ctx),),
|
||||
).fetchone()[0]
|
||||
else:
|
||||
presence_penalty = 0.0
|
||||
if prompt_size is None:
|
||||
if (
|
||||
curs_data.execute(
|
||||
"SELECT prompt_size FROM data WHERE guild_id = ?", (ctx.guild.id,)
|
||||
"SELECT prompt_size FROM data WHERE guild_id = ?", (ctx_to_guid(ctx),)
|
||||
).fetchone()[0]
|
||||
is not None
|
||||
and prompt_size is None
|
||||
):
|
||||
prompt_size = curs_data.execute(
|
||||
"SELECT prompt_size FROM data WHERE guild_id = ?", (ctx.guild.id,)
|
||||
"SELECT prompt_size FROM data WHERE guild_id = ?", (ctx_to_guid(ctx),)
|
||||
).fetchone()[0]
|
||||
else:
|
||||
prompt_size = 1
|
||||
@@ -144,7 +141,7 @@ class Settings(discord.Cog):
|
||||
frequency_penalty,
|
||||
presence_penalty,
|
||||
prompt_size,
|
||||
ctx.guild.id,
|
||||
ctx_to_guid(ctx),
|
||||
),
|
||||
)
|
||||
con_data.commit()
|
||||
@@ -154,11 +151,8 @@ class Settings(discord.Cog):
|
||||
@discord.slash_command(name="default", description="Default settings")
|
||||
@default_permissions(administrator=True)
|
||||
async def default(self, ctx: discord.ApplicationContext):
|
||||
debug(
|
||||
f"The user {ctx.author} ran the default command in the channel {ctx.channel} of the guild {ctx.guild}, named {ctx.guild.name}"
|
||||
)
|
||||
# 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_to_guid(ctx),))
|
||||
if curs_data.fetchone() is None:
|
||||
await ctx.respond(
|
||||
"This server is not setup, please run /setup", ephemeral=True
|
||||
@@ -167,7 +161,7 @@ class Settings(discord.Cog):
|
||||
# set the advanced settings (max_tokens, temperature, frequency_penalty, presence_penalty, prompt_size) and also prompt_prefix to their default values
|
||||
curs_data.execute(
|
||||
"UPDATE data SET max_tokens = ?, temperature = ?, frequency_penalty = ?, presence_penalty = ?, prompt_size = ? WHERE guild_id = ?",
|
||||
(64, 0.9, 0.0, 0.0, 5, ctx.guild.id),
|
||||
(64, 0.9, 0.0, 0.0, 5, ctx_to_guid(ctx)),
|
||||
)
|
||||
con_data.commit()
|
||||
await ctx.respond(
|
||||
@@ -183,13 +177,10 @@ class Settings(discord.Cog):
|
||||
)
|
||||
@default_permissions(administrator=True)
|
||||
async def info(self, ctx: discord.ApplicationContext):
|
||||
debug(
|
||||
f"The user {ctx.author} ran the info command in the channel {ctx.channel} of the guild {ctx.guild}, named {ctx.guild.name}"
|
||||
)
|
||||
# this command sends all the data about the guild, including the api key, the channel id, the advanced settings and the uses_count_today
|
||||
# check if the guild is in the database
|
||||
try:
|
||||
curs_data.execute("SELECT * FROM data WHERE guild_id = ?", (ctx.guild.id,))
|
||||
curs_data.execute("SELECT * FROM data WHERE guild_id = ?", (ctx_to_guid(ctx),))
|
||||
data = curs_data.fetchone()
|
||||
except:
|
||||
data = None
|
||||
@@ -197,7 +188,7 @@ class Settings(discord.Cog):
|
||||
await ctx.respond("This server is not setup", ephemeral=True)
|
||||
return
|
||||
try:
|
||||
curs_data.execute("SELECT * FROM model WHERE guild_id = ?", (ctx.guild.id,))
|
||||
curs_data.execute("SELECT * FROM model WHERE guild_id = ?", (ctx_to_guid(ctx),))
|
||||
model = curs_data.fetchone()[1]
|
||||
except:
|
||||
model = None
|
||||
@@ -224,11 +215,8 @@ class Settings(discord.Cog):
|
||||
@discord.slash_command(name="prefix", description="Change the prefix of the prompt")
|
||||
@default_permissions(administrator=True)
|
||||
async def prefix(self, ctx: discord.ApplicationContext, prefix: str = ""):
|
||||
debug(
|
||||
f"The user {ctx.author.name} ran the prefix command command in the channel {ctx.channel} of the guild {ctx.guild}, named {ctx.guild.name}"
|
||||
)
|
||||
try:
|
||||
curs_data.execute("SELECT * FROM data WHERE guild_id = ?", (ctx.guild.id,))
|
||||
curs_data.execute("SELECT * FROM data WHERE guild_id = ?", (ctx_to_guid(ctx),))
|
||||
data = curs_data.fetchone()
|
||||
api_key = data[2]
|
||||
except:
|
||||
@@ -248,7 +236,7 @@ class Settings(discord.Cog):
|
||||
await ctx.respond("Prefix changed !", ephemeral=True, delete_after=5)
|
||||
curs_data.execute(
|
||||
"UPDATE data SET prompt_prefix = ? WHERE guild_id = ?",
|
||||
(prefix, ctx.guild.id),
|
||||
(prefix, ctx_to_guid(ctx)),
|
||||
)
|
||||
con_data.commit()
|
||||
|
||||
@@ -263,12 +251,9 @@ class Settings(discord.Cog):
|
||||
)
|
||||
@default_permissions(administrator=True)
|
||||
async def pretend(self, ctx: discord.ApplicationContext, pretend_to_be: str = ""):
|
||||
debug(
|
||||
f"The user {ctx.author} ran the pretend command in the channel {ctx.channel} of the guild {ctx.guild}, named {ctx.guild.name}"
|
||||
)
|
||||
# check if the guild is in the database
|
||||
try:
|
||||
curs_data.execute("SELECT * FROM data WHERE guild_id = ?", (ctx.guild.id,))
|
||||
curs_data.execute("SELECT * FROM data WHERE guild_id = ?", (ctx_to_guid(ctx),))
|
||||
data = curs_data.fetchone()
|
||||
api_key = data[2]
|
||||
except:
|
||||
@@ -289,7 +274,7 @@ class Settings(discord.Cog):
|
||||
pretend_to_be = ""
|
||||
curs_data.execute(
|
||||
"UPDATE data SET pretend_enabled = 0 WHERE guild_id = ?",
|
||||
(ctx.guild.id,),
|
||||
(ctx_to_guid(ctx),),
|
||||
)
|
||||
con_data.commit()
|
||||
await ctx.respond("Pretend mode disabled", ephemeral=True, delete_after=5)
|
||||
@@ -298,7 +283,7 @@ class Settings(discord.Cog):
|
||||
else:
|
||||
curs_data.execute(
|
||||
"UPDATE data SET pretend_enabled = 1 WHERE guild_id = ?",
|
||||
(ctx.guild.id,),
|
||||
(ctx_to_guid(ctx),),
|
||||
)
|
||||
con_data.commit()
|
||||
await ctx.respond("Pretend mode enabled", ephemeral=True, delete_after=5)
|
||||
@@ -306,7 +291,7 @@ class Settings(discord.Cog):
|
||||
await ctx.guild.me.edit(nick=pretend_to_be)
|
||||
curs_data.execute(
|
||||
"UPDATE data SET pretend_to_be = ? WHERE guild_id = ?",
|
||||
(pretend_to_be, ctx.guild.id),
|
||||
(pretend_to_be, ctx_to_guid(ctx)),
|
||||
)
|
||||
con_data.commit()
|
||||
# if the usename is longer than 32 characters, shorten it
|
||||
@@ -319,7 +304,7 @@ class Settings(discord.Cog):
|
||||
@default_permissions(administrator=True)
|
||||
async def enable_tts(self, ctx: discord.ApplicationContext):
|
||||
# get the guild id
|
||||
guild_id = ctx.guild.id
|
||||
guild_id = ctx_to_guid(ctx)
|
||||
# connect to the database
|
||||
# update the tts value in the database
|
||||
curs_data.execute("UPDATE data SET tts = 1 WHERE guild_id = ?", (guild_id,))
|
||||
@@ -331,7 +316,7 @@ class Settings(discord.Cog):
|
||||
@default_permissions(administrator=True)
|
||||
async def disable_tts(self, ctx: discord.ApplicationContext):
|
||||
# get the guild id
|
||||
guild_id = ctx.guild.id
|
||||
guild_id = ctx_to_guid(ctx)
|
||||
# connect to the database
|
||||
# update the tts value in the database
|
||||
curs_data.execute("UPDATE data SET tts = 0 WHERE guild_id = ?", (guild_id,))
|
||||
@@ -353,16 +338,16 @@ class Settings(discord.Cog):
|
||||
@default_permissions(administrator=True)
|
||||
async def model(self, ctx: discord.ApplicationContext, model: str = "davinci"):
|
||||
try:
|
||||
curs_data.execute("SELECT * FROM model WHERE guild_id = ?", (ctx.guild.id,))
|
||||
curs_data.execute("SELECT * FROM model WHERE guild_id = ?", (ctx_to_guid(ctx),))
|
||||
data = curs_data.fetchone()[1]
|
||||
except:
|
||||
data = None
|
||||
if data is None:
|
||||
curs_data.execute("INSERT INTO model VALUES (?, ?)", (ctx.guild.id, model))
|
||||
curs_data.execute("INSERT INTO model VALUES (?, ?)", (ctx_to_guid(ctx), model))
|
||||
else:
|
||||
curs_data.execute(
|
||||
"UPDATE model SET model_name = ? WHERE guild_id = ?",
|
||||
(model, ctx.guild.id),
|
||||
(model, ctx_to_guid(ctx)),
|
||||
)
|
||||
con_data.commit()
|
||||
await ctx.respond("Model changed !", ephemeral=True)
|
||||
@@ -382,7 +367,7 @@ class Settings(discord.Cog):
|
||||
async def images(self, ctx: discord.ApplicationContext, enable_disable: str):
|
||||
try:
|
||||
curs_data.execute(
|
||||
"SELECT * FROM images WHERE guild_id = ?", (ctx.guild.id,)
|
||||
"SELECT * FROM images WHERE guild_id = ?", (ctx_to_guid(ctx),)
|
||||
)
|
||||
data = curs_data.fetchone()
|
||||
except:
|
||||
@@ -393,12 +378,12 @@ class Settings(discord.Cog):
|
||||
enable_disable = 0
|
||||
if data is None:
|
||||
curs_data.execute(
|
||||
"INSERT INTO images VALUES (?, ?, ?)", (ctx.guild.id, 0, enable_disable)
|
||||
"INSERT INTO images VALUES (?, ?, ?)", (ctx_to_guid(ctx), 0, enable_disable)
|
||||
)
|
||||
else:
|
||||
curs_data.execute(
|
||||
"UPDATE images SET is_enabled = ? WHERE guild_id = ?",
|
||||
(enable_disable, ctx.guild.id),
|
||||
(enable_disable, ctx_to_guid(ctx)),
|
||||
)
|
||||
con_data.commit()
|
||||
await ctx.respond(
|
||||
|
||||
@@ -1,7 +1,17 @@
|
||||
import discord
|
||||
from discord import default_permissions
|
||||
from config import debug, con_data, curs_data, con_premium, curs_premium
|
||||
from discord import default_permissions, guild_only
|
||||
from discord.ext import commands
|
||||
from config import debug, con_data, curs_data, con_premium, curs_premium, ctx_to_guid
|
||||
|
||||
class NoPrivateMessages(commands.CheckFailure):
|
||||
pass
|
||||
|
||||
def dms_only():
|
||||
async def predicate(ctx):
|
||||
if ctx.guild is not None:
|
||||
raise NoPrivateMessages('Hey no private messages!')
|
||||
return True
|
||||
return commands.check(predicate)
|
||||
|
||||
class Setup(discord.Cog):
|
||||
def __init__(self, bot: discord.Bot):
|
||||
@@ -12,15 +22,13 @@ class Setup(discord.Cog):
|
||||
@discord.option(name="channel_id", description="The channel id", required=True)
|
||||
@discord.option(name="api_key", description="The api key", required=True)
|
||||
@default_permissions(administrator=True)
|
||||
@guild_only()
|
||||
async def setup(
|
||||
self,
|
||||
ctx: discord.ApplicationContext,
|
||||
channel: discord.TextChannel,
|
||||
api_key: str,
|
||||
):
|
||||
debug(
|
||||
f"The user {ctx.author} ran the setup command in the channel {ctx.channel} of the guild {ctx.guild}, named {ctx.guild.name}"
|
||||
)
|
||||
if channel is None:
|
||||
await ctx.respond("Invalid channel id", ephemeral=True)
|
||||
return
|
||||
@@ -66,24 +74,75 @@ class Setup(discord.Cog):
|
||||
await ctx.respond(
|
||||
"The channel id and the api key have been added", ephemeral=True
|
||||
)
|
||||
@discord.slash_command(name="setup_dms", description="Setup the bot in dms")
|
||||
@discord.option(name="api_key", description="The api key", required=True)
|
||||
@default_permissions(administrator=True)
|
||||
@dms_only()
|
||||
async def setup_dms(
|
||||
self,
|
||||
ctx: discord.ApplicationContext,
|
||||
api_key: str,
|
||||
):
|
||||
channel = ctx.channel
|
||||
if channel is None:
|
||||
await ctx.respond("Invalid channel id", ephemeral=True)
|
||||
return
|
||||
try:
|
||||
curs_data.execute("SELECT * FROM data WHERE guild_id = ?", (ctx.user.id,))
|
||||
data = curs_data.fetchone()
|
||||
if data[3] == None:
|
||||
data = None
|
||||
except:
|
||||
data = None
|
||||
|
||||
if data != None:
|
||||
curs_data.execute(
|
||||
"UPDATE data SET channel_id = ?, api_key = ? WHERE guild_id = ?",
|
||||
(channel.id, api_key, ctx.user.id),
|
||||
)
|
||||
con_data.commit()
|
||||
await ctx.respond(
|
||||
"The channel id and the api key have been updated", ephemeral=True
|
||||
)
|
||||
else:
|
||||
curs_data.execute(
|
||||
"INSERT INTO data VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
(
|
||||
ctx.user.id,
|
||||
channel.id,
|
||||
api_key,
|
||||
False,
|
||||
64,
|
||||
0.9,
|
||||
0.0,
|
||||
0.0,
|
||||
0,
|
||||
5,
|
||||
"",
|
||||
False,
|
||||
"",
|
||||
False,
|
||||
),
|
||||
)
|
||||
con_data.commit()
|
||||
await ctx.respond(
|
||||
"The api key has been added", ephemeral=True
|
||||
)
|
||||
|
||||
@discord.slash_command(
|
||||
name="delete", description="Delete the information about this server"
|
||||
)
|
||||
@default_permissions(administrator=True)
|
||||
async def delete(self, ctx: discord.ApplicationContext):
|
||||
debug(
|
||||
f"The user {ctx.author} ran the delete command in the channel {ctx.channel} of the guild {ctx.guild}, named {ctx.guild.name}"
|
||||
)
|
||||
# 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_to_guid(ctx),))
|
||||
if curs_data.fetchone() is None:
|
||||
await ctx.respond("This server is not setup", ephemeral=True)
|
||||
return
|
||||
# delete the guild from the database, except the guild id and the uses_count_today
|
||||
curs_data.execute(
|
||||
"UPDATE data SET api_key = ?, channel_id = ?, is_active = ?, max_tokens = ?, temperature = ?, frequency_penalty = ?, presence_penalty = ?, prompt_size = ? WHERE guild_id = ?",
|
||||
(None, None, False, 50, 0.9, 0.0, 0.0, 0, ctx.guild.id),
|
||||
(None, None, False, 50, 0.9, 0.0, 0.0, 0, ctx_to_guid(ctx)),
|
||||
)
|
||||
con_data.commit()
|
||||
await ctx.respond("Deleted", ephemeral=True)
|
||||
@@ -92,23 +151,13 @@ class Setup(discord.Cog):
|
||||
@discord.slash_command(name="enable", description="Enable the bot")
|
||||
@default_permissions(administrator=True)
|
||||
async def enable(self, ctx: discord.ApplicationContext):
|
||||
# if the guild is eqal to 1014156298226515970, the guild is banned
|
||||
if ctx.guild.id == 1014156298226515970:
|
||||
await ctx.respond(
|
||||
"This server is banned for bad and nsfw use.", ephemeral=True
|
||||
)
|
||||
return
|
||||
# check if the guild is in the database
|
||||
debug(
|
||||
f"The user {ctx.author} ran the enable command in the channel {ctx.channel} of the guild {ctx.guild}, named {ctx.guild.name}"
|
||||
)
|
||||
curs_data.execute("SELECT * FROM data WHERE guild_id = ?", (ctx.guild.id,))
|
||||
curs_data.execute("SELECT * FROM data WHERE guild_id = ?", (ctx_to_guid(ctx),))
|
||||
if curs_data.fetchone() is None:
|
||||
await ctx.respond("This server is not setup", ephemeral=True)
|
||||
return
|
||||
# enable the guild
|
||||
curs_data.execute(
|
||||
"UPDATE data SET is_active = ? WHERE guild_id = ?", (True, ctx.guild.id)
|
||||
"UPDATE data SET is_active = ? WHERE guild_id = ?", (True, ctx_to_guid(ctx))
|
||||
)
|
||||
con_data.commit()
|
||||
await ctx.respond("Enabled", ephemeral=True)
|
||||
@@ -117,17 +166,14 @@ class Setup(discord.Cog):
|
||||
@discord.slash_command(name="disable", description="Disable the bot")
|
||||
@default_permissions(administrator=True)
|
||||
async def disable(self, ctx: discord.ApplicationContext):
|
||||
debug(
|
||||
f"The user {ctx.author} ran the disable command in the channel {ctx.channel} of the guild {ctx.guild}, named {ctx.guild.name}"
|
||||
)
|
||||
# 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_to_guid(ctx),))
|
||||
if curs_data.fetchone() is None:
|
||||
await ctx.respond("This server is not setup", ephemeral=True)
|
||||
return
|
||||
# disable the guild
|
||||
curs_data.execute(
|
||||
"UPDATE data SET is_active = ? WHERE guild_id = ?", (False, ctx.guild.id)
|
||||
"UPDATE data SET is_active = ? WHERE guild_id = ?", (False, ctx_to_guid(ctx))
|
||||
)
|
||||
con_data.commit()
|
||||
await ctx.respond("Disabled", ephemeral=True)
|
||||
@@ -144,12 +190,10 @@ class Setup(discord.Cog):
|
||||
required=False,
|
||||
)
|
||||
@default_permissions(administrator=True)
|
||||
@guild_only()
|
||||
async def add_channel(
|
||||
self, ctx: discord.ApplicationContext, channel: discord.TextChannel = None
|
||||
):
|
||||
debug(
|
||||
f"The user {ctx.author} ran the add_channel command in the channel {ctx.channel} of the guild {ctx.guild}, named {ctx.guild.name}"
|
||||
)
|
||||
# check if the guild is in the database
|
||||
curs_data.execute("SELECT * FROM data WHERE guild_id = ?", (ctx.guild.id,))
|
||||
if curs_data.fetchone() is None:
|
||||
@@ -217,12 +261,10 @@ class Setup(discord.Cog):
|
||||
required=False,
|
||||
)
|
||||
@default_permissions(administrator=True)
|
||||
@guild_only()
|
||||
async def remove_channel(
|
||||
self, ctx: discord.ApplicationContext, channel: discord.TextChannel = None
|
||||
):
|
||||
debug(
|
||||
f"The user {ctx.author} ran the remove_channel command in the channel {ctx.channel} of the guild {ctx.guild}, named {ctx.guild.name}"
|
||||
)
|
||||
# check if the guild is in the database
|
||||
curs_data.execute("SELECT * FROM data WHERE guild_id = ?", (ctx.guild.id,))
|
||||
if curs_data.fetchone() is None:
|
||||
|
||||
Reference in New Issue
Block a user