free-code
Version:
Makes free code for discord.js command/bots
41 lines (34 loc) • 1.56 kB
JavaScript
const {
Client,
Message,
MessageEmbed
} = require('discord.js');
module.exports = {
name: 'say',
description: 'Repeats your message to the specified channel. If no channel is given, then the message will be sent to the current channel.',
/**
* @param {Client} client
* @param {Message} message
* @param {String[]} args
*/
run: async (client, message, args) => {
let channel = message.mentions.channels.first() || message.guild.channels.cache.get(args[0]);
if (channel) {
args.shift();
} else channel = message.channel;
// Check type and viewable
if (channel.type != 'text' || !channel.viewable) return message.lineReply(`
Please mention an accessible text channel or provide a valid text channel ID
`);
if (!args[0]) return message.lineReply('Please provide a message for me to say');
// Check channel permissions
if (!channel.permissionsFor(message.guild.me).has(['SEND_MESSAGES']))
return message.lineReply('I do not have permission to send messages in the provided channel');
if (!channel.permissionsFor(message.member).has(['SEND_MESSAGES']))
return message.lineReply('You do not have permission to send messages in the provided channel');
const msg = message.content.slice(message.content.indexOf(args[0]), message.content.length);
channel.send(msg, {
disableMentions: 'everyone'
});
}
}