Files

79 lines
3.0 KiB
JavaScript

const { EmbedBuilder } = require('discord.js');
module.exports = {
name: "tweet",
debug: false,
global: false,
description: "Tweet your thoughts to the local twitter page",
usage: "[message]",
permissions: {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: [],
},
options: [
{
name: "message",
description: "Your message to tweet",
value: "message",
type: 3,
required: true,
},
{
name: "use_vpn",
description: "Tweet from an anonymous account",
value: "use_vpn",
type: 3,
choices: [{ name: "true", value: "true" }], // this just makes it look like we are enabling it optionally, but all
required: false, // we care for is that args[1] exists to send an anonymous tweet.
},
],
SlashCommand: {
/**
*
* @param {require("../structures/QuarksBot")} client
* @param {import("discord.js").Message} 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({ content: `You are not allowed to use the bot in this channel.`, flags: (1 << 6) });
}
const userID = interaction.member.user.id;
const avatar = interaction.member.user.avatar;
let tweetEmbed = new EmbedBuilder()
.setColor('#0099ff')
.setTitle('New Twitter Notifciation')
.setThumbnail('https://static.vecteezy.com/system/resources/previews/002/534/045/original/social-media-twitter-logo-blue-isolated-free-vector.jpg')
.setDescription(args[0].value)
.setTimestamp()
if (client.exists(args[1])) {
tweetEmbed.setAuthor({ name: 'Anonymous', iconURL: 'https://www.pngkey.com/png/detail/230-2301779_best-classified-apps-default-user-profile.png' })
} else {
tweetEmbed.setAuthor({ name: `${interaction.member.user.username}`, iconURL: `https://cdn.discordapp.com/avatars/${userID}/${avatar}.png` })
}
if (client.exists(GuildDB.tweetChannel)) {
const channel = interaction.guild.channels.cache.find(channel => channel.id === GuildDB.tweetChannel);
if (!channel) {
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:** ${err}\nThe channel may have been deleted\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return interaction.send({ embeds: [embed] });
}
try {
channel.send({ embeds: [tweetEmbed] });
} catch (err) {
return interaction.send({ content: `<@${client.user.id}> Does not have permissions to send to the channel.\nMake sure your admins give <@${client.user.id}> access to all channels required.` })
}
return interaction.send({ content: 'Tweeted!' });
} else {
return interaction.send({ content: 'Tweeted!', embeds: [tweetEmbed] });
}
},
},
}