added version 2.0
This commit is contained in:
parent
0163d40b4e
commit
0f18925d1a
3231 changed files with 1449 additions and 374732 deletions
37
commands/hubs/closeconv.js
Normal file
37
commands/hubs/closeconv.js
Normal 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();
|
||||
},
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue