Add option to disable logging creation

This commit is contained in:
Christopher Cookman 2024-06-24 14:20:27 -06:00
parent b725d9b662
commit 037d333f32
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42
2 changed files with 10 additions and 1 deletions

View file

@ -72,6 +72,12 @@ client.on('ready', async () => {
description: "The channel to log invites to", description: "The channel to log invites to",
type: 7, type: 7,
required: true required: true
},
{
name: "log_create",
description: "Log invite creation",
type: 5,
required: false
} }
], ],
default_member_permissions: 32 default_member_permissions: 32
@ -100,6 +106,7 @@ client.on('inviteCreate', (invite) => { //if someone creates an invite while bot
return; return;
} }
if (!row) return; if (!row) return;
if(!row.log_create) return;
client.channels.fetch(row.channel).then(channel => { client.channels.fetch(row.channel).then(channel => {
if (!channel) return; // They probably set perms wrong if (!channel) return; // They probably set perms wrong
channel.send({ channel.send({
@ -243,8 +250,9 @@ client.on('interactionCreate', async interaction => {
}); });
return; return;
} }
const log_create = interaction.options.getBoolean('log_create') || true;
const channel = interaction.options.getChannel('channel').id; const channel = interaction.options.getChannel('channel').id;
db.run(`INSERT OR REPLACE INTO guilds (id, channel) VALUES (?, ?)`, [interaction.guild.id.toString(), channel.toString()], (err) => { db.run(`INSERT OR REPLACE INTO guilds (id, channel, log_create) VALUES (?, ?, ?)`, [interaction.guild.id.toString(), channel.toString(), log_create], (err) => {
if (err) { if (err) {
console.error(err); console.error(err);
interaction.reply({ interaction.reply({

1
migrations/2.sql Normal file
View file

@ -0,0 +1 @@
ALTER TABLE guilds ADD COLUMN log_create BOOLEAN DEFAULT 1;