📦 Update – Logs System Overhaul (#33)
* chore(branch/dev): now have a dev branch to test my update * feat(logs/disable): adding the options to disable the logs - Adding the option to the logs command * feat(logs/disable): adding the options to disable the logs - Adding the option to the logs command * feat(logs/disable): finishing the disable command for logs - suppressing all the data stored in database (concerning the logs) - suppressing all the channels on the logs categories
This commit is contained in:
parent
13d950c99d
commit
13cb14cba3
1 changed files with 59 additions and 0 deletions
|
|
@ -37,6 +37,10 @@ export default {
|
|||
name: 'Configuration',
|
||||
value: 'logs_config',
|
||||
},
|
||||
{
|
||||
name: 'Disable',
|
||||
value: 'logs_disable',
|
||||
},
|
||||
),
|
||||
),
|
||||
async execute(interaction: CommandInteraction) {
|
||||
|
|
@ -278,6 +282,61 @@ export default {
|
|||
);
|
||||
break;
|
||||
}
|
||||
case 'logs_disable': {
|
||||
if (!userData.isOwner) {
|
||||
await interaction.reply({
|
||||
content: `${emoji.answer.no} | This command is only for owner`,
|
||||
flags: MessageFlags.Ephemeral,
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!guildData.logEnable) {
|
||||
await interaction.reply({
|
||||
content: `${emoji.answer.error} | The log is not setup on this server`,
|
||||
flags: MessageFlags.Ephemeral,
|
||||
});
|
||||
return;
|
||||
}
|
||||
const category: GuildCategory = await interaction.guild.channels.fetch(guildData.logCategory);
|
||||
try {
|
||||
for (const channel of category.children.cache.values()) {
|
||||
await channel.delete(
|
||||
`Delete cat of ${channel.name} (by ${interaction.username})`,
|
||||
);
|
||||
}
|
||||
await category.delete(
|
||||
`Delete cat of ${category.name} (by ${interaction.username})`,
|
||||
);
|
||||
await interaction.reply({
|
||||
content: `${emoji.answer.yes} | Disabled the logs of the guild`,
|
||||
flags: MessageFlags.Ephemeral,
|
||||
});
|
||||
}
|
||||
catch (err) {
|
||||
await interaction.reply({
|
||||
content: `${emoji.answer.error} | Cannot suppress the category's channels`,
|
||||
flags: MessageFlags.Ephemeral,
|
||||
});
|
||||
console.error(`Cannot suppress the category's channel:\n\t${err}`);
|
||||
return;
|
||||
}
|
||||
await prisma.guild.update({
|
||||
where: {
|
||||
id: interaction.guild.id,
|
||||
},
|
||||
data: {
|
||||
logEnable: false,
|
||||
logCategory: null,
|
||||
logBot: null,
|
||||
logChannels: null,
|
||||
logMember: null,
|
||||
logMod: null,
|
||||
logMsg: null,
|
||||
logServer: null,
|
||||
},
|
||||
});
|
||||
break;
|
||||
}
|
||||
default:
|
||||
console.error(`no choice on logs command ${choice}`);
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue