Bot
This commit is contained in:
parent
a48d517fc4
commit
bc346138dd
161 changed files with 14947 additions and 0 deletions
16
.env.example
Normal file
16
.env.example
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
TOKEN =
|
||||||
|
MONGO =
|
||||||
|
CLIENT_SECRET =
|
||||||
|
CLIENT_ID =
|
||||||
|
PORT =
|
||||||
|
REDIRECT =
|
||||||
|
DMLogID =
|
||||||
|
DMLogToken =
|
||||||
|
CMDLogID =
|
||||||
|
CMDLogToken =
|
||||||
|
ReadyLogID =
|
||||||
|
ReadyLogToken =
|
||||||
|
ErrorLogID =
|
||||||
|
ErrorLogToken =
|
||||||
|
ServerLogID =
|
||||||
|
ServerLogToken =
|
14
.gitignore
vendored
Normal file
14
.gitignore
vendored
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
node_modules/
|
||||||
|
/.env
|
||||||
|
/commands/CODM/
|
||||||
|
/dashboard/
|
||||||
|
/util/Data/aliases.json
|
||||||
|
/util/Data/attachments.json
|
||||||
|
/util/Data/builds.json
|
||||||
|
/util/Data/data.json
|
||||||
|
/util/Data/perk.json
|
||||||
|
/util/Data/skins.json
|
||||||
|
/util/Data/weapons.json
|
||||||
|
/util/functions/common.json
|
||||||
|
/util/bash.sh
|
||||||
|
/bot.js
|
2
.replit
Normal file
2
.replit
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
"language"="nodejs"
|
||||||
|
"run"="node ."
|
1
Procfile
Normal file
1
Procfile
Normal file
|
@ -0,0 +1 @@
|
||||||
|
worker: node index.js
|
17
cat/Path/fantastic.js
Normal file
17
cat/Path/fantastic.js
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "fantastic",
|
||||||
|
timeout: 60000,
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
message.delete();
|
||||||
|
const player = args.join(" ");
|
||||||
|
message.channel.send(
|
||||||
|
`${player} is a fantastic CoDM player. Just need to work on communication, map awareness, info scouting, bomb plants, positioning, teamfighting, gun skill , utility usage, rotations and getting kills.`
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
35
cat/Path/fight.js
Normal file
35
cat/Path/fight.js
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "fight",
|
||||||
|
description: "Gooooooooooooooooooolag!",
|
||||||
|
timeout: 10000,
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const Fight = [
|
||||||
|
"`Snow Gae`",
|
||||||
|
"`Not Gae`",
|
||||||
|
"`Ultimate Gae`",
|
||||||
|
"`Gae`",
|
||||||
|
"`Gae beyond repair`",
|
||||||
|
"`Akimbo Gae`",
|
||||||
|
"`Mega Gae`",
|
||||||
|
"`Super Gae`",
|
||||||
|
"`Ultra Gae`",
|
||||||
|
"`Terminal Gae`",
|
||||||
|
"`Dead`",
|
||||||
|
"`Path Gae`",
|
||||||
|
"`Cheez Gae`",
|
||||||
|
"`Zero Gae`",
|
||||||
|
"`KDR Gae`",
|
||||||
|
"`! not Gae`",
|
||||||
|
];
|
||||||
|
const fightIndex = Fight[Math.floor(Math.random() * Fight.length)];
|
||||||
|
message.channel.send(
|
||||||
|
`**You have taken a chance at redemption in The Gulag, you fight only to find out that you're ${fightIndex}. If you somehow turned out to not be gae, DM an admin to get unmuted early you lucky bastard!!**`
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
41
cat/Path/gae.js
Normal file
41
cat/Path/gae.js
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "gae",
|
||||||
|
timeout: 15000,
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const MEE6 = [
|
||||||
|
"u = gae",
|
||||||
|
"pLeaSe gAE",
|
||||||
|
"REEEEEEEEEEEEEEEEEEEEEE*GAE*EEEEEEEEEEEEEEEEEEEEEEEEEEE",
|
||||||
|
"Enough with the gae jokes, U gae",
|
||||||
|
"Plain ol' gae",
|
||||||
|
"<a:dankcutie:804313489488347146>",
|
||||||
|
"By the way, Deity bot is my senpai.\nShe is the most beautiful bot I've ever seen <3",
|
||||||
|
"aight imma gae out",
|
||||||
|
"*gae with extra steps*",
|
||||||
|
"**wae r u gae**",
|
||||||
|
"u gae bro?",
|
||||||
|
"**100%** gae",
|
||||||
|
"I bet you do **tiktok**",
|
||||||
|
"**G.A.E.**",
|
||||||
|
"The next person to chat is gae",
|
||||||
|
"Whoever used C.gae, is **gae**",
|
||||||
|
"*Its ok to be gae*",
|
||||||
|
"*succ my* **cheez**",
|
||||||
|
"**gae gae gae gae gae gae**",
|
||||||
|
"**Be gae**",
|
||||||
|
"There's no cooldown so y'all get muted for being *gae*",
|
||||||
|
"Ok stop using this command, really. U gae?",
|
||||||
|
"What the hell, u gae?",
|
||||||
|
"**GAEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE**",
|
||||||
|
];
|
||||||
|
const MEE6Index = MEE6[Math.floor(Math.random() * MEE6.length)];
|
||||||
|
message.delete();
|
||||||
|
message.channel.send(`${MEE6Index}`);
|
||||||
|
},
|
||||||
|
};
|
30
cat/Path/gg.js
Normal file
30
cat/Path/gg.js
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "gg",
|
||||||
|
timeout: 15000,
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const GG = [
|
||||||
|
"**GIT GUD**",
|
||||||
|
"Git gud kid",
|
||||||
|
"good game *question mark*",
|
||||||
|
"gg l0ser",
|
||||||
|
"delet cod gg",
|
||||||
|
"*ggwp*",
|
||||||
|
"I was lagging doe",
|
||||||
|
"```Stop using this command```",
|
||||||
|
"<a:partyy:804324497531863060> ez pz <a:partyy:804324497531863060>",
|
||||||
|
"<a:REEEE:804324566259204107>",
|
||||||
|
"**GOOD GAME WELL PLAYED**",
|
||||||
|
"<a:greenflame:804325192330641408> get rektd <a:greenflame:804325192330641408>",
|
||||||
|
"<a:lollll:804325253265621012><a:lollll:804325253265621012><a:lollll:804325253265621012><a:lollll:804325253265621012><a:lollll:804325253265621012>",
|
||||||
|
];
|
||||||
|
const GGIndex = GG[Math.floor(Math.random() * GG.length)];
|
||||||
|
message.delete();
|
||||||
|
message.channel.send(`${GGIndex}`);
|
||||||
|
},
|
||||||
|
};
|
29
cat/Path/how.js
Normal file
29
cat/Path/how.js
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
const { MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "howgae",
|
||||||
|
description: "Check how gae is the user",
|
||||||
|
usage: "(User)",
|
||||||
|
Path: true,
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const target = message.mentions.users.first() || message.author;
|
||||||
|
if (target.id === "366562874039992331") {
|
||||||
|
message.channel.send(
|
||||||
|
new MessageEmbed()
|
||||||
|
.setTitle(`${target.username}'s gae rate`)
|
||||||
|
.setDescription(`You are 69420% gae`)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
let simp = Math.floor(Math.random() * 100);
|
||||||
|
message.channel.send(
|
||||||
|
new MessageEmbed()
|
||||||
|
.setTitle(`${target.username}'s gae rate`)
|
||||||
|
.setDescription(`You are ${simp}% gae`)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
34
cat/Path/nab.js
Normal file
34
cat/Path/nab.js
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "nab",
|
||||||
|
timeout: 15000,
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const NAB = [
|
||||||
|
"stop being a nab, nab",
|
||||||
|
"Lmao you a nab",
|
||||||
|
"Biggest nab of all time",
|
||||||
|
"You're just a nab",
|
||||||
|
"Okay calm down nab",
|
||||||
|
"**Stop** spamming this command you **nab**",
|
||||||
|
"```I told you to stop spamming this command nab```",
|
||||||
|
"Get rekt nab XD Jajajajajaja",
|
||||||
|
"**N.A.B.**",
|
||||||
|
"Better luck next time nab",
|
||||||
|
"Ooooh look at me im better than you nab",
|
||||||
|
"Whoever used C.nab, is a nab",
|
||||||
|
"Stfu nab",
|
||||||
|
"**you cant aim**",
|
||||||
|
"*bonjour* nab",
|
||||||
|
"u = <a:pepetriggered:804327257145081877>",
|
||||||
|
"Go back to tiktok <a:frogcrazy:804327200659865610>",
|
||||||
|
];
|
||||||
|
const NABIndex = NAB[Math.floor(Math.random() * NAB.length)];
|
||||||
|
message.delete();
|
||||||
|
message.channel.send(`${NABIndex}`);
|
||||||
|
},
|
||||||
|
};
|
24
cat/Path/pp.js
Normal file
24
cat/Path/pp.js
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "pp",
|
||||||
|
description: "Check how long is the user",
|
||||||
|
usage: "(User)",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
let user = message.mentions.users.first() || message.author;
|
||||||
|
let embed = new MessageEmbed()
|
||||||
|
.addField(
|
||||||
|
`${user.username}\'s peepee`,
|
||||||
|
`8${"=".repeat(Math.floor(Math.random() * 20))}D`
|
||||||
|
)
|
||||||
|
.setColor(client.color)
|
||||||
|
.setTitle("Peepee size machine")
|
||||||
|
.setTimestamp()
|
||||||
|
.setFooter(`Made by Cath Team`);
|
||||||
|
message.inlineReply(embed);
|
||||||
|
},
|
||||||
|
};
|
32
commands/Config/check.js
Normal file
32
commands/Config/check.js
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "check",
|
||||||
|
description: "Check Goodbye/Welcome/Log Channel for the server",
|
||||||
|
usage: "(goodbye/welcome/log) (Channel)",
|
||||||
|
UserPerm: "ADMINISTRATOR",
|
||||||
|
category: "Config",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const data = await client.data.getGuild(message.guild.id);
|
||||||
|
if (!args[0]) return client.err(messgae, "Config", "check", 45);
|
||||||
|
if (args[0].toLowerCase() === "goodbye") {
|
||||||
|
const goodbye = data.Goodbye;
|
||||||
|
if (goodbye === "null") return client.err(messgae, "Config", "check", 10);
|
||||||
|
else message.channel.send(`The goodbye channel is <#${goodbye}>`);
|
||||||
|
} else if (args[0].toLowerCase() === "log") {
|
||||||
|
const log = data.Log;
|
||||||
|
if (log === "null") return client.err(messgae, "Config", "check", 10);
|
||||||
|
else message.channel.send(`The log channel is <#${log}>`);
|
||||||
|
} else if (args[0].toLowerCase() === "welcome") {
|
||||||
|
const welcome = data.Welcome;
|
||||||
|
if (welcome === "null") return client.err(messgae, "Config", "check", 10);
|
||||||
|
else message.channel.send(`The welcome channel is <#${welcome}>`);
|
||||||
|
} else {
|
||||||
|
return client.err(messgae, "Config", "check", 45);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
127
commands/Config/choices.js
Normal file
127
commands/Config/choices.js
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
const schema = require("../../models/modmail");
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "choices",
|
||||||
|
UserPerm: "ADMINISTRATOR",
|
||||||
|
description: "Add choices for modmail in a server",
|
||||||
|
usage: "(add/list/rmv) (Emoji) {Text}",
|
||||||
|
category: "Config",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
schema.findOne({ Guild: message.guild.id }, async (err, data) => {
|
||||||
|
if (data) return;
|
||||||
|
else {
|
||||||
|
new schema({
|
||||||
|
Guild: message.guild.id,
|
||||||
|
}).save();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (args[0].toLowerCase() === "add") {
|
||||||
|
if (!args[1]) return client.err(message, "Config", "choices", 11);
|
||||||
|
if (!args[2]) return client.err(message, "Config", "choices", 12);
|
||||||
|
if (!args.slice(2).join(" ").length > 100)
|
||||||
|
return client.err(message, "Config", "choices", 13);
|
||||||
|
const config = await schema.findOne({ Guild: message.guild.id });
|
||||||
|
if (
|
||||||
|
!config ||
|
||||||
|
!config.Choices ||
|
||||||
|
!Object.entries(config.Choices).length
|
||||||
|
) {
|
||||||
|
const choices = {
|
||||||
|
0: {
|
||||||
|
emoji: args[1],
|
||||||
|
text: args.slice(2).join(" "),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
schema.findOne({ Guild: message.guild.id }, async (err, data) => {
|
||||||
|
if (data) {
|
||||||
|
if (data.Choices) {
|
||||||
|
data.Choices = choices;
|
||||||
|
await schema.findOneAndUpdate({ Guild: message.guild.id }, data);
|
||||||
|
} else if (data.Guild) {
|
||||||
|
data.Choices = choices;
|
||||||
|
await schema.findOneAndUpdate({ Guild: message.guild.id }, data);
|
||||||
|
} else {
|
||||||
|
new schema({
|
||||||
|
Guild: message.guild.id,
|
||||||
|
Choices: choices,
|
||||||
|
}).save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return message.channel.send(
|
||||||
|
`${message.author.tag} has added ${args[1]} as a modmail choice`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
const choices = Object.entries(config.Choices);
|
||||||
|
if (choices.length >= 5)
|
||||||
|
return client.err(message, "Config", "choices", 14);
|
||||||
|
const last = choices[choices.length - 1];
|
||||||
|
const parsed = config.Choices;
|
||||||
|
parsed[(parseInt(last[0]) + 1).toString()] = {
|
||||||
|
emoji: args[1],
|
||||||
|
text: args.slice(2).join(" "),
|
||||||
|
};
|
||||||
|
schema.findOne({ Guild: message.guild.id }, async (err, data) => {
|
||||||
|
if (data) {
|
||||||
|
data.Choices = parsed;
|
||||||
|
await schema.findOneAndUpdate({ Guild: message.guild.id }, data);
|
||||||
|
} else {
|
||||||
|
new schema({
|
||||||
|
Guild: message.guild.id,
|
||||||
|
Choices: parsed,
|
||||||
|
}).save();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return message.channel.send(
|
||||||
|
`${message.author.tag} has added ${args[1]} as a modmail choice`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (args[0].toLowerCase() === "list") {
|
||||||
|
const Data = await schema.findOne({ Guild: message.guild.id });
|
||||||
|
if (!Data || !Data.Choices || !Object.entries(Data.Choices).length)
|
||||||
|
return client.err(message, "Config", "choices", 10);
|
||||||
|
else
|
||||||
|
return message.channel.send(
|
||||||
|
Object.entries(Data.Choices)
|
||||||
|
.map(value => {
|
||||||
|
return `${value[1].emoji}: ${value[1].text}`;
|
||||||
|
})
|
||||||
|
.join("\n")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (args[0].toLowerCase() === "rmv") {
|
||||||
|
if (!args[1]) return client.err(message, "Config", "choices", 11);
|
||||||
|
schema.findOne({ Guild: message.guild.id }, async (err, data) => {
|
||||||
|
if (!data || !data.Choices || !Object.entries(data.Choices).length)
|
||||||
|
return client.err(message, "Config", "choices", 10);
|
||||||
|
const choices = Object.entries(data.Choices);
|
||||||
|
const found = choices.find(value => value[1].emoji == args[1]);
|
||||||
|
if (!found) return client.err(message, "Config", "choices", 15);
|
||||||
|
const filtered = choices.filter(value => value[1].emoji != args[1]);
|
||||||
|
const parsed = {};
|
||||||
|
filtered.map(value => {
|
||||||
|
parsed[value[0]] = {
|
||||||
|
emoji: value[1].emoji,
|
||||||
|
text: value[1].text,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
if (data) {
|
||||||
|
data.Choices = parsed;
|
||||||
|
await schema.findOneAndUpdate({ Guild: message.guild.id }, data);
|
||||||
|
} else {
|
||||||
|
new schema({
|
||||||
|
Guild: message.guild.id,
|
||||||
|
Choices: parsed,
|
||||||
|
}).save();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return message.channel.send(`${args[1]} is removed from choices.`);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
25
commands/Config/cmd-list.js
Normal file
25
commands/Config/cmd-list.js
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
const schema = require("../../models/custom-commands");
|
||||||
|
const { MessageEmbed } = require("discord.js");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "cc-list",
|
||||||
|
UserPerm: "ADMINISTRATOR",
|
||||||
|
description: "Check the custom commands in a server",
|
||||||
|
category: "Config",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const data = await schema.find({ Guild: message.guild.id });
|
||||||
|
if (!!data === false) return client.err(messgae, "Config", "cmd-list", 10);
|
||||||
|
message.channel.send(
|
||||||
|
new MessageEmbed()
|
||||||
|
.setColor(client.color)
|
||||||
|
.setDescription(
|
||||||
|
data.map((cmd, i) => `${i + 1}: ${cmd.Command}`).join("\n")
|
||||||
|
)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
434
commands/Config/create.js
Normal file
434
commands/Config/create.js
Normal file
|
@ -0,0 +1,434 @@
|
||||||
|
const Discord = require("discord.js");
|
||||||
|
const db = require("../../models/custom-commands");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "cc-create",
|
||||||
|
UserPerm: "ADMINISTRATOR",
|
||||||
|
description: "Crate custom commands for a server",
|
||||||
|
category: "Config",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
message.delete();
|
||||||
|
message.channel.send(
|
||||||
|
new Discord.MessageEmbed()
|
||||||
|
.setTitle(`Setup | 1/3`)
|
||||||
|
.setDescription(
|
||||||
|
"What is the name of the command?\nYou can cancel the setup at any time by sending `cancel`."
|
||||||
|
)
|
||||||
|
.setColor(client.color)
|
||||||
|
);
|
||||||
|
await startMessageCollectors(client, message, args);
|
||||||
|
function startMessageCollectors(client, message, args) {
|
||||||
|
let nameFilter = m => m.author.id === message.author.id;
|
||||||
|
let nameCollector = new Discord.MessageCollector(
|
||||||
|
message.channel,
|
||||||
|
nameFilter,
|
||||||
|
{ max: 999 }
|
||||||
|
);
|
||||||
|
nameCollector.on("collect", async msg => {
|
||||||
|
let name = msg.content.toLowerCase();
|
||||||
|
const data = await db.findOne({
|
||||||
|
Guild: message.guild.id,
|
||||||
|
Command: name,
|
||||||
|
});
|
||||||
|
if (data) {
|
||||||
|
nameCollector.stop();
|
||||||
|
return message.inlineReply("This command has already exist.");
|
||||||
|
}
|
||||||
|
if (name === "cancel") {
|
||||||
|
msg.channel.send("The setup has been cancelled.");
|
||||||
|
db.findOneAndDelete({ Guild: message.guild.id, Command: name });
|
||||||
|
nameCollector.stop();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!name) {
|
||||||
|
await msg.channel.send("You don't specify a name. Cancelled setup.");
|
||||||
|
nameCollector.stop();
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
const newDB = new db({
|
||||||
|
Guild: message.guild.id,
|
||||||
|
Command: name,
|
||||||
|
});
|
||||||
|
await newDB.save();
|
||||||
|
console.log(newDB);
|
||||||
|
msg.channel.send(
|
||||||
|
new Discord.MessageEmbed()
|
||||||
|
.setTitle(`Setup | 2/3`)
|
||||||
|
.setDescription(
|
||||||
|
`The command name will be **${name}**.\nWhat is the response for the command? You can have mutliple response by joning them with differnt lines.`
|
||||||
|
)
|
||||||
|
.setColor(client.color)
|
||||||
|
);
|
||||||
|
nameCollector.stop();
|
||||||
|
}
|
||||||
|
let responseFilter = m => m.author.id === message.author.id;
|
||||||
|
let responseCollector = new Discord.MessageCollector(
|
||||||
|
message.channel,
|
||||||
|
responseFilter,
|
||||||
|
{ max: 999 }
|
||||||
|
);
|
||||||
|
responseCollector.on("collect", async msg => {
|
||||||
|
let response = msg.content.split("\n");
|
||||||
|
console.log(`Response: ${response}`);
|
||||||
|
|
||||||
|
if (msg.content.toLowerCase() === "cancel") {
|
||||||
|
msg.channel.send("The setup has been cancelled.");
|
||||||
|
responseCollector.stop();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!response) {
|
||||||
|
msg.channel.send(`You didn't specify a response. Setup cancelled.`);
|
||||||
|
responseCollector.stop();
|
||||||
|
}
|
||||||
|
if (response.length > 1) {
|
||||||
|
responseCollector.stop();
|
||||||
|
await db.findOne(
|
||||||
|
{ Guild: message.guild.id, Command: name },
|
||||||
|
async (err, data) => {
|
||||||
|
if (data) {
|
||||||
|
data.Response = response;
|
||||||
|
await db.findOneAndUpdate(
|
||||||
|
{ Guild: message.guild.id, Command: name },
|
||||||
|
data
|
||||||
|
);
|
||||||
|
console.log(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
msg.channel.send(
|
||||||
|
new Discord.MessageEmbed()
|
||||||
|
.setTitle(`Setup | 3/4`)
|
||||||
|
.setColor(client.color)
|
||||||
|
.setDescription(
|
||||||
|
`Ok so there will be ${response.length} responses. Do you want the response be randomized?\n\`Type yes or no\` \nIf you choose no, accumlative responses may let the command can\'t be sent out.`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
let randomFilter = m => m.author.id === message.author.id;
|
||||||
|
let randomCollector = new Discord.MessageCollector(
|
||||||
|
message.channel,
|
||||||
|
randomFilter,
|
||||||
|
{ max: 999 }
|
||||||
|
);
|
||||||
|
randomCollector.on("collect", async msg => {
|
||||||
|
let maybe;
|
||||||
|
if (msg.content.toLowerCase() === "yes") {
|
||||||
|
msg.channel.send(
|
||||||
|
new Discord.MessageEmbed()
|
||||||
|
.setColor(client.color)
|
||||||
|
.setTitle(`Setup | 4/4`)
|
||||||
|
.setDescription(
|
||||||
|
`The responses will be randomized. Do you want to have delete command usage? \`Type yes or no\``
|
||||||
|
)
|
||||||
|
);
|
||||||
|
randomCollector.stop();
|
||||||
|
maybe = true;
|
||||||
|
await db.findOne(
|
||||||
|
{
|
||||||
|
Guild: message.guild.id,
|
||||||
|
Response: response,
|
||||||
|
Command: name,
|
||||||
|
},
|
||||||
|
async (err, data) => {
|
||||||
|
if (data) {
|
||||||
|
data.Random = maybe;
|
||||||
|
await db.findOneAndUpdate(
|
||||||
|
{
|
||||||
|
Guild: message.guild.id,
|
||||||
|
Command: name,
|
||||||
|
Response: response,
|
||||||
|
},
|
||||||
|
data
|
||||||
|
);
|
||||||
|
console.log(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
console.log(`Random: ${maybe}`);
|
||||||
|
let deleteeeFilter = m => m.author.id === message.author.id;
|
||||||
|
let deleteeeCollector = new Discord.MessageCollector(
|
||||||
|
message.channel,
|
||||||
|
deleteeeFilter,
|
||||||
|
{ max: 999 }
|
||||||
|
);
|
||||||
|
deleteeeCollector.on("collect", async msg => {
|
||||||
|
let idkwor;
|
||||||
|
if (msg.content.toLowerCase() === "yes") {
|
||||||
|
deleteeeCollector.stop();
|
||||||
|
idkwor = true;
|
||||||
|
await db.findOne(
|
||||||
|
{
|
||||||
|
Guild: message.guild.id,
|
||||||
|
Command: name,
|
||||||
|
Response: response,
|
||||||
|
Random: maybe,
|
||||||
|
},
|
||||||
|
async (err, data) => {
|
||||||
|
if (data) {
|
||||||
|
data.Delete = idkwor;
|
||||||
|
await db.findOneAndUpdate(
|
||||||
|
{
|
||||||
|
Guild: message.guild.id,
|
||||||
|
Command: name,
|
||||||
|
Response: response,
|
||||||
|
Random: maybe,
|
||||||
|
},
|
||||||
|
data
|
||||||
|
);
|
||||||
|
console.log(data);
|
||||||
|
msg.inlineReply(
|
||||||
|
`Saved **${data.Command}** as a custom command`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
console.log(`Usage Delete: ${idkwor}`);
|
||||||
|
}
|
||||||
|
if (msg.content.toLowerCase() === "no") {
|
||||||
|
deleteeeCollector.stop();
|
||||||
|
idkwor = false;
|
||||||
|
await db.findOne(
|
||||||
|
{
|
||||||
|
Guild: message.guild.id,
|
||||||
|
Command: name,
|
||||||
|
Response: response,
|
||||||
|
Random: maybe,
|
||||||
|
},
|
||||||
|
async (err, data) => {
|
||||||
|
if (data) {
|
||||||
|
data.Delete = idkwor;
|
||||||
|
await db.findOneAndUpdate(
|
||||||
|
{
|
||||||
|
Guild: message.guild.id,
|
||||||
|
Command: name,
|
||||||
|
Response: response,
|
||||||
|
Random: maybe,
|
||||||
|
},
|
||||||
|
data
|
||||||
|
);
|
||||||
|
console.log(data);
|
||||||
|
msg.inlineReply(
|
||||||
|
`Saved **${data.Command}** as a custom command`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (msg.content.toLowerCase() === "cancel") {
|
||||||
|
msg.channel.send("The setup has been cancelled.");
|
||||||
|
deleteeeCollector.stop();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (msg.content.toLowerCase() === "no") {
|
||||||
|
msg.channel.send(
|
||||||
|
new Discord.MessageEmbed()
|
||||||
|
.setColor(client.color)
|
||||||
|
.setTitle(`Setup | 4/4`)
|
||||||
|
.setDescription(
|
||||||
|
`The responses won't be randomized. Do you want to have delete command usage? \`Type yes or no\``
|
||||||
|
)
|
||||||
|
);
|
||||||
|
randomCollector.stop();
|
||||||
|
maybe = false;
|
||||||
|
await db.findOne(
|
||||||
|
{
|
||||||
|
Guild: message.guild.id,
|
||||||
|
Command: name,
|
||||||
|
Response: response,
|
||||||
|
},
|
||||||
|
async (err, data) => {
|
||||||
|
if (data) {
|
||||||
|
data.Random = maybe;
|
||||||
|
await db.findOneAndUpdate(
|
||||||
|
{
|
||||||
|
Guild: message.guild.id,
|
||||||
|
Command: name,
|
||||||
|
Response: response,
|
||||||
|
},
|
||||||
|
data
|
||||||
|
);
|
||||||
|
console.log(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
let deleteeFilter = m => m.author.id === message.author.id;
|
||||||
|
let deleteeCollector = new Discord.MessageCollector(
|
||||||
|
message.channel,
|
||||||
|
deleteeFilter,
|
||||||
|
{ max: 999 }
|
||||||
|
);
|
||||||
|
deleteeCollector.on("collect", async msg => {
|
||||||
|
let idkwor;
|
||||||
|
if (msg.content.toLowerCase() === "yes") {
|
||||||
|
deleteeCollector.stop();
|
||||||
|
idkwor = true;
|
||||||
|
await db.findOne(
|
||||||
|
{
|
||||||
|
Guild: message.guild.id,
|
||||||
|
Command: name,
|
||||||
|
Response: response,
|
||||||
|
},
|
||||||
|
async (err, data) => {
|
||||||
|
if (data) {
|
||||||
|
data.Delete = idkwor;
|
||||||
|
await db.findOneAndUpdate(
|
||||||
|
{
|
||||||
|
Guild: message.guild.id,
|
||||||
|
Command: name,
|
||||||
|
Response: response,
|
||||||
|
Random: maybe,
|
||||||
|
},
|
||||||
|
data
|
||||||
|
);
|
||||||
|
msg.inlineReply(
|
||||||
|
`Saved **${data.Command}** as a custom command`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
console.log(`Usage Delete: ${idkwor}`);
|
||||||
|
}
|
||||||
|
if (msg.content.toLowerCase() === "no") {
|
||||||
|
deleteeCollector.stop();
|
||||||
|
idkwor = false;
|
||||||
|
await db.findOne(
|
||||||
|
{
|
||||||
|
Guild: message.guild.id,
|
||||||
|
Command: name,
|
||||||
|
Response: response,
|
||||||
|
Random: maybe,
|
||||||
|
},
|
||||||
|
async (err, data) => {
|
||||||
|
if (data) {
|
||||||
|
data.Delete = idkwor;
|
||||||
|
await db.findOneAndUpdate(
|
||||||
|
{
|
||||||
|
Guild: message.guild.id,
|
||||||
|
Command: name,
|
||||||
|
Response: response,
|
||||||
|
},
|
||||||
|
data
|
||||||
|
);
|
||||||
|
msg.inlineReply(
|
||||||
|
`Saved **${data.Command}** as a custom command`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (msg.content.toLowerCase() === "cancel") {
|
||||||
|
msg.channel.send("The setup has been cancelled.");
|
||||||
|
deleteeCollector.stop();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (msg.content.toLowerCase() === "cancel") {
|
||||||
|
msg.channel.send("The setup has been cancelled.");
|
||||||
|
randomCollector.stop();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
await db.findOne(
|
||||||
|
{ Guild: message.guild.id, Command: name },
|
||||||
|
async (err, data) => {
|
||||||
|
if (data) {
|
||||||
|
data.Response = response;
|
||||||
|
await db.findOneAndUpdate(
|
||||||
|
{ Guild: message.guild.id, Command: name },
|
||||||
|
data
|
||||||
|
);
|
||||||
|
console.log(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
msg.channel.send(
|
||||||
|
new Discord.MessageEmbed()
|
||||||
|
.setTitle(`Setup | 3/3`)
|
||||||
|
.setColor(client.color)
|
||||||
|
.setDescription(
|
||||||
|
`The response is \n**${response}**\nDo you to want have delete command usage?`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
responseCollector.stop();
|
||||||
|
let deleteFilter = m => m.author.id === message.author.id;
|
||||||
|
let deleteCollector = new Discord.MessageCollector(
|
||||||
|
message.channel,
|
||||||
|
deleteFilter,
|
||||||
|
{ max: 999 }
|
||||||
|
);
|
||||||
|
deleteCollector.on("collect", async msg => {
|
||||||
|
let idkwor;
|
||||||
|
if (msg.content.toLowerCase() === "yes") {
|
||||||
|
deleteCollector.stop();
|
||||||
|
idkwor = true;
|
||||||
|
await db.findOne(
|
||||||
|
{
|
||||||
|
Guild: message.guild.id,
|
||||||
|
Command: name,
|
||||||
|
Response: response,
|
||||||
|
},
|
||||||
|
async (err, data) => {
|
||||||
|
if (data) {
|
||||||
|
data.Delete = idkwor;
|
||||||
|
await db.findOneAndUpdate(
|
||||||
|
{
|
||||||
|
Guild: message.guild.id,
|
||||||
|
Command: name,
|
||||||
|
Response: response,
|
||||||
|
},
|
||||||
|
data
|
||||||
|
);
|
||||||
|
msg.inlineReply(
|
||||||
|
`Saved **${data.Command}** as a custom command`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (msg.content.toLowerCase() === "no") {
|
||||||
|
deleteCollector.stop();
|
||||||
|
idkwor = false;
|
||||||
|
await db.findOne(
|
||||||
|
{
|
||||||
|
Guild: message.guild.id,
|
||||||
|
Command: name,
|
||||||
|
Response: response,
|
||||||
|
},
|
||||||
|
async (err, data) => {
|
||||||
|
if (data) {
|
||||||
|
data.Delete = idkwor;
|
||||||
|
await db.findOneAndUpdate(
|
||||||
|
{
|
||||||
|
Guild: message.guild.id,
|
||||||
|
Command: name,
|
||||||
|
Response: response,
|
||||||
|
},
|
||||||
|
data
|
||||||
|
);
|
||||||
|
msg.inlineReply(
|
||||||
|
`Saved **${data.Command}** as a custom command`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (msg.content.toLowerCase() === "cancel") {
|
||||||
|
msg.channel.send("The setup has been cancelled.");
|
||||||
|
deleteCollector.stop();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
25
commands/Config/delete.js
Normal file
25
commands/Config/delete.js
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
const schema = require("../../models/custom-commands");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "cc-delete",
|
||||||
|
UserPerm: "ADMINISTRATOR",
|
||||||
|
usage: "(command)",
|
||||||
|
description: "Delete a custom command for a server",
|
||||||
|
category: "Config",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const name = args[0];
|
||||||
|
if (!name) return client.err(message, "Config", "cc-delete", 47);
|
||||||
|
const data = await schema.findOne({
|
||||||
|
Guild: message.guild.id,
|
||||||
|
Command: name,
|
||||||
|
});
|
||||||
|
if (!data) return client.err(message, "Config", "cc-delete", 404);
|
||||||
|
await schema.findOneAndDelete({ Guild: message.guild.id, Command: name });
|
||||||
|
message.inlineReply(`Removed **${name}** from custom commands.`);
|
||||||
|
},
|
||||||
|
};
|
53
commands/Config/disable.js
Normal file
53
commands/Config/disable.js
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
const fs = require("fs");
|
||||||
|
module.exports = {
|
||||||
|
name: "disable",
|
||||||
|
UserPerm: "MANAGE_CHANNELS",
|
||||||
|
usage: "(Command/Category) (Name)",
|
||||||
|
description: "Disable a command in a server",
|
||||||
|
category: "Config",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const type = args[0].toLowerCase();
|
||||||
|
if (!type) return client.err(message, "Config", "disable", 17);
|
||||||
|
const name = args[1].toLowerCase();
|
||||||
|
if (!name) return client.err(message, "Config", "disable", 17);
|
||||||
|
const data = await client.data.getGuild(message.guild.id);
|
||||||
|
if (!type) return client.err(message, "Config", "disable", 17);
|
||||||
|
if (type === "command") {
|
||||||
|
if (!!client.commands.get(name) === false)
|
||||||
|
return client.err(message, "Config", "disable", 404);
|
||||||
|
if (data.Commands.includes(name))
|
||||||
|
return client.err(message, "Config", "disable", 18);
|
||||||
|
message.channel.send(`This command is disabled now:\n\n\`${name}\``);
|
||||||
|
await client.data.disable(message.guild.id, "command", name);
|
||||||
|
}
|
||||||
|
if (type === "category") {
|
||||||
|
const category = fs.readdirSync("./commands");
|
||||||
|
const names = category.map(e => e.toLowerCase());
|
||||||
|
const i = names.indexOf(name);
|
||||||
|
const up = names[i][0].toUpperCase();
|
||||||
|
const others = names[i].substring(1);
|
||||||
|
if (!names.includes(name))
|
||||||
|
return client.err(message, "Config", "disable", 404);
|
||||||
|
if (data.Category) {
|
||||||
|
if (data.Category.includes(name))
|
||||||
|
return client.err(message, "Config", "disable", 18);
|
||||||
|
}
|
||||||
|
if (names.includes(name)) {
|
||||||
|
await client.data.disable(
|
||||||
|
message.guild.id,
|
||||||
|
"category",
|
||||||
|
`${up}${others}`
|
||||||
|
);
|
||||||
|
message.inlineReply(
|
||||||
|
`This command is disabled now:\n\n\`${up}${others}\``
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
48
commands/Config/enable.js
Normal file
48
commands/Config/enable.js
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
const fs = require("fs");
|
||||||
|
module.exports = {
|
||||||
|
name: "enable",
|
||||||
|
UserPerm: "MANAGE_CHANNELS",
|
||||||
|
usage: "(Command) {Channel}",
|
||||||
|
description: "Enable a command in a server",
|
||||||
|
category: "Config",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const type = args[0].toLowerCase();
|
||||||
|
const name = args[1].toLowerCase();
|
||||||
|
const data = await client.data.getGuild(message.guild.id);
|
||||||
|
if (!type) return client.err(message, "Config", "enable", 17);
|
||||||
|
if (!name) return client.err(message, "Config", "enable", 17);
|
||||||
|
if (type === "command") {
|
||||||
|
if (!!client.commands.get(name) === false)
|
||||||
|
return client.err(message, "Config", "enable", 404);
|
||||||
|
if (data.Commands.includes(name) && !!client.command.get(name) === true) {
|
||||||
|
await client.data.enable(message.guild.id, "command", name);
|
||||||
|
message.channel.send(`This command is enabled now:\n\n\`${cmd}\``);
|
||||||
|
} else return client.err(message, "Config", "enable", 18);
|
||||||
|
}
|
||||||
|
if (type === "category") {
|
||||||
|
const category = fs.readdirSync("./commands");
|
||||||
|
const names = category.map(e => e.toLowerCase());
|
||||||
|
const i = names.indexOf(name);
|
||||||
|
const up = names[i][0].toUpperCase();
|
||||||
|
const others = names[i].substring(1);
|
||||||
|
if (!names.includes(name))
|
||||||
|
return client.err(message, "Config", "enable", 404);
|
||||||
|
if (data.Category.includes(`${up}${others}`) && names.includes(name)) {
|
||||||
|
await client.data.enable(
|
||||||
|
message.guild.id,
|
||||||
|
"category",
|
||||||
|
`${up}${others}`
|
||||||
|
);
|
||||||
|
message.inlineReply(
|
||||||
|
`This command is enabled now:\n\n\`${up}${others}\``
|
||||||
|
);
|
||||||
|
} else return client.err(message, "Config", "enable", 18);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
26
commands/Config/migrate.js
Normal file
26
commands/Config/migrate.js
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "migrate",
|
||||||
|
usage: "(Server ID)",
|
||||||
|
description: "Migrate all emojis from a server",
|
||||||
|
category: "Config",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
try {
|
||||||
|
const oldGuild = args[0];
|
||||||
|
if (!oldGuild) return;
|
||||||
|
old = client.guilds.cache.get(oldGuild);
|
||||||
|
if (!old) return client.err(message, "Config", "migrate", 404);
|
||||||
|
await old.emojis.cache.map(async e => {
|
||||||
|
await message.guild.emojis.create(e.url, e.name);
|
||||||
|
});
|
||||||
|
return message.channel.send(`Created Emotes.`);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
35
commands/Config/modmail-category.js
Normal file
35
commands/Config/modmail-category.js
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
const schema = require("../../models/modmail");
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "modmail-category",
|
||||||
|
UserPerm: "ADMINISTRATOR",
|
||||||
|
description: "Setup modmail category in a server",
|
||||||
|
usage: "(Category ID)",
|
||||||
|
category: "Config",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
if (!args.length)
|
||||||
|
return client.err(message, "Config", "modmail-category", 0);
|
||||||
|
const category = message.guild.channels.cache.find(
|
||||||
|
ch => (ch.type = "category" && ch.id == args[0])
|
||||||
|
);
|
||||||
|
if (!category) return client.err(message, "Config", "modmail-category", 1);
|
||||||
|
schema.findOne({ Guild: message.guild.id }, async (err, data) => {
|
||||||
|
if (data) {
|
||||||
|
data.Category = category.id;
|
||||||
|
await schema.findOneAndUpdate({ Guild: message.guild.id }, data);
|
||||||
|
} else {
|
||||||
|
new schema({
|
||||||
|
Guild: message.guild.id,
|
||||||
|
Category: category.id,
|
||||||
|
}).save();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return message.channel.send(`**Saved category to ${category.name}**`);
|
||||||
|
},
|
||||||
|
};
|
32
commands/Config/modmail-role.js
Normal file
32
commands/Config/modmail-role.js
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
const schema = require("../../models/modmail");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "modmail-role",
|
||||||
|
UserPerm: "ADMINISTRATOR",
|
||||||
|
description: "Add role for modmail in a server",
|
||||||
|
usage: "(Role)",
|
||||||
|
category: "Config",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
if (!args.length) return client.err(message, "Config", "modmail-role", 0);
|
||||||
|
const role =
|
||||||
|
message.mentions.roles.first() || message.guild.roles.cache.get(args[0]);
|
||||||
|
if (!role) return client.err(message, "Config", "modmail-role", 404);
|
||||||
|
schema.findOne({ Guild: message.guild.id }, async (err, data) => {
|
||||||
|
if (data) {
|
||||||
|
data.Role = role.id;
|
||||||
|
await schema.findOneAndUpdate({ Guild: message.guild.id }, data);
|
||||||
|
} else {
|
||||||
|
new schema({
|
||||||
|
Guild: message.guild.id,
|
||||||
|
Role: role.id,
|
||||||
|
}).save();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return message.channel.send(`Updated **${role.name}** as the modmail role`);
|
||||||
|
},
|
||||||
|
};
|
33
commands/Config/panel.js
Normal file
33
commands/Config/panel.js
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
const Schema = require("../../models/reaction");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "panel",
|
||||||
|
description: "Reaction-Role Panel",
|
||||||
|
UserPerm: "ADMINISTRATOR",
|
||||||
|
category: "Config",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const channel = message.mentions.channels.first() || message.channel;
|
||||||
|
Schema.findOne({ Guild: message.guild.id }, async (err, data) => {
|
||||||
|
if (!data) return client.err(message, "Config", "panel", 10);
|
||||||
|
const mapped = Object.keys(data.Roles)
|
||||||
|
.map((value, index) => {
|
||||||
|
const role = message.guild.roles.cache.get(data.Roles[value][0]);
|
||||||
|
return `${index + 1}) ${data.Roles[value][1].raw} - ${role}`;
|
||||||
|
})
|
||||||
|
.join("\n\n");
|
||||||
|
channel.send(new MessageEmbed().setDescription(mapped)).then(msg => {
|
||||||
|
data.Message = msg.id;
|
||||||
|
data.save();
|
||||||
|
|
||||||
|
const reactions = Object.values(data.Roles).map(val => val[1].id); // ?? val[1].raw);
|
||||||
|
reactions.map(emoji => msg.react(emoji));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
41
commands/Config/prefix-reset.js
Normal file
41
commands/Config/prefix-reset.js
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
const schema = require("../../models/guilds");
|
||||||
|
const prefix = require("../../config.json").prefix;
|
||||||
|
const { confirmation } = require("@reconlx/discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "prefix-reset",
|
||||||
|
aliases: ["pr"],
|
||||||
|
description: 'Reset the prefix to "C." at the server',
|
||||||
|
UserPerm: "ADMINISTRATOR",
|
||||||
|
category: "Config",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message) => {
|
||||||
|
message.channel
|
||||||
|
.send("**Do you want to reset your prefix?**")
|
||||||
|
.then(async msg => {
|
||||||
|
const emoji = await confirmation(
|
||||||
|
msg,
|
||||||
|
message.author,
|
||||||
|
["✅", "❌"],
|
||||||
|
10000
|
||||||
|
);
|
||||||
|
if (emoji === "✅") {
|
||||||
|
msg.delete();
|
||||||
|
schema.findOne({ Guild: message.guild.id }, async (err, data) => {
|
||||||
|
if (data) {
|
||||||
|
data.Prefix = prefix;
|
||||||
|
await schema.findOneAndUpdate({ Guild: message.guild.id }, data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
message.channel.send(`The prefix has been reset to **${prefix}**`);
|
||||||
|
}
|
||||||
|
if (emoji === "❌") {
|
||||||
|
msg.delete();
|
||||||
|
message.channel.send("Cancelled.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
37
commands/Config/prefix.js
Normal file
37
commands/Config/prefix.js
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
const schema = require("../../models/guilds");
|
||||||
|
module.exports = {
|
||||||
|
name: "prefix",
|
||||||
|
usage: "(Prefix)",
|
||||||
|
description: "Set the prefix at the server",
|
||||||
|
UserPerm: "ADMINISTRATOR",
|
||||||
|
category: "Config",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const res = args.join(" ");
|
||||||
|
if (!res) return client.err(message, "Config", "prefix", 46);
|
||||||
|
schema.findOne({ Guild: message.guild.id }, async (err, data) => {
|
||||||
|
if (err) throw err;
|
||||||
|
if (data) {
|
||||||
|
schema.findOne({ Guild: message.guild.id }, async (err, data) => {
|
||||||
|
data.Prefix = res;
|
||||||
|
await schema.findOneAndUpdate({ Guild: message.guild.id }, data);
|
||||||
|
});
|
||||||
|
message.channel.send(`Your prefix has been updated to **${res}**`);
|
||||||
|
} else {
|
||||||
|
data = new schema({
|
||||||
|
Guild: message.guild.id,
|
||||||
|
Prefix: res,
|
||||||
|
});
|
||||||
|
data.save();
|
||||||
|
message.channel.send(
|
||||||
|
`Custom prefix in this server is now set to **${res}**`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
63
commands/Config/premium.js
Normal file
63
commands/Config/premium.js
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "premiumserveradd",
|
||||||
|
category: "Config",
|
||||||
|
timeout: 1000 * 60,
|
||||||
|
aliases: ["psadd", "psa", "premiumserver"],
|
||||||
|
description: "Add premium to a server",
|
||||||
|
Premium: true,
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
try {
|
||||||
|
const user = await client.data.getUser(message.author.id);
|
||||||
|
const guild = await client.data.getGuild(message.guild.id);
|
||||||
|
if (guild.Premium == true) {
|
||||||
|
return client.err(message, "Config", "premium", 506);
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
(user.Tier == 1 && user.PremiumServers.length >= 5) ||
|
||||||
|
(user.Tier == 2 && user.PremiumServers.length >= 2) ||
|
||||||
|
(user.Tier == 3 && user.PremiumServers.length >= 0)
|
||||||
|
) {
|
||||||
|
return client.err(message, "Config", "premium", 505);
|
||||||
|
}
|
||||||
|
await client.data.setPremium(message.guild.id, "true");
|
||||||
|
await client.data.pushGuild(message.author.id, message.guild.id, "push");
|
||||||
|
message.channel.send(
|
||||||
|
new MessageEmbed()
|
||||||
|
.setTitle("Success!")
|
||||||
|
.setDescription(`Premium added to **${message.guild.name}**! \n`)
|
||||||
|
.setFooter("Thank you for supporting Cath!")
|
||||||
|
.setColor("GREEN")
|
||||||
|
.setTimestamp()
|
||||||
|
.setAuthor(
|
||||||
|
message.author.tag,
|
||||||
|
message.author.displayAvatarURL({ dynamic: true })
|
||||||
|
)
|
||||||
|
);
|
||||||
|
client.ServerLog.send(
|
||||||
|
new MessageEmbed()
|
||||||
|
.setTitle("New Premium Server")
|
||||||
|
.addField("Server Info", [
|
||||||
|
`**>Server Name**: \n${message.guild.name}`,
|
||||||
|
`**>Server ID**: \n${message.guild.id}`,
|
||||||
|
`**>Server Member Count**: \n${message.guild.memberCount}`,
|
||||||
|
])
|
||||||
|
.addField("Owner Info", [
|
||||||
|
`**>Owner Tag**: \n${message.guild.owner.user.tag}`,
|
||||||
|
`**>Owner ID**: \n${message.guild.owner.id}`,
|
||||||
|
])
|
||||||
|
.setTimestamp()
|
||||||
|
.setThumbnail(message.guild.iconURL({ dynamic: true }))
|
||||||
|
.setColor("GREEN")
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
return client.err(message, "Config", "premium", 999);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
50
commands/Config/rr-add.js
Normal file
50
commands/Config/rr-add.js
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
const { Client, Message, MessageEmbed, Util } = require("discord.js");
|
||||||
|
const Schema = require("../../models/reaction");
|
||||||
|
module.exports = {
|
||||||
|
name: "rr-add",
|
||||||
|
UserPerm: "ADMINISTRATOR",
|
||||||
|
description: "Create reaction role for server",
|
||||||
|
usage: "(Role) (emoji(Must be in server)",
|
||||||
|
category: "Config",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const role =
|
||||||
|
message.mentions.roles.first() ||
|
||||||
|
message.guild.roles.cache.get(args[0]) ||
|
||||||
|
message.guild.roles.cache.find(r => r.name == args[0]);
|
||||||
|
let [, emoji] = args;
|
||||||
|
if (!emoji) return client.err(message, "Config", "rr-add", 11);
|
||||||
|
const parsedEmoji = Util.parseEmoji(emoji);
|
||||||
|
Schema.findOne({ Guild: message.guild.id }, async (err, data) => {
|
||||||
|
if (data) {
|
||||||
|
data.Roles[parsedEmoji.name] = [
|
||||||
|
role.id,
|
||||||
|
{
|
||||||
|
id: parsedEmoji.id,
|
||||||
|
raw: emoji,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
await Schema.findOneAndUpdate({ Guild: message.guild.id }, data);
|
||||||
|
} else {
|
||||||
|
new Schema({
|
||||||
|
Guild: message.guild.id,
|
||||||
|
Message: 0,
|
||||||
|
Roles: {
|
||||||
|
[parsedEmoji.name]: [
|
||||||
|
role.id,
|
||||||
|
{
|
||||||
|
id: parsedEmoji.id,
|
||||||
|
raw: emoji,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}).save();
|
||||||
|
}
|
||||||
|
message.channel.send(`Added ${role.name}.`);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
39
commands/Config/rr-rmv.js
Normal file
39
commands/Config/rr-rmv.js
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
const { Client, Message } = require("discord.js");
|
||||||
|
const Schema = require("../../models/reaction");
|
||||||
|
const { confirmation } = require("@reconlx/discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "rr-rmv",
|
||||||
|
UserPerm: "ADMINISTRATOR",
|
||||||
|
description: "Remove reaction role for server",
|
||||||
|
category: "Config",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
message.channel
|
||||||
|
.send("**Do you want to remove the reaction roles?**")
|
||||||
|
.then(async msg => {
|
||||||
|
Schema.findOne({ Guild: message.guild.id }, async (err, data) => {
|
||||||
|
if (err) throw err;
|
||||||
|
if (!data) return client.err(message, "Config", "rr-rmv", 10);
|
||||||
|
});
|
||||||
|
const emoji = await confirmation(
|
||||||
|
msg,
|
||||||
|
message.author,
|
||||||
|
["✅", "❌"],
|
||||||
|
10000
|
||||||
|
);
|
||||||
|
if (emoji === "✅") {
|
||||||
|
msg.delete();
|
||||||
|
await Schema.findOneAndDelete({ Guild: message.guild.id });
|
||||||
|
message.channel.send(`Removed reaction roles for this server.`);
|
||||||
|
}
|
||||||
|
if (emoji === "❌") {
|
||||||
|
msg.delete();
|
||||||
|
message.channel.send("Cancelled.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
34
commands/Config/set.js
Normal file
34
commands/Config/set.js
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "set",
|
||||||
|
description: "Set Goodbye/Welcome/Log Channel for the server",
|
||||||
|
usage: "(goodbye/welcome/log) (#Channel)",
|
||||||
|
UserPerm: "ADMINISTRATOR",
|
||||||
|
category: "Config",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
if (!args[0]) return client.err(message, "Config", "set", 45);
|
||||||
|
if (args[0].toLowerCase() === "goodbye") {
|
||||||
|
const channel = message.mentions.channels.first();
|
||||||
|
if (!channel) return client.err(message, "Config", "set", 28);
|
||||||
|
await client.data.setGoodbye(message.guild.id, channel.id);
|
||||||
|
message.channel.send(`Saved ${channel} as the goodbye channel.`);
|
||||||
|
} else if (args[0].toLowerCase() === "log") {
|
||||||
|
const channel = message.mentions.channels.first();
|
||||||
|
if (!channel) return client.err(message, "Config", "set", 28);
|
||||||
|
await client.data.setLog(message.guild.id, channel.id);
|
||||||
|
message.channel.send(`Saved ${channel} as the log channel.`);
|
||||||
|
} else if (args[0].toLowerCase() === "welcome") {
|
||||||
|
const channel = message.mentions.channels.first();
|
||||||
|
if (!channel) return client.err(message, "Config", "set", 28);
|
||||||
|
await client.data.setWelcome(message.guild.id, channel.id);
|
||||||
|
message.channel.send(`Saved ${channel} as the welcome channel.`);
|
||||||
|
} else {
|
||||||
|
return client.err(message, "Config", "set", 45);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
34
commands/Economy/bal.js
Normal file
34
commands/Economy/bal.js
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "balance",
|
||||||
|
aliases: ["bal"],
|
||||||
|
usage: "(User)",
|
||||||
|
category: "Economy",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const user =
|
||||||
|
message.mentions.members.first() ||
|
||||||
|
message.guild.members.cache.get(args[0]) ||
|
||||||
|
message.guild.members.cache.find(
|
||||||
|
r =>
|
||||||
|
r.user.username.toLowerCase() === args.join(" ").toLocaleLowerCase()
|
||||||
|
) ||
|
||||||
|
message.guild.members.cache.find(
|
||||||
|
r => r.displayName.toLowerCase() === args.join(" ").toLocaleLowerCase()
|
||||||
|
) ||
|
||||||
|
message.member;
|
||||||
|
const bal = await client.data.bal(user.id);
|
||||||
|
let embed = new MessageEmbed()
|
||||||
|
.addField(`${client.currency} Balance`, `**${bal}**`)
|
||||||
|
.setColor(client.color)
|
||||||
|
.setURL(client.web)
|
||||||
|
.setTitle(`${user.displayName}'s Balance`)
|
||||||
|
.setTimestamp()
|
||||||
|
.setFooter(`Requested by ${message.author.tag}`);
|
||||||
|
message.inlineReply(embed);
|
||||||
|
},
|
||||||
|
};
|
48
commands/Economy/bet.js
Normal file
48
commands/Economy/bet.js
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "gamble",
|
||||||
|
aliases: ["bet"],
|
||||||
|
usage: "(Number)",
|
||||||
|
timeout: 5000,
|
||||||
|
description: "Win double amount of coins or lose all coins",
|
||||||
|
category: "Economy",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const max = 1000000;
|
||||||
|
if (!args[0]) {
|
||||||
|
return client.err(message, "Economy", "gamble", 5);
|
||||||
|
}
|
||||||
|
if (isNaN(args[0])) {
|
||||||
|
return client.err(message, "Economy", "gamble", 7);
|
||||||
|
}
|
||||||
|
const amt = parseInt(args[0]);
|
||||||
|
if ((await client.data.bal(message.author.id)) < amt) {
|
||||||
|
return client.err(message, "Economy", "gamble", 20);
|
||||||
|
}
|
||||||
|
if (amt > max) {
|
||||||
|
return client.err(message, "Economy", "gamble", 101);
|
||||||
|
}
|
||||||
|
if (client.function.random() === true) {
|
||||||
|
const winamt = amt * 1;
|
||||||
|
await client.data.add(message.author.id, winamt);
|
||||||
|
const abc = new MessageEmbed()
|
||||||
|
.setColor("GREEN")
|
||||||
|
.setTimestamp()
|
||||||
|
.setTitle(`${message.author.username} wins a gamble game`)
|
||||||
|
.setDescription(`You win\n**${winamt}**${client.currency}`);
|
||||||
|
message.inlineReply(abc);
|
||||||
|
} else {
|
||||||
|
await client.data.rmv(message.author.id, amt);
|
||||||
|
const cba = new MessageEmbed()
|
||||||
|
.setColor("RED")
|
||||||
|
.setTimestamp()
|
||||||
|
.setTitle(`${message.author.username} loses a gamble game`)
|
||||||
|
.setDescription(`You lost\n**${amt}**${client.currency}`);
|
||||||
|
message.inlineReply(cba);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
290
commands/Economy/blackjack.js
Normal file
290
commands/Economy/blackjack.js
Normal file
|
@ -0,0 +1,290 @@
|
||||||
|
const Discord = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "blackjack",
|
||||||
|
aliases: ["bj"],
|
||||||
|
usage: "(Number)",
|
||||||
|
description: "Play a blackjack game to win money",
|
||||||
|
category: "Economy",
|
||||||
|
timeout: 10000,
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const money = parseInt(args[0]);
|
||||||
|
const author = message.author;
|
||||||
|
if (isNaN(money) || !money) {
|
||||||
|
return client.err(message, "Economy", "blackjack", 101);
|
||||||
|
}
|
||||||
|
if ((await client.data.bal(author.id)) < bet) {
|
||||||
|
client.err(message, "Economy", "blackjack", 20);
|
||||||
|
}
|
||||||
|
var numCardsPulled = 0;
|
||||||
|
var gameOver = false;
|
||||||
|
var player = {
|
||||||
|
cards: [],
|
||||||
|
score: 0,
|
||||||
|
};
|
||||||
|
var dealer = {
|
||||||
|
cards: [],
|
||||||
|
score: 0,
|
||||||
|
};
|
||||||
|
function getCardsValue(a) {
|
||||||
|
var cardArray = [],
|
||||||
|
sum = 0,
|
||||||
|
i = 0,
|
||||||
|
dk = 10.5,
|
||||||
|
doubleking = "QQ",
|
||||||
|
aceCount = 0;
|
||||||
|
cardArray = a;
|
||||||
|
for (i; i < cardArray.length; i += 1) {
|
||||||
|
if (
|
||||||
|
cardArray[i].rank === "J" ||
|
||||||
|
cardArray[i].rank === "Q" ||
|
||||||
|
cardArray[i].rank === "K"
|
||||||
|
) {
|
||||||
|
sum += 10;
|
||||||
|
} else if (cardArray[i].rank === "A") {
|
||||||
|
sum += 11;
|
||||||
|
aceCount += 1;
|
||||||
|
} else if (cardArray[i].rank === doubleking) {
|
||||||
|
sum += dk;
|
||||||
|
} else {
|
||||||
|
sum += cardArray[i].rank;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (aceCount > 0 && sum > 21) {
|
||||||
|
sum -= 10;
|
||||||
|
aceCount -= 1;
|
||||||
|
}
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
|
||||||
|
var deck = {
|
||||||
|
deckArray: [],
|
||||||
|
initialize: function () {
|
||||||
|
var suitArray, rankArray, s, r, n;
|
||||||
|
suitArray = ["b", "d", "g", "s"];
|
||||||
|
rankArray = [2, 3, 4, 5, 6, 7, 8, 9, 10, "J", "Q", "K", "A"];
|
||||||
|
n = 13;
|
||||||
|
|
||||||
|
for (s = 0; s < suitArray.length; s += 1) {
|
||||||
|
for (r = 0; r < rankArray.length; r += 1) {
|
||||||
|
this.deckArray[s * n + r] = {
|
||||||
|
rank: rankArray[r],
|
||||||
|
suit: suitArray[s],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
shuffle: function () {
|
||||||
|
var temp, i, rnd;
|
||||||
|
for (i = 0; i < this.deckArray.length; i += 1) {
|
||||||
|
rnd = Math.floor(Math.random() * this.deckArray.length);
|
||||||
|
temp = this.deckArray[i];
|
||||||
|
this.deckArray[i] = this.deckArray[rnd];
|
||||||
|
this.deckArray[rnd] = temp;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
deck.initialize();
|
||||||
|
deck.shuffle();
|
||||||
|
async function bet(outcome) {
|
||||||
|
if (outcome === "win") {
|
||||||
|
client.data.add(author.id, money);
|
||||||
|
//client.ADDbjWin(message.author.id);
|
||||||
|
}
|
||||||
|
if (outcome === "lose") {
|
||||||
|
client.data.rmv(author.id, money);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function endMsg(f, msg, cl, dealerC) {
|
||||||
|
let cardsMsg = "";
|
||||||
|
player.cards.forEach(function (card) {
|
||||||
|
var emAR = ["♥", "♦", "♠", "♣"];
|
||||||
|
var t = emAR[Math.floor(Math.random() * emAR.length)];
|
||||||
|
cardsMsg += "[`" + t + card.rank.toString();
|
||||||
|
if (card.suit == "d1") cardsMsg += "♥";
|
||||||
|
if (card.suit == "d2") cardsMsg += "♦";
|
||||||
|
if (card.suit == "d3") cardsMsg += "♠";
|
||||||
|
if (card.suit == "d4") cardsMsg += "♣";
|
||||||
|
cardsMsg += "`](https://cath.gq/) ";
|
||||||
|
});
|
||||||
|
cardsMsg += " > " + player.score.toString();
|
||||||
|
|
||||||
|
var dealerMsg = "";
|
||||||
|
if (!dealerC) {
|
||||||
|
var emAR = ["♥", "♦", "♠", "♣"];
|
||||||
|
var t = emAR[Math.floor(Math.random() * emAR.length)];
|
||||||
|
dealerMsg = "[`" + t + dealer.cards[0].rank.toString();
|
||||||
|
if (dealer.cards[0].suit == "d1") dealerMsg += "♥";
|
||||||
|
if (dealer.cards[0].suit == "d2") dealerMsg += "♦";
|
||||||
|
if (dealer.cards[0].suit == "d3") dealerMsg += "♠";
|
||||||
|
if (dealer.cards[0].suit == "d4") dealerMsg += "♣";
|
||||||
|
dealerMsg += " ? ?`](https://cath.gq/)";
|
||||||
|
} else {
|
||||||
|
dealerMsg = "";
|
||||||
|
dealer.cards.forEach(function (card) {
|
||||||
|
var emAR = ["♥", "♦", "♠", "♣"];
|
||||||
|
var t = emAR[Math.floor(Math.random() * emAR.length)];
|
||||||
|
dealerMsg += "[`" + t + card.rank.toString();
|
||||||
|
if (card.suit == "d1") dealerMsg += "♥";
|
||||||
|
if (card.suit == "d2") dealerMsg += "♦";
|
||||||
|
if (card.suit == "d3") dealerMsg += "♠";
|
||||||
|
if (card.suit == "d4") dealerMsg += "♣";
|
||||||
|
dealerMsg += "`](https://cath.gq/) ";
|
||||||
|
});
|
||||||
|
dealerMsg += " > " + dealer.score.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
const gambleEmbed = new Discord.MessageEmbed()
|
||||||
|
.setColor(cl)
|
||||||
|
.setTitle(message.author.username + `'s Blackjack game`)
|
||||||
|
.addField("You", cardsMsg, true)
|
||||||
|
.addField("cath.exe", dealerMsg, true)
|
||||||
|
.addField(f, msg);
|
||||||
|
|
||||||
|
message.channel.send(gambleEmbed);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function endGame() {
|
||||||
|
if (player.score === 21) {
|
||||||
|
bet("win");
|
||||||
|
gameOver = true;
|
||||||
|
await endMsg(
|
||||||
|
`Win! You got 21!`,
|
||||||
|
`cath.exe had ${dealer.score.toString()}`,
|
||||||
|
`GREEN`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (player.score > 21) {
|
||||||
|
bet("lose");
|
||||||
|
gameOver = true;
|
||||||
|
await endMsg(
|
||||||
|
`Lost! You reached over 21!`,
|
||||||
|
`cath.exe had ${dealer.score.toString()}`,
|
||||||
|
`RED`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (dealer.score === 21) {
|
||||||
|
bet("lose");
|
||||||
|
gameOver = true;
|
||||||
|
await endMsg(
|
||||||
|
`Lost! The dealer got 21!`,
|
||||||
|
`cath.exe had ${dealer.score.toString()}`,
|
||||||
|
`RED`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (dealer.score > 21) {
|
||||||
|
bet("win");
|
||||||
|
gameOver = true;
|
||||||
|
await endMsg(
|
||||||
|
`Win! cath.exe reached over 21!`,
|
||||||
|
`cath.exe had ${dealer.score.toString()}`,
|
||||||
|
`GREEN`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
dealer.score >= 17 &&
|
||||||
|
player.score > dealer.score &&
|
||||||
|
player.score < 21
|
||||||
|
) {
|
||||||
|
bet("win");
|
||||||
|
gameOver = true;
|
||||||
|
await endMsg(
|
||||||
|
`Win! You defeated cath.exe!`,
|
||||||
|
`cath.exe had ${dealer.score.toString()}`,
|
||||||
|
`GREEN`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
dealer.score >= 17 &&
|
||||||
|
player.score < dealer.score &&
|
||||||
|
dealer.score < 21
|
||||||
|
) {
|
||||||
|
bet("lose");
|
||||||
|
gameOver = true;
|
||||||
|
await endMsg(
|
||||||
|
`Lost! cath.exe won!`,
|
||||||
|
`cath.exe had ${dealer.score.toString()}`,
|
||||||
|
`RED`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
dealer.score >= 17 &&
|
||||||
|
player.score === dealer.score &&
|
||||||
|
dealer.score < 21
|
||||||
|
) {
|
||||||
|
gameOver = true;
|
||||||
|
await endMsg(
|
||||||
|
`Tie! UwU`,
|
||||||
|
`cath.exe had ${dealer.score.toString()}`,
|
||||||
|
`RED`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function dealerDraw() {
|
||||||
|
dealer.cards.push(deck.deckArray[numCardsPulled]);
|
||||||
|
dealer.score = getCardsValue(dealer.cards);
|
||||||
|
numCardsPulled += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
function newGame() {
|
||||||
|
hit();
|
||||||
|
hit();
|
||||||
|
dealerDraw();
|
||||||
|
endGame();
|
||||||
|
}
|
||||||
|
|
||||||
|
function hit() {
|
||||||
|
player.cards.push(deck.deckArray[numCardsPulled]);
|
||||||
|
player.score = getCardsValue(player.cards);
|
||||||
|
|
||||||
|
numCardsPulled += 1;
|
||||||
|
if (numCardsPulled > 2) {
|
||||||
|
endGame();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function stand() {
|
||||||
|
while (dealer.score < 17) {
|
||||||
|
dealerDraw();
|
||||||
|
}
|
||||||
|
endGame();
|
||||||
|
}
|
||||||
|
newGame();
|
||||||
|
async function loop() {
|
||||||
|
if (gameOver) return;
|
||||||
|
|
||||||
|
endMsg("To hit type `h`, for stand type `s`", `GoodLuck ;)`, `GRAY`);
|
||||||
|
|
||||||
|
let filter = m => m.author.id === message.author.id;
|
||||||
|
message.channel
|
||||||
|
.awaitMessages(filter, {
|
||||||
|
max: 1,
|
||||||
|
time: 1200000,
|
||||||
|
errors: ["time"],
|
||||||
|
})
|
||||||
|
.then(message => {
|
||||||
|
message = message.first();
|
||||||
|
if (message.content === "h" || message.content === "hit") {
|
||||||
|
hit();
|
||||||
|
loop();
|
||||||
|
return;
|
||||||
|
} else if (message.content === "s" || message.content === "stand") {
|
||||||
|
stand();
|
||||||
|
loop();
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
bet("lose");
|
||||||
|
endMsg("Invalid response", `You lost ${money}`, "RED");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(_ => {
|
||||||
|
message.channel.send("Lost!!");
|
||||||
|
bet("lose");
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
await loop();
|
||||||
|
},
|
||||||
|
};
|
71
commands/Economy/buy.js
Normal file
71
commands/Economy/buy.js
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
const inventory = require("../../models/econ");
|
||||||
|
const items = require("../../util/item");
|
||||||
|
module.exports = {
|
||||||
|
name: "purchase",
|
||||||
|
aliases: ["buy"],
|
||||||
|
usage: "(Item)",
|
||||||
|
description: "Buy something from the shop",
|
||||||
|
category: "Economy",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
if (!args[0]) {
|
||||||
|
return client.err(message, "Economy", "buy", 21);
|
||||||
|
}
|
||||||
|
const itemToBuy = args[0];
|
||||||
|
const validItem = !!items.find(
|
||||||
|
item => item.alias.toLowerCase() === itemToBuy
|
||||||
|
);
|
||||||
|
if (!validItem) {
|
||||||
|
return client.err(message, "Economy", "buy", 22);
|
||||||
|
}
|
||||||
|
const itemName = items.find(
|
||||||
|
item => item.alias.toLowerCase() === itemToBuy
|
||||||
|
).item;
|
||||||
|
const itemPrice = items.find(
|
||||||
|
item => item.alias.toLowerCase() === itemToBuy
|
||||||
|
).price;
|
||||||
|
if ((await client.data.bal(message.author.id)) < itemPrice)
|
||||||
|
return client.err(message, "Economy", "buy", 20);
|
||||||
|
const params = {
|
||||||
|
User: message.author.id,
|
||||||
|
};
|
||||||
|
inventory.findOne(params, async (err, data) => {
|
||||||
|
if (data.Inventory) {
|
||||||
|
const hasItem = Object.keys(data.Inventory).includes(itemName);
|
||||||
|
if (!hasItem) {
|
||||||
|
data.Inventory[itemName] = 1;
|
||||||
|
} else {
|
||||||
|
data.Inventory[itemName]++;
|
||||||
|
}
|
||||||
|
await inventory.findOneAndUpdate(params, data);
|
||||||
|
} else if (data.CP) {
|
||||||
|
data.Inventory = {
|
||||||
|
[itemName]: 1,
|
||||||
|
};
|
||||||
|
await inventory.findOneAndUpdate(params, data);
|
||||||
|
} else {
|
||||||
|
new inventory({
|
||||||
|
User: message.author.id,
|
||||||
|
Inventory: {
|
||||||
|
[itemName]: 1,
|
||||||
|
},
|
||||||
|
}).save();
|
||||||
|
}
|
||||||
|
message.inlineReply(
|
||||||
|
new MessageEmbed()
|
||||||
|
.setTimestamp()
|
||||||
|
.setDescription(
|
||||||
|
`**${message.author.username}** buys **${itemName}** for **${itemPrice}**${client.currency}`
|
||||||
|
)
|
||||||
|
.setColor("GREEN")
|
||||||
|
.setURL(client.web)
|
||||||
|
);
|
||||||
|
await client.data.rmv(message.author.id, itemPrice);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
51
commands/Economy/daily.js
Normal file
51
commands/Economy/daily.js
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "daily",
|
||||||
|
description: "Earns daily money",
|
||||||
|
category: "Economy",
|
||||||
|
timeout: 1000 * 60 * 60 * 24,
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
var money;
|
||||||
|
const user = await client.data.getUser(message.author.id);
|
||||||
|
if (user) {
|
||||||
|
if (user.Premium == true) {
|
||||||
|
money = 20000;
|
||||||
|
let pre_embed = new MessageEmbed()
|
||||||
|
.setAuthor(
|
||||||
|
message.author.tag,
|
||||||
|
message.author.displayAvatarURL({ dyanmic: true })
|
||||||
|
)
|
||||||
|
.setDescription(
|
||||||
|
`**Here is your daily ${money}${client.currency}!\nThanks for supporting Cath!**`
|
||||||
|
)
|
||||||
|
.setURL(client.web)
|
||||||
|
.setColor(client.color)
|
||||||
|
.setFooter(`Made by Cath Team`)
|
||||||
|
.setTimestamp();
|
||||||
|
await client.data.add(message.author.id, money);
|
||||||
|
return message.inlineReply(pre_embed);
|
||||||
|
} else {
|
||||||
|
money = 10000;
|
||||||
|
let norm_embed = new MessageEmbed()
|
||||||
|
.setAuthor(
|
||||||
|
message.author.tag,
|
||||||
|
message.author.displayAvatarURL({ dyanmic: true })
|
||||||
|
)
|
||||||
|
.setDescription(
|
||||||
|
`Here is your daily ${money}${client.currency}!\nBe [premium](https://discord.gg/SbQHChmGcp) user, you can get more coins everyday!`
|
||||||
|
)
|
||||||
|
.setURL(client.web)
|
||||||
|
.setColor(client.color)
|
||||||
|
.setFooter(`Made by Cath Team`)
|
||||||
|
.setTimestamp();
|
||||||
|
await client.data.add(message.author.id, money);
|
||||||
|
return message.inlineReply(norm_embed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
41
commands/Economy/drop.js
Normal file
41
commands/Economy/drop.js
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
require("../../inlinereply");
|
||||||
|
module.exports = {
|
||||||
|
name: "drop",
|
||||||
|
usage: "{Channel} (Number)",
|
||||||
|
description: "Drops money to a channel",
|
||||||
|
category: "Economy",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const p = await client.prefix(message);
|
||||||
|
const channel = message.mentions.channels.first() || message.channel;
|
||||||
|
const coinsAmount = args[0];
|
||||||
|
if (!coinsAmount) {
|
||||||
|
return client.err(message, "Economy", "drop", 5);
|
||||||
|
}
|
||||||
|
if ((await client.data.bal(message.author.id)) < coinsAmount) {
|
||||||
|
return client.err(message, "Economy", "drop", 20);
|
||||||
|
}
|
||||||
|
const filter = msg =>
|
||||||
|
msg.guild.id === message.guild.id && msg.content === `${p}claim`;
|
||||||
|
message.channel.send("The drop has started in " + channel.toString());
|
||||||
|
channel.send(
|
||||||
|
`${message.author.username} has dropped a ${client.currency} bomb! Use ${p}claim to claim ${client.currency}!!`
|
||||||
|
);
|
||||||
|
client.data.rmv(message.author.id, parseInt(coinsAmount));
|
||||||
|
channel.awaitMessages(filter, { max: 1, time: 60000 }).then(async msg => {
|
||||||
|
const id = msg.first().author.id;
|
||||||
|
const coinsToClaim = parseInt(coinsAmount);
|
||||||
|
await client.data.add(id, coinsToClaim);
|
||||||
|
msg
|
||||||
|
.first()
|
||||||
|
.inlineReply(
|
||||||
|
`Congratultions! You have claimed **${coinsToClaim}** ${client.currency}!`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
103
commands/Economy/gift.js
Normal file
103
commands/Economy/gift.js
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
const inventory = require("../../models/econ");
|
||||||
|
const items = require("../../util/item");
|
||||||
|
module.exports = {
|
||||||
|
name: "gift",
|
||||||
|
timeout: 5000,
|
||||||
|
usage: "(User) (Item)",
|
||||||
|
description: "Gift item to an user",
|
||||||
|
category: "Economy",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const user =
|
||||||
|
message.mentions.users.first() ||
|
||||||
|
message.guild.members.cache.find(
|
||||||
|
r => r.user.username.toLowerCase() === args[0].toLocaleLowerCase()
|
||||||
|
) ||
|
||||||
|
message.guild.members.cache.find(
|
||||||
|
r => r.displayName.toLowerCase() === args[0].toLocaleLowerCase()
|
||||||
|
);
|
||||||
|
if (!user) return client.err(message, "Economy", "gift", 1);
|
||||||
|
if (user.id === message.author.id)
|
||||||
|
return client.err(message, "Economy", "gift", 21);
|
||||||
|
/*
|
||||||
|
const number = args[1];
|
||||||
|
if (!number)
|
||||||
|
return error(
|
||||||
|
message,
|
||||||
|
message.author,
|
||||||
|
p,
|
||||||
|
"gift",
|
||||||
|
"(User) **(Number)** (Item)",
|
||||||
|
`Missing 'Number' argument`
|
||||||
|
);
|
||||||
|
if (isNaN(number))
|
||||||
|
return error(
|
||||||
|
message,
|
||||||
|
message.author,
|
||||||
|
p,
|
||||||
|
"gift",
|
||||||
|
"(User) **(Number)** (Item)",
|
||||||
|
`'Number' argument must be a number`
|
||||||
|
);
|
||||||
|
*/
|
||||||
|
const itemToGift = args[1];
|
||||||
|
if (!itemToGift) return client.err(message, "Economy", "gift", 21);
|
||||||
|
const validItem = !!items.find(
|
||||||
|
item => item.alias.toLowerCase() === itemToGift
|
||||||
|
);
|
||||||
|
if (!validItem) return client.err(message, "Economy", "gift", 22);
|
||||||
|
const itemName = items.find(
|
||||||
|
item => item.alias.toLowerCase() === itemToGift
|
||||||
|
).item;
|
||||||
|
const params = {
|
||||||
|
User: message.author.id,
|
||||||
|
};
|
||||||
|
const param = {
|
||||||
|
User: user.id,
|
||||||
|
};
|
||||||
|
inventory.findOne(params, async (err, data) => {
|
||||||
|
if (data.Inventory) {
|
||||||
|
const hasItem = Object.keys(data.Inventory).includes(itemName);
|
||||||
|
if (hasItem) {
|
||||||
|
if (data.Inventory[itemName] <= 0) {
|
||||||
|
return client.err(message, "Economy", "gift", 23);
|
||||||
|
} else {
|
||||||
|
data.Inventory[itemName]--;
|
||||||
|
message.channel.send(
|
||||||
|
new MessageEmbed()
|
||||||
|
.setColor(client.color)
|
||||||
|
.setTimestamp()
|
||||||
|
.setDescription(
|
||||||
|
`**${message.author.username}** has given **${user.username}** a **${itemName}**`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
await inventory.findOneAndUpdate(params, data);
|
||||||
|
}
|
||||||
|
} else return client.err(message, "Economy", "gift", 24);
|
||||||
|
} else return client.err(message, "Economy", "gift", 24);
|
||||||
|
});
|
||||||
|
inventory.findOne(param, async (err, data) => {
|
||||||
|
if (data.Inventory) {
|
||||||
|
const hasItem = Object.keys(data.Inventory).includes(itemName);
|
||||||
|
if (!hasItem) {
|
||||||
|
data.Inventory[itemName] = 1;
|
||||||
|
} else {
|
||||||
|
data.Inventory[itemName]++;
|
||||||
|
}
|
||||||
|
await inventory.findOneAndUpdate(param, data);
|
||||||
|
} else {
|
||||||
|
new inventory({
|
||||||
|
User: user.id,
|
||||||
|
Inventory: {
|
||||||
|
[itemName]: 1,
|
||||||
|
},
|
||||||
|
}).save();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
45
commands/Economy/give.js
Normal file
45
commands/Economy/give.js
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "give",
|
||||||
|
aliases: ["share"],
|
||||||
|
timeout: 5000,
|
||||||
|
usage: "(User) (Number)",
|
||||||
|
description: "Give money to an user",
|
||||||
|
category: "Economy",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const user =
|
||||||
|
message.mentions.users.first() ||
|
||||||
|
message.guild.members.cache.find(
|
||||||
|
r => r.user.username.toLowerCase() === args[0].toLocaleLowerCase()
|
||||||
|
) ||
|
||||||
|
message.guild.members.cache.find(
|
||||||
|
r => r.displayName.toLowerCase() === args[0].toLocaleLowerCase()
|
||||||
|
);
|
||||||
|
if (!user) return client.err(message, "Economy", "give", 1);
|
||||||
|
const parsed = parseInt(args[1]);
|
||||||
|
if (!args[1]) return client.err(message, "Economy", "give", 5);
|
||||||
|
if (isNaN(parsed)) return client.err(message, "Economy", "give", 7);
|
||||||
|
if (user.id === message.author.id)
|
||||||
|
return client.err(message, "Economy", "give", 2);
|
||||||
|
if (parsed > (await client.data.bal(message.author.id))) {
|
||||||
|
return client.err(message, "Economy", "give", 20);
|
||||||
|
}
|
||||||
|
await client.data.rmv(message.author.id, parsed);
|
||||||
|
await client.data.add(user.id, parsed);
|
||||||
|
message.channel.send(
|
||||||
|
new MessageEmbed()
|
||||||
|
.setColor(client.color)
|
||||||
|
.setTimestamp()
|
||||||
|
.setDescription(
|
||||||
|
`**${message.author.username}** has given **${
|
||||||
|
user.username
|
||||||
|
}** **${parsed.toLocaleString()}**${client.currrency}`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
51
commands/Economy/inv.js
Normal file
51
commands/Economy/inv.js
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
const inv = require("../../models/econ");
|
||||||
|
const util = require("../../util/pagination");
|
||||||
|
module.exports = {
|
||||||
|
name: "inventory",
|
||||||
|
aliases: ["inv"],
|
||||||
|
description: "Check the inventory of an user",
|
||||||
|
usage: "{User}",
|
||||||
|
category: "Economy",
|
||||||
|
timeout: 5000,
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const p = await client.prefix(message);
|
||||||
|
const user =
|
||||||
|
message.mentions.users.first() ||
|
||||||
|
message.guild.members.cache.get(args[0]) ||
|
||||||
|
message.guild.members.cache.find(
|
||||||
|
r =>
|
||||||
|
r.user.username.toLowerCase() === args.join(" ").toLocaleLowerCase()
|
||||||
|
) ||
|
||||||
|
message.guild.members.cache.find(
|
||||||
|
r => r.displayName.toLowerCase() === args.join(" ").toLocaleLowerCase()
|
||||||
|
) ||
|
||||||
|
message.member;
|
||||||
|
inv.findOne({ User: user.id }, async (err, data) => {
|
||||||
|
if (!data.Inventory)
|
||||||
|
return client.err(message, "Economy", "inventory", 25);
|
||||||
|
const mappedData = Object.keys(data.Inventory).map(key => {
|
||||||
|
return `\n**${key}** — ${data.Inventory[key]}`;
|
||||||
|
});
|
||||||
|
const c = util.chunk(mappedData, 5).map(x => x.join("\n"));
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setTimestamp()
|
||||||
|
.setTitle(`${user.displayName}'s inventory`)
|
||||||
|
.setColor("client.color")
|
||||||
|
.setDescription(c[0])
|
||||||
|
.setFooter(`Page 1 of ${c.length}`);
|
||||||
|
try {
|
||||||
|
const msg = await message.channel.send(embed);
|
||||||
|
if (mappedData.length > 5)
|
||||||
|
await util.pagination(msg, message.author, c);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
39
commands/Economy/lb.js
Normal file
39
commands/Economy/lb.js
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
const Levels = require("discord-xp");
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "leaderboard",
|
||||||
|
aliases: ["lb"],
|
||||||
|
timeout: 5000,
|
||||||
|
usage: "Check the leaderboard of a server",
|
||||||
|
category: "Economy",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const rawLeaderboard = await Levels.fetchLeaderboard(message.guild.id, 10);
|
||||||
|
if (rawLeaderboard.length < 1)
|
||||||
|
return client.err(message, "Economy", "lb", 10);
|
||||||
|
const leaderboard = await Levels.computeLeaderboard(
|
||||||
|
client,
|
||||||
|
rawLeaderboard,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
const lb = leaderboard.map(
|
||||||
|
e =>
|
||||||
|
`**${e.position}**. ${e.username}#${e.discriminator} Level: ${
|
||||||
|
e.level
|
||||||
|
} XP: ${e.xp.toLocaleString()}`
|
||||||
|
);
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setTitle(`**Leaderboard for ${message.guild.name}**`)
|
||||||
|
.setDescription(`\n${lb.join("\n")}`)
|
||||||
|
.setFooter(
|
||||||
|
`Requested by ${message.author.tag}`,
|
||||||
|
message.author.displayAvatarURL({ dynamic: true })
|
||||||
|
)
|
||||||
|
.setColor(client.color);
|
||||||
|
message.inlineReply(embed);
|
||||||
|
},
|
||||||
|
};
|
33
commands/Economy/shop.js
Normal file
33
commands/Economy/shop.js
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
const util = require("../../util/pagination");
|
||||||
|
const items = require("../../util/item");
|
||||||
|
module.exports = {
|
||||||
|
name: "shop",
|
||||||
|
description: "Check the items from the shop",
|
||||||
|
category: "Economy",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const list = items.map((value, index) => {
|
||||||
|
return `**${value.item}** — ${value.price.toLocaleString()}${
|
||||||
|
client.currency
|
||||||
|
}\nID: \`${value.id}\``;
|
||||||
|
});
|
||||||
|
const c = util.chunk(list, 5).map(x => x.join("\n\n"));
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setTitle("**cath.exe shop**")
|
||||||
|
.setTimestamp()
|
||||||
|
.setDescription(c[0])
|
||||||
|
.setColor(client.color)
|
||||||
|
.setFooter(`Page 1 of ${c.length}`);
|
||||||
|
try {
|
||||||
|
const msg = await message.channel.send(embed);
|
||||||
|
if (list.length > 5) await util.pagination(msg, message.author, c);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
92
commands/Economy/slots.js
Normal file
92
commands/Economy/slots.js
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "slots",
|
||||||
|
usage: "(Number)",
|
||||||
|
timeout: 5000,
|
||||||
|
description: "Win more coins by slots",
|
||||||
|
category: "Economy",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const max = 1000000;
|
||||||
|
const slots = [
|
||||||
|
"<:dumbcat:818913965353730068>",
|
||||||
|
"<:nicecat:740978278055280722>",
|
||||||
|
"<:wah:836951911729987597>",
|
||||||
|
"<:startledcat:836619417550061580>",
|
||||||
|
];
|
||||||
|
const slotOne = slots[Math.floor(Math.random() * slots.length)];
|
||||||
|
const slotTwo = slots[Math.floor(Math.random() * slots.length)];
|
||||||
|
const slotThree = slots[Math.floor(Math.random() * slots.length)];
|
||||||
|
const slotfour = slots[Math.floor(Math.random() * slots.length)];
|
||||||
|
const slotfive = slots[Math.floor(Math.random() * slots.length)];
|
||||||
|
const slotsix = slots[Math.floor(Math.random() * slots.length)];
|
||||||
|
const slotseven = slots[Math.floor(Math.random() * slots.length)];
|
||||||
|
const sloteight = slots[Math.floor(Math.random() * slots.length)];
|
||||||
|
const slotnine = slots[Math.floor(Math.random() * slots.length)];
|
||||||
|
if (!args[0]) return client.err(message, "Economy", "slots", 5);
|
||||||
|
if (isNaN(args[0])) return client.err(message, "Economy", "slots", 7);
|
||||||
|
const amt = parseInt(args[0]);
|
||||||
|
if (amt > max) return client.err(message, "Economy", "slots", 101);
|
||||||
|
if ((await client.data.bal(message.author.id)) < amt) {
|
||||||
|
return client.err(message, "Economy", "slots", 20);
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
(slotOne === slotTwo && slotOne === slotThree) ||
|
||||||
|
(slotfour === slotfive && slotfour === slotsix) ||
|
||||||
|
(slotseven === sloteight && slotseven === slotnine)
|
||||||
|
) {
|
||||||
|
const winamt = Math.floor(Math.random() * 2 * amt);
|
||||||
|
await client.data.add(message.author.id, winamt);
|
||||||
|
const won = new MessageEmbed()
|
||||||
|
.setColor("GREEN")
|
||||||
|
.addField(
|
||||||
|
"|-----|-----|----|",
|
||||||
|
`| ${slotfour} | ${slotfive} | ${slotsix} |`
|
||||||
|
)
|
||||||
|
.addField(
|
||||||
|
"|-----|-----|----|",
|
||||||
|
`| ${slotOne} | ${slotTwo} | ${slotThree} |`
|
||||||
|
)
|
||||||
|
.addField(
|
||||||
|
"|-----|-----|----|",
|
||||||
|
`| ${slotseven} | ${sloteight} | ${slotnine} |`
|
||||||
|
)
|
||||||
|
.setTitle(`${message.author.username} wins a slots game`)
|
||||||
|
.setDescription(
|
||||||
|
`You win\n**${winamt}**${client.currency}\nYou now have **${
|
||||||
|
parseInt(await client.data.bal(message.author.id)) - amt
|
||||||
|
}**${client.currency}`
|
||||||
|
);
|
||||||
|
message.inlineReply(won);
|
||||||
|
console.log(`Coins: ${await client.data.bal(message.author.id)}`);
|
||||||
|
} else {
|
||||||
|
await client.data.rmv(message.author.id, amt);
|
||||||
|
const lost = new MessageEmbed()
|
||||||
|
.setColor("RED")
|
||||||
|
.addField(
|
||||||
|
"|-----|-----|----|",
|
||||||
|
`| ${slotfour} | ${slotfive} | ${slotsix} |`
|
||||||
|
)
|
||||||
|
.addField(
|
||||||
|
"|-----|-----|----|",
|
||||||
|
`| ${slotOne} | ${slotTwo} | ${slotThree} |`
|
||||||
|
)
|
||||||
|
.addField(
|
||||||
|
"|-----|-----|----|",
|
||||||
|
`| ${slotseven} | ${sloteight} | ${slotnine} |`
|
||||||
|
)
|
||||||
|
.setTitle(`${message.author.username} loses a slots game`)
|
||||||
|
.setDescription(
|
||||||
|
`You lose\n**${amt}**${client.currency}\nYou now have **${
|
||||||
|
parseInt(await client.data.bal(message.author.id)) - amt
|
||||||
|
}**${client.currency}`
|
||||||
|
);
|
||||||
|
message.inlineReply(lost);
|
||||||
|
console.log(`Coins: ${await client.data.bal(message.author.id)}`);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
122
commands/Economy/steal.js
Normal file
122
commands/Economy/steal.js
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
const db = require("../../models/econ");
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "steal",
|
||||||
|
description: "Steal money from an user",
|
||||||
|
usage: "(User)",
|
||||||
|
aliases: ["rob"],
|
||||||
|
category: "Economy",
|
||||||
|
timeout: 120000,
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
var tryrob =
|
||||||
|
message.mentions.users.first() ||
|
||||||
|
message.guild.members.cache.get(args[0]) ||
|
||||||
|
message.guild.members.cache.find(
|
||||||
|
r =>
|
||||||
|
r.user.username.toLowerCase() === args.join(" ").toLocaleLowerCase()
|
||||||
|
) ||
|
||||||
|
message.guild.members.cache.find(
|
||||||
|
r => r.displayName.toLowerCase() === args.join(" ").toLocaleLowerCase()
|
||||||
|
);
|
||||||
|
if (!tryrob || !args[0]) {
|
||||||
|
return client.err(message, "Economy", "steal", 1);
|
||||||
|
}
|
||||||
|
if (tryrob.id === message.author.id) {
|
||||||
|
return client.err(message, "Economy", "steal", 2);
|
||||||
|
}
|
||||||
|
await db.findOne({ User: message.author.id }, async (err, data) => {
|
||||||
|
if (err) throw err;
|
||||||
|
if (data) {
|
||||||
|
if (!data.CP) {
|
||||||
|
data.CP = 0;
|
||||||
|
data.save();
|
||||||
|
return client.err(message, "Economy", "steal", 20);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!data) {
|
||||||
|
new db({
|
||||||
|
User: message.author.id,
|
||||||
|
CP: 0,
|
||||||
|
Inventory: "",
|
||||||
|
}).save();
|
||||||
|
return client.err(message, "Economy", "steal", 20);
|
||||||
|
} else if (data) {
|
||||||
|
await db.findOne({ User: tryrob.id }, async (err1, data1) => {
|
||||||
|
const coins = Math.floor(Math.random() * data.CP) + 1;
|
||||||
|
const coins1 = Math.floor(Math.random() * data1.CP) + 1;
|
||||||
|
if (err1) throw err1;
|
||||||
|
if (!data1) {
|
||||||
|
new db({
|
||||||
|
User: tryrob.id,
|
||||||
|
CP: 0,
|
||||||
|
Inventory: "",
|
||||||
|
}).save();
|
||||||
|
return message.inlineReply(
|
||||||
|
new MessageEmbed()
|
||||||
|
.setAuthor(
|
||||||
|
message.author.tag,
|
||||||
|
message.author.displayAvatarURL({ dynamic: true })
|
||||||
|
)
|
||||||
|
.setColor("RED")
|
||||||
|
.setDescription(
|
||||||
|
`They don't have any ${client.currency}. Be kind!`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else if (data1) {
|
||||||
|
if (data1.CP <= 0 || !data1.CP) {
|
||||||
|
return message.inlineReply(
|
||||||
|
new MessageEmbed()
|
||||||
|
.setAuthor(
|
||||||
|
message.author.tag,
|
||||||
|
message.author.displayAvatarURL({ dynamic: true })
|
||||||
|
)
|
||||||
|
.setColor("RED")
|
||||||
|
.setDescription(
|
||||||
|
`They don't have any ${client.currency}. Be kind!`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (client.function.random() === true) {
|
||||||
|
data.CP += coins1;
|
||||||
|
data.save();
|
||||||
|
data1.CP -= coins1;
|
||||||
|
data1.save();
|
||||||
|
return message.inlineReply(
|
||||||
|
new MessageEmbed()
|
||||||
|
.setAuthor(
|
||||||
|
message.author.tag,
|
||||||
|
message.author.displayAvatarURL({ dynamic: true })
|
||||||
|
)
|
||||||
|
.setColor("GREEN")
|
||||||
|
.setDescription(
|
||||||
|
`You robbed ${tryrob}! And you got \`${coins}\`${client.currency}`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
data.CP -= coins;
|
||||||
|
data.save();
|
||||||
|
data1.CP += coins;
|
||||||
|
data1.save();
|
||||||
|
return message.inlineReply(
|
||||||
|
new MessageEmbed()
|
||||||
|
.setAuthor(
|
||||||
|
message.author.tag,
|
||||||
|
message.author.displayAvatarURL({ dynamic: true })
|
||||||
|
)
|
||||||
|
.setColor("RED")
|
||||||
|
.setDescription(
|
||||||
|
`You failed on robbing ${tryrob}! And you had to pay him/her \`${coins}\`${client.currency}`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
29
commands/Economy/work.js
Normal file
29
commands/Economy/work.js
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
require("../../inlinereply");
|
||||||
|
module.exports = {
|
||||||
|
name: "work",
|
||||||
|
description: "Work to earn money",
|
||||||
|
category: "Economy",
|
||||||
|
timeout: 1000 * 60 * 10,
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const job = [
|
||||||
|
"Software engineer",
|
||||||
|
"Programmer",
|
||||||
|
"Teacher",
|
||||||
|
"YouTuber",
|
||||||
|
"Student",
|
||||||
|
"Desginer",
|
||||||
|
"Editor",
|
||||||
|
"Banker",
|
||||||
|
];
|
||||||
|
const earning = client.function.rndint(5000, 3000);
|
||||||
|
const jobs = job[Math.floor(Math.random() * job.length)];
|
||||||
|
await client.data.add(message.author.id, earning);
|
||||||
|
return message.inlineReply(`You worked as a ${jobs} and earned ${earning}`);
|
||||||
|
},
|
||||||
|
};
|
30
commands/Fun/cat.js
Normal file
30
commands/Fun/cat.js
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
const api = require("imageapi.js");
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "cat",
|
||||||
|
aliases: ["cats"],
|
||||||
|
category: "Fun",
|
||||||
|
description: "A cat command",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const wait = await message.inlineReply("Getting cat picture...");
|
||||||
|
let subreddits = ["cat", "cats"];
|
||||||
|
let subreddit = subreddits[Math.floor(Math.random() * subreddits.length)];
|
||||||
|
const img = await api(subreddit).catch(err => console.log(err));
|
||||||
|
const Embed = new MessageEmbed()
|
||||||
|
.setTitle(`A cat picture from r/${subreddit}`)
|
||||||
|
.setURL(`https://reddit.com/r/${subreddit}`)
|
||||||
|
.setColor(client.color)
|
||||||
|
.setImage(img)
|
||||||
|
.setTimestamp()
|
||||||
|
.setAuthor(
|
||||||
|
message.author.tag,
|
||||||
|
message.author.displayAvatarURL({ dynamic: true })
|
||||||
|
);
|
||||||
|
wait.edit("", { embed: Embed });
|
||||||
|
},
|
||||||
|
};
|
22
commands/Fun/coinflip.js
Normal file
22
commands/Fun/coinflip.js
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "coinflip",
|
||||||
|
aliases: ["cf"],
|
||||||
|
description: "Flip a coin",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
let HT = ["Heads!", "Tails!"];
|
||||||
|
let pick = HT[Math.floor(Math.random() * HT.length)];
|
||||||
|
let embed = new MessageEmbed()
|
||||||
|
.setColor(client.color)
|
||||||
|
.setTitle("CoinFilp Game")
|
||||||
|
.setTimestamp()
|
||||||
|
.setFooter(`Made by Cath Team`)
|
||||||
|
.setDescription(pick);
|
||||||
|
message.inlineReply(embed);
|
||||||
|
},
|
||||||
|
};
|
309
commands/Fun/connect4.js
Normal file
309
commands/Fun/connect4.js
Normal file
|
@ -0,0 +1,309 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "connect4",
|
||||||
|
aliases: ["c4"],
|
||||||
|
usage: "(User)",
|
||||||
|
description: "Play a connect 4 game with a user",
|
||||||
|
category: "Fun",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const challenger = message.member;
|
||||||
|
const oppenent = message.mentions.members.first();
|
||||||
|
|
||||||
|
if (!oppenent) return client.err(message, "Fun", "connect4", 1);
|
||||||
|
|
||||||
|
const question = await message.channel.send(
|
||||||
|
`${oppenent}, would you like to play connect 4 against ${challenger}?`
|
||||||
|
);
|
||||||
|
|
||||||
|
["✅", "❌"].forEach(async el => await question.react(el));
|
||||||
|
|
||||||
|
const filter = (reaction, user) =>
|
||||||
|
["✅", "❌"].includes(reaction.emoji.name) && user.id === oppenent.id;
|
||||||
|
|
||||||
|
const response = await question.awaitReactions(filter, { max: 1 });
|
||||||
|
|
||||||
|
const reaction = response.first();
|
||||||
|
|
||||||
|
if (reaction.emoji.name === "❌")
|
||||||
|
return question.edit("Looks like they didn't want to play");
|
||||||
|
else {
|
||||||
|
await message.delete();
|
||||||
|
await question.delete();
|
||||||
|
|
||||||
|
const board = [
|
||||||
|
["⚪", "⚪", "⚪", "⚪", "⚪", "⚪", "⚪"],
|
||||||
|
["⚪", "⚪", "⚪", "⚪", "⚪", "⚪", "⚪"],
|
||||||
|
["⚪", "⚪", "⚪", "⚪", "⚪", "⚪", "⚪"],
|
||||||
|
["⚪", "⚪", "⚪", "⚪", "⚪", "⚪", "⚪"],
|
||||||
|
["⚪", "⚪", "⚪", "⚪", "⚪", "⚪", "⚪"],
|
||||||
|
["⚪", "⚪", "⚪", "⚪", "⚪", "⚪", "⚪"],
|
||||||
|
];
|
||||||
|
|
||||||
|
const renderBoard = board => {
|
||||||
|
let tempString = "";
|
||||||
|
for (const boardSection of board) {
|
||||||
|
tempString += `${boardSection.join("")}\n`;
|
||||||
|
}
|
||||||
|
|
||||||
|
tempString = tempString.concat("1️⃣2️⃣3️⃣4️⃣5️⃣6️⃣7️⃣");
|
||||||
|
|
||||||
|
return tempString;
|
||||||
|
};
|
||||||
|
|
||||||
|
const initialState = renderBoard(board);
|
||||||
|
|
||||||
|
const initial = new MessageEmbed().setDescription(initialState);
|
||||||
|
|
||||||
|
const gameMessage = await message.channel.send(initial);
|
||||||
|
|
||||||
|
["1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣"].forEach(async el =>
|
||||||
|
gameMessage.react(el)
|
||||||
|
);
|
||||||
|
|
||||||
|
const gameFilter = (reaction, user) =>
|
||||||
|
["1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣"].includes(
|
||||||
|
reaction.emoji.name
|
||||||
|
) &&
|
||||||
|
(user.id === oppenent.id || user.id === challenger.id);
|
||||||
|
|
||||||
|
const gameCollector = gameMessage.createReactionCollector(gameFilter);
|
||||||
|
|
||||||
|
const gameData = [
|
||||||
|
{ member: challenger, playerColor: "🔴" },
|
||||||
|
{ member: oppenent, playerColor: "🟡" },
|
||||||
|
];
|
||||||
|
|
||||||
|
let player = 0;
|
||||||
|
|
||||||
|
const checkFour = (a, b, c, d) =>
|
||||||
|
a === b && b === c && c === d && a !== "⚪";
|
||||||
|
|
||||||
|
const horizontalCheck = () => {
|
||||||
|
for (let i = 0; i < 6; i++) {
|
||||||
|
for (let j = 0; j < 4; j++) {
|
||||||
|
if (
|
||||||
|
checkFour(
|
||||||
|
board[i][j],
|
||||||
|
board[i][j + 1],
|
||||||
|
board[i][j + 2],
|
||||||
|
board[i][j + 3]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return [
|
||||||
|
board[i][j],
|
||||||
|
board[i][j + 1],
|
||||||
|
board[i][j + 2],
|
||||||
|
board[i][j + 3],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const verticalCheck = () => {
|
||||||
|
for (let j = 0; j < 7; j++) {
|
||||||
|
for (let i = 0; i < 3; i++) {
|
||||||
|
if (
|
||||||
|
checkFour(
|
||||||
|
board[i][j],
|
||||||
|
board[i + 1][j],
|
||||||
|
board[i + 2][j],
|
||||||
|
board[i + 3][j]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return [
|
||||||
|
board[i][j],
|
||||||
|
board[i + 1][j],
|
||||||
|
board[i + 2][j],
|
||||||
|
board[i + 3][j],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const diagonal1 = () => {
|
||||||
|
for (let col = 0; col < 4; col++) {
|
||||||
|
for (let row = 0; row < 3; row++) {
|
||||||
|
if (
|
||||||
|
checkFour(
|
||||||
|
board[row][col],
|
||||||
|
board[row + 1][col + 1],
|
||||||
|
board[row + 2][col + 2],
|
||||||
|
board[row + 3][col + 3]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return [
|
||||||
|
board[row][col],
|
||||||
|
board[row + 1][col + 1],
|
||||||
|
board[row + 2],
|
||||||
|
board[col + 2],
|
||||||
|
board[row + 3][col + 3],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const diagonal2 = () => {
|
||||||
|
for (let col = 0; col < 4; col++) {
|
||||||
|
for (let row = 5; row > 2; row--) {
|
||||||
|
if (
|
||||||
|
checkFour(
|
||||||
|
board[row][col],
|
||||||
|
board[row - 1][col + 1],
|
||||||
|
board[row - 2][col + 2],
|
||||||
|
board[row - 3][col + 3]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return [
|
||||||
|
board[row][col],
|
||||||
|
board[row - 1][col + 1],
|
||||||
|
board[row - 2][col + 2],
|
||||||
|
board[row - 3][col + 3],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const tieCheck = () => {
|
||||||
|
let count = 0;
|
||||||
|
for (const el of board) {
|
||||||
|
for (const string of el) {
|
||||||
|
if (string !== "⚪") count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (count === 42) return true;
|
||||||
|
else return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
const checks = [horizontalCheck, verticalCheck, diagonal1, diagonal2];
|
||||||
|
|
||||||
|
gameCollector.on("collect", (reaction, user) => {
|
||||||
|
if (user.id === gameData[player].member.id) {
|
||||||
|
const openSpaces = [];
|
||||||
|
|
||||||
|
switch (reaction.emoji.name) {
|
||||||
|
case "1️⃣":
|
||||||
|
for (let i = 5; i > -1; i--) {
|
||||||
|
if (board[i][0] === "⚪") openSpaces.push({ i, j: 0 });
|
||||||
|
}
|
||||||
|
if (openSpaces.length === 0)
|
||||||
|
return message.channel.send(
|
||||||
|
`${gameData[player].member}, that column is already full. Choose a differnt one.`
|
||||||
|
);
|
||||||
|
else
|
||||||
|
board[openSpaces[0].i][openSpaces[0].j] =
|
||||||
|
gameData[player].playerColor;
|
||||||
|
|
||||||
|
break;
|
||||||
|
case "2️⃣":
|
||||||
|
for (let i = 5; i > -1; i--) {
|
||||||
|
if (board[i][1] === "⚪") openSpaces.push({ i, j: 1 });
|
||||||
|
}
|
||||||
|
if (openSpaces.length === 0)
|
||||||
|
return message.channel.send(
|
||||||
|
`${gameData[player].member}, that column is already full. Choose a differnt one.`
|
||||||
|
);
|
||||||
|
else
|
||||||
|
board[openSpaces[0].i][openSpaces[0].j] =
|
||||||
|
gameData[player].playerColor;
|
||||||
|
|
||||||
|
break;
|
||||||
|
case "3️⃣":
|
||||||
|
for (let i = 5; i > -1; i--) {
|
||||||
|
if (board[i][2] === "⚪") openSpaces.push({ i, j: 2 });
|
||||||
|
}
|
||||||
|
if (openSpaces.length === 0)
|
||||||
|
return message.channel.send(
|
||||||
|
`${gameData[player].member}, that column is already full. Choose a differnt one.`
|
||||||
|
);
|
||||||
|
else
|
||||||
|
board[openSpaces[0].i][openSpaces[0].j] =
|
||||||
|
gameData[player].playerColor;
|
||||||
|
break;
|
||||||
|
case "4️⃣":
|
||||||
|
for (let i = 5; i > -1; i--) {
|
||||||
|
if (board[i][3] === "⚪") openSpaces.push({ i, j: 3 });
|
||||||
|
}
|
||||||
|
if (openSpaces.length === 0)
|
||||||
|
return message.channel.send(
|
||||||
|
`${gameData[player].member}, that column is already full. Choose a differnt one.`
|
||||||
|
);
|
||||||
|
else
|
||||||
|
board[openSpaces[0].i][openSpaces[0].j] =
|
||||||
|
gameData[player].playerColor;
|
||||||
|
break;
|
||||||
|
case "5️⃣":
|
||||||
|
for (let i = 5; i > -1; i--) {
|
||||||
|
if (board[i][4] === "⚪") openSpaces.push({ i, j: 4 });
|
||||||
|
}
|
||||||
|
if (openSpaces.length === 0)
|
||||||
|
return message.channel.send(
|
||||||
|
`${gameData[player].member}, that column is already full. Choose a differnt one.`
|
||||||
|
);
|
||||||
|
else
|
||||||
|
board[openSpaces[0].i][openSpaces[0].j] =
|
||||||
|
gameData[player].playerColor;
|
||||||
|
break;
|
||||||
|
case "6️⃣":
|
||||||
|
for (let i = 5; i > -1; i--) {
|
||||||
|
if (board[i][5] === "⚪") openSpaces.push({ i, j: 5 });
|
||||||
|
}
|
||||||
|
if (openSpaces.length === 0)
|
||||||
|
return message.channel.send(
|
||||||
|
`${gameData[player].member}, that column is already full. Choose a differnt one.`
|
||||||
|
);
|
||||||
|
else
|
||||||
|
board[openSpaces[0].i][openSpaces[0].j] =
|
||||||
|
gameData[player].playerColor;
|
||||||
|
break;
|
||||||
|
case "7️⃣":
|
||||||
|
for (let i = 5; i > -1; i--) {
|
||||||
|
if (board[i][6] === "⚪") openSpaces.push({ i, j: 6 });
|
||||||
|
}
|
||||||
|
if (openSpaces.length === 0)
|
||||||
|
return message.channel.send(
|
||||||
|
`${gameData[player].member}, that column is already full. Choose a differnt one.`
|
||||||
|
);
|
||||||
|
else
|
||||||
|
board[openSpaces[0].i][openSpaces[0].j] =
|
||||||
|
gameData[player].playerColor;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tieCheck()) {
|
||||||
|
const TieEmbed = new MessageEmbed().setDescription(
|
||||||
|
renderBoard(board)
|
||||||
|
);
|
||||||
|
gameCollector.stop("Tie Game");
|
||||||
|
return gameMessage.edit(`It was a tie game!`, { embed: TieEmbed });
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const func of checks) {
|
||||||
|
const data = func();
|
||||||
|
if (data) {
|
||||||
|
const WinEmbed = new MessageEmbed().setDescription(
|
||||||
|
renderBoard(board)
|
||||||
|
);
|
||||||
|
gameCollector.stop(`${gameData[player].member.id} won`);
|
||||||
|
return gameMessage.edit(
|
||||||
|
`${gameData[player].member} has won the game!`,
|
||||||
|
{ embed: WinEmbed }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
player = (player + 1) % 2;
|
||||||
|
|
||||||
|
const newEmbed = new MessageEmbed().setDescription(
|
||||||
|
renderBoard(board)
|
||||||
|
);
|
||||||
|
gameMessage.edit("", { embed: newEmbed });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
30
commands/Fun/dog.js
Normal file
30
commands/Fun/dog.js
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
const api = require("imageapi.js");
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "dog",
|
||||||
|
aliases: ["dogs"],
|
||||||
|
category: "Fun",
|
||||||
|
description: "A dog command",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const wait = await message.inlineReply("Getting dog picture...");
|
||||||
|
let subreddits = ["dog", "dogs"];
|
||||||
|
let subreddit = subreddits[Math.floor(Math.random() * subreddits.length)];
|
||||||
|
const img = await api(subreddit).catch(err => console.log(err));
|
||||||
|
const Embed = new MessageEmbed()
|
||||||
|
.setTitle(`A dog picture from r/${subreddit}`)
|
||||||
|
.setURL(`https://reddit.com/r/${subreddit}`)
|
||||||
|
.setColor(client.color)
|
||||||
|
.setImage(img)
|
||||||
|
.setTimestamp()
|
||||||
|
.setAuthor(
|
||||||
|
message.author.tag,
|
||||||
|
message.author.displayAvatarURL({ dynamic: true })
|
||||||
|
);
|
||||||
|
wait.edit("", { embed: Embed });
|
||||||
|
},
|
||||||
|
};
|
92
commands/Fun/hangman.js
Normal file
92
commands/Fun/hangman.js
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
const { stripIndents } = require("common-tags");
|
||||||
|
const { get } = require("node-superfetch");
|
||||||
|
const playing = new Set();
|
||||||
|
module.exports = {
|
||||||
|
name: "hangman",
|
||||||
|
description: "Play a hangman game",
|
||||||
|
category: "Fun",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
if (playing.has(message.channel.id))
|
||||||
|
return message.reply("Only one game may be occurring per channel.");
|
||||||
|
playing.add(message.channel.id);
|
||||||
|
try {
|
||||||
|
const { body } = await get("https://emilia-api.xyz/api/hangman").set(
|
||||||
|
"Authorization",
|
||||||
|
`Bearer MzU2MDA1NzA4MTQ5NTU1MjAy.5r4BVOkZX8L1ial8chloqopkphU0w19us0UbqgxOQOo`
|
||||||
|
);
|
||||||
|
const word = body.word;
|
||||||
|
let points = 0;
|
||||||
|
let displayText = null;
|
||||||
|
let guessed = false;
|
||||||
|
const confirmation = [];
|
||||||
|
const incorrect = [];
|
||||||
|
const display = new Array(word.length).fill("◯");
|
||||||
|
while (word.length !== confirmation.length && points < 6) {
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setColor(client.color)
|
||||||
|
.setTitle("Hangman game").setDescription(stripIndents`
|
||||||
|
${displayText === null ? "Here we go!" : displayText ? "Good job!" : "Nope!"}
|
||||||
|
\`${display.join(" ")}\`. Which letter do you choose?
|
||||||
|
Incorrect Tries: ${incorrect.join(", ") || "None"}
|
||||||
|
\`\`\`
|
||||||
|
. ┌─────┐
|
||||||
|
. ┃ ┋
|
||||||
|
. ┃ ${points > 0 ? "O" : ""}
|
||||||
|
. ┃ ${points > 2 ? "/" : " "}${points > 1 ? "|" : ""}${
|
||||||
|
points > 3 ? "\\" : ""
|
||||||
|
}
|
||||||
|
. ┃ ${points > 4 ? "/" : ""}${points > 5 ? "\\" : ""}
|
||||||
|
=============
|
||||||
|
\`\`\`
|
||||||
|
`);
|
||||||
|
let m = await message.channel.send(embed);
|
||||||
|
const filter = res => {
|
||||||
|
const choice = res.content.toLowerCase();
|
||||||
|
return (
|
||||||
|
res.author.id === message.author.id &&
|
||||||
|
!confirmation.includes(choice) &&
|
||||||
|
!incorrect.includes(choice)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
const guess = await message.channel.awaitMessages(filter, {
|
||||||
|
max: 1,
|
||||||
|
time: 30000,
|
||||||
|
});
|
||||||
|
//m.delete();
|
||||||
|
if (!guess.size) {
|
||||||
|
await message.reply("Sorry, time is up!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const choice = guess.first().content.toLowerCase();
|
||||||
|
if (choice === "end") break;
|
||||||
|
if (choice.length > 1 && choice === word) {
|
||||||
|
guessed = true;
|
||||||
|
break;
|
||||||
|
} else if (word.includes(choice)) {
|
||||||
|
displayText = true;
|
||||||
|
for (let i = 0; i < word.length; i++) {
|
||||||
|
if (word.charAt(i) !== choice) continue; // eslint-disable-line max-depth
|
||||||
|
confirmation.push(word.charAt(i));
|
||||||
|
display[i] = word.charAt(i);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
displayText = false;
|
||||||
|
if (choice.length === 1) incorrect.push(choice);
|
||||||
|
points++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
playing.delete(message.channel.id);
|
||||||
|
if (word.length === confirmation.length || guessed)
|
||||||
|
return message.channel.send(`You won. The word is **${word}**!`);
|
||||||
|
return message.channel.send(`You lost. The word is **${word}**.`);
|
||||||
|
} catch (err) {
|
||||||
|
playing.delete(message.channel.id);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
34
commands/Fun/hug.js
Normal file
34
commands/Fun/hug.js
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "hug",
|
||||||
|
usage: "(User)",
|
||||||
|
description: "Hug someone",
|
||||||
|
category: "Fun",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const words = args.slice(1).join(" ");
|
||||||
|
const user =
|
||||||
|
message.mentions.users.first() ||
|
||||||
|
message.guild.members.cache.get(args[0]);
|
||||||
|
if (!user) {
|
||||||
|
return client.err(message, "Fun", "hug", 1);
|
||||||
|
}
|
||||||
|
if (user.id === message.author.id) {
|
||||||
|
return client.err(message, "Fun", "hug", 33);
|
||||||
|
}
|
||||||
|
const embed = new MessageEmbed();
|
||||||
|
embed.setDescription(`${message.author} **hugs** ${user}`);
|
||||||
|
if (words) {
|
||||||
|
embed.addField("Words:", reason);
|
||||||
|
}
|
||||||
|
embed.setImage(
|
||||||
|
`https://media.tenor.com/images/ca88f916b116711c60bb23b8eb608694/tenor.gif`
|
||||||
|
);
|
||||||
|
embed.setColor(client.color);
|
||||||
|
message.inlineReply(embed).then(msg => msg.react("💕"));
|
||||||
|
},
|
||||||
|
};
|
34
commands/Fun/kiss.js
Normal file
34
commands/Fun/kiss.js
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "kiss",
|
||||||
|
usage: "(User)",
|
||||||
|
description: "Kiss someone",
|
||||||
|
category: "Fun",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const words = args.slice(1).join(" ");
|
||||||
|
const user =
|
||||||
|
message.mentions.users.first() ||
|
||||||
|
message.guild.members.cache.get(args[0]);
|
||||||
|
if (!user) {
|
||||||
|
return client.err(message, "Fun", "kiss", 1);
|
||||||
|
}
|
||||||
|
if (user.id === message.author.id) {
|
||||||
|
return client.err(message, "Fun", "kiss", 33);
|
||||||
|
}
|
||||||
|
const embed = new MessageEmbed();
|
||||||
|
embed.setDescription(`${message.author} **kisses** ${user}`);
|
||||||
|
if (words) {
|
||||||
|
embed.addField("Words: ", words);
|
||||||
|
}
|
||||||
|
embed.setImage(
|
||||||
|
`https://media.discordapp.net/attachments/814310468906123274/817656819416825896/image0.gif`
|
||||||
|
);
|
||||||
|
embed.setColor(client.color);
|
||||||
|
message.inlineReply(embed).then(msg => msg.react("💕"));
|
||||||
|
},
|
||||||
|
};
|
30
commands/Fun/meme.js
Normal file
30
commands/Fun/meme.js
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
const api = require("imageapi.js");
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "meme",
|
||||||
|
aliases: ["memes"],
|
||||||
|
category: "Fun",
|
||||||
|
description: "A meme command",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const wait = await message.inlineReply("Getting meme...");
|
||||||
|
let subreddits = ["comedyheaven", "dank", "meme", "memes"];
|
||||||
|
let subreddit = subreddits[Math.floor(Math.random() * subreddits.length)];
|
||||||
|
const img = await api(subreddit).catch(err => console.log(err));
|
||||||
|
const Embed = new MessageEmbed()
|
||||||
|
.setTitle(`A meme from r/${subreddit}`)
|
||||||
|
.setURL(`https://reddit.com/r/${subreddit}`)
|
||||||
|
.setColor(client.color)
|
||||||
|
.setImage(img)
|
||||||
|
.setTimestamp()
|
||||||
|
.setAuthor(
|
||||||
|
message.author.tag,
|
||||||
|
message.author.displayAvatarURL({ dynamic: true })
|
||||||
|
);
|
||||||
|
wait.edit("", { embed: Embed });
|
||||||
|
},
|
||||||
|
};
|
17
commands/Fun/say.js
Normal file
17
commands/Fun/say.js
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
const { Client, Message, Util } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "say",
|
||||||
|
description: "Pretend a bot to say",
|
||||||
|
usage: "(Words)",
|
||||||
|
category: "Fun",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
if (!args.length) return;
|
||||||
|
message.delete();
|
||||||
|
return message.channel.send(Util.cleanContent(args.join(" "), message));
|
||||||
|
},
|
||||||
|
};
|
31
commands/Fun/simprate.js
Normal file
31
commands/Fun/simprate.js
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "simprate",
|
||||||
|
aliases: ["simp"],
|
||||||
|
description: "Check how simp is the user",
|
||||||
|
usage: "(@User)",
|
||||||
|
category: "Fun",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
let simp = Math.floor(Math.random() * 100);
|
||||||
|
if (message.mentions.users.first()) {
|
||||||
|
let target = message.mentions.users.first();
|
||||||
|
message.inlineReply(
|
||||||
|
new MessageEmbed()
|
||||||
|
.setTitle(`${target.username}'s simp rate`)
|
||||||
|
.setDescription(`${target.username} is a ${simp}% simp`)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
const target = message.author;
|
||||||
|
message.inlineReply(
|
||||||
|
new MessageEmbed()
|
||||||
|
.setTitle(`${target.username}'s simp rate`)
|
||||||
|
.setDescription(`You are a ${simp}% simp`)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
22
commands/Giveaway/end.js
Normal file
22
commands/Giveaway/end.js
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "gend",
|
||||||
|
UserPerm: "MANAGE_MESSAGES",
|
||||||
|
usage: "(Message ID)",
|
||||||
|
description: "End a giveaway",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
if (!args[0]) return client.err(message, "Giveaway", "end", 27);
|
||||||
|
const giveaway = client.giveaways.giveaways.find(
|
||||||
|
g => g.messageID === args.join(" ")
|
||||||
|
);
|
||||||
|
if (!giveaway) return client.err(message, "Giveaway", "end", 26);
|
||||||
|
client.giveaways.edit(giveaway.messageID, {
|
||||||
|
setEndTimestamp: Date.now(),
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
52
commands/Giveaway/giveaway.js
Normal file
52
commands/Giveaway/giveaway.js
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
const ms = require("ms");
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "giveaway",
|
||||||
|
aliases: ["gstart"],
|
||||||
|
description: "Start a giveaway",
|
||||||
|
usage: "(Channel) (Time) (Winners(Number)) (Prize)",
|
||||||
|
UserPerm: "MANAGE_MESSAGES",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const channel = message.mentions.channels.first();
|
||||||
|
if (!channel) return client.err(message, "Giveaway", "giveaway", 28);
|
||||||
|
const duration = args[1];
|
||||||
|
if (!duration) return client.err(message, "Giveaway", "giveaway", 29);
|
||||||
|
const winners = parseInt(args[2]);
|
||||||
|
if (!winners) return client.err(message, "Giveaway", "giveaway", 30);
|
||||||
|
if (isNaN(winners)) return client.err(message, "Giveaway", "giveaway", 31);
|
||||||
|
const prize = args.slice(3).join(" ");
|
||||||
|
if (!prize) return client.err(message, "Giveaway", "giveaway", 32);
|
||||||
|
client.giveaways.start(channel, {
|
||||||
|
time: ms(duration),
|
||||||
|
prize: prize,
|
||||||
|
winnerCount: winners,
|
||||||
|
hostedBy: message.author,
|
||||||
|
messages: {
|
||||||
|
giveaway: "🎉🎉 **GIVEAWAY** 🎉🎉",
|
||||||
|
giveawayEnded: "🎉🎉 **GIVEAWAY ENDED** 🎉🎉",
|
||||||
|
timeRemaining: "Time Remaining **{duration}**!",
|
||||||
|
inviteToParticipate: "React with 🎉 to enter!",
|
||||||
|
winMessage: `Congratulations {winners}! You won the **${prize}**!`,
|
||||||
|
noWinner: "Could not determine a winner!",
|
||||||
|
embedFooter: "Made by Ń1ght",
|
||||||
|
hostedBy: "Hosted by: {user}",
|
||||||
|
winners: "Winner(s)",
|
||||||
|
messageURL: "",
|
||||||
|
endedAt: "Ends at",
|
||||||
|
units: {
|
||||||
|
seconds: "seconds",
|
||||||
|
minutes: "minutes",
|
||||||
|
hours: "hours",
|
||||||
|
days: "days",
|
||||||
|
pluralS: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
message.inlineReply(`Giveaway is started in ${channel}`);
|
||||||
|
},
|
||||||
|
};
|
21
commands/Giveaway/reroll.js
Normal file
21
commands/Giveaway/reroll.js
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "reroll",
|
||||||
|
aliases: ["greroll"],
|
||||||
|
usage: "(Message ID)",
|
||||||
|
description: "Reroll a giveaway",
|
||||||
|
UserPerm: "MANAGE_MESSAGES",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
if (!args[0]) return client.err(message, "Giveaway", "reroll", 27);
|
||||||
|
const giveaway = client.giveaways.giveaways.find(
|
||||||
|
g => g.messageID === args[0]
|
||||||
|
);
|
||||||
|
if (!giveaway) return client.err(message, "Giveaway", "reroll", 26);
|
||||||
|
client.giveaways.reroll(giveaway.messageID);
|
||||||
|
},
|
||||||
|
};
|
45
commands/Moderation/announce.js
Normal file
45
commands/Moderation/announce.js
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "announce",
|
||||||
|
UserPerm: "MANAGE_MESSAGES",
|
||||||
|
BotPerm: "MANAGE_MESSAGES",
|
||||||
|
usage: "{Channel} (Message)",
|
||||||
|
description: "Announce a message to a channel.",
|
||||||
|
category: "Moderation",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const channel = message.mentions.channels.first() || message.channel;
|
||||||
|
if (!args[0]) return client.err(message, "Moderation", "announce", 4);
|
||||||
|
try {
|
||||||
|
message.delete();
|
||||||
|
channel.send(
|
||||||
|
new MessageEmbed()
|
||||||
|
.setAuthor(
|
||||||
|
`Sent by ${message.member.displayName}`,
|
||||||
|
message.author.displayAvatarURL({ dynamic: true })
|
||||||
|
)
|
||||||
|
.setDescription(args.slice(0).join(" "))
|
||||||
|
.setTimestamp()
|
||||||
|
.setColor(client.color)
|
||||||
|
);
|
||||||
|
message.inlineReply(
|
||||||
|
new MessageEmbed()
|
||||||
|
.setTitle(`Message Announced`)
|
||||||
|
.addField("**Moderator**", message.author.tag, true)
|
||||||
|
.setTimestamp()
|
||||||
|
.setFooter(
|
||||||
|
message.member.displayName,
|
||||||
|
message.author.displayAvatarURL({ dynamic: true })
|
||||||
|
)
|
||||||
|
.setColor(client.color)
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
return client.err(message, "Moderation", "announce", 999);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
59
commands/Moderation/ban.js
Normal file
59
commands/Moderation/ban.js
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "ban",
|
||||||
|
description: "Ban an user",
|
||||||
|
BotPerm: "BAN_MEMBERS",
|
||||||
|
UserPerm: "BAN_MEMBERS",
|
||||||
|
usage: "(User) {Reason}",
|
||||||
|
category: "Moderation",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
let target =
|
||||||
|
message.mentions.members.first() ||
|
||||||
|
message.guild.members.cache.get(args[0]);
|
||||||
|
let reason = args.slice(1).join(" ") || "No reason provided";
|
||||||
|
if (!target) {
|
||||||
|
try {
|
||||||
|
target = await client.users.fetch(args[0]);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
return client.err(message, "Moderation", "ban", 1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (target.id === message.author.id)
|
||||||
|
return client.err(message, "Moderation", "ban", 2);
|
||||||
|
if (message.member.roles.highest.position < target.roles.highest.position)
|
||||||
|
return client.err(message, "Moderation", "ban", 8);
|
||||||
|
if (
|
||||||
|
message.guild.me.roles.highest.position < target.roles.highest.position
|
||||||
|
)
|
||||||
|
return client.err(message, "Moderation", "ban", 9);
|
||||||
|
}
|
||||||
|
if (reason.length > 1024) reason = reason.slice(0, 1021) + "...";
|
||||||
|
try {
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setTitle("User Banned")
|
||||||
|
.addField("**Moderator**", message.author.tag, true)
|
||||||
|
.addField("**User**", target.user.tag, true)
|
||||||
|
.addField("**Reason**", reason, true)
|
||||||
|
.setFooter(
|
||||||
|
message.member.displayName || message.author.username,
|
||||||
|
message.author.displayAvatarURL({ dynamic: true })
|
||||||
|
)
|
||||||
|
.setThumbnail(client.user.displayAvatarURL())
|
||||||
|
.setColor(client.color)
|
||||||
|
.setTimestamp();
|
||||||
|
message.inlineReply(embed);
|
||||||
|
await message.guild.members.ban(target.id, {
|
||||||
|
reason: reason,
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
return client.err(message, "Moderation", "ban", 999);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
47
commands/Moderation/clear.js
Normal file
47
commands/Moderation/clear.js
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
const ms = require("ms");
|
||||||
|
module.exports = {
|
||||||
|
name: "purge",
|
||||||
|
aliases: ["clear", "c"],
|
||||||
|
UserPerm: "MANAGE_MESSAGES",
|
||||||
|
BotPerm: "MANAGE_MESSAGES",
|
||||||
|
description: "Clear/Purge 1-100 messages in the channel",
|
||||||
|
usage: "(Number)",
|
||||||
|
category: "Moderation",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
if (
|
||||||
|
!args[0] ||
|
||||||
|
isNaN(args[0]) ||
|
||||||
|
parseInt(args[0]) > 100 ||
|
||||||
|
parseInt(args[0] < 0)
|
||||||
|
)
|
||||||
|
return client.err(message, "Moderation", "clear", 7);
|
||||||
|
const messages = await message.channel.messages.fetch({
|
||||||
|
limit: parseInt(args[0]),
|
||||||
|
});
|
||||||
|
const usable = messages.filter(
|
||||||
|
m => m.createdTimestamp - Date.now() < ms("14d") && !m.pinned
|
||||||
|
);
|
||||||
|
await message.delete();
|
||||||
|
await message.channel.bulkDelete(usable).then(() =>
|
||||||
|
message.channel
|
||||||
|
.send(
|
||||||
|
new MessageEmbed()
|
||||||
|
.setTitle(`Message Cleared`)
|
||||||
|
.addField("**Moderator**", message.author.tag, true)
|
||||||
|
.setTimestamp()
|
||||||
|
.setFooter(
|
||||||
|
message.member.displayName,
|
||||||
|
message.author.displayAvatarURL({ dynamic: true })
|
||||||
|
)
|
||||||
|
.setColor(client.color)
|
||||||
|
)
|
||||||
|
.then(m => m.delete({ timeout: 10000 }))
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
48
commands/Moderation/clearWarns.js
Normal file
48
commands/Moderation/clearWarns.js
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
const db = require("../../models/warns");
|
||||||
|
module.exports = {
|
||||||
|
name: "clear-warns",
|
||||||
|
aliases: ["cw"],
|
||||||
|
usage: "(User)",
|
||||||
|
description: "Clear an user's warns",
|
||||||
|
UserPerm: "MANAGE_MESSAGES",
|
||||||
|
category: "Moderation",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const user =
|
||||||
|
message.mentions.members.first() ||
|
||||||
|
message.guild.members.cache.get(args[0]) ||
|
||||||
|
message.author;
|
||||||
|
if (!user) {
|
||||||
|
return client.err(message, "Moderation", "clearWarns", 1);
|
||||||
|
}
|
||||||
|
db.findOne(
|
||||||
|
{ Guild: message.guild.id, User: user.id },
|
||||||
|
async (err, data) => {
|
||||||
|
if (data) {
|
||||||
|
await db.findOneAndDelete({
|
||||||
|
Guild: message.guild.id,
|
||||||
|
User: user.id,
|
||||||
|
});
|
||||||
|
return message.inlineReply(
|
||||||
|
new MessageEmbed()
|
||||||
|
.setTitle(`Warns Cleared`)
|
||||||
|
.addField("**Moderator**", message.author.tag, true)
|
||||||
|
.addField("**User**", user.tag, true)
|
||||||
|
.setTimestamp()
|
||||||
|
.setFooter(
|
||||||
|
message.member.displayName,
|
||||||
|
message.author.displayAvatarURL({ dynamic: true })
|
||||||
|
)
|
||||||
|
.setColor(client.color)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return client.err(message, "Moderation", "clearWarns", 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
52
commands/Moderation/kick.js
Normal file
52
commands/Moderation/kick.js
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "kick",
|
||||||
|
description: "Kick an user",
|
||||||
|
UserPerm: "KICK_MEMBERS",
|
||||||
|
BotPem: "KICK_MEMBERS",
|
||||||
|
usage: "(User) {Reason}",
|
||||||
|
category: "Moderation",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
let target =
|
||||||
|
message.mentions.members.first() ||
|
||||||
|
message.guild.members.cache.get(args[0]);
|
||||||
|
let reason = args.slice(1).join(" ") || "No reason provided";
|
||||||
|
if (!target) {
|
||||||
|
return client.err(message, "Moderation", "kick", 1);
|
||||||
|
} else {
|
||||||
|
if (target.id === message.author.id)
|
||||||
|
return client.err(message, "Moderation", "kick", 2);
|
||||||
|
if (message.member.roles.highest.position < target.roles.highest.position)
|
||||||
|
return client.err(message, "Moderation", "kick", 8);
|
||||||
|
if (
|
||||||
|
message.guild.me.roles.highest.position < target.roles.highest.position
|
||||||
|
)
|
||||||
|
return client.err(message, "Moderation", "kick", 9);
|
||||||
|
}
|
||||||
|
if (reason.length > 1024) reason = reason.slice(0, 1021) + "...";
|
||||||
|
try {
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setTitle("User Kicked")
|
||||||
|
.addField("**Moderator**", message.author.tag, true)
|
||||||
|
.addField("**User**", target.user.tag, true)
|
||||||
|
.addField("**Reason**", reason, true)
|
||||||
|
.setFooter(
|
||||||
|
message.member.displayName || message.author.username,
|
||||||
|
message.author.displayAvatarURL({ dynamic: true })
|
||||||
|
)
|
||||||
|
.setThumbnail(client.user.displayAvatarURL())
|
||||||
|
.setColor(client.color)
|
||||||
|
.setTimestamp();
|
||||||
|
message.inlineReply(embed);
|
||||||
|
await target.kick(reason);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
return client.err(message, "Moderation", "kick", 999);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
33
commands/Moderation/lock.js
Normal file
33
commands/Moderation/lock.js
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "lockdown",
|
||||||
|
aliases: ["lock"],
|
||||||
|
description: "Lock a channel",
|
||||||
|
UserPerm: "MANAGE_CHANNELS",
|
||||||
|
BotPerm: "MANAGE_CHANNELS",
|
||||||
|
category: "Moderation",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
message.channel
|
||||||
|
.createOverwrite(message.guild.id, { SEND_MESSAGES: false })
|
||||||
|
.then(() => {
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setTitle("Channel Locked")
|
||||||
|
.addField("**Moderator**", message.author.tag, true)
|
||||||
|
.addField("**Channel**", `<#${message.channel.id}>`, true)
|
||||||
|
.setFooter(
|
||||||
|
message.member.displayName || message.author.username,
|
||||||
|
message.author.displayAvatarURL({ dynamic: true })
|
||||||
|
)
|
||||||
|
.setThumbnail(client.user.displayAvatarURL())
|
||||||
|
.setColor(client.color)
|
||||||
|
.setTimestamp();
|
||||||
|
message.inlineReply(embed);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
146
commands/Moderation/mute.js
Normal file
146
commands/Moderation/mute.js
Normal file
|
@ -0,0 +1,146 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
const ms = require("ms");
|
||||||
|
module.exports = {
|
||||||
|
name: "mute",
|
||||||
|
description: "Mute an user.",
|
||||||
|
usage: "(User) (Time) {Reason}",
|
||||||
|
UserPerm: "MANAGE_MESSAGES",
|
||||||
|
BotPerm: "MANAGE_ROLES",
|
||||||
|
category: "Moderation",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
let Member = message.mentions.members.first();
|
||||||
|
const time = args[1];
|
||||||
|
if (!Member) return client.err(message, "Moderation", "mute", 1);
|
||||||
|
if (!time) {
|
||||||
|
let reason = "No reason provided";
|
||||||
|
const role = message.guild.roles.cache.find(x => x.name === "Muted");
|
||||||
|
if (!role) {
|
||||||
|
try {
|
||||||
|
let muterole = await message.guild.roles.create({
|
||||||
|
data: {
|
||||||
|
name: "Muted",
|
||||||
|
permissions: [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
message.guild.channels.cache
|
||||||
|
.filter(c => c.type === "text")
|
||||||
|
.forEach(async (channel, id) => {
|
||||||
|
await channel.createOverwrite(muterole, {
|
||||||
|
SEND_MESSAGES: false,
|
||||||
|
ADD_REACTIONS: false,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
return client.err(message, "Moderation", "mute", 999);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let role2 = message.guild.roles.cache.find(x => x.name === "Muted");
|
||||||
|
await Member.roles.add(role2);
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setTitle("User Muted")
|
||||||
|
.addField("**Moderator**", message.author.tag, true)
|
||||||
|
.addField("**User**", Member.user.tag, true)
|
||||||
|
.addField("**Reason**", reason, true)
|
||||||
|
.setFooter(
|
||||||
|
message.member.displayName || message.author.username,
|
||||||
|
message.author.displayAvatarURL({ dynamic: true })
|
||||||
|
)
|
||||||
|
.setThumbnail(client.user.displayAvatarURL())
|
||||||
|
.setColor(client.color)
|
||||||
|
.setTimestamp();
|
||||||
|
message.inlineReply(embed);
|
||||||
|
}
|
||||||
|
if (!ms(time)) {
|
||||||
|
let reason = args.slice(1).join(" ") || "No reason provided";
|
||||||
|
const role = message.guild.roles.cache.find(x => x.name === "Muted");
|
||||||
|
if (!role) {
|
||||||
|
try {
|
||||||
|
let muterole = await message.guild.roles.create({
|
||||||
|
data: {
|
||||||
|
name: "Muted",
|
||||||
|
permissions: [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
message.guild.channels.cache
|
||||||
|
.filter(c => c.type === "text")
|
||||||
|
.forEach(async (channel, id) => {
|
||||||
|
await channel.createOverwrite(muterole, {
|
||||||
|
SEND_MESSAGES: false,
|
||||||
|
ADD_REACTIONS: false,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.log(err);
|
||||||
|
return client.err(message, "Moderation", "mute", 999);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let role2 = message.guild.roles.cache.find(x => x.name === "Muted");
|
||||||
|
await Member.roles.add(role2);
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setTitle("User Muted")
|
||||||
|
.addField("**Moderator**", message.author.tag, true)
|
||||||
|
.addField("**User**", Member.user.tag, true)
|
||||||
|
.addField("**Reason**", reason, true)
|
||||||
|
.setFooter(
|
||||||
|
message.member.displayName || message.author.username,
|
||||||
|
message.author.displayAvatarURL({ dynamic: true })
|
||||||
|
)
|
||||||
|
.setThumbnail(client.user.displayAvatarURL())
|
||||||
|
.setColor(client.color)
|
||||||
|
.setTimestamp();
|
||||||
|
message.inlineReply(embed);
|
||||||
|
setTimeout(async () => {
|
||||||
|
await Member.roles.remove(role2);
|
||||||
|
}, ms(time));
|
||||||
|
} else {
|
||||||
|
let reason = args.slice(2).join(" ") || "No reason provided";
|
||||||
|
const role = message.guild.roles.cache.find(x => x.name === "Muted");
|
||||||
|
if (!role) {
|
||||||
|
try {
|
||||||
|
let muterole = await message.guild.roles.create({
|
||||||
|
data: {
|
||||||
|
name: "Muted",
|
||||||
|
permissions: [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
message.guild.channels.cache
|
||||||
|
.filter(c => c.type === "text")
|
||||||
|
.forEach(async (channel, id) => {
|
||||||
|
await channel.createOverwrite(muterole, {
|
||||||
|
SEND_MESSAGES: false,
|
||||||
|
ADD_REACTIONS: false,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
return client.err(message, "Moderation", "mute", 999);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let role2 = message.guild.roles.cache.find(x => x.name === "Muted");
|
||||||
|
await Member.roles.add(role2);
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setTitle("User Muted")
|
||||||
|
.addField("**Moderator**", message.author.tag, true)
|
||||||
|
.addField("**User**", Member.user.tag, true)
|
||||||
|
.addField("**Time**", ms(ms(time), { long: true }), true)
|
||||||
|
.addField("**Reason**", reason, true)
|
||||||
|
.setFooter(
|
||||||
|
message.member.displayName || message.author.username,
|
||||||
|
message.author.displayAvatarURL({ dynamic: true })
|
||||||
|
)
|
||||||
|
.setThumbnail(client.user.displayAvatarURL())
|
||||||
|
.setColor(client.color)
|
||||||
|
.setTimestamp();
|
||||||
|
message.inlineReply(embed);
|
||||||
|
setTimeout(async () => {
|
||||||
|
await Member.roles.remove(role2);
|
||||||
|
}, ms(time));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
59
commands/Moderation/nuke.js
Normal file
59
commands/Moderation/nuke.js
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
const { Client, Message } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "nuke",
|
||||||
|
description: "Destroy a channel and create a new one",
|
||||||
|
usage: "{Channel}",
|
||||||
|
UserPerm: "MANAGE_CHANNELS",
|
||||||
|
BotPerm: "MANAGE_CHANNELS",
|
||||||
|
category: "Moderation",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
try {
|
||||||
|
let filter = m => m.author.id === message.author.id;
|
||||||
|
message.channel.send("Do you want to nuke this channel? (Yes/No)");
|
||||||
|
message.channel
|
||||||
|
.awaitMessages(filter, {
|
||||||
|
max: 1,
|
||||||
|
time: 99999,
|
||||||
|
errors: ["time"],
|
||||||
|
})
|
||||||
|
.then(msg => {
|
||||||
|
message = msg.first();
|
||||||
|
if (
|
||||||
|
message.content.toLowerCase() == "yes" ||
|
||||||
|
message.content.toLowerCase() == "y"
|
||||||
|
) {
|
||||||
|
let channel = client.channels.cache.get(message.channel.id);
|
||||||
|
channel.clone().then(ch => {
|
||||||
|
if (channel.parent) {
|
||||||
|
ch.setParent(channel.parent.id);
|
||||||
|
} else;
|
||||||
|
ch.setPosition(channel.position);
|
||||||
|
channel.delete();
|
||||||
|
ch.send(
|
||||||
|
"https://i.pinimg.com/originals/06/c3/92/06c392b847166a9a671bfcd590d8fff7.gif \nFriendly nuke has been launched."
|
||||||
|
);
|
||||||
|
});
|
||||||
|
} else if (
|
||||||
|
message.content.toLowerCase() == "no" ||
|
||||||
|
message.content.toLowerCase() == "n"
|
||||||
|
) {
|
||||||
|
message.delete();
|
||||||
|
return message.channel.send("The process has been cancelled");
|
||||||
|
} else {
|
||||||
|
message.delete();
|
||||||
|
return message.channel.send(
|
||||||
|
`The process has been cancelled due to invalid response`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
return client.err(message, "Moderation", "nuke", 999);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
58
commands/Moderation/removeWarn.js
Normal file
58
commands/Moderation/removeWarn.js
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
const db = require("../../models/warns");
|
||||||
|
module.exports = {
|
||||||
|
name: "remove-warn",
|
||||||
|
aliases: ["rw"],
|
||||||
|
UserPerm: "MANAGE_MESSAGES",
|
||||||
|
description: "Remove a latest warn for an user",
|
||||||
|
usage: "(User)",
|
||||||
|
category: "Moderation",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
try {
|
||||||
|
const user =
|
||||||
|
message.mentions.members.first() ||
|
||||||
|
message.guild.members.cache.get(args[0]) ||
|
||||||
|
message.guild.members.cache.find(
|
||||||
|
r =>
|
||||||
|
r.user.username.toLowerCase() === args.join(" ").toLocaleLowerCase()
|
||||||
|
) ||
|
||||||
|
message.guild.members.cache.find(
|
||||||
|
r =>
|
||||||
|
r.displayName.toLowerCase() === args.join(" ").toLocaleLowerCase()
|
||||||
|
);
|
||||||
|
if (!user) return client.err(message, "Moderation", "removeWarn", 1);
|
||||||
|
db.findOne(
|
||||||
|
{ guildid: message.guild.id, user: user.user.id },
|
||||||
|
async (err, data) => {
|
||||||
|
if (err) throw err;
|
||||||
|
if (data) {
|
||||||
|
let number = parseInt(args[1]) - 1;
|
||||||
|
data.Warns.splice(number, 1);
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setTitle("Warn Removed")
|
||||||
|
.addField("**Moderator**", message.author.tag, true)
|
||||||
|
.addField("**User**", user.user.tag, true)
|
||||||
|
.setFooter(
|
||||||
|
message.member.displayName || message.author.username,
|
||||||
|
message.author.displayAvatarURL({ dynamic: true })
|
||||||
|
)
|
||||||
|
.setThumbnail(client.user.displayAvatarURL())
|
||||||
|
.setColor(client.color)
|
||||||
|
.setTimestamp();
|
||||||
|
message.inlineReply(embed);
|
||||||
|
data.save();
|
||||||
|
} else {
|
||||||
|
return client.err(message, "Moderation", "removeWarn", 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
return client.err(message, "Moderation", "removeWarn", 999);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
57
commands/Moderation/role.js
Normal file
57
commands/Moderation/role.js
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
const { MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "role",
|
||||||
|
UserPerm: "MANAGE_ROLES",
|
||||||
|
BotPerm: "MANAGE_ROLES",
|
||||||
|
usage: "(Role) (User)",
|
||||||
|
description: "Add/Remove a role for an user",
|
||||||
|
category: "Moderation",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
try {
|
||||||
|
const target =
|
||||||
|
message.mentions.members.first() ||
|
||||||
|
message.guild.members.cache.get(args[1]);
|
||||||
|
if (!target) return client.err(message, "Moderation", "role", 1);
|
||||||
|
const role =
|
||||||
|
message.mentions.roles.first() ||
|
||||||
|
message.guild.roles.cache.get(args[0]) ||
|
||||||
|
message.guild.roles.cache.find(r => r.name == args[0]);
|
||||||
|
if (!role) return client.err(message, "Moderation", "role", 3);
|
||||||
|
if (target.roles.cache.has(role.id)) {
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setTitle("Role Removed")
|
||||||
|
.addField("**Moderator**", message.author.tag, true)
|
||||||
|
.addField("**User**", target.user.tag, true)
|
||||||
|
.setFooter(
|
||||||
|
message.member.displayName || message.author.username,
|
||||||
|
message.author.displayAvatarURL({ dynamic: true })
|
||||||
|
)
|
||||||
|
.setThumbnail(client.user.displayAvatarURL())
|
||||||
|
.setColor(client.color)
|
||||||
|
.setTimestamp();
|
||||||
|
message.inlineReply(embed).then(await target.roles.remove(role));
|
||||||
|
} else {
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setTitle("Role Added")
|
||||||
|
.addField("**Moderator**", message.author.tag, true)
|
||||||
|
.addField("**User**", target.user.tag, true)
|
||||||
|
.setFooter(
|
||||||
|
message.member.displayName || message.author.username,
|
||||||
|
message.author.displayAvatarURL({ dynamic: true })
|
||||||
|
)
|
||||||
|
.setThumbnail(client.user.displayAvatarURL())
|
||||||
|
.setColor(client.color)
|
||||||
|
.setTimestamp();
|
||||||
|
message.inlineReply(embed).then(await target.roles.add(role));
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
return client.err(message, "Moderation", "role", 999);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
62
commands/Moderation/slowmode.js
Normal file
62
commands/Moderation/slowmode.js
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
const ms = require("ms");
|
||||||
|
module.exports = {
|
||||||
|
name: "slowmode",
|
||||||
|
UserPerm: "MANAGE_CHANNELS",
|
||||||
|
description: "Set slowmode at a specific channel",
|
||||||
|
BotPerm: "MANAGE_CHANNELS",
|
||||||
|
usage: "(Time)",
|
||||||
|
category: "Moderation",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
try {
|
||||||
|
if (!args[0]) {
|
||||||
|
message.channel.setRateLimitPerUser(0);
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setTitle("Slowmode Removed")
|
||||||
|
.addField("**Moderator**", message.author.tag, true)
|
||||||
|
.addField("**Channel**", `<#${message.channel.id}>`, true)
|
||||||
|
.setFooter(
|
||||||
|
message.member.displayName || message.author.username,
|
||||||
|
message.author.displayAvatarURL({ dynamic: true })
|
||||||
|
)
|
||||||
|
.setThumbnail(client.user.displayAvatarURL())
|
||||||
|
.setColor(client.color)
|
||||||
|
.setTimestamp();
|
||||||
|
message.inlineReply(embed);
|
||||||
|
}
|
||||||
|
const milliseconds = ms(args[0]);
|
||||||
|
if (isNaN(milliseconds))
|
||||||
|
return client.err(message, "Moderation", "slowmode", 101);
|
||||||
|
if (milliseconds < 1000)
|
||||||
|
return client.err(message, "Moderation", "slowmode", 16);
|
||||||
|
message.channel.setRateLimitPerUser(milliseconds / 1000);
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setTitle("Slowmode Added")
|
||||||
|
.addField("**Moderator**", message.author.tag, true)
|
||||||
|
.addField("**Channel**", `<#${message.channel.id}>`, true)
|
||||||
|
.addField(
|
||||||
|
"**Rate**",
|
||||||
|
ms(milliseconds, {
|
||||||
|
long: true,
|
||||||
|
}),
|
||||||
|
true
|
||||||
|
)
|
||||||
|
.setFooter(
|
||||||
|
message.member.displayName || message.author.username,
|
||||||
|
message.author.displayAvatarURL({ dynamic: true })
|
||||||
|
)
|
||||||
|
.setThumbnail(client.user.displayAvatarURL())
|
||||||
|
.setColor(client.color)
|
||||||
|
.setTimestamp();
|
||||||
|
message.inlineReply(embed);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
return client.err(message, "Moderation", "slowmode", 999);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
35
commands/Moderation/unban.js
Normal file
35
commands/Moderation/unban.js
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "unban",
|
||||||
|
description: "Unban an user",
|
||||||
|
UserPerm: "BAN_MEMBERS",
|
||||||
|
BotPerm: "BAN_MEMBERS",
|
||||||
|
usage: "(User)",
|
||||||
|
category: "Moderation",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
try {
|
||||||
|
if (!args[0]) return client.err(message, "Moderation", "unban", 1);
|
||||||
|
const user = await message.guild.members.unban(args[0]);
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setTitle("User Unbanned")
|
||||||
|
.addField("**Moderator**", message.author.tag, true)
|
||||||
|
.addField("**User**", user.user.tag, true)
|
||||||
|
.setFooter(
|
||||||
|
message.member.displayName || message.author.username,
|
||||||
|
message.author.displayAvatarURL({ dynamic: true })
|
||||||
|
)
|
||||||
|
.setThumbnail(client.user.displayAvatarURL())
|
||||||
|
.setColor(client.color)
|
||||||
|
.setTimestamp();
|
||||||
|
message.inlineReply(embed);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
return client.err(message, "Moderation", "unban", 999);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
32
commands/Moderation/unlock.js
Normal file
32
commands/Moderation/unlock.js
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "unlock",
|
||||||
|
description: "Lock a channel",
|
||||||
|
UserPerm: "MANAGE_CHANNELS",
|
||||||
|
BotPerm: "MANAGE_CHANNELS",
|
||||||
|
category: "Moderation",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
message.channel
|
||||||
|
.createOverwrite(message.guild.id, { SEND_MESSAGES: true })
|
||||||
|
.then(() => {
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setTitle("Channel Unlocked")
|
||||||
|
.addField("**Moderator**", message.author.tag, true)
|
||||||
|
.addField("**Channel**", `<#${message.channel.id}>`, true)
|
||||||
|
.setFooter(
|
||||||
|
message.member.displayName || message.author.username,
|
||||||
|
message.author.displayAvatarURL({ dynamic: true })
|
||||||
|
)
|
||||||
|
.setThumbnail(client.user.displayAvatarURL())
|
||||||
|
.setColor(client.color)
|
||||||
|
.setTimestamp();
|
||||||
|
message.inlineReply(embed);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
52
commands/Moderation/unmute.js
Normal file
52
commands/Moderation/unmute.js
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "unmute",
|
||||||
|
UserPerm: "MANAGE_MESSAGES",
|
||||||
|
BotPerm: "MANAGE_ROLES",
|
||||||
|
usage: "(User)",
|
||||||
|
description: "Unmute an user",
|
||||||
|
category: "Moderation",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
try {
|
||||||
|
const user =
|
||||||
|
message.mentions.members.first() ||
|
||||||
|
message.guild.members.cache.get(args[0]);
|
||||||
|
if (!user) return client.err(message, "Moderation", "unmute", 1);
|
||||||
|
const role = message.guild.roles.cache.find(r => r.name === "Muted");
|
||||||
|
if (!role) {
|
||||||
|
try {
|
||||||
|
await message.guild.roles.create({
|
||||||
|
data: {
|
||||||
|
name: "Muted",
|
||||||
|
permissions: [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
return client.err(message, "Moderation", "unmute", 999);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await user.roles.remove(role);
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setTitle("User Unmuted")
|
||||||
|
.addField("**Moderator**", message.author.tag, true)
|
||||||
|
.addField("**User**", user.user.tag, true)
|
||||||
|
.setFooter(
|
||||||
|
message.member.displayName || message.author.username,
|
||||||
|
message.author.displayAvatarURL({ dynamic: true })
|
||||||
|
)
|
||||||
|
.setThumbnail(client.user.displayAvatarURL())
|
||||||
|
.setColor(client.color)
|
||||||
|
.setTimestamp();
|
||||||
|
message.inlineReply(embed);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
return client.err(message, "Moderation", "unmute", 999);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
64
commands/Moderation/warn.js
Normal file
64
commands/Moderation/warn.js
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
const db = require("../../models/warns");
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "warn",
|
||||||
|
UserPerm: "MANAGE_MESSAGES",
|
||||||
|
usage: "(User) {Reason}",
|
||||||
|
description: "Warn a user",
|
||||||
|
category: "Moderation",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
try {
|
||||||
|
const user =
|
||||||
|
message.mentions.members.first() ||
|
||||||
|
message.guild.members.cache.get(args[0]);
|
||||||
|
if (!user) return client.err(message, "Moderation", "warn", 1);
|
||||||
|
const reason = args.slice(1).join(" ") || "No reason provided";
|
||||||
|
db.findOne(
|
||||||
|
{ Guild: message.guild.id, User: user.id },
|
||||||
|
async (err, data) => {
|
||||||
|
if (!data) {
|
||||||
|
data = new db({
|
||||||
|
Guild: message.guild.id,
|
||||||
|
User: user.id,
|
||||||
|
Warns: [
|
||||||
|
{
|
||||||
|
Reason: reason,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const obj = {
|
||||||
|
Reason: reason,
|
||||||
|
};
|
||||||
|
data.Warns.push(obj);
|
||||||
|
}
|
||||||
|
data.save();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
user.send(
|
||||||
|
`You have been warned in **${message.guild.name}** for **${reason}**`
|
||||||
|
);
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setTitle("User Warned")
|
||||||
|
.addField("**Moderator**", message.author.tag, true)
|
||||||
|
.addField("**User**", user.user.tag, true)
|
||||||
|
.addField("**Reason**", reason, true)
|
||||||
|
.setFooter(
|
||||||
|
message.member.displayName || message.author.username,
|
||||||
|
message.author.displayAvatarURL({ dynamic: true })
|
||||||
|
)
|
||||||
|
.setThumbnail(client.user.displayAvatarURL())
|
||||||
|
.setColor(client.color)
|
||||||
|
.setTimestamp();
|
||||||
|
message.inlineReply(embed);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
return client.err(message, "Moderation", "warn", 1);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
53
commands/Moderation/warns.js
Normal file
53
commands/Moderation/warns.js
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
const db = require("../../models/warns");
|
||||||
|
const { Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "warns",
|
||||||
|
UserPerm: "MANAGE_MESSAGES",
|
||||||
|
description: "Check the warns of an user",
|
||||||
|
usage: "{User}",
|
||||||
|
category: "Moderation",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
try {
|
||||||
|
const user =
|
||||||
|
message.mentions.members.first() ||
|
||||||
|
message.guild.members.cache.get(args[0]) ||
|
||||||
|
message.guild.members.cache.find(
|
||||||
|
r =>
|
||||||
|
r.user.username.toLowerCase() === args.join(" ").toLocaleLowerCase()
|
||||||
|
) ||
|
||||||
|
message.guild.members.cache.find(
|
||||||
|
r =>
|
||||||
|
r.displayName.toLowerCase() === args.join(" ").toLocaleLowerCase()
|
||||||
|
) ||
|
||||||
|
message.author;
|
||||||
|
db.findOne(
|
||||||
|
{ Guild: message.guild.id, User: user.id },
|
||||||
|
async (err, data) => {
|
||||||
|
if (data) {
|
||||||
|
message.channel.send(
|
||||||
|
new MessageEmbed()
|
||||||
|
.setTitle(`${user.user.tag}'s warns`)
|
||||||
|
.setDescription(
|
||||||
|
data.Warns.map(
|
||||||
|
(w, i) => `\`${i + 1}\` | Reason : ${w.Reason}`
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setTimestamp()
|
||||||
|
.setColor("client.color")
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return client.err(message, "Moderation", "warns", 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
return client.err(message, "Moderation", "warns", 999);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
35
commands/Music/leave.js
Normal file
35
commands/Music/leave.js
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "disconnect",
|
||||||
|
aliases: ["dc"],
|
||||||
|
description: "Leave The Voice Channel",
|
||||||
|
category: "Music",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
let channel = message.member.voice.channel;
|
||||||
|
if (!channel) return client.err(message, "Music", "disconnect", 35);
|
||||||
|
if (!message.guild.me.voice.channel)
|
||||||
|
return client.err(message, "Music", "disconnect", 41);
|
||||||
|
try {
|
||||||
|
await message.guild.me.voice.channel.leave();
|
||||||
|
} catch (error) {
|
||||||
|
await message.guild.me.voice.kick(message.guild.me.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
const Embed = new MessageEmbed()
|
||||||
|
.setAuthor("Left Voice Channel", client.user.displayAvatarURL())
|
||||||
|
.setColor("GREEN")
|
||||||
|
.setTitle(
|
||||||
|
`By user: ${message.author.tag}`,
|
||||||
|
message.author.displayAvatarURL({ dynamic: true })
|
||||||
|
)
|
||||||
|
.setDescription("🎶 Left The Voice Channel.")
|
||||||
|
.setTimestamp();
|
||||||
|
|
||||||
|
return message.channel.send(Embed);
|
||||||
|
},
|
||||||
|
};
|
26
commands/Music/loop.js
Normal file
26
commands/Music/loop.js
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "loop",
|
||||||
|
description: "Music loop",
|
||||||
|
category: "Music",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const serverQueue = message.client.queue.get(message.guild.id);
|
||||||
|
if (serverQueue) {
|
||||||
|
serverQueue.loop = !serverQueue.loop;
|
||||||
|
return message.channel.send({
|
||||||
|
embed: {
|
||||||
|
color: "GREEN",
|
||||||
|
description: `🔁 **|** Loop is ${
|
||||||
|
serverQueue.loop === true ? "enabled" : "disabled"
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return client.err(message, "Music", "loop", 34);
|
||||||
|
},
|
||||||
|
};
|
42
commands/Music/lyrics.js
Normal file
42
commands/Music/lyrics.js
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
const lyricsFinder = require("lyrics-finder");
|
||||||
|
const splitlyrics = require("../../util/pagination");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "lyrics",
|
||||||
|
description: "Get lyrics for the currently playing song",
|
||||||
|
category: "Music",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const queue = message.client.queue.get(message.guild.id);
|
||||||
|
if (!queue) return client.err(message, "Music", "lyrics", 34);
|
||||||
|
let lyrics = null;
|
||||||
|
try {
|
||||||
|
lyrics = await lyricsFinder(queue.songs[0].title, "");
|
||||||
|
if (!lyrics)
|
||||||
|
lyrics = `**No lyrics are found for ${queue.songs[0].title}.**`;
|
||||||
|
} catch (error) {
|
||||||
|
lyrics = `**No lyrics are found for ${queue.songs[0].title}.**`;
|
||||||
|
}
|
||||||
|
const splittedLyrics = splitlyrics.chunk(lyrics, 1024);
|
||||||
|
|
||||||
|
let lyricsEmbed = new MessageEmbed()
|
||||||
|
.setAuthor(
|
||||||
|
`${queue.songs[0].title} — Lyrics`,
|
||||||
|
"https://i.imgur.com/qHPXWxN.gif"
|
||||||
|
)
|
||||||
|
.setThumbnail(queue.songs[0].img)
|
||||||
|
.setColor("YELLOW")
|
||||||
|
.setDescription(splittedLyrics[0])
|
||||||
|
.setFooter(`Page 1 of ${splittedLyrics.length}.`)
|
||||||
|
.setTimestamp();
|
||||||
|
|
||||||
|
const lyricsMsg = await message.channel.send(lyricsEmbed);
|
||||||
|
if (splittedLyrics.length > 1)
|
||||||
|
await splitlyrics.pagination(lyricsMsg, message.author, splittedLyrics);
|
||||||
|
},
|
||||||
|
};
|
25
commands/Music/nowplaying.js
Normal file
25
commands/Music/nowplaying.js
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "nowplaying",
|
||||||
|
description: "To show the music which is currently playing in this server",
|
||||||
|
category: "Music",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const serverQueue = message.client.queue.get(message.guild.id);
|
||||||
|
if (!serverQueue) return client.err(message, "Music", "nowplaying", 34);
|
||||||
|
let song = serverQueue.songs[0];
|
||||||
|
let thing = new MessageEmbed()
|
||||||
|
.setAuthor("Now Playing", "https://i.imgur.com/qHPXWxN.gif")
|
||||||
|
.setThumbnail(song.img)
|
||||||
|
.setColor("client.color")
|
||||||
|
.addField("Name:", `**${song.title}**`, true)
|
||||||
|
.addField("Duration:", `**${song.duration}**`, true)
|
||||||
|
.addField("Requested by:", `**${song.req.tag}**`, true)
|
||||||
|
.setFooter(`Views:${song.views} | ${song.ago}`);
|
||||||
|
return message.channel.send(thing);
|
||||||
|
},
|
||||||
|
};
|
29
commands/Music/pause.js
Normal file
29
commands/Music/pause.js
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "pause",
|
||||||
|
description: "To pause the current music in the server",
|
||||||
|
category: "Music",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const serverQueue = message.client.queue.get(message.guild.id);
|
||||||
|
if (serverQueue && serverQueue.playing) {
|
||||||
|
serverQueue.playing = false;
|
||||||
|
try {
|
||||||
|
serverQueue.connection.dispatcher.pause();
|
||||||
|
} catch (error) {
|
||||||
|
message.client.queue.delete(message.guild.id);
|
||||||
|
return client.err(message, "Music", "pause", 36);
|
||||||
|
}
|
||||||
|
let xd = new MessageEmbed()
|
||||||
|
.setDescription(`⏸ Paused the music for ${message.author.username}`)
|
||||||
|
.setColor("YELLOW")
|
||||||
|
.setTitle("Music has been paused.");
|
||||||
|
return message.channel.send(xd);
|
||||||
|
}
|
||||||
|
return client.err(message, "Music", "pause", 34);
|
||||||
|
},
|
||||||
|
};
|
204
commands/Music/play.js
Normal file
204
commands/Music/play.js
Normal file
|
@ -0,0 +1,204 @@
|
||||||
|
const { Client, Message, MessageEmbed, Util } = require("discord.js");
|
||||||
|
const ytdl = require("ytdl-core");
|
||||||
|
const ytdlDiscord = require("discord-ytdl-core");
|
||||||
|
const yts = require("yt-search");
|
||||||
|
const scdl = require("soundcloud-downloader").default;
|
||||||
|
const config = require("../../config.json");
|
||||||
|
module.exports = {
|
||||||
|
name: "play",
|
||||||
|
description: "Play songs",
|
||||||
|
usage: "(YouTube_URL)/(Song Name)",
|
||||||
|
aliases: ["p"],
|
||||||
|
category: "Music",
|
||||||
|
BotPerm: ["CONNECT", "SPEAK"],
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
let channel = message.member.voice.channel;
|
||||||
|
if (!channel) return client.err(message, "Music", "play", 35);
|
||||||
|
var searchString = args.join(" ");
|
||||||
|
if (!searchString) return client.err(message, "Music", "play", 0);
|
||||||
|
const url = args[0] ? args[0].replace(/<(.+)>/g, "$1") : "";
|
||||||
|
var serverQueue = message.client.queue.get(message.guild.id);
|
||||||
|
|
||||||
|
let songInfo;
|
||||||
|
let song;
|
||||||
|
if (
|
||||||
|
url.match(/^(https?:\/\/)?(www\.)?(m\.)?(youtube\.com|youtu\.?be)\/.+$/gi)
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
songInfo = await ytdl.getInfo(url);
|
||||||
|
if (!songInfo) return client.err(message, "Music", "play", 42);
|
||||||
|
song = {
|
||||||
|
id: songInfo.videoDetails.videoId,
|
||||||
|
title: songInfo.videoDetails.title,
|
||||||
|
url: songInfo.videoDetails.video_url,
|
||||||
|
img: songInfo.player_response.videoDetails.thumbnail.thumbnails[0]
|
||||||
|
.url,
|
||||||
|
duration: songInfo.videoDetails.lengthSeconds,
|
||||||
|
ago: songInfo.videoDetails.publishDate,
|
||||||
|
views: String(songInfo.videoDetails.viewCount).padStart(10, " "),
|
||||||
|
req: message.author,
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.log(e);
|
||||||
|
return client.err(message, "Music", "play", 999);
|
||||||
|
}
|
||||||
|
} else if (url.match(/^https?:\/\/(soundcloud\.com)\/(.*)$/gi)) {
|
||||||
|
try {
|
||||||
|
songInfo = await scdl.getInfo(url);
|
||||||
|
if (!songInfo) return client.err(message, "Music", "play", 43);
|
||||||
|
song = {
|
||||||
|
id: songInfo.permalink,
|
||||||
|
title: songInfo.title,
|
||||||
|
url: songInfo.permalink_url,
|
||||||
|
img: songInfo.artwork_url,
|
||||||
|
ago: songInfo.last_modified,
|
||||||
|
views: String(songInfo.playback_count).padStart(10, " "),
|
||||||
|
duration: Math.ceil(songInfo.duration / 1000),
|
||||||
|
req: message.author,
|
||||||
|
};
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
return client.err(message, "Music", "play", 999);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
var searched = await yts.search(searchString);
|
||||||
|
if (searched.videos.length === 0)
|
||||||
|
return client.err(message, "Music", "play", 44);
|
||||||
|
songInfo = searched.videos[0];
|
||||||
|
song = {
|
||||||
|
id: songInfo.videoId,
|
||||||
|
title: Util.escapeMarkdown(songInfo.title),
|
||||||
|
views: String(songInfo.views).padStart(10, " "),
|
||||||
|
url: songInfo.url,
|
||||||
|
ago: songInfo.ago,
|
||||||
|
duration: songInfo.duration.toString(),
|
||||||
|
img: songInfo.image,
|
||||||
|
req: message.author,
|
||||||
|
};
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
return client.err(message, "Music", "play", 999);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (serverQueue) {
|
||||||
|
serverQueue.songs.push(song);
|
||||||
|
let thing = new MessageEmbed()
|
||||||
|
.setAuthor(
|
||||||
|
"Song has been added to queue",
|
||||||
|
"https://i.imgur.com/qHPXWxN.gif"
|
||||||
|
)
|
||||||
|
.setThumbnail(song.img)
|
||||||
|
.setColor("YELLOW")
|
||||||
|
.addField("Name:", `**${song.title}**`, true)
|
||||||
|
.addField("Duration:", `**${song.duration}**`, true)
|
||||||
|
.addField("Requested by:", `**${song.req.tag}**`, true)
|
||||||
|
.setFooter(`Views:${song.views} | ${song.ago}`);
|
||||||
|
return message.channel.send(thing);
|
||||||
|
}
|
||||||
|
|
||||||
|
const queueConstruct = {
|
||||||
|
textChannel: message.channel,
|
||||||
|
voiceChannel: channel,
|
||||||
|
connection: null,
|
||||||
|
songs: [],
|
||||||
|
volume: 80,
|
||||||
|
playing: true,
|
||||||
|
loop: false,
|
||||||
|
};
|
||||||
|
message.client.queue.set(message.guild.id, queueConstruct);
|
||||||
|
queueConstruct.songs.push(song);
|
||||||
|
|
||||||
|
const play = async song => {
|
||||||
|
const queue = message.client.queue.get(message.guild.id);
|
||||||
|
if (!song) {
|
||||||
|
message.guild.me.voice.channel.leave(); //If you want your bot stay in vc 24/7 remove this line :D
|
||||||
|
message.client.queue.delete(message.guild.id);
|
||||||
|
return client.err(message, "Music", "play", 40);
|
||||||
|
}
|
||||||
|
let stream;
|
||||||
|
let streamType;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (song.url.includes("soundcloud.com")) {
|
||||||
|
try {
|
||||||
|
stream = await scdl.downloadFormat(
|
||||||
|
song.url,
|
||||||
|
scdl.FORMATS.OPUS,
|
||||||
|
config.soundcloud
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
stream = await scdl.downloadFormat(
|
||||||
|
song.url,
|
||||||
|
scdl.FORMATS.MP3,
|
||||||
|
config.soundcloud
|
||||||
|
);
|
||||||
|
streamType = "unknown";
|
||||||
|
}
|
||||||
|
} else if (song.url.includes("youtube.com")) {
|
||||||
|
stream = await ytdlDiscord(song.url, {
|
||||||
|
filter: "audioonly",
|
||||||
|
quality: "highestaudio",
|
||||||
|
highWaterMark: 1 << 25,
|
||||||
|
opusEncoded: true,
|
||||||
|
});
|
||||||
|
streamType = "opus";
|
||||||
|
stream.on("error", function (er) {
|
||||||
|
if (er) {
|
||||||
|
if (queue) {
|
||||||
|
queue.songs.shift();
|
||||||
|
play(queue.songs[0]);
|
||||||
|
return client.err(message, "Music", "play", 999);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
if (queue) {
|
||||||
|
queue.songs.shift();
|
||||||
|
play(queue.songs[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
queue.connection.on("disconnect", () =>
|
||||||
|
message.client.queue.delete(message.guild.id)
|
||||||
|
);
|
||||||
|
const dispatcher = queue.connection
|
||||||
|
.play(stream, { type: streamType })
|
||||||
|
.on("finish", () => {
|
||||||
|
const shiffed = queue.songs.shift();
|
||||||
|
if (queue.loop === true) {
|
||||||
|
queue.songs.push(shiffed);
|
||||||
|
}
|
||||||
|
play(queue.songs[0]);
|
||||||
|
});
|
||||||
|
|
||||||
|
dispatcher.setVolumeLogarithmic(queue.volume / 100);
|
||||||
|
let thing = new MessageEmbed()
|
||||||
|
.setAuthor(`Playing song`, "https://i.imgur.com/qHPXWxN.gif")
|
||||||
|
.setThumbnail(song.img)
|
||||||
|
.setColor("client.color")
|
||||||
|
.addField("Name:", `**${song.title}**`, true)
|
||||||
|
.addField("Duration:", `**${song.duration}**`, true)
|
||||||
|
.addField("Requested by:", `**${song.req.tag}**`, true)
|
||||||
|
.setFooter(`Views:${song.views} | ${song.ago}`);
|
||||||
|
queue.textChannel.send(thing);
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const connection = await channel.join();
|
||||||
|
queueConstruct.connection = connection;
|
||||||
|
play(queueConstruct.songs[0]);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(e);
|
||||||
|
message.client.queue.delete(message.guild.id);
|
||||||
|
await channel.leave();
|
||||||
|
return client.err(message, "Music", "play", 39);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
201
commands/Music/playlist.js
Normal file
201
commands/Music/playlist.js
Normal file
|
@ -0,0 +1,201 @@
|
||||||
|
const { Client, Message, MessageEmbed, Util } = require("discord.js");
|
||||||
|
const yts = require("yt-search");
|
||||||
|
const ytdlDiscord = require("discord-ytdl-core");
|
||||||
|
var ytpl = require("ytpl");
|
||||||
|
const scdl = require("soundcloud-downloader").default;
|
||||||
|
const config = require("../../config.json");
|
||||||
|
module.exports = {
|
||||||
|
name: "playlist",
|
||||||
|
description: "Play songs",
|
||||||
|
usage: "(YouTube Playlist URL)/(Playlist Name)",
|
||||||
|
category: "Music",
|
||||||
|
BotPerm: ["CONNECT", "SPEAK"],
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const channel = message.member.voice.channel;
|
||||||
|
if (!channel) return client.err(message, "Music", "playlist", 35);
|
||||||
|
const url = args[0] ? args[0].replace(/<(.+)>/g, "$1") : "";
|
||||||
|
var searchString = args.join(" ");
|
||||||
|
if (!searchString || !url)
|
||||||
|
return client.err(message, "Music", "playlist", 0);
|
||||||
|
if (url.match(/^https?:\/\/(www.youtube.com|youtube.com)\/playlist(.*)$/)) {
|
||||||
|
try {
|
||||||
|
const playlist = await ytpl(url.split("list=")[1]);
|
||||||
|
if (!playlist) return client.err(messgae, "Music", "playlist", 404);
|
||||||
|
const videos = await playlist.items;
|
||||||
|
for (const video of videos) {
|
||||||
|
await handleVideo(video, message, channel, true);
|
||||||
|
}
|
||||||
|
return message.channel.send({
|
||||||
|
embed: {
|
||||||
|
color: "GREEN",
|
||||||
|
description: `✅ **|** Playlist: **\`${videos[0].title}\`** has been added to the queue`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
return client.err(message, "Music", "playlist", 999);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
var searched = await yts.search(searchString);
|
||||||
|
if (searched.playlists.length === 0)
|
||||||
|
return client.err(message, "Music", "playlist", 38);
|
||||||
|
var songInfo = searched.playlists[0];
|
||||||
|
let listurl = songInfo.listId;
|
||||||
|
const playlist = await ytpl(listurl);
|
||||||
|
const videos = await playlist.items;
|
||||||
|
for (const video of videos) {
|
||||||
|
// eslint-disable-line no-await-in-loop
|
||||||
|
await handleVideo(video, message, channel, true); // eslint-disable-line no-await-in-loop
|
||||||
|
}
|
||||||
|
let thing = new MessageEmbed()
|
||||||
|
.setAuthor(
|
||||||
|
"Playlist has been added to queue",
|
||||||
|
"https://i.imgur.com/qHPXWxN.gif"
|
||||||
|
)
|
||||||
|
.setThumbnail(songInfo.thumbnail)
|
||||||
|
.setColor("GREEN")
|
||||||
|
.setDescription(
|
||||||
|
`✅ **|** Playlist: **\`${songInfo.title}\`** has been added \`${songInfo.videoCount}\` video to the queue.`
|
||||||
|
);
|
||||||
|
return message.channel.send(thing);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
return client.err(message, "Music", "playlist", 999);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function handleVideo(video, message, channel, playlist = false) {
|
||||||
|
const serverQueue = message.client.queue.get(message.guild.id);
|
||||||
|
const song = {
|
||||||
|
id: video.id,
|
||||||
|
title: Util.escapeMarkdown(video.title),
|
||||||
|
views: video.views ? video.views : "-",
|
||||||
|
ago: video.ago ? video.ago : "-",
|
||||||
|
duration: video.duration,
|
||||||
|
url: `https://www.youtube.com/watch?v=${video.id}`,
|
||||||
|
img: video.thumbnail,
|
||||||
|
req: message.author,
|
||||||
|
};
|
||||||
|
if (!serverQueue) {
|
||||||
|
const queueConstruct = {
|
||||||
|
textChannel: message.channel,
|
||||||
|
voiceChannel: channel,
|
||||||
|
connection: null,
|
||||||
|
songs: [],
|
||||||
|
volume: 80,
|
||||||
|
playing: true,
|
||||||
|
loop: false,
|
||||||
|
};
|
||||||
|
message.client.queue.set(message.guild.id, queueConstruct);
|
||||||
|
queueConstruct.songs.push(song);
|
||||||
|
|
||||||
|
try {
|
||||||
|
var connection = await channel.join();
|
||||||
|
queueConstruct.connection = connection;
|
||||||
|
play(message.guild, queueConstruct.songs[0]);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
message.client.queue.delete(message.guild.id);
|
||||||
|
return client.err(message, "Music", "playlist", 39);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
serverQueue.songs.push(song);
|
||||||
|
if (playlist) return;
|
||||||
|
let thing = new MessageEmbed()
|
||||||
|
.setAuthor(
|
||||||
|
"Song has been added to queue",
|
||||||
|
"https://i.imgur.com/qHPXWxN.gif"
|
||||||
|
)
|
||||||
|
.setThumbnail(song.img)
|
||||||
|
.setColor("YELLOW")
|
||||||
|
.addField("Name:", `**${song.title}**`, true)
|
||||||
|
.addField("Duration:", `**${song.duration}**`, true)
|
||||||
|
.addField("Requested by:", `**${song.req.tag}**`, true)
|
||||||
|
.setFooter(`Views:${song.views} | ${song.ago}`);
|
||||||
|
return message.channel.send(thing);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function play(guild, song) {
|
||||||
|
const serverQueue = message.client.queue.get(message.guild.id);
|
||||||
|
if (!song) {
|
||||||
|
message.guild.me.voice.channel.leave();
|
||||||
|
message.client.queue.delete(message.guild.id);
|
||||||
|
return client.err(message, "Music", "playlist", 40);
|
||||||
|
}
|
||||||
|
let stream;
|
||||||
|
let streamType;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (song.url.includes("soundcloud.com")) {
|
||||||
|
try {
|
||||||
|
stream = await scdl.downloadFormat(
|
||||||
|
song.url,
|
||||||
|
scdl.FORMATS.OPUS,
|
||||||
|
config.soundcloud
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
stream = await scdl.downloadFormat(
|
||||||
|
song.url,
|
||||||
|
scdl.FORMATS.MP3,
|
||||||
|
config.soundcloud
|
||||||
|
);
|
||||||
|
streamType = "unknown";
|
||||||
|
}
|
||||||
|
} else if (song.url.includes("youtube.com")) {
|
||||||
|
stream = await ytdlDiscord(song.url, {
|
||||||
|
filter: "audioonly",
|
||||||
|
quality: "highestaudio",
|
||||||
|
highWaterMark: 1 << 25,
|
||||||
|
opusEncoded: true,
|
||||||
|
});
|
||||||
|
streamType = "opus";
|
||||||
|
stream.on("error", function (er) {
|
||||||
|
if (er) {
|
||||||
|
if (serverQueue) {
|
||||||
|
serverQueue.songs.shift();
|
||||||
|
play(serverQueue.songs[0]);
|
||||||
|
return client.err(message, "Music", "playlist", 999);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
if (serverQueue) {
|
||||||
|
console.log(error);
|
||||||
|
serverQueue.songs.shift();
|
||||||
|
play(serverQueue.songs[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
serverQueue.connection.on("disconnect", () =>
|
||||||
|
message.client.queue.delete(message.guild.id)
|
||||||
|
);
|
||||||
|
const dispatcher = serverQueue.connection
|
||||||
|
.play(stream, { type: streamType })
|
||||||
|
.on("finish", () => {
|
||||||
|
const shiffed = serverQueue.songs.shift();
|
||||||
|
if (serverQueue.loop === true) {
|
||||||
|
serverQueue.songs.push(shiffed);
|
||||||
|
}
|
||||||
|
play(guild, serverQueue.songs[0]);
|
||||||
|
});
|
||||||
|
|
||||||
|
dispatcher.setVolume(serverQueue.volume / 100);
|
||||||
|
let thing = new MessageEmbed()
|
||||||
|
.setAuthor("Playing music", "https://i.imgur.com/qHPXWxN.gif")
|
||||||
|
.setThumbnail(song.img)
|
||||||
|
.setColor("BLUE")
|
||||||
|
.addField("Name:", `**${song.title}**`, true)
|
||||||
|
.addField("Duration:", `**${song.duration}**`, true)
|
||||||
|
.addField("Requested by:", `**${song.req.tag}**`, true)
|
||||||
|
.setFooter(`Views:${song.views} | ${song.ago}`);
|
||||||
|
serverQueue.textChannel.send(thing);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
52
commands/Music/queue.js
Normal file
52
commands/Music/queue.js
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
const util = require("../../util/pagination");
|
||||||
|
module.exports = {
|
||||||
|
name: "queue",
|
||||||
|
description: "To show the songs queue",
|
||||||
|
aliases: ["q"],
|
||||||
|
category: "Music",
|
||||||
|
BotPerm: ["MANAGE_MESSAGES", "ADD_REACTIONS"],
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const queue = message.client.queue.get(message.guild.id);
|
||||||
|
if (!queue) return client.err(message, "Music", "queue", 34);
|
||||||
|
const que = queue.songs.map(
|
||||||
|
(t, i) => `\`${++i}.\` | [\`${t.title}\`](${t.url}) - [<@${t.req.id}>]`
|
||||||
|
);
|
||||||
|
const chunked = util.chunk(que, 10).map(x => x.join("\n"));
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setAuthor("Songs Queue", "https://i.imgur.com/qHPXWxN.gif")
|
||||||
|
.setThumbnail(message.guild.iconURL())
|
||||||
|
.setColor("client.color")
|
||||||
|
.setDescription(chunked[0])
|
||||||
|
.addField(
|
||||||
|
"Now Playing",
|
||||||
|
`[${queue.songs[0].title}](${queue.songs[0].url})`,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
.addField("Text Channel", queue.textChannel, true)
|
||||||
|
.addField("Voice Channel", queue.voiceChannel, true)
|
||||||
|
.setFooter(
|
||||||
|
`Currently Server Volume is ${queue.volume} | Page 1 of ${chunked.length}.`
|
||||||
|
);
|
||||||
|
if (queue.songs.length === 1)
|
||||||
|
embed.setDescription(
|
||||||
|
`**No songs to play next. Add songs by \`\`${await client.prefix(
|
||||||
|
message
|
||||||
|
)}play <song_name>\`\`**`
|
||||||
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const queueMsg = await message.channel.send(embed);
|
||||||
|
if (chunked.length > 1)
|
||||||
|
await util.pagination(queueMsg, message.author, chunked);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
return client.err(message, "Music", "queue", 999);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
35
commands/Music/remove.js
Normal file
35
commands/Music/remove.js
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "remove",
|
||||||
|
description: "Remove song from the queue",
|
||||||
|
usage: "(Number)",
|
||||||
|
aliases: ["rm"],
|
||||||
|
category: "Music",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const queue = message.client.queue.get(message.guild.id);
|
||||||
|
if (!queue) return client.err(message, "Music", "remove", 37);
|
||||||
|
if (!args.length) return client.err(message, "Music", "remove", 101);
|
||||||
|
if (isNaN(args[0])) return client.err(message, "Music", "remove", 7);
|
||||||
|
if (queue.songs.length == 1)
|
||||||
|
return client.err(message, "Music", "remove", 37);
|
||||||
|
if (args[0] > queue.songs.length)
|
||||||
|
return client.err(message, "Music", "remove", 101);
|
||||||
|
try {
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setColor(client.color)
|
||||||
|
.setDescription(`❌ **|** Removed: **${song[0].title}** from the queue`)
|
||||||
|
.setTimestamp("Made by Cath Team");
|
||||||
|
const song = queue.songs.splice(args[0] - 1, 1);
|
||||||
|
message.inlineReply(embed);
|
||||||
|
message.react("✅");
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
return client.err(message, "Music", "remove", 999);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
28
commands/Music/resume.js
Normal file
28
commands/Music/resume.js
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "resume",
|
||||||
|
description: "To resume the paused music",
|
||||||
|
aliases: ["continue"],
|
||||||
|
category: "Music",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const serverQueue = message.client.queue.get(message.guild.id);
|
||||||
|
if (serverQueue && !serverQueue.playing) {
|
||||||
|
serverQueue.playing = true;
|
||||||
|
serverQueue.connection.dispatcher.resume();
|
||||||
|
let xd = new MessageEmbed()
|
||||||
|
.setDescription(`▶ Resumed the music for ${message.author.username}`)
|
||||||
|
.setColor("YELLOW")
|
||||||
|
.setAuthor(
|
||||||
|
"Music has been resumed.",
|
||||||
|
"https://i.imgur.com/qHPXWxN.gif"
|
||||||
|
);
|
||||||
|
return message.channel.send(xd);
|
||||||
|
}
|
||||||
|
return client.err(message, "Music", "resume", 34);
|
||||||
|
},
|
||||||
|
};
|
29
commands/Music/shuffle.js
Normal file
29
commands/Music/shuffle.js
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "shuffle",
|
||||||
|
description: "Shuffle queue",
|
||||||
|
category: "Music",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const serverQueue = message.client.queue.get(message.guild.id);
|
||||||
|
if (!serverQueue) return client.err(message, "Music", "shuffle", 37);
|
||||||
|
try {
|
||||||
|
let songs = serverQueue.songs;
|
||||||
|
for (let i = songs.length - 1; i > 1; i--) {
|
||||||
|
let j = 1 + Math.floor(Math.random() * i);
|
||||||
|
[songs[i], songs[j]] = [songs[j], songs[i]];
|
||||||
|
}
|
||||||
|
serverQueue.songs = songs;
|
||||||
|
message.client.queue.set(message.guild.id, serverQueue);
|
||||||
|
message.react("✅");
|
||||||
|
} catch (error) {
|
||||||
|
message.guild.me.voice.channel.leave();
|
||||||
|
message.client.queue.delete(message.guild.id);
|
||||||
|
return client.err(message, "Music", "shuffle", 36);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
37
commands/Music/skip.js
Normal file
37
commands/Music/skip.js
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "skip",
|
||||||
|
description: "To skip the current music",
|
||||||
|
category: "Music",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const channel = message.member.voice.channel;
|
||||||
|
if (!channel) return client.err(message, "Music", "skip", 35);
|
||||||
|
const serverQueue = message.client.queue.get(message.guild.id);
|
||||||
|
if (!serverQueue) return client.err(message, "Music", "skip", 34);
|
||||||
|
if (!serverQueue.connection) return;
|
||||||
|
if (!serverQueue.connection.dispatcher) return;
|
||||||
|
if (serverQueue && !serverQueue.playing) {
|
||||||
|
serverQueue.playing = true;
|
||||||
|
serverQueue.connection.dispatcher.resume();
|
||||||
|
let xd = new MessageEmbed()
|
||||||
|
.setDescription(`▶ Skipped the music for ${message.author.username}`)
|
||||||
|
.setColor("YELLOW")
|
||||||
|
.setTitle("Music has been skipped");
|
||||||
|
return message.channel.send(xd).catch(err => console.log(err));
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
serverQueue.connection.dispatcher.end();
|
||||||
|
} catch (error) {
|
||||||
|
serverQueue.voiceChannel.leave();
|
||||||
|
message.client.queue.delete(message.guild.id);
|
||||||
|
return client.err(message, "Music", "skip", 36);
|
||||||
|
}
|
||||||
|
message.react("✅");
|
||||||
|
},
|
||||||
|
};
|
46
commands/Music/skipto.js
Normal file
46
commands/Music/skipto.js
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "skipto",
|
||||||
|
description: "Skip to the selected queue number",
|
||||||
|
usage: "(Number)",
|
||||||
|
category: "Music",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
if (!args.length || isNaN(args[0]))
|
||||||
|
return client.err(message, "Music", "skipto", 101);
|
||||||
|
const queue = message.client.queue.get(message.guild.id);
|
||||||
|
if (!queue) return client.err(message, "Music", "skipto", 37);
|
||||||
|
if (args[0] > queue.songs.length)
|
||||||
|
return client.err(message, "Music", "skipto", 101);
|
||||||
|
queue.playing = true;
|
||||||
|
|
||||||
|
if (queue.loop) {
|
||||||
|
for (let i = 0; i < args[0] - 2; i++) {
|
||||||
|
queue.songs.push(queue.songs.shift());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
queue.songs = queue.songs.slice(args[0] - 2);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
queue.connection.dispatcher.end();
|
||||||
|
} catch (error) {
|
||||||
|
queue.voiceChannel.leave();
|
||||||
|
message.client.queue.delete(message.guild.id);
|
||||||
|
return client.err(message, "Music", "skipto", 36);
|
||||||
|
}
|
||||||
|
|
||||||
|
queue.textChannel
|
||||||
|
.send({
|
||||||
|
embed: {
|
||||||
|
color: "GREEN",
|
||||||
|
description: `${message.author} ⏭ skipped ${args[0] - 1} songs`,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.catch(console.error);
|
||||||
|
message.react("✅");
|
||||||
|
},
|
||||||
|
};
|
29
commands/Music/stop.js
Normal file
29
commands/Music/stop.js
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "stop",
|
||||||
|
description: "To stop the music and clear the queue",
|
||||||
|
category: "Music",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const channel = message.member.voice.channel;
|
||||||
|
if (!channel) return client.err(message, "Music", "stop", 35);
|
||||||
|
const serverQueue = message.client.queue.get(message.guild.id);
|
||||||
|
if (!serverQueue) return client.err(message, "Music", "stop", 34);
|
||||||
|
if (!serverQueue.connection) return;
|
||||||
|
if (!serverQueue.connection.dispatcher) return;
|
||||||
|
try {
|
||||||
|
serverQueue.connection.dispatcher.end();
|
||||||
|
} catch (error) {
|
||||||
|
message.guild.me.voice.channel.leave();
|
||||||
|
message.client.queue.delete(message.guild.id);
|
||||||
|
return client.err(message, "Music", "stop", 36);
|
||||||
|
}
|
||||||
|
message.client.queue.delete(message.guild.id);
|
||||||
|
serverQueue.songs = [];
|
||||||
|
message.react("✅");
|
||||||
|
},
|
||||||
|
};
|
35
commands/Music/volume.js
Normal file
35
commands/Music/volume.js
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "volume",
|
||||||
|
description: "To change the server song queue volume",
|
||||||
|
usage: "(Number)",
|
||||||
|
aliases: ["vol"],
|
||||||
|
category: "Music",
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const channel = message.member.voice.channel;
|
||||||
|
if (!channel) return client.err(message, "Music", "volume", 35);
|
||||||
|
const serverQueue = message.client.queue.get(message.guild.id);
|
||||||
|
if (!serverQueue) return client.err(message, "Music", "volume", 34);
|
||||||
|
if (!serverQueue.connection)
|
||||||
|
return client.err(message, "Music", "volume", 34);
|
||||||
|
if (!args[0])
|
||||||
|
return message.channel.send(
|
||||||
|
`The current volume is: **${serverQueue.volume}**`
|
||||||
|
);
|
||||||
|
if (isNaN(args[0])) return client.err(message, "Music", "volume", 101);
|
||||||
|
if (parseInt(args[0]) > 150 || args[0] < 0)
|
||||||
|
return client.err(message, "Music", "volume", 101);
|
||||||
|
serverQueue.volume = args[0];
|
||||||
|
serverQueue.connection.dispatcher.setVolumeLogarithmic(args[0] / 100);
|
||||||
|
let xd = new MessageEmbed()
|
||||||
|
.setDescription(`Tuned the volume to: **${args[0] / 1}/100**`)
|
||||||
|
.setAuthor("Server Volume Manager", "https://i.imgur.com/qHPXWxN.gif")
|
||||||
|
.setColor("client.color");
|
||||||
|
return message.channel.send(xd);
|
||||||
|
},
|
||||||
|
};
|
43
commands/Owner/accept.js
Normal file
43
commands/Owner/accept.js
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
const { Suggestion } = require("../../config.json");
|
||||||
|
module.exports = {
|
||||||
|
name: "accept",
|
||||||
|
category: "Owner",
|
||||||
|
usage: "(Message)",
|
||||||
|
description: "Accept a suggestion",
|
||||||
|
Owner: true,
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const MessageID = args[0];
|
||||||
|
const acceptQuery =
|
||||||
|
args.slice(1).join(" ") || `Night doesn't leave any message.`;
|
||||||
|
|
||||||
|
if (!MessageID) return message.reply("Please specify a valid ID");
|
||||||
|
try {
|
||||||
|
const suggestionChannel = message.guild.channels.cache.get(Suggestion);
|
||||||
|
const suggestEmbed = await suggestionChannel.messages.fetch(MessageID);
|
||||||
|
console.log(suggestEmbed);
|
||||||
|
const data = suggestEmbed.embeds[0];
|
||||||
|
const acceptEmbed = new MessageEmbed()
|
||||||
|
.setAuthor(data.author.name, data.author.iconURL)
|
||||||
|
.setDescription(data.description)
|
||||||
|
.setColor("GREEN")
|
||||||
|
.addField("**Status(ACCEPTED)**", acceptQuery);
|
||||||
|
|
||||||
|
suggestEmbed.edit(acceptEmbed);
|
||||||
|
|
||||||
|
const user = await client.users.cache.find(
|
||||||
|
u => u.tag === data.author.name
|
||||||
|
);
|
||||||
|
message.channel.send("Suggestion accepted.");
|
||||||
|
user.send(acceptEmbed);
|
||||||
|
} catch (err) {
|
||||||
|
message.channel.send("That suggestion doesn't exist");
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
20
commands/Owner/add.js
Normal file
20
commands/Owner/add.js
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "add",
|
||||||
|
category: "Owner",
|
||||||
|
usage: "(Number)",
|
||||||
|
description: "Add coins from someone",
|
||||||
|
Owner: true,
|
||||||
|
/**
|
||||||
|
* @param {Client}client
|
||||||
|
* @param {Message}message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
if (!args[0] || isNaN(args[0]))
|
||||||
|
return message.channel.send("Number of coins?");
|
||||||
|
const user = message.mentions.members.first() || message.author;
|
||||||
|
client.data.add(user.id, parseInt(args[0]));
|
||||||
|
message.react("<a:a_yes:808683134786863124>");
|
||||||
|
},
|
||||||
|
};
|
31
commands/Owner/blacklist.js
Normal file
31
commands/Owner/blacklist.js
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "bk",
|
||||||
|
category: "Owner",
|
||||||
|
usage: "(User) (Toggle) (Reason)",
|
||||||
|
description: "Blacklist someone from the bot",
|
||||||
|
Owner: true,
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
let user = args[0];
|
||||||
|
toggle = args[1];
|
||||||
|
reason = args.slice(2).join(" ");
|
||||||
|
if (toggle === "true") {
|
||||||
|
await client.data.BK(user, toggle, reason);
|
||||||
|
message.inlineReply(
|
||||||
|
`**Blacklisted** ${message.guild.members.cache.get(
|
||||||
|
user
|
||||||
|
)}.\n**Reason: **${reason}`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
await client.data.BK(user, toggle, reason);
|
||||||
|
message.inlineReply(
|
||||||
|
`Removed blacklist from ${message.guild.members.cache.get(user)}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
41
commands/Owner/deny.js
Normal file
41
commands/Owner/deny.js
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
const { Suggestion } = require("../../config.json");
|
||||||
|
module.exports = {
|
||||||
|
name: "deny",
|
||||||
|
category: "Owner",
|
||||||
|
usage: "(Message)",
|
||||||
|
description: "Deny a suggestion",
|
||||||
|
Owner: true,
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const MessageID = args[0];
|
||||||
|
const denyQuery =
|
||||||
|
args.slice(1).join(" ") || `Night doesn't leave any message.`;
|
||||||
|
|
||||||
|
if (!MessageID) return message.reply("Please specify a valid ID");
|
||||||
|
try {
|
||||||
|
const suggestionChannel = message.guild.channels.cache.get(Suggestion);
|
||||||
|
const suggestEmbed = await suggestionChannel.messages.fetch(MessageID);
|
||||||
|
console.log(suggestEmbed);
|
||||||
|
const data = suggestEmbed.embeds[0];
|
||||||
|
const denyEmbed = new MessageEmbed()
|
||||||
|
.setAuthor(data.author.name, data.author.iconURL)
|
||||||
|
.setDescription(data.description)
|
||||||
|
.setColor("RED")
|
||||||
|
.addField("**Status(DENIED)**", denyQuery);
|
||||||
|
suggestEmbed.edit(denyEmbed);
|
||||||
|
const user = await client.users.cache.find(
|
||||||
|
u => u.tag === data.author.name
|
||||||
|
);
|
||||||
|
message.channel.send("Suggestion denied.");
|
||||||
|
user.send(denyEmbed);
|
||||||
|
} catch (err) {
|
||||||
|
message.channel.send("That suggestion doesn't exist");
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
25
commands/Owner/dm.js
Normal file
25
commands/Owner/dm.js
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "dm",
|
||||||
|
category: "Owner",
|
||||||
|
usage: "(User) (Message)",
|
||||||
|
description: "DM a user",
|
||||||
|
Owner: true,
|
||||||
|
/**
|
||||||
|
* @param {Client}client
|
||||||
|
* @param {Message}message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const user = client.users.cache.get(id);
|
||||||
|
if (!user) return message.inlineReply("User?");
|
||||||
|
if (!args.slice(1).join(" ")) return message.inlineReply("Message?");
|
||||||
|
try {
|
||||||
|
await user
|
||||||
|
.send(args.slice(1).join(" "))
|
||||||
|
.then(() => message.channel.send(`Sent message.`));
|
||||||
|
} catch (err) {
|
||||||
|
message.author.send("That user can't be dmed");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
45
commands/Owner/encrypt.js
Normal file
45
commands/Owner/encrypt.js
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "code",
|
||||||
|
Owner: true,
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const encrypted = encrypt(args.slice(0).join(" "));
|
||||||
|
message.channel.send(`\`\`\`${encrypted}\`\`\``);
|
||||||
|
message.channel.send(`\`\`\`${decrypt(encrypted)}\`\`\``);
|
||||||
|
function encrypt(inp) {
|
||||||
|
var str = inp.split(""),
|
||||||
|
out = "";
|
||||||
|
str.forEach((c, i) => {
|
||||||
|
if (c == " ") {
|
||||||
|
out += " ";
|
||||||
|
} else if (i % 3 == 0) {
|
||||||
|
out += String.fromCharCode(c.charCodeAt(0) + 3);
|
||||||
|
} else {
|
||||||
|
out += String.fromCharCode(c.charCodeAt(0) - 2);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
function decrypt(inp) {
|
||||||
|
var str = inp.split(""),
|
||||||
|
out = "";
|
||||||
|
str.forEach((c, i) => {
|
||||||
|
if (c == " ") {
|
||||||
|
out += " ";
|
||||||
|
} else if (i % 3 == 0) {
|
||||||
|
out += String.fromCharCode(c.charCodeAt(0) - 3);
|
||||||
|
} else {
|
||||||
|
out += String.fromCharCode(c.charCodeAt(0) + 2);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
47
commands/Owner/eval.js
Normal file
47
commands/Owner/eval.js
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
const util = require("util");
|
||||||
|
module.exports = {
|
||||||
|
name: "eval",
|
||||||
|
category: "Owner",
|
||||||
|
aliases: ["e"],
|
||||||
|
usage: "(Code)",
|
||||||
|
Owner: true,
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
let code = args.join(" ");
|
||||||
|
const embed = new MessageEmbed();
|
||||||
|
if (!code) {
|
||||||
|
return client.err(message, "Owner", "eval", "Missing 'Code' argument");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
let evaled = await eval(code),
|
||||||
|
output;
|
||||||
|
if (evaled.constructor.name === `Promise`) {
|
||||||
|
output = `📤 Output (Promise)`;
|
||||||
|
} else {
|
||||||
|
output = `📤 Output`;
|
||||||
|
}
|
||||||
|
if (evaled.length > 800) {
|
||||||
|
evaled = evaled.substring(0, 800) + `...`;
|
||||||
|
}
|
||||||
|
embed
|
||||||
|
.addField(`📥 Input`, `\`\`\`\n${code}\n\`\`\``)
|
||||||
|
.addField(output, `\`\`\`js\n${evaled}\n\`\`\``)
|
||||||
|
.setColor(client.color)
|
||||||
|
.addField(`Status`, `\`\`\`diff\n+ Success\`\`\``);
|
||||||
|
return message.channel.send(embed);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e.stack);
|
||||||
|
embed
|
||||||
|
.addField(`📥 Input`, `\`\`\`\n${code}\n\`\`\``)
|
||||||
|
.addField(`📤 Output`, `\`\`\`js\n${e}\n\`\`\``)
|
||||||
|
.addField(`Status`, `\`\`\`diff\n- Failed\`\`\``)
|
||||||
|
.setColor(client.color);
|
||||||
|
return message.channel.send(embed);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
50
commands/Owner/getinvite.js
Normal file
50
commands/Owner/getinvite.js
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "getinvite",
|
||||||
|
category: "Owner",
|
||||||
|
usage: "(Guild)",
|
||||||
|
description: "Generates an invitation to the server",
|
||||||
|
Owner: true,
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
let guild = null;
|
||||||
|
if (!args[0]) return client.err(message, "Owner", "getinvite", 0);
|
||||||
|
if (args[0]) {
|
||||||
|
let fetched = client.guilds.cache.find(g => g.name === args.join(" "));
|
||||||
|
let found = client.guilds.cache.get(args[0]);
|
||||||
|
if (!found) {
|
||||||
|
if (fetched) {
|
||||||
|
guild = fetched;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
guild = found;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return message.inlineReply("Invalid Name/ID!");
|
||||||
|
}
|
||||||
|
if (guild) {
|
||||||
|
let tChannel = guild.channels.cache.find(
|
||||||
|
ch =>
|
||||||
|
ch.type == "text" &&
|
||||||
|
ch.permissionsFor(ch.guild.me).has("CREATE_INSTANT_INVITE")
|
||||||
|
);
|
||||||
|
if (!tChannel) {
|
||||||
|
return client.err(message, "Owner", "getinvite", 6);
|
||||||
|
}
|
||||||
|
let invite = await tChannel
|
||||||
|
.createInvite({ temporary: false, maxAge: 0 })
|
||||||
|
.catch(err => {
|
||||||
|
return message.inlineReply(`${err} has occured!`);
|
||||||
|
});
|
||||||
|
message.inlineReply(invite.url);
|
||||||
|
} else {
|
||||||
|
return message.inlineReply(
|
||||||
|
`\`${args.join(" ")}\` - Bot is Not in this server`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
29
commands/Owner/guilds.js
Normal file
29
commands/Owner/guilds.js
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "guilds",
|
||||||
|
category: "Owner",
|
||||||
|
description: "Check top 10 guilds of the bot",
|
||||||
|
Owner: true,
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const guilds = client.guilds.cache
|
||||||
|
.sort((a, b) => b.memberCount - a.memberCount)
|
||||||
|
.first(10);
|
||||||
|
const description = guilds
|
||||||
|
.map((guild, index) => {
|
||||||
|
return `${index + 1}) ${guild.name} -> ${guild.memberCount}members`;
|
||||||
|
})
|
||||||
|
.join("\n");
|
||||||
|
let embed = new MessageEmbed()
|
||||||
|
.setTitle("Guilds")
|
||||||
|
.setDescription(description)
|
||||||
|
.setColor(client.color)
|
||||||
|
.setFooter(`Made by Cath Team`)
|
||||||
|
.setTimestamp();
|
||||||
|
message.channel.send(embed);
|
||||||
|
},
|
||||||
|
};
|
22
commands/Owner/premium.js
Normal file
22
commands/Owner/premium.js
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "setpremium",
|
||||||
|
category: "Owner",
|
||||||
|
usage: "(User) (Toggle) (Tier)",
|
||||||
|
description: "Set someone into Premium with tiers",
|
||||||
|
Owner: true,
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const member =
|
||||||
|
message.mentions.members.first() ||
|
||||||
|
message.guild.members.cache.get(args[0]);
|
||||||
|
client.data.Premium(member.id, "true", args[1]);
|
||||||
|
message.inlineReply(
|
||||||
|
`**${member.user.username}**'s premium status:\nTier **${args[1]}**`
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
56
commands/Owner/reaction-role.js
Normal file
56
commands/Owner/reaction-role.js
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "test",
|
||||||
|
Owner: true,
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setAuthor(
|
||||||
|
"Ń1ght and Cath Nation",
|
||||||
|
"https://images-ext-2.discordapp.net/external/JyjN4pXpaLIaSOSszAR9dyp03Hf3ouzjUb8kRa0OFiE/%3Fsize%3D2048/https/cdn.discordapp.com/icons/718762019586572341/c35c387563c7527f056276f2a16f526b.webp"
|
||||||
|
)
|
||||||
|
.setColor(client.color)
|
||||||
|
.setDescription(
|
||||||
|
"*Welcome to Ń1ght and Cath Nation*.\n**Please get a role below by reacting!**\n**[Invite](https://discord.com/api/oauth2/authorize?client_id=800966959268364288&permissions=4231314550&scope=bot%20applications.commands) | [Support](https://discord.gg/SbQHChmGcp) | [YouTube](https://youtube.com/c/Kirito01) | [Website](https://www.cath.gq)**"
|
||||||
|
)
|
||||||
|
.addFields(
|
||||||
|
{
|
||||||
|
name: "Gold<:gold:841194046419370024>",
|
||||||
|
value: "<@&841200768706543636>",
|
||||||
|
inline: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Platinum<:platinum:841194040165924865>",
|
||||||
|
value: "<@&840536973126270976>",
|
||||||
|
inline: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Updates<:Update:841196992385253408>",
|
||||||
|
value: "<@&841200845885538325>",
|
||||||
|
inline: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Announcements<:announce_dark:841195615458951168>",
|
||||||
|
value: "<@&841026716181069824>",
|
||||||
|
inline: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "YouTube<:YouTube:841186450497339412>",
|
||||||
|
value: "<@&765928569397575750>",
|
||||||
|
inline: true,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.setThumbnail(client.user.displayAvatarURL())
|
||||||
|
.setURL(client.web)
|
||||||
|
.setFooter(
|
||||||
|
"Ń1ght#0001",
|
||||||
|
"https://images-ext-2.discordapp.net/external/JyjN4pXpaLIaSOSszAR9dyp03Hf3ouzjUb8kRa0OFiE/%3Fsize%3D2048/https/cdn.discordapp.com/icons/718762019586572341/c35c387563c7527f056276f2a16f526b.webp"
|
||||||
|
)
|
||||||
|
.setTimestamp();
|
||||||
|
message.channel.send(embed);
|
||||||
|
},
|
||||||
|
};
|
19
commands/Owner/restart.js
Normal file
19
commands/Owner/restart.js
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "restart",
|
||||||
|
category: "Owner",
|
||||||
|
description: "Restart the bot",
|
||||||
|
Owner: true,
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
message.channel
|
||||||
|
.send("Restarting...")
|
||||||
|
.then(message => client.destroy())
|
||||||
|
.then(() => client.login(process.env.TOKEN));
|
||||||
|
message.channel.send("Restarted");
|
||||||
|
},
|
||||||
|
};
|
20
commands/Owner/rmv.js
Normal file
20
commands/Owner/rmv.js
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
const { Client, Message, MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "rmv",
|
||||||
|
category: "Owner",
|
||||||
|
usage: "(Number)",
|
||||||
|
description: "Remove coins from someone",
|
||||||
|
Owner: true,
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
if (!args[0] || isNaN(args[0]))
|
||||||
|
return message.channel.send("Number of coins?");
|
||||||
|
const user = message.mentions.members.first() || message.author;
|
||||||
|
client.data.rmv(user.id, parseInt(args[0]));
|
||||||
|
message.react("<a:a_yes:808683134786863124>");
|
||||||
|
},
|
||||||
|
};
|
25
commands/Owner/setBotAvatar.js
Normal file
25
commands/Owner/setBotAvatar.js
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
const { MessageEmbed } = require("discord.js");
|
||||||
|
module.exports = {
|
||||||
|
name: "setavatar",
|
||||||
|
category: "Owner",
|
||||||
|
usage: "(Link)",
|
||||||
|
description: "Set bot avatar from a link",
|
||||||
|
Owner: true,
|
||||||
|
/**
|
||||||
|
* @param {Client} client
|
||||||
|
* @param {Message} message
|
||||||
|
* @param {String[]} args
|
||||||
|
*/
|
||||||
|
run: async (client, message, args) => {
|
||||||
|
if (message.deletable) {
|
||||||
|
message.delete();
|
||||||
|
}
|
||||||
|
if (!args || args.length < 1) {
|
||||||
|
return client.err(message, "Owner", "setBotAvatar", 404);
|
||||||
|
}
|
||||||
|
client.user.setAvatar(args.join(" "));
|
||||||
|
message.channel
|
||||||
|
.send("Profile picture has been changed.")
|
||||||
|
.then(m => m.delete({ timeout: 10000 }));
|
||||||
|
},
|
||||||
|
};
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue