added version 2.0

This commit is contained in:
Lukian LEIZOUR 2024-03-04 20:38:46 +01:00
parent 0163d40b4e
commit 0f18925d1a
3231 changed files with 1449 additions and 374732 deletions

43
commands/hubs/addhub.js Normal file
View file

@ -0,0 +1,43 @@
const {
SlashCommandBuilder,
EmbedBuilder,
ButtonBuilder,
ActionRowBuilder,
ButtonStyle,
PermissionsBitField,
} = require("discord.js");
const { errorEmbed } = require("../../libs/embeds.js");
module.exports = {
data: new SlashCommandBuilder()
.setName("addhub")
.setDescription("Add a conversation hub to the database.")
.setDMPermission(false),
async execute(interaction) {
if (
!interaction.member.permissions.has(
PermissionsBitField.Flags.Administrator
)
) {
const embed = errorEmbed(
"You need the administrator permission to use this command."
);
return interaction.reply({ embeds: [embed] });
}
const embed = new EmbedBuilder()
.setTitle("Conversation hub")
.setDescription("Click on the button below to create a conversation.")
.setColor("#F6C6F9")
.setFooter({ text: "Bot by @ninja_jambon" });
const button = new ButtonBuilder()
.setCustomId("create_conversation")
.setLabel("Create conversation")
.setStyle(ButtonStyle.Success);
const actionRow = new ActionRowBuilder().addComponents(button);
await interaction.reply({ embeds: [embed], components: [actionRow] });
},
};

View file

@ -0,0 +1,37 @@
const { SlashCommandBuilder } = require("discord.js");
const { getConv, removeConv } = require("../../libs/mysql.js");
const { errorEmbed } = require("../../libs/embeds.js");
const { sendLog } = require("../../libs/logs.js");
module.exports = {
data: new SlashCommandBuilder()
.setName("closeconv")
.setDescription("Close the current conversation.")
.setDMPermission(false),
async execute(interaction) {
const conv = await getConv(interaction.channelId).catch((err) => {
sendLog(err);
const embed = errorEmbed(
"An error occured while trying to get your conversation data."
);
return interaction.reply({ embeds: [embed], ephemeral: true });
});
if (!conv[0]) {
const embed = errorEmbed("This channel is not a conversation.");
return interaction.reply({ embeds: [embed], ephemeral: true });
}
if (conv[0].userid != interaction.user.id) {
const embed = errorEmbed("You are not the owner of this conversation.");
return interaction.reply({ embeds: [embed], ephemeral: true });
}
var channel = interaction.guild.channels.cache.get(interaction.channelId);
await removeConv(channel.id);
await channel.delete();
},
};