Рефакторинг

This commit is contained in:
JonnyBro 2021-12-11 01:11:50 +05:00
parent aefb17ebcb
commit beb4a7e6af
73 changed files with 499 additions and 1199 deletions

View file

@ -80,7 +80,7 @@ class Backup extends Command {
// Displays the server from which this backup comes
.addField(message.translate("administration/backup:TITLE_SERVER_ID"), backupInfos.data.guildID, true)
// Display the size (in mb) of the backup
.addField(message.translate("administration/backup:TITLE_SIZE"), backupInfos.size+" mb", true)
.addField(message.translate("administration/backup:TITLE_SIZE"), `${backupInfos.size}mb`, true)
// Display when the backup was created
.addField(message.translate("administration/backup:TITLE_CREATED_AT"), message.printDate(new Date(backupInfos.data.createdTimestamp)), true)
.setColor(data.config.embed.color)

View file

@ -19,7 +19,7 @@ class Setlang extends Command {
async run (message, args, data) {
const language = this.client.languages.find((l) => l.name === args[0] || l.aliases.includes(args[0]));
if (!args[0] || !language) return message.error("administration/setlang:MISSING_LANG", { list: this.client.languages.map((l) => "`"+l.name+"`").join(", ") });
if (!args[0] || !language) return message.error("administration/setlang:MISSING_LANG", { list: this.client.languages.map((l) => `\`${l.name}\``).join(", ") });
data.guild.language = language.name;
await data.guild.save();

View file

@ -34,7 +34,7 @@ class Birthdate extends Command {
const d = new Date(tyear, tmonth, tday);
if (!(tday == d.getDate() && tmonth == d.getMonth() && tyear == d.getFullYear())) return message.error("economy/birthdate:INVALID_DATE_FORMAT");
if (d.getTime() > Date.now()) return message.error("economy/birthdate:DATE_TOO_HIGH");
if (d.getTime() < (Date.now()-2.523e+12))return message.error("economy/birthdate:DATE_TOO_LOW");
if (d.getTime() < (Date.now() - 2.523e+12))return message.error("economy/birthdate:DATE_TOO_LOW");
data.userData.birthdate = d;
data.userData.save();

View file

@ -28,14 +28,14 @@ class Leaderboard extends Command {
membersLeaderboard = members.map((m) => {
return {
id: m.id,
value: m.money+m.bankSold
value: m.money + m.bankSold
};
}).sort((a,b) => b.value - a.value);
const table = new AsciiTable("LEADERBOARD");
table.setHeading("#", message.translate("common:USER"), message.translate("common:CREDITS"));
if (membersLeaderboard.length > 20) membersLeaderboard.length = 20;
const newTable = await fetchUsers(membersLeaderboard, table, this.client);
message.channel.send("```\n"+newTable.toString()+"```");
message.channel.send(`\`\`\`\n${newTable.toString()}\`\`\``);
} else if (type === "level") {
const members = await this.client.membersData.find({ guildID: message.guild.id }).lean(),
membersLeaderboard = members.map((m) => {
@ -48,7 +48,7 @@ class Leaderboard extends Command {
table.setHeading("#", message.translate("common:USER"), message.translate("common:LEVEL"));
if (membersLeaderboard.length > 20) membersLeaderboard.length = 20;
const newTable = await fetchUsers(membersLeaderboard, table, this.client);
message.channel.send("```\n"+newTable.toString()+"```");
message.channel.send(`\`\`\`\n${newTable.toString()}\`\`\``);
} else if (type === "rep") {
const users = await this.client.usersData.find().lean(),
usersLeaderboard = users.map((u) => {
@ -61,7 +61,7 @@ class Leaderboard extends Command {
table.setHeading("#", message.translate("common:USER"), message.translate("common:POINTS"));
if (usersLeaderboard.length > 20) usersLeaderboard.length = 20;
const newTable = await fetchUsers(usersLeaderboard, table, this.client);
message.channel.send("```\n"+newTable.toString()+"```");
message.channel.send(`\`\`\`\n${newTable.toString()}\`\`\``);
};
if (isOnlyOnMobile) message.sendT("economy/leaderboard:MOBILE");

View file

@ -77,7 +77,7 @@ class FindWords extends Command {
message.success("fun/findwords:WORD_FOUND", { winner: `<@${reason}>` });
winners.push(reason);
}
if (i < nbGames-1) {
if (i < nbGames - 1) {
i++;
generateGame.call(this, words[i]);
} else {

View file

@ -44,7 +44,7 @@ class Number extends Command {
const parsedNumber = parseInt(msg.content, 10);
if (parsedNumber === number) {
const time = this.client.functions.convertTime(message.guild, Date.now()-gameCreatedAt);
const time = this.client.functions.convertTime(message.guild, Date.now() - gameCreatedAt);
message.sendT("fun/number:GAME_STATS", { winner: msg.author.toString(), number, time, participantCount: participants.length, participants: participants.map(p => `<@${p}>`).join("\n") });
message.sendT("fun/number:WON", { winner: msg.author.toString() });
const userdata = await this.client.findOrCreateMember({ id: msg.author.id, guildID: message.guild.id });

View file

@ -6,7 +6,7 @@ class Invite extends Command {
super(client, {
name: "invite",
dirname: __dirname,
enabled: true,
enabled: false,
guildOnly: false,
aliases: [ "i", "add", "vote" ],
memberPermissions: [],

View file

@ -1,7 +1,6 @@
const Command = require("../../base/Command.js");
class Setafk extends Command {
constructor (client) {
super(client, {
name: "setafk",
@ -17,22 +16,15 @@ class Setafk extends Command {
}
async run (message, args, data) {
const reason = args.join(" ");
if(!reason){
return message.error("general/setafk:MISSING_REASON");
}
if (!reason) return message.error("general/setafk:MISSING_REASON");
// Send success message
message.success("general/setafk:SUCCESS", {
reason
});
message.success("general/setafk:SUCCESS", { reason });
data.userData.afk = reason;
data.userData.save();
}
}
};
module.exports = Setafk;

View file

@ -3,7 +3,6 @@ const Command = require("../../base/Command.js"),
fetch = require("node-fetch");
class ShortURL extends Command {
constructor (client) {
super(client, {
name: "shorturl",
@ -21,25 +20,19 @@ class ShortURL extends Command {
async run (message, args, data) {
const url = args[0];
if(!url){
return message.error("general/shorturl:MISSING_URL");
}
if (!url) return message.error("general/shorturl:MISSING_URL");
const res = await fetch(`https://is.gd/create.php?format=simple&url=${encodeURI(url)}`);
const body = await res.text();
if(body === "Error: Please enter a valid URL to shorten"){
return message.error("general/shorturl:MISSING_URL");
}
if (body === "Error: Please enter a valid URL to shorten") return message.error("general/shorturl:MISSING_URL");
const embed = new Discord.MessageEmbed()
.setColor(data.config.embed.color)
.setFooter(data.config.embed.footer)
.setDescription(body);
message.channel.send(embed);
}
}
};
module.exports = ShortURL;

View file

@ -2,7 +2,6 @@ const Command = require("../../base/Command.js"),
Discord = require("discord.js");
class Someone extends Command {
constructor (client) {
super(client, {
name: "someone",
@ -19,7 +18,6 @@ class Someone extends Command {
}
async run (message, args, data) {
const member = message.guild.members.cache.random(1)[0];
const embed = new Discord.MessageEmbed()
@ -29,9 +27,7 @@ class Someone extends Command {
.setThumbnail(member.user.displayAvatarURL({ size: 512, dynamic: true, format: 'png' }))
.setColor(data.config.embed.color);
message.channel.send(embed);
}
}
};
module.exports = Someone;

View file

@ -2,7 +2,6 @@ const Command = require("../../base/Command.js"),
Discord = require("discord.js");
class Staff extends Command {
constructor (client) {
super(client, {
name: "staff",
@ -23,16 +22,13 @@ class Staff extends Command {
const administrators = message.guild.members.cache.filter((m) => m.hasPermission("ADMINISTRATOR") && !m.user.bot);
const moderators = message.guild.members.cache.filter((m) => !administrators.has(m.id) && m.hasPermission("MANAGE_MESSAGES") && !m.user.bot);
const embed = new Discord.MessageEmbed()
.setAuthor(message.translate("general/staff:TITLE", {
guild: message.guild.name
}))
.setAuthor(message.translate("general/staff:TITLE", { guild: message.guild.name }))
.addField(message.translate("general/staff:ADMINS"), (administrators.size > 0 ? administrators.map((a) => `${this.client.customEmojis.status[a.presence.status]} | ${a.user.tag}`).join("\n") :message.translate("general/staff:NO_ADMINS")))
.addField(message.translate("general/staff:MODS"), (moderators.size > 0 ? moderators.map((m) => `${this.client.customEmojis.status[m.presence.status]} | ${m.user.tag}`).join("\n") : message.translate("general/staff:NO_MODS")))
.setColor(data.config.embed.color)
.setFooter(data.config.embed.footer);
message.channel.send(embed);
}
}
};
module.exports = Staff;

View file

@ -2,7 +2,6 @@ const Command = require("../../base/Command.js"),
Discord = require("discord.js");
class Stats extends Command {
constructor (client) {
super(client, {
name: "stats",
@ -19,43 +18,27 @@ class Stats extends Command {
}
async run (message, args, data) {
const statsEmbed = new Discord.MessageEmbed()
.setColor(data.config.embed.color)
.setFooter(data.config.embed.footer)
.setAuthor(message.translate("common:STATS"))
.setDescription(message.translate("general/stats:MADE"))
.addField(this.client.customEmojis.stats+" "+message.translate("general/stats:COUNTS_TITLE"), message.translate("general/stats:COUNTS_CONTENT", {
servers: this.client.guilds.cache.size,
users: this.client.users.cache.size
}), true)
.addField(this.client.customEmojis.stats+" "+message.translate("general/stats:COUNTS_TITLE"), message.translate("general/stats:COUNTS_CONTENT", { servers: this.client.guilds.cache.size, users: this.client.users.cache.size }), true)
.addField(this.client.customEmojis.version+" "+message.translate("general/stats:VERSIONS_TITLE"), `\`Discord.js : v${Discord.version}\`\n\`Nodejs : v${process.versions.node}\``, true)
.addField(this.client.customEmojis.ram+" "+message.translate("general/stats:RAM_TITLE"), `\`${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)}MB\``, true)
.addField(this.client.customEmojis.status.online+" "+message.translate("general/stats:ONLINE_TITLE"), message.translate("general/stats:ONLINE_CONTENT", {
time: message.convertTime(Date.now()+this.client.uptime, "from", true)
}))
.addField(this.client.customEmojis.voice+" "+message.translate("general/stats:MUSIC_TITLE"), message.translate("general/stats:MUSIC_CONTENT", {
count: this.client.voice.connections.size
}))
.addField(this.client.customEmojis.status.online+" "+message.translate("general/stats:ONLINE_TITLE"), message.translate("general/stats:ONLINE_CONTENT", { time: message.convertTime(Date.now()+this.client.uptime, "from", true) }))
.addField(this.client.customEmojis.voice+" "+message.translate("general/stats:MUSIC_TITLE"), message.translate("general/stats:MUSIC_CONTENT", { count: this.client.voice.connections.size }))
.addField(message.translate("general/stats:CREDITS_TITLE"), message.translate("general/stats:CREDITS_CONTENT", {
donators: [ ":(" ].join("\n"),
translators: [ "`Jonny_Bro#4226` (:flag_ru:)", "`[ДАННЫЕ УДАЛЕНЫ]#2789` (:flag_ua:)" ].join("\n")
}));
statsEmbed.addField(this.client.customEmojis.link+" "+message.translate("general/stats:LINKS_TITLE"), message.translate("misc:STATS_FOOTER", {
donateLink: "",
dashboardLink: "",
inviteLink: await this.client.generateInvite({
permissions: ["ADMINISTRATOR"]
}),
githubLink: "https://github.com/Androz2091",
supportLink: ""
})
);
dashboardLink: "https://jaba.pp.ua",
donateLink: "https://qiwi.com/n/JONNYBRO"
}));
message.channel.send(statsEmbed);
}
}
};
module.exports = Stats;

View file

@ -2,7 +2,6 @@ const Command = require("../../base/Command.js"),
Discord = require("discord.js");
class Suggest extends Command {
constructor (client) {
super(client, {
name: "suggest",
@ -19,21 +18,14 @@ class Suggest extends Command {
}
async run (message, args, data) {
const suggChannel = message.guild.channels.cache.get(data.guild.plugins.suggestions);
if(!suggChannel){
return message.error("general/suggest:MISSING_CHANNEL");
}
if (!suggChannel) return message.error("general/suggest:MISSING_CHANNEL");
const sugg = args.join(" ");
if(!sugg){
return message.error("general/suggest:MISSING_CONTENT");
}
if (!sugg) return message.error("general/suggest:MISSING_CONTENT");
const embed = new Discord.MessageEmbed()
.setAuthor(message.translate("general/suggest:TITLE", {
user: message.author.username
}), message.author.displayAvatarURL({ size: 512, dynamic: true, format: 'png' }))
.setAuthor(message.translate("general/suggest:TITLE", { user: message.author.username }), message.author.displayAvatarURL({ size: 512, dynamic: true, format: 'png' }))
.addField(message.translate("common:AUTHOR"), `\`${message.author.username}#${message.author.discriminator}\``, true)
.addField(message.translate("common:DATE"), message.printDate(new Date(Date.now())), true)
.addField(message.translate("common:CONTENT"), "**"+sugg+"**")
@ -48,11 +40,8 @@ class Suggest extends Command {
await m.react(error);
});
message.success("general/suggest:SUCCESS", {
channel: suggChannel.toString()
});
message.success("general/suggest:SUCCESS", { channel: suggChannel.toString() });
}
}
};
module.exports = Suggest;

View file

@ -5,7 +5,6 @@ const Command = require("../../base/Command.js"),
const langs = ["afrikaans", "albanian", "amharic", "arabic", "armenian", "azerbaijani", "bangla", "basque", "belarusian", "bengali", "bosnian", "bulgarian", "burmese", "catalan", "cebuano", "chichewa", "corsican", "croatian", "czech", "danish", "dutch", "english", "esperanto", "estonian", "filipino", "finnish", "french", "frisian", "galician", "georgian", "german", "greek", "gujarati", "haitian creole", "hausa", "hawaiian", "hebrew", "hindi", "hmong", "hungarian", "icelandic", "igbo", "indonesian", "irish", "italian", "japanese", "javanese", "kannada", "kazakh", "khmer", "korean", "kurdish (kurmanji)", "kyrgyz", "lao", "latin", "latvian", "lithuanian", "luxembourgish", "macedonian", "malagasy", "malay", "malayalam", "maltese", "maori", "marathi", "mongolian", "myanmar (burmese)", "nepali", "norwegian", "nyanja", "pashto", "persian", "polish", "portugese", "punjabi", "romanian", "russian", "samoan", "scottish gaelic", "serbian", "sesotho", "shona", "sindhi", "sinhala", "slovak", "slovenian", "somali", "spanish", "sundanese", "swahili", "swedish", "tajik", "tamil", "telugu", "thai", "turkish", "ukrainian", "urdu", "uzbek", "vietnamese", "welsh", "xhosa", "yiddish", "yoruba", "zulu"];
class Translate extends Command {
constructor (client) {
super(client, {
name: "translate",
@ -22,47 +21,28 @@ class Translate extends Command {
}
async run (message, args, data) {
if(args[0] === "langs-list"){
const langsList = "```Css\n"+(langs.map((l, i) => `#${i+1} - ${l}`).join("\n"))+"```";
if (args[0] === "langs-list") {
const langsList = "```css\n"+(langs.map((l, i) => `#${i+1} - ${l}`).join("\n"))+"```";
message.author.send(langsList).then(() => {
message.success("general/translate:LIST_SENT");
}).catch(() => {
message.error("misc:CANNOT_DM");
});
return;
}
};
const pWait = await message.sendT("misc:PLEASE_WAIT", null, {
prefixEmoji: "loading"
});
const pWait = await message.sendT("misc:PLEASE_WAIT", null, { prefixEmoji: "loading" });
if(!args[0]){
return pWait.error("general/translate:MISSING_LANGUAGE", {
prefix: data.guild.prefix
}, {
edit: true
});
}
if (!args[0]) return pWait.error("general/translate:MISSING_LANGUAGE", { prefix: data.guild.prefix }, { edit: true });
if(!args[1]){
return pWait.error("general/translate:MISSING_CONTENT", null, {
edit: true
});
}
if (!args[1]) return pWait.error("general/translate:MISSING_CONTENT", null, { edit: true });
// Gets different args
const language = args[0].toLowerCase();
const toTranslate = args.slice(1).join(" ");
if(!langs.includes(language)){
return pWait.error("general/translate:INVALID_LANGUAGE", {
prefix: data.guild.prefix,
search: language
}, {
edit: true
});
}
if (!langs.includes(language)) return pWait.error("general/translate:INVALID_LANGUAGE", { prefix: data.guild.prefix, search: language}, { edit: true });
const translated = await translate(toTranslate, { to: language });
@ -74,9 +54,7 @@ class Translate extends Command {
.setFooter(data.config.embed.footer);
return pWait.edit("", { embed: resEmbed });
}
}
};
module.exports = Translate;

View file

@ -3,7 +3,6 @@ const Command = require("../../base/Command.js"),
fetch = require("node-fetch");
class Userinfo extends Command {
constructor (client) {
super(client, {
name: "userinfo",
@ -20,34 +19,26 @@ class Userinfo extends Command {
}
async run (message, args, data) {
let displayPresence = true;
const isID = !isNaN(args[0]);
var user;
if(!args[0]){
user = message.author;
}
if(message.mentions.users.first()){
user = message.mentions.users.first();
}
if(isID && !user){
if (!args[0]) user = message.author;
if (message.mentions.users.first()) user = message.mentions.users.first();
if (isID && !user) {
user = this.client.users.cache.get(args[0]);
if(!user){
if (!user) {
user = await this.client.users.fetch(args[0], true).catch(() => {});
displayPresence = false;
}
}
};
};
if(!user){
return message.error("general/userinfo:INVALID_USER");
}
if (!user) return message.error("general/userinfo:INVALID_USER");
let member = null;
if(message.guild){
member = await message.guild.members.fetch(user).catch(() => {});
}
if (message.guild) member = await message.guild.members.fetch(user).catch(() => {});
const embed = new Discord.MessageEmbed()
.setAuthor(user.tag, user.displayAvatarURL({ size: 512, dynamic: true, format: 'png' }))
@ -60,29 +51,25 @@ class Userinfo extends Command {
.setColor(data.config.embed.color)
.setFooter(data.config.embed.footer);
if(displayPresence){
if (displayPresence) {
embed.addField(this.client.customEmojis.games+" "+message.translate("common:GAME"), (user.presence.activity ? user.presence.activity.name : message.translate("general/userinfo:NO_GAME")), true)
.addField(this.client.customEmojis.status.online+" "+message.translate("common:STATUS"), message.translate("common:STATUS_"+(user.presence.status.toUpperCase())), true);
}
embed.addField(this.client.customEmojis.status.online+" "+message.translate("common:STATUS"), message.translate("common:STATUS_"+(user.presence.status.toUpperCase())), true);
};
if(member){
if (member) {
embed.addField(this.client.customEmojis.up+" "+message.translate("common:ROLE"), (member.roles.highest ? member.roles.highest : message.translate("general/userinfo:NO_ROLE")), true)
.addField(this.client.customEmojis.calendar2+" "+message.translate("common:JOIN"), message.printDate(member.joinedAt),true)
.addField(this.client.customEmojis.color+" "+message.translate("common:COLOR"), member.displayHexColor, true)
.addField(this.client.customEmojis.pencil+" "+message.translate("common:NICKNAME"), (member.nickname ? member.nickname : message.translate("general/userinfo:NO_NICKNAME")), true)
.addField(this.client.customEmojis.roles+" "+message.translate("common:ROLES"), (
member.roles.size > 10
? member.roles.cache.map((r) => r).slice(0, 9).join(", ")+" "+message.translate("general/userinfo:MORE_ROLES", { count: member.roles.cache.size - 10 })
: (member.roles.cache.size < 1) ? message.translate("general/userinfo:NO_ROLE") : member.roles.cache.map((r) => r).join(", ")
));
}
embed.addField(this.client.customEmojis.calendar2+" "+message.translate("common:JOIN"), message.printDate(member.joinedAt),true)
embed.addField(this.client.customEmojis.color+" "+message.translate("common:COLOR"), member.displayHexColor, true)
embed.addField(this.client.customEmojis.pencil+" "+message.translate("common:NICKNAME"), (member.nickname ? member.nickname : message.translate("general/userinfo:NO_NICKNAME")), true)
embed.addField(this.client.customEmojis.roles+" "+message.translate("common:ROLES"), (member.roles.size > 10 ? member.roles.cache.map((r) => r).slice(0, 9).join(", ")+" "+message.translate("general/userinfo:MORE_ROLES", { count: member.roles.cache.size - 10 }) : (member.roles.cache.size < 1) ? message.translate("general/userinfo:NO_ROLE") : member.roles.cache.map((r) => r).join(", ")));
};
if(user.bot && this.client.config.apiKeys.dbl && (this.client.config.apiKeys.dbl !== "")){
if (user.bot && this.client.config.apiKeys.dbl && (this.client.config.apiKeys.dbl !== "")) {
const res = await fetch("https://discordbots.org/api/bots/"+user.id, {
headers: { "Authorization": this.client.config.apiKeys.dbl }
});
const data = await res.json();
if(!data.error){
if (!data.error) {
embed.addField(this.client.customEmojis.desc+" "+message.translate("common:DESCRIPTION"), data.shortdesc, true)
.addField(this.client.customEmojis.stats+" "+message.translate("common:STATS"), message.translate("general/userinfo:BOT_STATS", {
votes: data.monthlyPoints || 0,
@ -90,15 +77,12 @@ class Userinfo extends Command {
shards: (data.shards || [0]).length,
lib: data.lib || "unknown"
}), true)
.addField(this.client.customEmojis.link+" "+message.translate("common:LINKS"),
`${data.support ? `[${message.translate("common:SUPPORT")}](${data.support}) | ` : ""}${data.invite ? `[${message.translate("common:INVITE")}](${data.invite}) | ` : ""}${data.github ? `[GitHub](${data.github}) | ` : ""}${data.website ? `[${message.translate("common:WEBSITE")}](${data.website})` : ""}`
, true);
}
}
.addField(this.client.customEmojis.link+" "+message.translate("common:LINKS"), `${data.support ? `[${message.translate("common:SUPPORT")}](${data.support}) | ` : ""}${data.invite ? `[${message.translate("common:INVITE")}](${data.invite}) | ` : ""}${data.github ? `[GitHub](${data.github}) | ` : ""}${data.website ? `[${message.translate("common:WEBSITE")}](${data.website})` : ""}`, true);
};
};
message.channel.send(embed);
}
}
};
module.exports = Userinfo;

View file

@ -18,18 +18,13 @@ class Approved extends Command {
}
async run (message, args) {
const user = await this.client.resolveUser(args[0]) || message.author;
const m = await message.sendT("misc:PLEASE_WAIT", null, {
prefixEmoji: "loading"
});
const m = await message.sendT("misc:PLEASE_WAIT", null, { prefixEmoji: "loading" });
const buffer = await this.client.AmeAPI.generate("approved", { url: user.displayAvatarURL({ format: "png", size: 512 }) });
const attachment = new Discord.MessageAttachment(buffer, "approved.png");
m.delete();
message.channel.send(attachment);
}
}
};
module.exports = Approved;

View file

@ -18,16 +18,13 @@ class Avatar extends Command {
}
async run (message, args) {
let user = await this.client.resolveUser(args[0]);
if(!user) user = message.author;
if (!user) user = message.author;
const avatarURL = user.displayAvatarURL({ size: 512, dynamic: true, format: 'png' });
if(message.content.includes("-v")) message.channel.send("<"+avatarURL+">");
if (message.content.includes("-v")) message.channel.send("<"+avatarURL+">");
const attachment = new Discord.MessageAttachment(avatarURL, `avatar.${avatarURL.split(".").pop().split("?")[0]}`);
message.channel.send(attachment);
}
}
};
module.exports = Avatar;

View file

@ -18,21 +18,16 @@ class BatSlap extends Command {
}
async run (message, args) {
const users = [
await this.client.resolveUser(args[0]) || message.author,
await this.client.resolveUser(args[1]) || message.author
];
const m = await message.sendT("misc:PLEASE_WAIT", null, {
prefixEmoji: "loading"
});
const m = await message.sendT("misc:PLEASE_WAIT", null, { prefixEmoji: "loading" });
const buffer = await this.client.AmeAPI.generate("batslap", { avatar: users[0].displayAvatarURL({ format: "png", size: 512 }), url: users[1].displayAvatarURL({ format: "png", size: 512 }) });
const attachment = new Discord.MessageAttachment(buffer, "batslap.png");
m.delete();
message.channel.send(attachment);
}
}
};
module.exports = BatSlap;

View file

@ -18,18 +18,13 @@ class Beautiful extends Command {
}
async run (message, args) {
const user = await this.client.resolveUser(args[0]) || message.author;
const m = await message.sendT("misc:PLEASE_WAIT", null, {
prefixEmoji: "loading"
});
const m = await message.sendT("misc:PLEASE_WAIT", null, { prefixEmoji: "loading" });
const buffer = await this.client.AmeAPI.generate("beautiful", { url: user.displayAvatarURL({ format: "png", size: 512 }) });
const attachment = new Discord.MessageAttachment(buffer, "beautiful.png");
m.delete();
message.channel.send(attachment);
}
}
};
module.exports = Beautiful;

View file

@ -19,15 +19,12 @@ class Bed extends Command {
}
async run (message, args) {
const users = [
await this.client.resolveUser(args[0]) || message.author,
await this.client.resolveUser(args[1]) || message.author
];
const m = await message.sendT("misc:PLEASE_WAIT", null, {
prefixEmoji: "loading"
});
const m = await message.sendT("misc:PLEASE_WAIT", null, { prefixEmoji: "loading" });
try {
const buffer = await canvacord.Canvas.bed(users[0].displayAvatarURL({ format: "png" }), users[1].displayAvatarURL({ format: "png" }));
const attachment = new Discord.MessageAttachment(buffer, "bed.png");
@ -35,13 +32,9 @@ class Bed extends Command {
m.delete();
} catch(e){
console.log(e);
m.error("misc:ERROR_OCCURRED", null, {
edit: true
});
}
m.error("misc:ERROR_OCCURRED", null, { edit: true });
};
}
}
};
module.exports = Bed;

View file

@ -18,18 +18,13 @@ class Brazzers extends Command {
}
async run (message, args) {
const user = await this.client.resolveUser(args[0]) || message.author;
const m = await message.sendT("misc:PLEASE_WAIT", null, {
prefixEmoji: "loading"
});
const m = await message.sendT("misc:PLEASE_WAIT", null, { prefixEmoji: "loading" });
const buffer = await this.client.AmeAPI.generate("brazzers", { url: user.displayAvatarURL({ format: "png", size: 512 }) });
const attachment = new Discord.MessageAttachment(buffer, "brazzers.png");
m.delete();
message.channel.send(attachment);
}
}
};
module.exports = Brazzers;

View file

@ -18,18 +18,13 @@ class Burn extends Command {
}
async run (message, args) {
const user = await this.client.resolveUser(args[0]) || message.author;
const m = await message.sendT("misc:PLEASE_WAIT", null, {
prefixEmoji: "loading"
});
const m = await message.sendT("misc:PLEASE_WAIT", null, { prefixEmoji: "loading" });
const buffer = await this.client.AmeAPI.generate("burn", { url: user.displayAvatarURL({ format: "png", size: 512 }) });
const attachment = new Discord.MessageAttachment(buffer, "burn.png");
m.delete();
message.channel.send(attachment);
}
}
};
module.exports = Burn;

View file

@ -19,11 +19,8 @@ class Captcha extends Command {
}
async run (message, args) {
const user = await this.client.resolveUser(args[0]) || message.author;
const m = await message.sendT("misc:PLEASE_WAIT", null, {
prefixEmoji: "loading"
});
const m = await message.sendT("misc:PLEASE_WAIT", null, { prefixEmoji: "loading" });
try {
const res = await fetch(encodeURI(`https://nekobot.xyz/api/imagegen?type=captcha&username=${user.username}&url=${user.displayAvatarURL({ format: "png", size: 512 })}`));
const json = await res.json();
@ -35,10 +32,8 @@ class Captcha extends Command {
m.error("misc:ERR_OCCURRED", null, {
edit: true
});
}
};
}
}
};
module.exports = Captcha;

View file

@ -18,18 +18,13 @@ class Challenger extends Command {
}
async run (message, args) {
const user = await this.client.resolveUser(args[0]) || message.author;
const m = await message.sendT("misc:PLEASE_WAIT", null, {
prefixEmoji: "loading"
});
const m = await message.sendT("misc:PLEASE_WAIT", null, { prefixEmoji: "loading" });
const buffer = await this.client.AmeAPI.generate("challenger", { url: user.displayAvatarURL({ format: "png", size: 512 }) });
const attachment = new Discord.MessageAttachment(buffer, "challenger.png");
m.delete();
message.channel.send(attachment);
}
}
};
module.exports = Challenger;

View file

@ -19,16 +19,11 @@ class Clyde extends Command {
}
async run (message, args) {
const text = args.join(" ");
if(!text){
return message.error("images/clyde:MISSING_TEXT");
}
if (!text) return message.error("images/clyde:MISSING_TEXT");
const m = await message.sendT("misc:PLEASE_WAIT", null, {
prefixEmoji: "loading"
});
const m = await message.sendT("misc:PLEASE_WAIT", null, { prefixEmoji: "loading" });
try {
const res = await fetch(encodeURI(`https://nekobot.xyz/api/imagegen?type=clyde&text=${text}`));
const json = await res.json();
@ -37,13 +32,9 @@ class Clyde extends Command {
m.delete();
} catch(e){
console.log(e);
m.error("misc:ERROR_OCCURRED", null, {
edit: true
});
}
m.error("misc:ERROR_OCCURRED", null, { edit: true });
};
}
}
};
module.exports = Clyde;

View file

@ -18,18 +18,13 @@ class Dictator extends Command {
}
async run (message, args) {
const user = await this.client.resolveUser(args[0]) || message.author;
const m = await message.sendT("misc:PLEASE_WAIT", null, {
prefixEmoji: "loading"
});
const m = await message.sendT("misc:PLEASE_WAIT", null, { prefixEmoji: "loading" });
const buffer = await this.client.AmeAPI.generate("dictator", { url: user.displayAvatarURL({ format: "png", size: 512 }) });
const attachment = new Discord.MessageAttachment(buffer, "dictator.png");
m.delete();
message.channel.send(attachment);
}
}
};
module.exports = Dictator;

View file

@ -19,11 +19,8 @@ class Facepalm extends Command {
}
async run (message, args) {
const user = await this.client.resolveUser(args[0]) || message.author,
m = await message.sendT("misc:PLEASE_WAIT", null, {
prefixEmoji: "loading"
});
m = await message.sendT("misc:PLEASE_WAIT", null, { prefixEmoji: "loading" });
const canvas = Canvas.createCanvas(632, 357),
ctx = canvas.getContext("2d");
@ -44,9 +41,7 @@ class Facepalm extends Command {
m.delete();
message.channel.send(attachment);
}
}
};
module.exports = Facepalm;

View file

@ -18,18 +18,13 @@ class Fire extends Command {
}
async run (message, args) {
const user = await this.client.resolveUser(args[0]) || message.author;
const m = await message.sendT("misc:PLEASE_WAIT", null, {
prefixEmoji: "loading"
});
const m = await message.sendT("misc:PLEASE_WAIT", null, { prefixEmoji: "loading" });
const buffer = await this.client.AmeAPI.generate("fire", { url: user.displayAvatarURL({ format: "png", size: 512 }) });
const attachment = new Discord.MessageAttachment(buffer, "fire.png");
m.delete();
message.channel.send(attachment);
}
}
};
module.exports = Fire;

View file

@ -18,18 +18,13 @@ class Jail extends Command {
}
async run (message, args) {
const user = await this.client.resolveUser(args[0]) || message.author;
const m = await message.sendT("misc:PLEASE_WAIT", null, {
prefixEmoji: "loading"
});
const m = await message.sendT("misc:PLEASE_WAIT", null, { prefixEmoji: "loading" });
const buffer = await this.client.AmeAPI.generate("jail", { url: user.displayAvatarURL({ format: "png", size: 1024 }) });
const attachment = new Discord.MessageAttachment(buffer, "jail.png");
m.delete();
message.channel.send(attachment);
}
}
};
module.exports = Jail;

View file

@ -19,15 +19,12 @@ class Love extends Command {
}
async run (message, args) {
const users = [
await this.client.resolveUser(args[0]) || message.author,
await this.client.resolveUser(args[1]) || message.author
];
const m = await message.sendT("misc:PLEASE_WAIT", null, {
prefixEmoji: "loading"
});
const m = await message.sendT("misc:PLEASE_WAIT", null, { prefixEmoji: "loading" });
try {
const res = await fetch(encodeURI(`https://nekobot.xyz/api/imagegen?type=ship&user1=${users[0].displayAvatarURL({ format: "png", size: 512 })}&user2=${users[1].displayAvatarURL({ format: "png", size: 512 })}`));
const json = await res.json();
@ -36,13 +33,9 @@ class Love extends Command {
m.delete();
} catch(e){
console.log(e);
m.error("misc:ERROR_OCCURRED", null, {
edit: true
});
}
m.error("misc:ERROR_OCCURRED", null, { edit: true });
};
}
}
};
module.exports = Love;

View file

@ -18,18 +18,13 @@ class Mission extends Command {
}
async run (message, args) {
const user = await this.client.resolveUser(args[0]) || message.author;
const m = await message.sendT("images/mission:PLEASE_WAIT", null, {
prefixEmoji: "loading"
});
const m = await message.sendT("images/mission:PLEASE_WAIT", null, { prefixEmoji: "loading" });
const buffer = await this.client.AmeAPI.generate("missionpassed", { url: user.displayAvatarURL({ format: "png", size: 2048 }) });
const attachment = new Discord.MessageAttachment(buffer, "mission.png");
m.delete();
message.channel.send(attachment);
}
}
};
module.exports = Mission;

View file

@ -19,19 +19,16 @@ class Phcomment extends Command {
}
async run (message, args) {
let user = await this.client.resolveUser(args[0]);
let text = args.join(" ");
if(user){
if (user) {
text = args.slice(1).join(" ");
} else {
user = message.author;
}
};
if(!text){
return message.error("images/phcomment:MISSING_TEXT");
}
if (!text) return message.error("images/phcomment:MISSING_TEXT");
const m = await message.sendT("misc:PLEASE_WAIT", null, {
prefixEmoji: "loading"
@ -47,13 +44,9 @@ class Phcomment extends Command {
m.delete();
} catch(e){
console.log(e);
m.error("misc:ERROR_OCCURRED", null, {
edit: true
});
}
m.error("misc:ERROR_OCCURRED", null, { edit: true });
};
}
}
};
module.exports = Phcomment;

View file

@ -2,7 +2,6 @@ const Command = require("../../base/Command.js"),
Discord = require("discord.js");
class Qrcode extends Command {
constructor (client) {
super(client, {
name: "qrcode",
@ -19,24 +18,17 @@ class Qrcode extends Command {
}
async run (message, args, data) {
const text = args.join(" ");
if(!text){
return message.error("images/qrcode:MISSING_TEXT");
}
if (!text) return message.error("images/qrcode:MISSING_TEXT");
const pleaseWait = await message.sendT("misc:PLEASE_WAIT", null, {
prefixEmoji: "loading"
});
const pleaseWait = await message.sendT("misc:PLEASE_WAIT", null, { prefixEmoji: "loading" });
const embed = new Discord.MessageEmbed()
.setImage(`https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=${text.replace(new RegExp(" ", "g"), "%20")}`)
.setColor(data.config.embed.color);
pleaseWait.edit(message.translate("images/qrcode:SUCCESS"), { embed });
}
}
};
module.exports = Qrcode;

View file

@ -18,18 +18,13 @@ class Rip extends Command {
}
async run (message, args) {
const user = await this.client.resolveUser(args[0]) || message.author;
const m = await message.sendT("misc:PLEASE_WAIT", null, {
prefixEmoji: "loading"
});
const m = await message.sendT("misc:PLEASE_WAIT", null, { prefixEmoji: "loading" });
const buffer = await this.client.AmeAPI.generate("rip", { url: user.displayAvatarURL({ format: "png", size: 512 }) });
const attachment = new Discord.MessageAttachment(buffer, "rip.png");
m.delete();
message.channel.send(attachment);
}
}
};
module.exports = Rip;

View file

@ -18,18 +18,13 @@ class Scary extends Command {
}
async run (message, args) {
const user = await this.client.resolveUser(args[0]) || message.author;
const m = await message.sendT("misc:PLEASE_WAIT", null, {
prefixEmoji: "loading"
});
const m = await message.sendT("misc:PLEASE_WAIT", null, { prefixEmoji: "loading" });
const buffer = await this.client.AmeAPI.generate("scary", { url: user.displayAvatarURL({ format: "png", size: 512 }) });
const attachment = new Discord.MessageAttachment(buffer, "scary.png");
m.delete();
message.channel.send(attachment);
}
}
};
module.exports = Scary;

