discord_bot/commands/utility/greet.js

36 lines
1.1 KiB
JavaScript
Raw Normal View History

const discord = require("discord.js");
const { MessageEmbed } = require("discord.js");
const guildDB = require("../../mongo/guildDB");
module.exports = {
name: "greet",
description: "Toogles-Greet-System",
usage: ``,
category: "utility",
aliases: ["greet"],
run: async (client, message, args) => {
message.delete().catch(() => {});
if (!message.member.hasPermission("ADMINISTRATOR"))
return message.channel.send(`:x: Fehlende Berechtigung`);
let channel = message.mentions.channels.first() || message.channel;
let data = await guildDB.find({ guild: message.guild.id })
if(!data?.length) {
await guildDB.create({
guild: message.guild.id,
channel: channel.id,
})
message.reply({
content: `Begrüssung für ${channel} aktiviert.`
})
} else {
var ch = data.map((guildDB) => {
return [ `${guildDB.channel}` ]})
guildDB.updateOne({ guild: message.guild.id }, { channel: ch + channel.id }, function(err, res) {});
message.reply({
content: `Begrüssung für ${channel} aktiviert.`
})
}
}
}