JaBa/commands/Owner/say.js

88 lines
2.1 KiB
JavaScript
Raw Normal View History

const Command = require("../../base/Command");
2022-01-04 02:18:28 +05:00
class Say extends Command {
constructor(client) {
super(client, {
name: "say",
dirname: __dirname,
enabled: true,
guildOnly: false,
aliases: [],
memberPermissions: [],
botPermissions: ["SEND_MESSAGES"],
nsfw: false,
ownerOnly: true,
cooldown: 2000
});
}
2022-01-13 00:26:23 +05:00
async run(message, args) {
2022-01-17 13:43:36 +05:00
if (!args[0]) {
if (message.deletable) return message.delete();
}
2022-01-04 02:18:28 +05:00
// Arguments split
2022-01-13 00:26:23 +05:00
const split = "++";
2022-01-04 02:18:28 +05:00
args = args.join(" ").split(split);
2022-01-17 13:36:55 +05:00
for (let i = 0; i < args.length; i++) args[i] = args[i].trim();
2022-01-04 02:18:28 +05:00
2022-01-17 13:36:55 +05:00
let attachment = null;
2022-01-28 17:17:06 +05:00
let sayChannel = null;
2022-01-17 13:36:55 +05:00
if (message.attachments.size > 0) attachment = message.attachments.first();
2022-01-04 02:18:28 +05:00
2022-01-17 13:43:36 +05:00
if (!args[1] && !args[2]) {
if (message.deletable) message.delete();
2022-01-28 17:17:06 +05:00
sayChannel = message.channel;
sayChannel.sendTyping();
2022-01-04 02:18:28 +05:00
setTimeout(function () {
2022-01-28 17:17:06 +05:00
if (attachment) sayChannel.send({
content: args[0],
2022-01-17 13:36:55 +05:00
files: [{
name: attachment.name,
attachment: attachment.url
}]
2022-01-04 02:18:28 +05:00
});
2022-01-28 17:17:06 +05:00
else sayChannel.send({
content: args[0]
});
2022-01-04 02:18:28 +05:00
}, 2000);
2022-01-17 13:43:36 +05:00
} else if (args[1] && !args[2]) {
if (message.deletable) message.delete();
2022-01-28 17:17:06 +05:00
sayChannel = message.guild.channels.cache.find(channel => channel.name.includes(args[1]) || channel.id === args[1]);
sayChannel.sendTyping();
2022-01-04 02:18:28 +05:00
setTimeout(function () {
2022-01-28 17:17:06 +05:00
if (attachment) sayChannel.send({
content: args[0],
2022-01-17 13:36:55 +05:00
files: [{
name: attachment.name,
attachment: attachment.url
}]
2022-01-04 02:18:28 +05:00
});
2022-01-28 17:17:06 +05:00
else sayChannel.send({
content: args[0]
});
2022-01-04 02:18:28 +05:00
}, 2000);
2022-01-17 13:43:36 +05:00
} else if (args[2]) {
if (message.deletable) message.delete();
2022-01-28 17:17:06 +05:00
sayChannel = this.client.guilds.cache.find(guild => guild.name.includes(args[2]) || guild.id === args[2]).channels.cache.find(channel => channel.name.includes(args[1]) || channel.id === args[1]);
sayChannel.sendTyping();
2022-01-04 02:18:28 +05:00
setTimeout(function () {
2022-01-28 17:17:06 +05:00
if (attachment) sayChannel.send({
content: args[0],
2022-01-17 13:36:55 +05:00
files: [{
name: attachment.name,
attachment: attachment.url
}]
2022-01-04 02:18:28 +05:00
});
2022-01-28 17:17:06 +05:00
else sayChannel.send({
content: args[0]
});
2022-01-04 02:18:28 +05:00
}, 2000);
2022-01-13 00:26:23 +05:00
}
2022-01-04 02:18:28 +05:00
}
2022-01-13 00:26:23 +05:00
}
2022-01-04 02:18:28 +05:00
module.exports = Say;