View file

@ -18,18 +18,13 @@ class Tobecontinued extends Command {
}
async run (message, args) {
const user = await this.client.resolveUser(args[0]) || message.author;
const m = await message.sendT("misc:PLEASE_WAIT", null, {
prefixEmoji: "loading"
});
const m = await message.sendT("misc:PLEASE_WAIT", null, { prefixEmoji: "loading" });
const buffer = await this.client.AmeAPI.generate("tobecontinued", { url: user.displayAvatarURL({ format: "png", size: 512 }) });
const attachment = new Discord.MessageAttachment(buffer, "tobecontinued.png");
m.delete();
message.channel.send(attachment);
}
}
};
module.exports = Tobecontinued;

View file

@ -19,18 +19,13 @@ class Trash extends Command {
}
async run (message, args) {
const user = await this.client.resolveUser(args[0]) || message.author;
const m = await message.sendT("misc:PLEASE_WAIT", null, {
prefixEmoji: "loading"
});
const m = await message.sendT("misc:PLEASE_WAIT", null, { prefixEmoji: "loading" });
const buffer = await canvacord.Canvas.trash(user.displayAvatarURL({ format: "png", size: 512 }));
const attachment = new Discord.MessageAttachment(buffer, "trash.png");
m.delete();
message.channel.send(attachment);
}
}
};
module.exports = Trash;

