Files
quarksBot/commands/setTweetChannel.js
T

46 lines
1.9 KiB
JavaScript

const { MessageEmbed } = require('discord.js');
module.exports = {
name: "settweetchannel",
description: "Select a channel to send tweets",
usage: "[channel]",
permissions: {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: ["MANAGE_GUILD"],
},
SlashCommand: {
options: [
{
name: "channel",
description: "Channel to add to allowed channles",
value: "channel",
type: 7,
required: true,
},
],
/**
*
* @param {require("../structures/QuarksBot")} client
* @param {import("discord.js").MessageCreate} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, interaction, args, { GuildDB }) => {
if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id)) {
return interaction.send(`You are not allowed to use the bot in this channel.`);
}
let channelid = args[0].value;
let channel = client.channels.cache.get(channelid);
if (!channel) return interaction.send(`Cannot find that channel.`);
if (channel.type=="voice") return interaction.send(`Connot set voice channel to preferred channel.`);
if (channel.deleted) return interaction.send(`Connot set deleted channel to preferred channel.`);
let guild = await client.dbo.collection("guilds").findOne({"server.serverID":interaction.guild.id}).then(guild => guild);
if (client.exists(guild.server.tweetChannel)&&guild.server.tweetChannel==channelid) return interaction.send(`The channel <#${args[0].value}> has already been set for tweets.`);
client.dbo.collection("guilds").updateOne({"server.serverID":interaction.guild.id},{$set:{"server.tweetChannel":channelid}},function(err, res) {
if (err) throw err;
return interaction.send(`Successfully set <#${args[0].value}> for tweets.`);
});
},
},
}