View file

@ -18,18 +18,13 @@ class Triggered extends Command {
}
async run (message, args) {
const user = await this.client.resolveUser(args[0]) || message.author;
const m = await message.sendT("misc:PLEASE_WAIT", null, {
prefixEmoji: "loading"
});
const m = await message.sendT("misc:PLEASE_WAIT", null, { prefixEmoji: "loading" });
const buffer = await this.client.AmeAPI.generate("triggered", { url: user.displayAvatarURL({ format: "png", size: 512 }), sepia: "true", invert: "true" });
const attachment = new Discord.MessageAttachment(buffer, "triggered.gif");
m.delete();
message.channel.send(attachment);
}
}
};
module.exports = Triggered;

View file

@ -2,7 +2,6 @@ const Command = require("../../base/Command.js"),
Discord = require("discord.js");
class Tweet extends Command {
constructor (client) {
super(client, {
name: "tweet",
@ -19,21 +18,14 @@ class Tweet extends Command {
}
async run (message, args) {
const user = message.mentions.users.first() || message.author;
const text = args.slice(1).join(" ");
if(!user){
return message.error("images/tweet:MISSING_USERNAME");
}
if (!user) return message.error("images/tweet:MISSING_USERNAME");
if(!text){
return message.error("images/tweet:MISSING_TEXT");
}
if (!text) return message.error("images/tweet:MISSING_TEXT");
const m = await message.sendT("misc:PLEASE_WAIT", null, {
prefixEmoji: "loading"
});
const m = await message.sendT("misc:PLEASE_WAIT", null, { prefixEmoji: "loading" });
await message.guild.members.fetch();
const randomMembers = message.guild.members.cache.random(3);
@ -48,9 +40,7 @@ class Tweet extends Command {
const attachment = new Discord.MessageAttachment(buffer, "twitter.png");
m.delete();
message.channel.send(attachment);
}
}
};
module.exports = Tweet;

View file

@ -18,18 +18,13 @@ class Wanted extends Command {
}
async run (message, args) {
const user = await this.client.resolveUser(args[0]) || message.author;
const m = await message.sendT("misc:PLEASE_WAIT", null, {
prefixEmoji: "loading"
});
const m = await message.sendT("misc:PLEASE_WAIT", null, { prefixEmoji: "loading" });
const buffer = await this.client.AmeAPI.generate("wanted", { url: user.displayAvatarURL({ format: "png", size: 512 }) });
const attachment = new Discord.MessageAttachment(buffer, "wanted.png");
m.delete();
message.channel.send(attachment);
}
}
};
module.exports = Wanted;

View file

@ -18,18 +18,13 @@ class Wasted extends Command {
}
async run (message, args) {
const user = await this.client.resolveUser(args[0]) || message.author;
const m = await message.sendT("misc:PLEASE_WAIT", null, {
prefixEmoji: "loading"
});
const m = await message.sendT("misc:PLEASE_WAIT", null, { prefixEmoji: "loading" });
const buffer = await this.client.AmeAPI.generate("wasted", { url: user.displayAvatarURL({ format: "png", size: 512 }) });
const attachment = new Discord.MessageAttachment(buffer, "wasted.png");
m.delete();
message.channel.send(attachment);
}
}
};
module.exports = Wasted;

View file

@ -19,23 +19,18 @@ class YouTubeComment extends Command {
}
async run (message, args) {
let user = await this.client.resolveUser(args[0]);
let text = args.join(" ");
if(user){
if (user) {
text = args.slice(1).join(" ");
} else {
user = message.author;
}
};
if(!text){
return message.error("images/phcomment:MISSING_TEXT"); // same text as phcomment
}
if (!text) return message.error("images/phcomment:MISSING_TEXT"); // same text as phcomment
const m = await message.sendT("misc:PLEASE_WAIT", null, {
prefixEmoji: "loading"
});
const m = await message.sendT("misc:PLEASE_WAIT", null, { prefixEmoji: "loading" });
const image = await canvacord.Canvas.youtube({
username: user.username,
avatar: user.displayAvatarURL({ format: "png" }),
@ -44,9 +39,7 @@ class YouTubeComment extends Command {
const attachment = new Discord.MessageAttachment(image, "ytb-comment.png");
m.delete();
message.channel.send(attachment);
}
}
};
module.exports = YouTubeComment;

View file

@ -2,7 +2,6 @@ const Command = require("../../base/Command.js"),
Discord = require("discord.js");
class Announcement extends Command {
constructor (client) {
super(client, {
name: "announcement",
@ -19,64 +18,54 @@ class Announcement extends Command {
}
async run (message, args, data) {
const text = args.join(" ");
if(!text){
return message.error("moderation/announcement:MISSING_TEXT");
}
if(text.length > 1030){
return message.error("moderation/announcement:TOO_LONG");
}
if (!text) return message.error("moderation/announcement:MISSING_TEXT");
if (text.length > 1030) return message.error("moderation/announcement:TOO_LONG");
message.delete().catch(() => {});
let mention = "";
const msg = await message.sendT("moderation/announcement:MENTION_PROMPT");
const collector = new Discord.MessageCollector(message.channel, (m) => m.author.id === message.author.id, { time: 240000 });
collector.on("collect", async (tmsg) => {
if(tmsg.content.toLowerCase() === message.translate("common:NO").toLowerCase()){
if (tmsg.content.toLowerCase() === message.translate("common:NO").toLowerCase()) {
tmsg.delete();
msg.delete();
collector.stop(true);
}
};
if(tmsg.content.toLowerCase() === message.translate("common:YES").toLowerCase()){
if (tmsg.content.toLowerCase() === message.translate("common:YES").toLowerCase()) {
tmsg.delete();
msg.delete();
const tmsg1 = await message.sendT("moderation/announcement:MENTION_TYPE_PROMPT");
const c = new Discord.MessageCollector(message.channel, (m) => m.author.id === message.author.id, { time: 60000 });
c.on("collect", (m) => {
if(m.content.toLowerCase() === "here"){
if (m.content.toLowerCase() === "here") {
mention = "@here";
tmsg1.delete();
m.delete();
collector.stop(true);
c.stop(true);
} else if(m.content.toLowerCase() === "every"){
} else if (m.content.toLowerCase() === "every") {
mention = "@everyone";
tmsg1.delete();
m.delete();
collector.stop(true);
c.stop(true);
}
};
});
c.on("end", (collected, reason) => {
if(reason === "time"){
if (reason === "time") {
return message.error("misc:TIMES_UP");
}
};
});
}
};
});
collector.on("end", (collected, reason) => {
if(reason === "time"){
if (reason === "time") {
return message.error("misc:TIMES_UP");
}
};
const embed = new Discord.MessageEmbed()
.setAuthor(message.translate("moderation/announcement:TITLE"))
@ -87,9 +76,7 @@ class Announcement extends Command {
message.channel.send(mention, embed);
});
}
}
};
module.exports = Announcement;

View file

@ -2,7 +2,6 @@ const Command = require("../../base/Command.js"),
Discord = require("discord.js");
class Ban extends Command {
constructor (client) {
super(client, {
name: "ban",
@ -19,43 +18,28 @@ class Ban extends Command {
}
async run (message, args, data) {
const user = await this.client.resolveUser(args[0]);
if(!user){
return message.error("moderation/ban:MISSING_MEMBER");
}
if (!user) return message.error("moderation/ban:MISSING_MEMBER");
const memberData = message.guild.members.cache.get(user.id) ? await this.client.findOrCreateMember({ id: user.id, guildID: message.guild.id }) : null;
if(user.id === message.author.id){
return message.error("moderation/ban:YOURSELF");
}
if (user.id === message.author.id) return message.error("moderation/ban:YOURSELF");
// If the user is already banned
const banned = await message.guild.fetchBans();
if(banned.some((m) => m.user.id === user.id)){
return message.error("moderation/ban:ALREADY_BANNED", {
username: user.tag
});
}
if (banned.some((m) => m.user.id === user.id)) return message.error("moderation/ban:ALREADY_BANNED", { username: user.tag });
// Gets the ban reason
let reason = args.slice(1).join(" ");
if(!reason){
reason = message.translate("misc:NO_REASON_PROVIDED");
}
if (!reason) reason = message.translate("misc:NO_REASON_PROVIDED");
const member = await message.guild.members.fetch(user.id).catch(() => {});
if(member){
if (member) {
const memberPosition = member.roles.highest.position;
const moderationPosition = message.member.roles.highest.position;
if(message.member.ownerID !== message.author.id && !(moderationPosition > memberPosition)){
return message.error("moderation/ban:SUPERIOR");
}
if(!member.bannable) {
return message.error("moderation/ban:MISSING_PERM");
}
}
if (message.member.ownerID !== message.author.id && !(moderationPosition > memberPosition))return message.error("moderation/ban:SUPERIOR");
if (!member.bannable) return message.error("moderation/ban:MISSING_PERM");
};
await user.send(message.translate("moderation/ban:BANNED_DM", {
username: user.tag,
@ -66,7 +50,6 @@ class Ban extends Command {
// Ban the user
message.guild.members.ban(user, { reason } ).then(() => {
// Send a success message in the current channel
message.sendT("moderation/ban:BANNED", {
username: user.tag,
@ -84,35 +67,31 @@ class Ban extends Command {
reason
};
if(memberData){
if (memberData) {
memberData.sanctions.push(caseInfo);
memberData.save();
}
};
data.guild.casesCount++;
data.guild.save();
if(data.guild.plugins.modlogs){
if (data.guild.plugins.modlogs) {
const channel = message.guild.channels.cache.get(data.guild.plugins.modlogs);
if(!channel) return;
if (!channel) return;
const embed = new Discord.MessageEmbed()
.setAuthor(message.translate("moderation/ban:CASE", {
count: data.guild.casesCount
}))
.setAuthor(message.translate("moderation/ban:CASE", { count: data.guild.casesCount }))
.addField(message.translate("common:USER"), `\`${user.tag}\` (${user.toString()})`, true)
.addField(message.translate("common:MODERATOR"), `\`${message.author.tag}\` (${message.author.toString()})`, true)
.addField(message.translate("common:REASON"), reason, true)
.setColor("#e02316");
channel.send(embed);
}
};
}).catch((err) => {
console.log(err);
return message.error("moderation/ban:MISSING_PERM");
});
}
}
};
module.exports = Ban;

View file

@ -2,7 +2,6 @@ const Command = require("../../base/Command.js"),
Discord = require("discord.js");
class Checkinvites extends Command {
constructor (client) {
super(client, {
name: "checkinvites",
@ -19,25 +18,22 @@ class Checkinvites extends Command {
}
async run (message, args, data) {
const members = message.guild.members;
const withInvite = [];
members.cache.forEach((m) => {
const possibleLinks = m.user.presence.activities.map((a) => [ a.state, a.details, a.name ]).flat();
const inviteLinks = possibleLinks.filter((l) => /(discord\.(gg|io|me|li)\/.+|discordapp\.com\/invite\/.+)/i.test(l));
if(inviteLinks.length > 0) {
if (inviteLinks.length > 0) {
withInvite.push({
id: m.user.id,
tag: Discord.Util.escapeMarkdown(m.user.tag),
links: "**"+Discord.Util.escapeMarkdown(inviteLinks.join(", "))+"**"
});
}
};
});
const text = (withInvite.length > 0 ?
withInvite.map((m) => "`"+m.id+"` ("+m.tag+") : "+m.links).join("\n")
: message.translate("moderation/checkinvites:NOBODY"));
const text = (withInvite.length > 0 ? withInvite.map((m) => "`"+m.id+"` ("+m.tag+") : "+m.links).join("\n") : message.translate("moderation/checkinvites:NOBODY"));
const embed = new Discord.MessageEmbed()
.setDescription(text)
@ -46,7 +42,6 @@ class Checkinvites extends Command {
message.channel.send(embed);
}
}
};
module.exports = Checkinvites;

View file

@ -1,7 +1,6 @@
const Command = require("../../base/Command.js");
class Clearsanctions extends Command {
constructor (client) {
super(client, {
name: "clear-sanctions",
@ -18,19 +17,14 @@ class Clearsanctions extends Command {
}
async run (message, args) {
const member = await this.client.resolveMember(args[0], message.guild);
if(!member){
return message.error("moderation/clear-sanctions:MISSING_MEMBER");
}
if (!member) return message.error("moderation/clear-sanctions:MISSING_MEMBER");
const memberData = await this.client.findOrCreateMember({ id: member.id, guildID: message.guild.id });
memberData.sanctions = [];
memberData.save();
message.success("moderation/clear-sanctions:SUCCESS", {
username: member.user.tag
});
message.success("moderation/clear-sanctions:SUCCESS", { username: member.user.tag });
}
}
};
module.exports = Clearsanctions;

View file

@ -1,7 +1,6 @@
const Command = require("../../base/Command.js");
class Clear extends Command {
constructor (client) {
super(client, {
name: "clear",
@ -18,8 +17,7 @@ class Clear extends Command {
}
async run (message, args) {
if(args[0] === "all"){
if (args[0] === "all") {
message.sendT("moderation/clear:ALL_CONFIRM");
await message.channel.awaitMessages((m) => (m.author.id === message.author.id) && (m.content === "confirm"), {
max: 1,
@ -33,12 +31,10 @@ class Clear extends Command {
await message.channel.delete();
newChannel.setPosition(position);
return newChannel.send(message.translate("moderation/clear:CHANNEL_CLEARED"));
}
};
let amount = args[0];
if(!amount || isNaN(amount) || parseInt(amount) < 1){
return message.error("moderation/clear:MISSING_AMOUNT");
}
if (!amount || isNaN(amount) || parseInt(amount) < 1) return message.error("moderation/clear:MISSING_AMOUNT");
await message.delete();
@ -46,12 +42,9 @@ class Clear extends Command {
let messages = await message.channel.messages.fetch({limit:100});
messages = messages.array();
if(user){
messages = messages.filter((m) => m.author.id === user.id);
}
if(messages.length > amount){
messages.length = parseInt(amount, 10);
}
if (user) messages = messages.filter((m) => m.author.id === user.id);
if (messages.length > amount) messages.length = parseInt(amount, 10);
messages = messages.filter((m) => !m.pinned);
amount++;
@ -59,23 +52,16 @@ class Clear extends Command {
let toDelete = null;
if(user){
toDelete = await message.success("moderation/clear:CLEARED_MEMBER", {
amount: --amount,
username: user.tag
});
if (user) {
toDelete = await message.success("moderation/clear:CLEARED_MEMBER", { amount: --amount, username: user.tag });
} else {
toDelete = await message.success("moderation/clear:CLEARED", {
amount: --amount
});
}
toDelete = await message.success("moderation/clear:CLEARED", { amount: --amount });
};
setTimeout(function(){
toDelete.delete();
}, 2000);
}
}
};
module.exports = Clear;

View file

@ -2,7 +2,6 @@ const Command = require("../../base/Command.js"),
ms = require("ms");
class Giveaway extends Command {
constructor (client) {
super(client, {
name: "giveaway",
@ -19,47 +18,24 @@ class Giveaway extends Command {
}
async run (message, args, data) {
const status = args[0];
if(!status){
return message.error("moderation/giveaway:MISSING_STATUS");
}
if (!status)return message.error("moderation/giveaway:MISSING_STATUS");
if(status === "create"){
if (status === "create") {
const currentGiveaways = this.client.giveawaysManager.giveaways.filter((g) => g.guildID === message.guild.id && !g.ended).length;
if(currentGiveaways > 3){
return message.error("moderation/giveaway:MAX_COUNT");
}
if (currentGiveaways > 3) return message.error("moderation/giveaway:MAX_COUNT");
const time = args[1];
if(!time){
return message.error("moderation/giveaway:INVALID_CREATE", {
prefix: data.guild.prefix
});
}
if(isNaN(ms(time))){
return message.error("misc:INVALID_TIME");
}
if(ms(time) > ms("15d")){
return message.error("moderation/giveaway:MAX_DURATION");
}
if (!time) return message.error("moderation/giveaway:INVALID_CREATE", { prefix: data.guild.prefix });
if (isNaN(ms(time))) return message.error("misc:INVALID_TIME");
if (ms(time) > ms("15d")) return message.error("moderation/giveaway:MAX_DURATION");
const winnersCount = args[2];
if(!winnersCount){
return message.error("moderation/giveaway:INVALID_CREATE", {
prefix: data.guild.prefix
});
}
if(isNaN(winnersCount) || winnersCount > 10 || winnersCount < 1){
return message.error("misc:INVALID_NUMBER_RANGE", {
min: 1,
max: 10
});
}
if (!winnersCount) return message.error("moderation/giveaway:INVALID_CREATE", { prefix: data.guild.prefix });
if (isNaN(winnersCount) || winnersCount > 10 || winnersCount < 1) return message.error("misc:INVALID_NUMBER_RANGE", { min: 1, max: 10 });
const prize = args.slice(3).join(" ");
if(!prize){
return message.error("moderation/giveaway:INVALID_CREATE", {
prefix: data.guild.prefix
});
}
if (!prize) return message.error("moderation/giveaway:INVALID_CREATE", { prefix: data.guild.prefix });
this.client.giveawaysManager.start(message.channel, {
time: ms(time),
prize: prize,
@ -86,52 +62,39 @@ class Giveaway extends Command {
});
} else if(status === "reroll"){
const messageID = args[1];
if(!messageID){
return message.error("moderation/giveaway:MISSING_ID");
}
if (!messageID)return message.error("moderation/giveaway:MISSING_ID");
this.client.giveawaysManager.reroll(messageID, {
congrat: message.translate("moderation/giveaway:REROLL_CONGRAT"),
error: message.translate("moderation/giveaway:REROLL_ERROR")
}).then(() => {
return message.success("moderation/giveaway:GIVEAWAY_REROLLED");
}).catch(() => {
return message.error("moderation/giveaway:NOT_FOUND_ENDED", {
messageID
});
return message.error("moderation/giveaway:NOT_FOUND_ENDED", { messageID });
});
} else if(status === "delete"){
const messageID = args[1];
if(!messageID){
return message.error("moderation/giveaway:MISSING_ID");
}
if(!messageID) return message.error("moderation/giveaway:MISSING_ID");
this.client.giveawaysManager.delete(messageID).then(() => {
return message.success("moderation/giveaway:GIVEAWAY_DELETED");
}).catch(() => {
return message.error("moderation/giveaway:NOT_FOUND", {
messageID
});
return message.error("moderation/giveaway:NOT_FOUND", { messageID });
});
} else if(status === "end"){
const messageID = args[1];
if(!messageID){
return message.error("moderation/giveaway:MISSING_ID");
}
if (!messageID) return message.error("moderation/giveaway:MISSING_ID");
try {
this.client.giveawaysManager.edit(messageID, {
setEndTimestamp: Date.now()
});
this.client.giveawaysManager.edit(messageID, { setEndTimestamp: Date.now() });
return message.success("moderation/giveaway:GIVEAWAY_ENDED");
} catch(e){
return message.error("moderation/giveaway:NOT_FOUND", {
messageID
});
}
return message.error("moderation/giveaway:NOT_FOUND", { messageID });
};
} else {
return message.error("moderation/giveaway:MISSING_STATUS");
}
}
}
};
module.exports = Giveaway;

View file

@ -2,7 +2,6 @@ const Command = require("../../base/Command.js"),
Discord = require("discord.js");
class Kick extends Command {
constructor (client) {
super(client, {
name: "kick",
@ -19,33 +18,21 @@ class Kick extends Command {
}
async run (message, args, data) {
const member = await this.client.resolveMember(args[0], message.guild);
if(!member){
return message.error("moderation/kick:MISSING_MEMBER");
}
if (!member) return message.error("moderation/kick:MISSING_MEMBER");
if(member.id === message.author.id){
return message.error("moderation/ban:YOURSELF");
}
if (member.id === message.author.id) return message.error("moderation/ban:YOURSELF");
const memberData = await this.client.findOrCreateMember({ id: member.id, guildID: message.guild.id });
// Gets the kcik reason
let reason = args.slice(1).join(" ");
if(!reason){
reason = message.translate("misc:NO_REASON_PROVIDED");
}
if (!reason) reason = message.translate("misc:NO_REASON_PROVIDED");
const memberPosition = member.roles.highest.position;
const moderationPosition = message.member.roles.highest.position;
if(message.member.ownerID !== message.author.id && !(moderationPosition > memberPosition)){
return message.error("moderation/ban:SUPERIOR");
}
if(!member.kickable) {
return message.error("moderation/kick:MISSING_PERM");
}
if (message.member.ownerID !== message.author.id && !(moderationPosition > memberPosition)) return message.error("moderation/ban:SUPERIOR");
if (!member.kickable) return message.error("moderation/kick:MISSING_PERM");
await member.send(message.translate("moderation/kick:KICKED_DM", {
username: member.user.tag,
@ -56,7 +43,6 @@ class Kick extends Command {
// Kick the user
member.kick(reason).then(() => {
// Send a success message in the current channel
message.sendT("moderation/kick:KICKED", {
username: member.user.tag,
@ -80,26 +66,22 @@ class Kick extends Command {
memberData.sanctions.push(caseInfo);
memberData.save();
if(data.guild.plugins.modlogs){
if (data.guild.plugins.modlogs) {
const channel = message.guild.channels.cache.get(data.guild.plugins.modlogs);
if(!channel) return;
if (!channel) return;
const embed = new Discord.MessageEmbed()
.setAuthor(message.translate("moderation/kick:CASE", {
count: data.guild.casesCount
}))
.setAuthor(message.translate("moderation/kick:CASE", { count: data.guild.casesCount}))
.addField(message.translate("common:USER"), `\`${member.user.tag}\` (${member.user.toString()})`, true)
.addField(message.translate("common:MODERATOR"), `\`${message.author.tag}\` (${message.author.toString()})`, true)
.addField(message.translate("common:REASON"), reason, true)
.setColor("#e88709");
channel.send(embed);
}
};
}).catch(() => {
return message.error("moderation/kick:MISSING_PERM");
});
}
}
};
module.exports = Kick;

View file

@ -3,7 +3,6 @@ const Command = require("../../base/Command.js"),
ms = require("ms");
class Mute extends Command {
constructor (client) {
super(client, {
name: "mute",
@ -20,33 +19,20 @@ class Mute extends Command {
}
async run (message, args, data) {
const member = await this.client.resolveMember(args[0], message.guild);
if(!member){
return message.error("moderation/mute:MISSING_MEMBER");
}
if(member.id === message.author.id){
return message.error("moderation/ban:YOURSELF");
}
if (!member) return message.error("moderation/mute:MISSING_MEMBER");
if (member.id === message.author.id) return message.error("moderation/ban:YOURSELF");
const memberPosition = member.roles.highest.position;
const moderationPosition = message.member.roles.highest.position;
if(message.member.ownerID !== message.author.id && !(moderationPosition > memberPosition)){
return message.error("moderation/ban:SUPERIOR");
}
if (message.member.ownerID !== message.author.id && !(moderationPosition > memberPosition)) return message.error("moderation/ban:SUPERIOR");
const memberData = await this.client.findOrCreateMember({ id: member.id, guildID: message.guild.id });
const time = args[1];
if(!time || isNaN(ms(time))){
return message.error("misc:INVALID_TIME");
}
if (!time || isNaN(ms(time))) return message.error("misc:INVALID_TIME");
let reason = args.slice(2).join(" ");
if(!reason){
reason = message.translate("misc:NO_REASON_PROVIDED");
}
if (!reason) reason = message.translate("misc:NO_REASON_PROVIDED");
message.guild.channels.cache.forEach((channel) => {
channel.updateOverwrite(member.id, {
@ -97,13 +83,11 @@ class Mute extends Command {
this.client.databaseCache.mutedUsers.set(`${member.id}${message.guild.id}`, memberData);
if(data.guild.plugins.modlogs){
if (data.guild.plugins.modlogs) {
const channel = message.guild.channels.cache.get(data.guild.plugins.modlogs);
if(!channel) return;
if (!channel) return;
const embed = new Discord.MessageEmbed()
.setAuthor(message.translate("moderation/mute:CASE", {
count: data.guild.casesCount
}))
.setAuthor(message.translate("moderation/mute:CASE", { count: data.guild.casesCount }))
.addField(message.translate("common:USER"), `\`${member.user.tag}\` (${member.user.toString()})`, true)
.addField(message.translate("common:MODERATOR"), `\`${message.author.tag}\` (${message.author.toString()})`, true)
.addField(message.translate("common:REASON"), reason, true)
@ -112,9 +96,7 @@ class Mute extends Command {
.setColor("#f44271");
channel.send(embed);
}
}
}
};
module.exports = Mute;

View file

@ -2,7 +2,6 @@ const Command = require("../../base/Command.js"),
Discord = require("discord.js");
class Poll extends Command {
constructor (client) {
super(client, {
name: "poll",
@ -19,61 +18,53 @@ class Poll extends Command {
}
async run (message, args, data) {
const question = args.join(" ");
if(!question){
return message.error("moderation/poll:MISSING_QUESTION");
}
if (!question) return message.error("moderation/poll:MISSING_QUESTION");
message.delete().catch(() => {});
let mention = "";
const msg = await message.sendT("moderation/announcement:MENTION_PROMPT");
const collector = new Discord.MessageCollector(message.channel, (m) => m.author.id === message.author.id, { time: 240000 });
collector.on("collect", async (tmsg) => {
if(tmsg.content.toLowerCase() === message.translate("common:NO").toLowerCase()){
if (tmsg.content.toLowerCase() === message.translate("common:NO").toLowerCase()) {
tmsg.delete();
msg.delete();
collector.stop(true);
}
};
if(tmsg.content.toLowerCase() === message.translate("common:YES").toLowerCase()){
if (tmsg.content.toLowerCase() === message.translate("common:YES").toLowerCase()) {
tmsg.delete();
msg.delete();
const tmsg1 = await message.sendT("moderation/announcement:MENTION_TYPE_PROMPT");
const c = new Discord.MessageCollector(message.channel, (m) => m.author.id === message.author.id, { time: 60000 });
c.on("collect", (m) => {
if(m.content.toLowerCase() === "here"){
if (m.content.toLowerCase() === "here") {
mention = "@here";
tmsg1.delete();
m.delete();
collector.stop(true);
c.stop(true);
} else if(m.content.toLowerCase() === "every"){
} else if (m.content.toLowerCase() === "every") {
mention = "@everyone";
tmsg1.delete();
m.delete();
collector.stop(true);
c.stop(true);
}
};
});
c.on("end", (collected, reason) => {
if(reason === "time"){
if (reason === "time") {
return message.error("misc:TIMES_UP");
}
};
});
}
};
});
collector.on("end", (collected, reason) => {
if(reason === "time"){
if (reason === "time") {
return message.error("misc:TIMES_UP");
}
};
const success = this.client.customEmojis.success.split(":")[1];
const error = this.client.customEmojis.error.split(":")[1];
@ -86,19 +77,14 @@ class Poll extends Command {
const embed = new Discord.MessageEmbed()
.setAuthor(message.translate("moderation/poll:TITLE"))
.setColor(data.config.embed.color)
.addField(question, message.translate("moderation/poll:REACT", {
success: emojis[0].toString(),
error: emojis[1].toString()
}));
.addField(question, message.translate("moderation/poll:REACT", { success: emojis[0].toString(), error: emojis[1].toString() }));
message.channel.send(mention, embed).then(async (m) => {
await m.react(emojis[0]);
await m.react(emojis[1]);
});
});
}
}
};
module.exports = Poll;

View file

@ -2,7 +2,6 @@ const Command = require("../../base/Command.js"),
Discord = require("discord.js");
class Sanctions extends Command {
constructor (client) {
super(client, {
name: "sanctions",
@ -19,11 +18,9 @@ class Sanctions extends Command {
}
async run (message, args, data) {
const user = await this.client.resolveUser(args[0]);
if(!user){
return message.error("moderation/sanctions:MISSING_MEMBER");
}
if (!user) return message.error("moderation/sanctions:MISSING_MEMBER");
const memberData = await this.client.findOrCreateMember({ id: user.id, guildID: message.guild.id });
const embed = new Discord.MessageEmbed()
@ -31,20 +28,16 @@ class Sanctions extends Command {
.setColor(data.config.embed.color)
.setFooter(data.config.embed.footer);
if(memberData.sanctions.length < 1){
embed.setDescription(message.translate("moderation/sanctions:NO_SANCTION", {
username: user.tag
}));
if (memberData.sanctions.length < 1) {
embed.setDescription(message.translate("moderation/sanctions:NO_SANCTION", { username: user.tag }));
return message.channel.send(embed);
} else {
memberData.sanctions.forEach((s) => {
embed.addField(s.type+" | #"+s.case, `${message.translate("common:MODERATOR")}: <@${s.moderator}>\n${message.translate("common:REASON")}: ${s.reason}`, true);
});
}
};
message.channel.send(embed);
}
}
};
module.exports = Sanctions;

View file

@ -1,7 +1,6 @@
const Command = require("../../base/Command.js");
class Setwarns extends Command {
constructor (client) {
super(client, {
name: "setwarns",
@ -18,64 +17,40 @@ class Setwarns extends Command {
}
async run (message, args, data) {
const sanction = args[0];
if(!sanction || (sanction !== "kick" && sanction !== "ban")){
return message.error("moderation/setwarns:MISSING_TYPE");
}
if (!sanction || (sanction !== "kick" && sanction !== "ban")) return message.error("moderation/setwarns:MISSING_TYPE");
const number = args[1];
if(number === "reset"){
if(sanction === "kick"){
if (number === "reset") {
if (sanction === "kick") {
data.guild.plugins.warnsSanctions.kick = false;
data.guild.markModified("plugins.warnsSanctions");
data.guild.save();
return message.success("moderation/setwarns:SUCCESS_KICK_RESET", {
prefix: data.guild.prefix,
count: number
});
}
if(sanction === "ban"){
return message.success("moderation/setwarns:SUCCESS_KICK_RESET", { prefix: data.guild.prefix, count: number });
} else if(sanction === "ban") {
data.guild.plugins.warnsSanctions.ban = false;
data.guild.markModified("plugins.warnsSanctions");
data.guild.save();
return message.success("moderation/setwarns:SUCCESS_BAN_RESET", {
prefix: data.guild.prefix,
count: number
});
}
}
return message.success("moderation/setwarns:SUCCESS_BAN_RESET", { prefix: data.guild.prefix, count: number });
};
};
if(!number || isNaN(number)){
return message.error("misc:INVALID_NUMBER");
}
if(number < 1 || number > 10){
return message.error("misc:INVALID_NUMBER_RANGE", 1, 10);
}
if (!number || isNaN(number)) return message.error("misc:INVALID_NUMBER");
if (number < 1 || number > 10) return message.error("misc:INVALID_NUMBER_RANGE", 1, 10);
if(sanction === "kick"){
if (sanction === "kick") {
data.guild.plugins.warnsSanctions.kick = number;
data.guild.markModified("plugins.warnsSanctions");
data.guild.save();
return message.success("moderation/setwarns:SUCCESS_KICK", {
prefix: data.guild.prefix,
count: number
});
}
if(sanction === "ban"){
return message.success("moderation/setwarns:SUCCESS_KICK", { prefix: data.guild.prefix, count: number });
} else if (sanction === "ban") {
data.guild.plugins.warnsSanctions.ban = number;
data.guild.markModified("plugins.warnsSanctions");
data.guild.save();
return message.success("moderation/setwarns:SUCCESS_BAN", {
prefix: data.guild.prefix,
count: number
});
}
return message.success("moderation/setwarns:SUCCESS_BAN", { prefix: data.guild.prefix, count: number });
};
}
}
};
module.exports = Setwarns;

View file

@ -1,7 +1,6 @@
const Command = require("../../base/Command.js");
class Unban extends Command {
constructor (client) {
super(client, {
name: "unban",
@ -18,17 +17,14 @@ class Unban extends Command {
}
async run (message, args) {
let user = null;
if(!args[0]){
return message.error("moderation/unban:MISSING_ID");
}
if (!args[0]) return message.error("moderation/unban:MISSING_ID");
// Check if the arg is an ID or a username
const isId = !isNaN(args[0]);
if(isId){
if (isId) {
// Try to find a user with that ID
await this.client.users.fetch(args[0]).then((u) => {
// if a user was found
@ -36,39 +32,26 @@ class Unban extends Command {
}).catch(() => {});
} else if(!isId) {
const arr = args[0].split("#");
if(arr.length < 2){
if (arr.length < 2) {
return message.error("misc:NO_USER_FOUND_ID", {
id: args[0]
});
}
};
user = this.client.users.filter((u) => u.username === arr[0]).find((u) => u.discriminator === arr[1]);
}
};
if(!user){
return message.error("misc:NO_USER_FOUND_ID", {
id: args[0]
});
}
if (!user) return message.error("misc:NO_USER_FOUND_ID", { id: args[0] });
// check if the user is banned
const banned = await message.guild.fetchBans();
if(!banned.some((e) => e.user.id === user.id)){
return message.success("moderation/unban:NOT_BANNED", {
username: user.tag
});
}
if (!banned.some((e) => e.user.id === user.id)) return message.success("moderation/unban:NOT_BANNED", { username: user.tag });
// Unban user
message.guild.members.unban(user).catch(() => {});
// Send a success message in the current channel
message.success("moderation/unban:UNBANNED", {
username: user.tag,
server: message.guild.name
});
message.success("moderation/unban:UNBANNED", { username: user.tag, server: message.guild.name });
}
}
};
module.exports = Unban;

View file

@ -1,7 +1,6 @@
const Command = require("../../base/Command.js");
class Unmute extends Command {
constructor (client) {
super(client, {
name: "unmute",
@ -18,36 +17,24 @@ class Unmute extends Command {
}
async run (message, args) {
const member = await this.client.resolveMember(args[0], message.guild);
if(!member){
return message.success("moderation/unmute:MISSING_MEMBER");
}
if (!member) return message.success("moderation/unmute:MISSING_MEMBER");
const memberPosition = member.roles.highest.position;
const moderationPosition = message.member.roles.highest.position;
if(message.member.ownerID !== message.author.id && !(moderationPosition > memberPosition)){
return message.error("moderation/ban:SUPERIOR");
}
if (message.member.ownerID !== message.author.id && !(moderationPosition > memberPosition)) return message.error("moderation/ban:SUPERIOR");
const memberData = await this.client.findOrCreateMember({ id: member.id, guildID: message.guild.id });
if(memberData.mute.muted){
if (memberData.mute.muted) {
memberData.mute.endDate = Date.now();
memberData.markModified("mute");
memberData.save();
message.success("moderation/unmute:SUCCESS", {
username: member.user.tag
});
message.success("moderation/unmute:SUCCESS", { username: member.user.tag });
} else {
message.error("moderation/unmute:NOT_MUTED", {
username: member.user.tag
});
}
message.error("moderation/unmute:NOT_MUTED", { username: member.user.tag });
};
}
}
};
module.exports = Unmute;

View file

@ -2,7 +2,6 @@ const Command = require("../../base/Command.js"),
Discord = require("discord.js");
class Warn extends Command {
constructor (client) {
super(client, {
name: "warn",
@ -19,30 +18,20 @@ class Warn extends Command {
}
async run (message, args, data) {
const member = await this.client.resolveMember(args[0], message.guild);
if(!member){
return message.error("moderation/warn:MISSING_MEMBER");
}
if(member.user.bot){
return message.error("misc:BOT_USER");
}
if (!member) return message.error("moderation/warn:MISSING_MEMBER");
if (member.user.bot) return message.error("misc:BOT_USER");
const memberData = await this.client.findOrCreateMember({ id: member.id, guildID: message.guild.id });
if(member.id === message.author.id){
return message.error("moderation/ban:YOURSELF");
}
if (member.id === message.author.id) return message.error("moderation/ban:YOURSELF");
const memberPosition = member.roles.highest.position;
const moderationPosition = message.member.roles.highest.position;
if(message.member.ownerID !== message.author.id && !(moderationPosition > memberPosition)){
return message.error("moderation/ban:SUPERIOR");
}
if (message.member.ownerID !== message.author.id && !(moderationPosition > memberPosition)) return message.error("moderation/ban:SUPERIOR");
const reason = args.slice(1).join(" ");
if(!reason){
return message.error("moderation/warn:MISSING_REASON");
}
if (!reason) return message.error("moderation/warn:MISSING_REASON");
// Gets current member sanctions
const sanctions = memberData.sanctions.filter((s) => s.type === "warn").length;
@ -66,74 +55,43 @@ class Warn extends Command {
.addField(message.translate("common:MODERATOR"), `\`${message.author.tag}\` (${message.author.toString()}`)
.addField(message.translate("common:REASON"), reason, true);
if(banCount){
if(sanctions >= banCount){
member.send(message.translate("moderation/ban:BANNED_DM", {
username: member.user,
moderator: message.author.tag,
server: message.guild.name,
reason
}));
if (banCount) {
if (sanctions >= banCount) {
member.send(message.translate("moderation/ban:BANNED_DM", { username: member.user, moderator: message.author.tag, server: message.guild.name, reason }));
caseInfo.type = "ban";
embed.setAuthor(message.translate("moderation/ban:CASE", {
count: data.guild.casesCount
}))
embed.setAuthor(message.translate("moderation/ban:CASE", { count: data.guild.casesCount }))
.setColor("#e02316");
message.guild.members.ban(member).catch(() => {});
message.success("moderation/setwarns:AUTO_BAN", {
username: member.user.tag,
count: banCount
});
}
}
message.success("moderation/setwarns:AUTO_BAN", { username: member.user.tag, count: banCount });
};
};
if(kickCount){
if(sanctions >= kickCount){
member.send(message.translate("moderation/kick:KICKED_DM", {
username: member.user,
moderator: message.author.tag,
server: message.guild.name,
reason
}));
if (kickCount) {
if (sanctions >= kickCount) {
member.send(message.translate("moderation/kick:KICKED_DM", { username: member.user, moderator: message.author.tag, server: message.guild.name, reason }));
caseInfo.type = "kick";
embed.setAuthor(message.translate("moderation/kick:CASE", {
count: data.guild.casesCount
}))
embed.setAuthor(message.translate("moderation/kick:CASE", { count: data.guild.casesCount }))
.setColor("#e88709");
member.kick().catch(() => {});
message.success("moderation/setwarns:AUTO_KICK", {
username: member.user.tag,
count: kickCount
});
}
}
message.success("moderation/setwarns:AUTO_KICK", { username: member.user.tag, count: kickCount });
};
};
member.send(message.translate("moderation/warn:WARNED_DM", {
username: member.user.tag,
server: message.guild.name,
moderator: message.author.tag,
reason
}));
member.send(message.translate("moderation/warn:WARNED_DM", { username: member.user.tag, server: message.guild.name, moderator: message.author.tag, reason }));
caseInfo.type = "warn";
embed.setAuthor(message.translate("moderation/warn:CASE", {
caseNumber: data.guild.casesCount
}))
embed.setAuthor(message.translate("moderation/warn:CASE", { caseNumber: data.guild.casesCount }))
.setColor("#8c14e2");
message.success("moderation/warn:WARNED", {
username: member.user.tag,
reason
});
message.success("moderation/warn:WARNED", { username: member.user.tag, reason });
memberData.sanctions.push(caseInfo);
memberData.save();
if(data.guild.plugins.modlogs){
if (data.guild.plugins.modlogs) {
const channel = message.guild.channels.cache.get(data.guild.plugins.modlogs);
if(!channel) return;
channel.send(embed);
}
};
}
}
};
module.exports = Warn;

View file

@ -1,7 +1,6 @@
const Command = require("../../base/Command.js");
class AutoPlay extends Command {
constructor (client) {
super(client, {
name: "autoplay",
@ -18,26 +17,18 @@ class AutoPlay extends Command {
}
async run (message) {
const queue = this.client.player.getQueue(message);
const voice = message.member.voice.channel;
if (!voice){
return message.error("music/play:NO_VOICE_CHANNEL");
}
if(!queue){
return message.error("music:play:NOT_PLAYING");
}
if (!voice) return message.error("music/play:NO_VOICE_CHANNEL");
if (!queue) return message.error("music:play:NOT_PLAYING");
// Gets the current song
await this.client.player.setAutoPlay(message, !queue.autoPlay);
// Send the embed in the current channel
message.sendT(`music/autoplay:SUCCESS_${queue.autoPlay ? "ENABLED" : "DISABLED"}`);
}
}
};
module.exports = AutoPlay;

View file

@ -2,7 +2,6 @@ const Command = require("../../base/Command.js"),
Discord = require("discord.js");
class Back extends Command {
constructor (client) {
super(client, {
name: "back",
@ -19,21 +18,13 @@ class Back extends Command {
}
async run (message, args, data) {
const queue = this.client.player.getQueue(message);
const voice = message.member.voice.channel;
if (!voice){
return message.error("music/play:NO_VOICE_CHANNEL");
}
if(!queue){
return message.error("music/play:NOT_PLAYING");
}
if(!queue.previousTracks[0]){
return message.error("music/back:NO_PREV_SONG");
}
if (!voice) return message.error("music/play:NO_VOICE_CHANNEL");
if (!queue) return message.error("music/play:NOT_PLAYING");
if (!queue.previousTracks[0]) return message.error("music/back:NO_PREV_SONG");
const members = voice.members.filter((m) => !m.user.bot);
@ -45,25 +36,18 @@ class Back extends Command {
const m = await message.channel.send(embed);
if(members.size > 1){
if (members.size > 1) {
m.react("👍");
const mustVote = Math.floor(members.size/2+1);
embed.setDescription(message.translate("music/back:VOTE_CONTENT", {
songName: queue.tracks[0].name,
voteCount: 0,
requiredCount: mustVote
}));
embed.setDescription(message.translate("music/back:VOTE_CONTENT", { songName: queue.tracks[0].name, voteCount: 0, requiredCount: mustVote }));
m.edit(embed);
const filter = (reaction, user) => {
const member = message.guild.members.cache.get(user.id);
const voiceChannel = member.voice.channel;
if(voiceChannel){
return voiceChannel.id === voice.id;
}
if (voiceChannel) return voiceChannel.id === voice.id;
};
const collector = await m.createReactionCollector(filter, {
@ -71,36 +55,28 @@ class Back extends Command {
});
collector.on("collect", (reaction) => {
const haveVoted = reaction.count-1;
if(haveVoted >= mustVote){
const haveVoted = reaction.count - 1;
if (haveVoted >= mustVote) {
this.client.player.back(message);
embed.setDescription(message.translate("music/back:SUCCESS"));
m.edit(embed);
collector.stop(true);
} else {
embed.setDescription(message.translate("music/back:VOTE_CONTENT", {
songName: queue.tracks[0].title,
voteCount: haveVoted,
requiredCount: mustVote
}));
embed.setDescription(message.translate("music/back:VOTE_CONTENT", { songName: queue.tracks[0].title, voteCount: haveVoted, requiredCount: mustVote }));
m.edit(embed);
}
});
collector.on("end", (collected, isDone) => {
if(!isDone){
return message.error("misc:TIMES_UP");
}
if (!isDone) return message.error("misc:TIMES_UP");
});
} else {
this.client.player.back(message);
embed.setDescription(message.translate("music/back:SUCCESS"));
m.edit(embed);
}
};
}
}
};
module.exports = Back;

View file

@ -2,7 +2,6 @@ const Command = require("../../base/Command.js"),
FiltersList = require("../../assets/json/filters.json");
class Filter extends Command {
constructor (client) {
super(client, {
name: "filter",
@ -19,40 +18,28 @@ class Filter extends Command {
}
async run (message, args, data) {
const queue = this.client.player.getQueue(message);
const voice = message.member.voice.channel;
if (!voice){
return message.error("music/play:NO_VOICE_CHANNEL");
}
if(!queue){
return message.error("music/play:NOT_PLAYING");
}
if (!voice) return message.error("music/play:NO_VOICE_CHANNEL");
if (!queue) return message.error("music/play:NOT_PLAYING");
const filter = args[0];
if(!filter) return message.error("music/filter:MISSING_FILTER", {
prefix: data.guild.prefix
});
if (!filter) return message.error("music/filter:MISSING_FILTER", { prefix: data.guild.prefix });
const filterToUpdate = Object.values(FiltersList).find((f) => f.toLowerCase() === filter.toLowerCase());
if(!filterToUpdate) return message.error("music/filter:UNKNOWN_FILTER", {
prefix: data.guild.prefix
});
if (!filterToUpdate) return message.error("music/filter:UNKNOWN_FILTER", { prefix: data.guild.prefix });
const filterRealName = Object.keys(FiltersList).find((f) => FiltersList[f] === filterToUpdate);
const queueFilters = this.client.player.getQueue(message).filters;
const filtersUpdated = {};
filtersUpdated[filterRealName] = queueFilters[filterRealName] ? false : true;
this.client.player.setFilters(message, filtersUpdated);
if(filtersUpdated[filterRealName]) message.success("music/filter:ADDING_FILTER");
if (filtersUpdated[filterRealName]) message.success("music/filter:ADDING_FILTER");
else message.success("music/filter:REMOVING_FILTER");
}
}
};
module.exports = Filter;

View file

@ -3,7 +3,6 @@ const Command = require("../../base/Command.js"),
FiltersList = require("../../assets/json/filters.json");
class Filters extends Command {
constructor (client) {
super(client, {
name: "filters",
@ -20,17 +19,11 @@ class Filters extends Command {
}
async run (message, args, data) {
const queue = this.client.player.getQueue(message);
const voice = message.member.voice.channel;
if (!voice){
return message.error("music/play:NO_VOICE_CHANNEL");
}
if(!queue){
return message.error("music/play:NOT_PLAYING");
}
if (!voice) return message.error("music/play:NO_VOICE_CHANNEL");
if (!queue) return message.error("music/play:NOT_PLAYING");
const filtersStatuses = [ [], [] ];
@ -40,16 +33,13 @@ class Filters extends Command {
});
const list = new Discord.MessageEmbed()
.setDescription(message.translate("music/filters:CONTENT", {
prefix: data.guild.prefix
}))
.setDescription(message.translate("music/filters:CONTENT", { prefix: data.guild.prefix }))
.addField(message.translate("music/filters:TITLE"), filtersStatuses[0].join("\n"), true)
.addField("** **", filtersStatuses[1].join("\n"), true)
.setColor(data.config.embed.color);
message.channel.send(list);
}
}
};
module.exports = Filters;

View file

@ -3,7 +3,6 @@ const Command = require("../../base/Command.js"),
lyricsParse = require("lyrics-finder");
class Lyrics extends Command {
constructor (client) {
super(client, {
name: "lyrics",
@ -20,48 +19,36 @@ class Lyrics extends Command {
}
async run (message, args, data) {
const [songName, artistName] = args.join(" ").split("|");
if(!songName){
return message.error("music/lyrics:MISSING_SONG_NAME");
}
if (!songName) return message.error("music/lyrics:MISSING_SONG_NAME");
const embed = new Discord.MessageEmbed()
.setAuthor(message.translate("music/lyrics:LYRICS_OF", {
songName
}))
.setAuthor(message.translate("music/lyrics:LYRICS_OF", { songName }))
.setColor(data.config.embed.color)
.setFooter(data.config.embed.footer);
try {
const songNameFormated = songName
.toLowerCase()
.replace(/\(lyrics|lyric|official music video|audio|official|official video|official video hd|clip officiel|clip|extended|hq\)/g, "")
.split(" ").join("%20");
let lyrics = await lyricsParse(songNameFormated, artistName) || "Not Found!";
let lyrics = await lyricsParse(songNameFormated, artistName) || "Не найдено!";
if(lyrics.length > 2040) {
if (lyrics.length > 2040) {
lyrics = lyrics.substr(0, 2000) + message.translate("music/lyrics:AND_MORE") + " ["+message.translate("music/lyrics:CLICK_HERE")+"]"+`https://www.musixmatch.com/search/${songName}`;
} else if(!lyrics.length) {
return message.error("music/lyrics:NO_LYRICS_FOUND", {
songName
});
}
} else if (!lyrics.length) {
return message.error("music/lyrics:NO_LYRICS_FOUND", { songName });
};
embed.setDescription(lyrics);
message.channel.send(embed);
} catch(e){
console.log(e);
message.error("music/lyrics:NO_LYRICS_FOUND", {
songName
});
message.error("music/lyrics:NO_LYRICS_FOUND", { songName });
}
}
}
};
module.exports = Lyrics;

View file

@ -2,7 +2,6 @@ const Command = require("../../base/Command.js"),
Discord = require("discord.js");
class Np extends Command {
constructor (client) {
super(client, {
name: "np",
@ -19,17 +18,12 @@ class Np extends Command {
}
async run (message, args, data) {
const queue = this.client.player.getQueue(message);
const voice = message.member.voice.channel;
if (!voice){
return message.error("music/play:NO_VOICE_CHANNEL");
}
if (!voice) return message.error("music/play:NO_VOICE_CHANNEL");
if(!queue){
return message.error("music/play:NOT_PLAYING");
}
if (!queue) return message.error("music/play:NOT_PLAYING");
// Gets the current song
const track = await this.client.player.nowPlaying(message);
@ -41,9 +35,7 @@ class Np extends Command {
.addField(message.translate("music/np:T_TITLE"), track.title, true)
.addField(message.translate("music/np:T_CHANNEL"), track.author, true)
.addField(message.translate("music/np:T_DURATION"), message.convertTime(Date.now()+track.durationMS, "to", true), true)
.addField(message.translate("music/np:T_DESCRIPTION"),
track.description ?
(track.description.substring(0, 150)+"\n"+(message.translate("common:AND_MORE").toLowerCase())) : message.translate("music/np:NO_DESCRIPTION"), true)
.addField(message.translate("music/np:T_DESCRIPTION"), track.description ? (track.description.substring(0, 150)+"\n"+(message.translate("common:AND_MORE").toLowerCase())) : message.translate("music/np:NO_DESCRIPTION"), true)
.addField("\u200B", this.client.player.createProgressBar(message, { timecodes: true }))
.setTimestamp()
.setColor(data.config.embed.color)
@ -51,9 +43,7 @@ class Np extends Command {
// Send the embed in the current channel
message.channel.send(embed);
}
}
};
module.exports = Np;

View file

@ -1,7 +1,6 @@
const Command = require("../../base/Command.js");
class Pause extends Command {
constructor (client) {
super(client, {
name: "pause",
@ -18,26 +17,18 @@ class Pause extends Command {
}
async run (message) {
const queue = this.client.player.getQueue(message);
const voice = message.member.voice.channel;
if (!voice){
return message.error("music/play:NO_VOICE_CHANNEL");
}
if(!queue){
return message.error("music:play:NOT_PLAYING");
}
if (!voice) return message.error("music/play:NO_VOICE_CHANNEL");
if (!queue) return message.error("music:play:NOT_PLAYING");
// Gets the current song
await this.client.player.pause(message);
// Send the embed in the current channel
message.sendT("music/pause:SUCCESS");
}
}
};
module.exports = Pause;

View file

@ -1,7 +1,6 @@
const Command = require("../../base/Command.js");
class Play extends Command {
constructor (client) {
super(client, {
name: "play",
@ -18,26 +17,18 @@ class Play extends Command {
}
async run (message, args) {
const name = args.join(" ");
if(!name){
return message.error("music/play:MISSING_SONG_NAME");
}
if (!name) return message.error("music/play:MISSING_SONG_NAME");
const voice = message.member.voice.channel;
if(!voice){
return message.error("music/play:NO_VOICE_CHANNEL");
}
if (!voice) return message.error("music/play:NO_VOICE_CHANNEL");
// Check my permissions
const perms = voice.permissionsFor(this.client.user);
if(!perms.has("CONNECT") || !perms.has("SPEAK")){
return message.error("music/play:VOICE_CHANNEL_CONNECT");
}
if (!perms.has("CONNECT") || !perms.has("SPEAK")) return message.error("music/play:VOICE_CHANNEL_CONNECT");
await this.client.player.play(message, args.join(" "));
}
}
};
module.exports = Play;

View file

@ -3,7 +3,6 @@ const Command = require("../../base/Command.js"),
Pagination = require("discord-paginationembed");
class Queue extends Command {
constructor (client) {
super(client, {
name: "queue",
@ -20,25 +19,20 @@ class Queue extends Command {
}
async run (message, args, data) {
const voice = message.member.voice.channel;
if (!voice){
return message.error("music/play:NO_VOICE_CHANNEL");
}
if (!voice) return message.error("music/play:NO_VOICE_CHANNEL");
const queue = this.client.player.getQueue(message);
if(!queue){
return message.error("music/play:NOT_PLAYING");
}
if (!queue) return message.error("music/play:NOT_PLAYING");
if(queue.tracks.length === 1){
if (queue.tracks.length === 1) {
const embed = new Discord.MessageEmbed()
.setColor(data.config.embed.color)
.setAuthor(message.translate("music/queue:TITLE"), message.guild.iconURL({ dynamic: true }))
.addField(message.translate("music/np:CURRENTLY_PLAYING"), `[${queue.tracks[0].title}](${queue.tracks[0].url})\n*Requested by ${queue.tracks[0].requestedBy}*\n`);
return message.channel.send(embed);
}
};
let i = 0;
const FieldsEmbed = new Pagination.FieldsEmbed();
@ -56,9 +50,7 @@ class Queue extends Command {
.formatField("Queue", (track) => `${++i}. [${track.title}](${track.url})\n*Requested by ${track.requestedBy}*\n`);
FieldsEmbed.build();
}
}
};
module.exports = Queue;

View file

@ -1,7 +1,6 @@
const Command = require("../../base/Command.js");
class Resume extends Command {
constructor (client) {
super(client, {
name: "resume",
@ -18,17 +17,11 @@ class Resume extends Command {
}
async run (message) {
const queue = this.client.player.getQueue(message);
const voice = message.member.voice.channel;
if (!voice){
return message.error("music/play:NO_VOICE_CHANNEL");
}
if(!queue){
return message.error("music:play:NOT_PLAYING");
}
if (!voice) return message.error("music/play:NO_VOICE_CHANNEL");
if (!queue) return message.error("music:play:NOT_PLAYING");
// Gets the current song
await this.client.player.resume(message);
@ -36,7 +29,6 @@ class Resume extends Command {
// Send the embed in the current channel
message.sendT("music/resume:SUCCESS");
}
}
};
module.exports = Resume;

View file

@ -2,7 +2,6 @@ const Command = require("../../base/Command.js");
const ms = require("ms");
class Seek extends Command {
constructor (client) {
super(client, {
name: "seek",
@ -19,22 +18,15 @@ class Seek extends Command {
}
async run (message, args) {
const queue = this.client.player.getQueue(message);
const voice = message.member.voice.channel;
if (!voice){
return message.error("music/play:NO_VOICE_CHANNEL");
}
if (!voice) return message.error("music/play:NO_VOICE_CHANNEL");
if(!queue){
return message.error("music/play:NOT_PLAYING");
}
if (!queue) return message.error("music/play:NOT_PLAYING");
const time = ms(args[0]);
if (isNaN(time)) {
return message.error("music/seek:INVALID_TIME");
}
if (isNaN(time)) return message.error("music/seek:INVALID_TIME");
// Change the song position
await this.client.player.setPosition(message, queue.currentStreamTime + time);
@ -42,7 +34,6 @@ class Seek extends Command {
// Send the embed in the current channel
message.sendT("music/seek:SUCCESS");
}
}
};
module.exports = Seek;

View file

@ -2,7 +2,6 @@ const Command = require("../../base/Command.js"),
Discord = require("discord.js");
class Skip extends Command {
constructor (client) {
super(client, {
name: "skip",
@ -19,21 +18,12 @@ class Skip extends Command {
}
async run (message, args, data) {
const queue = this.client.player.getQueue(message);
const voice = message.member.voice.channel;
if (!voice){
return message.error("music/play:NO_VOICE_CHANNEL");
}
if(!queue){
return message.error("music/play:NOT_PLAYING");
}
if(!queue.tracks[0]){
return message.error("music/skip:NO_NEXT_SONG");
}
if (!voice) return message.error("music/play:NO_VOICE_CHANNEL");
if (!queue) return message.error("music/play:NOT_PLAYING");
if (!queue.tracks[0]) return message.error("music/skip:NO_NEXT_SONG");
const members = voice.members.filter((m) => !m.user.bot);
@ -45,25 +35,18 @@ class Skip extends Command {
const m = await message.channel.send(embed);
if(members.size > 1){
if (members.size > 1) {
m.react("👍");
const mustVote = Math.floor(members.size/2+1);
embed.setDescription(message.translate("music/skip:VOTE_CONTENT", {
songName: queue.tracks[0].name,
voteCount: 0,
requiredCount: mustVote
}));
embed.setDescription(message.translate("music/skip:VOTE_CONTENT", { songName: queue.tracks[0].name, voteCount: 0, requiredCount: mustVote }));
m.edit(embed);
const filter = (reaction, user) => {
const member = message.guild.members.cache.get(user.id);
const voiceChannel = member.voice.channel;
if(voiceChannel){
return voiceChannel.id === voice.id;
}
if (voiceChannel) return voiceChannel.id === voice.id;
};
const collector = await m.createReactionCollector(filter, {
@ -71,36 +54,28 @@ class Skip extends Command {
});
collector.on("collect", (reaction) => {
const haveVoted = reaction.count-1;
if(haveVoted >= mustVote){
const haveVoted = reaction.count - 1;
if (haveVoted >= mustVote) {
this.client.player.skip(message);
embed.setDescription(message.translate("music/skip:SUCCESS"));
m.edit(embed);
collector.stop(true);
} else {
embed.setDescription(message.translate("music/skip:VOTE_CONTENT", {
songName: queue.tracks[0].title,
voteCount: haveVoted,
requiredCount: mustVote
}));
embed.setDescription(message.translate("music/skip:VOTE_CONTENT", { songName: queue.tracks[0].title, voteCount: haveVoted, requiredCount: mustVote }));
m.edit(embed);
}
};
});
collector.on("end", (collected, isDone) => {
if(!isDone){
return message.error("misc:TIMES_UP");
}
if (!isDone) return message.error("misc:TIMES_UP");
});
} else {
this.client.player.skip(message);
embed.setDescription(message.translate("music/skip:SUCCESS"));
m.edit(embed);
}
};
}
}
};
module.exports = Skip;

View file

@ -2,7 +2,6 @@ const Command = require("../../base/Command.js"),
Discord = require("discord.js");
class Stop extends Command {
constructor (client) {
super(client, {
name: "stop",
@ -19,17 +18,11 @@ class Stop extends Command {
}
async run (message, args, data) {
const queue = await this.client.player.getQueue(message);
const voice = message.member.voice.channel;
if(!voice){
return message.error("music/play:NO_VOICE_CHANNEL");
}
if(!queue){
return message.error("music/play:NOT_PLAYING");
}
if (!voice) return message.error("music/play:NO_VOICE_CHANNEL");
if (!queue) return message.error("music/play:NOT_PLAYING");
const members = voice.members.filter((m) => !m.user.bot);
@ -40,24 +33,18 @@ class Stop extends Command {
const m = await message.channel.send(embed);
if(members.size > 1){
if (members.size > 1) {
m.react("👍");
const mustVote = Math.floor(members.size/2+1);
embed.setDescription(message.translate("music/stop:VOTE_CONTENT", {
voteCount: 0,
requiredCount: mustVote
}));
embed.setDescription(message.translate("music/stop:VOTE_CONTENT", { voteCount: 0, requiredCount: mustVote }));
m.edit(embed);
const filter = (reaction, user) => {
const member = message.guild.members.cache.get(user.id);
const voiceChannel = member.voice.channel;
if(voiceChannel){
return voiceChannel.id === voice.id;
}
if (voiceChannel) return voiceChannel.id === voice.id;
};
const collector = await m.createReactionCollector(filter, {
@ -65,35 +52,28 @@ class Stop extends Command {
});
collector.on("collect", (reaction) => {
const haveVoted = reaction.count-1;
if(haveVoted >= mustVote){
const haveVoted = reaction.count - 1;
if (haveVoted >= mustVote) {
this.client.player.stop(message);
embed.setDescription(message.translate("music/stop:SUCCESS"));
m.edit(embed);
collector.stop(true);
} else {
embed.setDescription(message.translate("music/stop:VOTE_CONTENT", {
voteCount: haveVoted,
requiredCount: mustVote
}));
embed.setDescription(message.translate("music/stop:VOTE_CONTENT", { voteCount: haveVoted, requiredCount: mustVote }));
m.edit(embed);
}
});
collector.on("end", (collected, isDone) => {
if(!isDone){
return message.error("misc:TIMES_UP");
}
if (!isDone) return message.error("misc:TIMES_UP");
});
} else {
this.client.player.stop(message);
embed.setDescription(message.translate("music/stop:SUCCESS"));
m.edit(embed);
}
};
}
}
};
module.exports = Stop;

View file

@ -1,7 +1,6 @@
const Command = require("../../base/Command.js");
class Eval extends Command {
constructor (client) {
super(client, {
name: "eval",
@ -19,7 +18,6 @@ class Eval extends Command {
// eslint-disable-next-line no-unused-vars
async run (message, args, data) {
// eslint-disable-next-line no-unused-vars
const usersData = this.client.usersData;
// eslint-disable-next-line no-unused-vars
@ -29,27 +27,15 @@ class Eval extends Command {
const result = new Promise((resolve) => resolve(eval(content)));
return result.then((output) => {
if(typeof output !== "string"){
output = require("util").inspect(output, { depth: 0 });
}
if(output.includes(this.client.token)){
output = output.replace(this.client.token, "T0K3N");
}
message.channel.send(output, {
code: "js"
});
if (typeof output !== "string") output = require("util").inspect(output, { depth: 0 });
if (output.includes(this.client.token)) output = output.replace(this.client.token, "T0K3N");
message.channel.send(output, { code: "js" });
}).catch((err) => {
err = err.toString();
if(err.includes(this.client.token)){
err = err.replace(this.client.token, "T0K3N");
}
message.channel.send(err, {
code: "js"
});
if (err.includes(this.client.token)) err = err.replace(this.client.token, "T0K3N");
message.channel.send(err, { code: "js" });
});
}
}
};
module.exports = Eval;

View file

@ -1,7 +1,6 @@
const Command = require("../../base/Command.js");
class Reload extends Command {
constructor (client) {
super(client, {
name: "reload",
@ -20,18 +19,12 @@ class Reload extends Command {
async run (message, args) {
const command = args[0];
const cmd = this.client.commands.get(command) || this.client.commands.get(this.client.aliases.get(command));
if(!cmd){
message.error("owner/reload:NOT_FOUND", {
search: command
});
}
if (!cmd) message.error("owner/reload:NOT_FOUND", { search: command });
await this.client.unloadCommand(cmd.conf.location, cmd.help.name);
await this.client.loadCommand(cmd.conf.location, cmd.help.name);
message.success("owner/reload:SUCCESS", {
command: cmd.help.name
});
message.success("owner/reload:SUCCESS", { command: cmd.help.name });
}
}
};
module.exports = Reload;

View file

@ -2,7 +2,6 @@ const Command = require("../../base/Command.js"),
Discord = require("discord.js");
class ServersList extends Command {
constructor (client) {
super(client, {
name: "servers-list",
@ -19,15 +18,13 @@ class ServersList extends Command {
}
async run (message, args, data) {
await message.delete();
let i0 = 0;
let i1 = 10;
let page = 1;
let description =
`${message.translate("common:SERVERS")}: ${this.client.guilds.cache.size}\n\n`+
let description = `${message.translate("common:SERVERS")}: ${this.client.guilds.cache.size}\n\n` +
this.client.guilds.cache.sort((a,b) => b.memberCount-a.memberCount).map((r) => r)
.map((r, i) => `**${i + 1}** - ${r.name} | ${r.memberCount} ${message.translate("common:MEMBERS").toLowerCase()}`)
.slice(0, 10)
@ -49,23 +46,17 @@ class ServersList extends Command {
const collector = msg.createReactionCollector((reaction, user) => user.id === message.author.id);
collector.on("collect", async(reaction) => {
if(reaction._emoji.name === "⬅") {
if (reaction._emoji.name === "⬅") {
// Updates variables
i0 = i0-10;
i1 = i1-10;
page = page-1;
i0 = i0 - 10;
i1 = i1 - 10;
page = page - 1;
// if there is no guild to display, delete the message
if(i0 < 0){
return msg.delete();
}
if(!i0 || !i1){
return msg.delete();
}
if (i0 < 0) return msg.delete();
if (!i0 || !i1) return msg.delete();
description = `${message.translate("common:SERVERS")}: ${this.client.guilds.cache.size}\n\n`+
description = `${message.translate("common:SERVERS")}: ${this.client.guilds.cache.size}\n\n` +
this.client.guilds.cache.sort((a,b) => b.memberCount-a.memberCount).map((r) => r)
.map((r, i) => `**${i + 1}** - ${r.name} | ${r.memberCount} ${message.translate("common:MEMBERS")}`)
.slice(i0, i1)
@ -77,25 +68,19 @@ class ServersList extends Command {
// Edit the message
msg.edit(embed);
};
}
if(reaction._emoji.name === "➡"){
if (reaction._emoji.name === "➡") {
// Updates variables
i0 = i0+10;
i1 = i1+10;
page = page+1;
i0 = i0 + 10;
i1 = i1 + 10;
page = page + 1;
// if there is no guild to display, delete the message
if(i1 > this.client.guilds.cache.size + 10){
return msg.delete();
}
if(!i0 || !i1){
return msg.delete();
}
if (i1 > this.client.guilds.cache.size + 10) return msg.delete();
if (!i0 || !i1) return msg.delete();
description = `${message.translate("common:SERVERS")}: ${this.client.guilds.cache.size}\n\n`+
description = `${message.translate("common:SERVERS")}: ${this.client.guilds.cache.size}\n\n` +
this.client.guilds.cache.sort((a,b) => b.memberCount-a.memberCount).map((r) => r)
.map((r, i) => `**${i + 1}** - ${r.name} | ${r.memberCount} ${message.translate("common:MEMBERS").toLowerCase()}`)
.slice(i0, i1)
@ -107,19 +92,14 @@ class ServersList extends Command {
// Edit the message
msg.edit(embed);
};
}
if(reaction._emoji.name === "❌"){
return msg.delete();
}
if (reaction._emoji.name === "❌") return msg.delete();
// Remove the reaction when the user react to the message
await reaction.users.remove(message.author.id);
});
}
}
};
module.exports = ServersList;

View file

@ -8,7 +8,7 @@
"INVALID_TIME": "Укажите действительное время! Доступные единицы: `s`, `m`, `h` or `d`",
"INVALID_NUMBER": "Пожалуйста, укажите число!",
"INVALID_NUMBER_RANGE": "Укажите число от **{{min}}** до **{{max}}**!",
"STATS_FOOTER": "[Панель управления]({{dashboardLink}}) ● [Поддержать]({{donateLink}}) ● [Приглашение]({{inviteLink}}) ● [Сервер поддержки]({{supportLink}}) ● [Github]({{githubLink}})",
"STATS_FOOTER": "[Панель управления]({{dashboardLink}})\n● [Поддержать]({{donateLink}}) (для других способов пишите в ЛС @<{{owner}}>)",
"BOT_USER": "Этот пользователь бот!",
"NO_REASON_PROVIDED": "Причина не указана",
"NO_USER_FOUND_ID": "Пользователя с ID `{{id}}` не существует!",