├── .github
└── FUNDING.yml
├── LICENSE
├── README.md
├── Tutorial-1.1-Handler
├── commands
│ ├── fun
│ │ └── say.js
│ └── info
│ │ └── ping.js
├── config.json
├── handlers
│ └── command.js
├── index.js
└── package.json
├── Tutorial-1.2-FinishHandler
├── commands
│ ├── fun
│ │ └── say.js
│ └── info
│ │ ├── help.js
│ │ ├── ping.js
│ │ └── uptime.js
├── config.json
├── handlers
│ └── command.js
├── index.js
└── package.json
├── Tutorial-1
├── index.js
└── package.json
├── Tutorial-10
├── commands
│ ├── fun
│ │ └── say.js
│ └── info
│ │ ├── apply.js
│ │ ├── help.js
│ │ ├── ping.js
│ │ └── uptime.js
├── config.json
├── handlers
│ └── command.js
├── index.js
├── package-lock.json
└── package.json
├── Tutorial-11
├── commands
│ ├── fun
│ │ └── say.js
│ └── info
│ │ ├── apply.js
│ │ ├── help.js
│ │ ├── ping.js
│ │ └── uptime.js
├── config.json
├── handlers
│ └── command.js
├── index.js
├── json.sqlite
├── package-lock.json
└── package.json
├── Tutorial-2
├── commands
│ ├── fun
│ │ ├── embed.js
│ │ └── say.js
│ └── info
│ │ ├── help.js
│ │ ├── ping.js
│ │ └── uptime.js
├── config.json
├── handlers
│ └── command.js
├── index.js
└── package-lock.json
├── Tutorial-3
├── commands
│ ├── fun
│ │ └── say.js
│ └── info
│ │ ├── help.js
│ │ ├── ping.js
│ │ └── uptime.js
├── config.json
├── handlers
│ └── command.js
├── index.js
└── package-lock.json
├── Tutorial-4
├── commands
│ ├── fun
│ │ └── say.js
│ ├── info
│ │ ├── help.js
│ │ ├── ping.js
│ │ └── uptime.js
│ └── user
│ │ └── avatar.js
├── config.json
├── handlers
│ └── command.js
├── index.js
└── package-lock.json
├── Tutorial-5
├── commands
│ ├── fun
│ │ └── say.js
│ ├── info
│ │ ├── help.js
│ │ ├── ping.js
│ │ └── uptime.js
│ └── user
│ │ └── userinfo.js
├── config.json
├── handlers
│ └── command.js
├── index.js
└── package-lock.json
├── Tutorial-6
├── commands
│ ├── fun
│ │ └── say.js
│ ├── info
│ │ ├── help.js
│ │ ├── ping.js
│ │ └── uptime.js
│ └── user
│ │ ├── addrole.js
│ │ └── removerole.js
├── config.json
├── handlers
│ └── command.js
├── index.js
└── package-lock.json
├── Tutorial-7
├── commands
│ ├── fun
│ │ └── say.js
│ ├── info
│ │ ├── help.js
│ │ ├── ping.js
│ │ └── uptime.js
│ └── user
│ │ ├── ban.js
│ │ └── kick.js
├── config.json
├── handlers
│ └── command.js
├── index.js
└── package-lock.json
├── Tutorial-8
├── commands
│ ├── fun
│ │ └── say.js
│ ├── info
│ │ ├── help.js
│ │ ├── ping.js
│ │ └── uptime.js
│ └── user
│ │ ├── addrole.js
│ │ └── removerole.js
├── config.json
├── handlers
│ └── command.js
├── index.js
└── package-lock.json
└── Tutorial-9
├── commands
├── fun
│ └── say.js
└── info
│ ├── help.js
│ ├── ping.js
│ ├── serverinfo.js
│ └── uptime.js
├── config.json
├── handlers
└── command.js
├── index.js
├── package-lock.json
└── package.json
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | custom: ['milrato.eu', 'dc.milrato.eu', 'bero.milrato.eu', 'bittmax.milrato.eu' ]
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## DISCORD BOT TUTORIAL
2 |
3 | [](http://makeapullrequest.com)
4 | [](https://GitHub.com/Tomato6966/)
5 | [](https://GitHub.com/Tomato6966/Ask-Me-Anything)
6 | [](https://discord.gg/fS6qBSm)
7 |
8 | ## [**DISCORD SUPPORT SERVER INVITE**](https://support.milrato.eu)
9 |
10 | In dieser VIDEO SERIE Erfährst du wie du deinen EIGENEN DISCORD BOT PROGRAMMIERST!
11 |
12 | Link: [```https://www.youtube.com/playlist?list=PLbLeA7W1w2T7bluFjJ0aWXM5zI_EcB8ye```](https://www.youtube.com/playlist?list=PLbLeA7W1w2T7bluFjJ0aWXM5zI_EcB8ye)
13 |
14 | ## Other important tutorials:
15 | - Install nodejs: [```https://www.youtube.com/watch?v=YsDkgpARBT0```](https://www.youtube.com/watch?v=YsDkgpARBT0)
16 | - Install python: [```https://www.youtube.com/watch?v=7LdRnyuIHj4```](https://www.youtube.com/watch?v=7LdRnyuIHj4)
17 | - Install ffmpeg: [```https://www.youtube.com/watch?v=x5PfJoVNtzc```](https://www.youtube.com/watch?v=x5PfJoVNtzc)
18 |
19 |
20 | ### Node.js:
21 | [```https://nodejs.org/en/```](https://nodejs.org/en/)
22 | ### Python:
23 | [```https://www.python.org/downloads/```](https://www.python.org/downloads/)
24 | ### FFmpeg:
25 | [```https://ffmpeg.org/download.html```](https://ffmpeg.org/download.html)
26 | ### Visual Studio CODE:
27 | [```https://code.visualstudio.com```](https://code.visualstudio.com)
28 |
29 | #### Discord.js:
30 | [```https://www.npmjs.com/package/discord.js```](https://www.npmjs.com/package/discord.js)
31 | #### Discord Developer Portal:
32 | [```https://discord.com/developers/application```](https://discord.com/developers/application)
33 | #### Discord Bot Invite Link generator:
34 | [```https://discordapi.com/permissions.html```](https://discordapi.com/permissions.html)
35 |
36 |
37 |
38 | ***
39 |
40 | ## [Discord Server 😎](https://discord.gg/milrato) | [Website](https://milrato.dev)
41 |
42 |
43 | ***
44 |
45 | ## SUPPORT ME AND MILRATO DEVELOPMENT
46 |
47 | > You can always Support me by inviting one of my **own Discord Bots**
48 |
49 | [](https://lava.milrato.dev)
50 | [](https://musicium.musicium.dev)
51 | [](https://milrato.milrato.dev)
52 |
53 | # Credits
54 |
55 | > If consider using this Bot, make sure to credit me!
56 |
--------------------------------------------------------------------------------
/Tutorial-1.1-Handler/commands/fun/say.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: "say",
3 | category: "fun",
4 | description: "Resends the message",
5 | run: async (client, message, args) => {
6 | message.channel.send(args.join(" "))
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/Tutorial-1.1-Handler/commands/info/ping.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: "ping",
3 | aliases: ["latency"],
4 | category: "info",
5 | description: "Returns latency and API ping",
6 | run: async (client, message, args) => {
7 | const msg = await message.channel.send(`🏓 Pinging....`);
8 | msg.edit(`🏓 Pong!
9 | Ping ${Math.round(client.ws.ping)}ms`);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Tutorial-1.1-Handler/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "token": "Nzg5MDY0NDE4OTI2Mzk1NDEz.X9sngQ.CJaUIJH8h3AE36TjoFYcpRmaHeo",
3 | "prefix": "!"
4 | }
--------------------------------------------------------------------------------
/Tutorial-1.1-Handler/handlers/command.js:
--------------------------------------------------------------------------------
1 | const { readdirSync } = require("fs");
2 | const ascii = require("ascii-table");
3 | let table = new ascii("Commands");
4 | table.setHeading("Command", "Load status");
5 | console.log("Welcome to SERVICE HANDLER // By https://x10-gaming.eu/service/dc // Discord: Tomato#6966")
6 | module.exports = (client) => {
7 | readdirSync("./commands/").forEach(dir => {
8 | const commands = readdirSync(`./commands/${dir}/`).filter(file => file.endsWith(".js"));
9 | for (let file of commands) {
10 | let pull = require(`../commands/${dir}/${file}`);
11 | if (pull.name) {
12 | client.commands.set(pull.name, pull);
13 | table.addRow(file, 'Ready');
14 | } else {
15 | table.addRow(file, `error -> missing a help.name, or help.name is not a string.`);
16 | continue;
17 | }
18 | if (pull.aliases && Array.isArray(pull.aliases)) pull.aliases.forEach(alias => client.aliases.set(alias, pull.name));
19 | }
20 | });
21 | console.log(table.toString());
22 | console.log("Welcome to SERVICE HANDLER // By https://x10-gaming.eu/service/dc // Discord: Tomato#6966");
23 | console.log("Logging into the BOT...");
24 | }
25 |
--------------------------------------------------------------------------------
/Tutorial-1.1-Handler/index.js:
--------------------------------------------------------------------------------
1 | //Modules
2 | const { Client, Collection } = require("discord.js");
3 | const config = require("./config.json");
4 | const fs = require("fs");
5 | const client = new Client({
6 | disableEveryone: true
7 | , partials: ['MESSAGE', 'CHANNEL', 'REACTION'] });
8 | client.commands = new Collection();
9 | client.aliases = new Collection();
10 | client.categories = fs.readdirSync("./commands/");
11 | ["command"].forEach(handler => {
12 | require(`./handlers/${handler}`)(client);
13 | });
14 | client.on("ready", () => {
15 | console.log(`Discord Bot is online!`);
16 | });
17 | client.on("message", async message => {
18 | const prefix = (config.prefix);
19 | if (message.author.bot) return;
20 | if (!message.guild) return;
21 | if (!message.content.startsWith(prefix)) return;
22 | const args = message.content.slice(prefix.length).trim().split(/ +/g);
23 | const cmd = args.shift().toLowerCase();
24 | if (cmd.length === 0) return;
25 | let command = client.commands.get(cmd);
26 | if (!command) command = client.commands.get(client.aliases.get(cmd));
27 | if (command)
28 | command.run(client, message, args);
29 | });
30 | client.login(config.token);
31 |
--------------------------------------------------------------------------------
/Tutorial-1.1-Handler/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "DiscordBotHandler-Withauto-HELP",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "dependencies": {
7 | "ascii-table": "^0.0.9",
8 | "common-tags": "^1.8.0",
9 | "discord.js": "^12.5.1",
10 | "got": "^11.8.1"
11 | },
12 | "devDependencies": {},
13 | "scripts": {
14 | "test": "echo \"Error: no test specified\" && exit 1",
15 | "start": "node index.js"
16 | },
17 | "author": "Tomato#6966",
18 | "license": "ISC"
19 | }
20 |
--------------------------------------------------------------------------------
/Tutorial-1.2-FinishHandler/commands/fun/say.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = {
3 | name: "say",
4 | category: "fun",
5 | description: "Resends the message",
6 | run: async (client, message, args) => {
7 | message.channel.send(args.join(" "))
8 | }
9 | }
--------------------------------------------------------------------------------
/Tutorial-1.2-FinishHandler/commands/info/help.js:
--------------------------------------------------------------------------------
1 | const { MessageEmbed } = require("discord.js");
2 | const { stripIndents } = require("common-tags");
3 | const config = require("../../config.json");
4 | module.exports = {
5 | name: "help",
6 | aliases: ["h", "cmds"],
7 | category: "info",
8 | description: "Returns all Commands, or one specific Command information",
9 | usage: "[command], [aliases], [command ]",
10 | run: async (client,message,args) => {
11 | if(args[0]){
12 | return getCMD(client,message,args[0]);
13 | }
14 | else{
15 | return getAll(client, message);
16 | }
17 | }
18 | }
19 |
20 | function getAll(client,message){
21 | const embed = new MessageEmbed()
22 | .setColor("ORANGE")
23 | .setThumbnail(client.user.displayAvatarURL())
24 | .setTitle("HELP MENU")
25 | .addField("**__BOT BY:__**", `
26 | >>> <@442355791412854784> \`Tomato#6966\` [\`Website\`](https://musicium.eu)
27 | `)
28 | .setFooter(`TO see command descriptions and inforamtion, type: ${config.prefix}help [CMD NAME]`, client.user.displayAvatarURL())
29 | const commands = (category) => {
30 | return client.commands.filter(cmd => cmd.category === category)
31 | .map(cmd => `\`${cmd.name}\``).join(", ")
32 | }
33 | const info = client.categories.map(cat => stripIndents`**__${cat[0].toUpperCase() + cat.slice(1)}__**\n> ${commands(cat)}`)
34 | .reduce((string, category) => string + "\n" + category);
35 | return message.channel.send(embed.setDescription(info))
36 | }
37 | function getCMD(client,message,input){
38 | const embed = new MessageEmbed()
39 | const cmd = client.commands.get(input.toLowerCase()) || client.commands.get(client.aliases.get(input.toLowerCase()))
40 | let info = `No Information found for command **${input.toLowerCase()}**`;
41 | if(!cmd){
42 | return message.channel.send(embed.setColor("RED").setDescription(info));
43 | }
44 | info = "";
45 | if(cmd.name) info += `**Command name**: \`${cmd.name}\``
46 | if(cmd.aliases) info += `**Aliases**: ${cmd.aliases.map(a => `\`${a}\``).join(", ")}`
47 | if(cmd.description) info += `**Description**: \`${cmd.description}\``
48 | if(cmd.usage) {
49 | info += `\n**Usage**: ${cmd.usage}`;
50 | embed.setFooter("Syntax: <> = required, [] = optional");
51 | }
52 | return message.channel.send(embed.setColor("ORANGE").setDescription(info))
53 | }
54 |
--------------------------------------------------------------------------------
/Tutorial-1.2-FinishHandler/commands/info/ping.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: "ping",
3 | aliases: ["latency"],
4 | category: "info",
5 | description: "Returns latency and API ping",
6 | run: async (client, message, args) => {
7 | const msg = await message.channel.send(`🏓 Pinging....`);
8 | msg.edit(`🏓 Pong!
9 | API Latency is ${Math.round(client.ws.ping)}ms`);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Tutorial-1.2-FinishHandler/commands/info/uptime.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: "uptime",
3 | aliases: ["uptime"],
4 | category: "info",
5 | description: "Returns the duration of how long the Bot is online",
6 | usage: "[command], [aliases]",
7 | run: async (client,message,args) => {
8 | function duration(ms) {
9 | const sec = Math.floor(ms / 1000 % 60).toString();
10 | const min = Math.floor(ms / (60*1000) % 60).toString();
11 | const hrs = Math.floor(ms / (60*60*1000) % 60).toString();
12 | const days = Math.floor(ms / (24*60*60*1000) % 60).toString();
13 | return `\`${days} Days\`, \`${hrs} Hours\`, \`${min} Minutes\`, \`${sec} Seconds\``
14 | }
15 | message.reply(`:white_check_mark: **${client.user.username}** is since ${duration(client.uptime)} online`);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Tutorial-1.2-FinishHandler/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "token": "Nzg5MDY0NDE4OTI2Mzk1NDEz.X9sngQ.CJaUIJH8h3AE36TjoFYcpRmaHeo",
3 | "prefix": "!"
4 | }
--------------------------------------------------------------------------------
/Tutorial-1.2-FinishHandler/handlers/command.js:
--------------------------------------------------------------------------------
1 | const { readdirSync } = require("fs");
2 | const ascii = require("ascii-table");
3 | let table = new ascii("Commands");
4 | table.setHeading("Command", "Load status");
5 | console.log("Welcome to SERVICE HANDLER // By https://x10-gaming.eu/service/dc // Discord: Tomato#6966")
6 | module.exports = (client) => {
7 | readdirSync("./commands/").forEach(dir => {
8 | const commands = readdirSync(`./commands/${dir}/`).filter(file => file.endsWith(".js"));
9 | for (let file of commands) {
10 | let pull = require(`../commands/${dir}/${file}`);
11 | if (pull.name) {
12 | client.commands.set(pull.name, pull);
13 | table.addRow(file, 'Ready');
14 | } else {
15 | table.addRow(file, `error -> missing a help.name, or help.name is not a string.`);
16 | continue;
17 | }
18 | if (pull.aliases && Array.isArray(pull.aliases)) pull.aliases.forEach(alias => client.aliases.set(alias, pull.name));
19 | }
20 | });
21 | console.log(table.toString());
22 | console.log("Welcome to SERVICE HANDLER // By https://x10-gaming.eu/service/dc // Discord: Tomato#6966")
23 | console.log("Logging into the BOT...");
24 | }
25 |
--------------------------------------------------------------------------------
/Tutorial-1.2-FinishHandler/index.js:
--------------------------------------------------------------------------------
1 | //Modules
2 | const { Client, Collection } = require("discord.js");
3 | const config = require("./config.json");
4 | const fs = require("fs");
5 |
6 | const client = new Client({
7 | disableEveryone: true
8 | , partials: ['MESSAGE', 'CHANNEL', 'REACTION'] });
9 |
10 | client.commands = new Collection();
11 | client.aliases = new Collection();
12 |
13 | client.categories = fs.readdirSync("./commands/");
14 |
15 | ["command"].forEach(handler => {
16 | require(`./handlers/${handler}`)(client);
17 | });
18 |
19 | client.on("ready", () => {
20 | console.log(`Discord Bot is online!`);
21 | });
22 |
23 | client.on("message", async message => {
24 | const prefix = (config.prefix);
25 | if (message.author.bot) return;
26 | if (!message.guild) return;
27 |
28 | if (!message.content.startsWith(prefix)) return;
29 |
30 | const args = message.content.slice(prefix.length).trim().split(/ +/g);
31 | const cmd = args.shift().toLowerCase();
32 |
33 | if (cmd.length === 0) return;
34 |
35 | let command = client.commands.get(cmd);
36 | if (!command) command = client.commands.get(client.aliases.get(cmd));
37 |
38 |
39 | if (command)
40 | command.run(client, message, args);
41 |
42 | });
43 |
44 | client.login(config.token);
--------------------------------------------------------------------------------
/Tutorial-1.2-FinishHandler/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "DiscordBotHandler-Withauto-HELP",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "dependencies": {
7 | "ascii-table": "^0.0.9",
8 | "common-tags": "^1.8.0",
9 | "discord.js": "^12.5.1",
10 | "got": "^11.8.1"
11 | },
12 | "devDependencies": {},
13 | "scripts": {
14 | "test": "echo \"Error: no test specified\" && exit 1",
15 | "start": "node index.js"
16 | },
17 | "author": "Tomato#6966",
18 | "license": "ISC"
19 | }
20 |
--------------------------------------------------------------------------------
/Tutorial-1/index.js:
--------------------------------------------------------------------------------
1 | const Discord = require("discord.js");
2 |
3 | const client = new Discord.Client();
4 |
5 | const config = {
6 | prefix: "!",
7 | token: "Nzg5MDY0NDE4OTI2Mzk1NDEz.X9sngQ.bJwjn0SiOdee_0XD5v3WZObuhag"
8 | }
9 |
10 | client.on("ready", () => {
11 | console.log("Der Bot ist gestartet!")
12 | })
13 |
14 | client.on("message", (message) => {
15 | if(message.author.bot) return;
16 | if(!message.content.startsWith(config.prefix)) return;
17 |
18 | const args = message.content.slice(config.prefix.length).split(" ");
19 | const command = args.shift();
20 |
21 | switch(command){
22 | case "ping":
23 | message.channel.send(`Mein Ping ist: ${client.ws.ping}`);
24 | break;
25 | case "say":
26 | message.channel.send(args.join(" "));
27 | break;
28 | default:
29 | message.channel.send("UNKNOWN COMMAND");
30 | break;
31 | }
32 | })
33 |
34 | client.login(config.token);
--------------------------------------------------------------------------------
/Tutorial-1/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "discord_bot",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "node index.js"
9 | },
10 | "author": "",
11 | "license": "ISC",
12 | "dependencies": {
13 | "discord.js": "^12.5.1"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Tutorial-10/commands/fun/say.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = {
3 | name: "say",
4 | category: "fun",
5 | aliases: ["say"],
6 | description: "Resends the message",
7 | run: async (client, message, args) => {
8 | message.channel.send(args.join(" "))
9 | }
10 | }
--------------------------------------------------------------------------------
/Tutorial-10/commands/info/apply.js:
--------------------------------------------------------------------------------
1 | const { MessageEmbed } = require("discord.js");
2 | const config = require("../../config.json");
3 | module.exports = {
4 | name: "apply",
5 | aliases: [""],
6 | category: "info",
7 | description: "Apply for this TEAM",
8 | usage: "[command], [aliases], [command ]",
9 | run: async (client,message,args) => {
10 | var antworten = [];
11 | var fragen = [
12 | "Wie heißt du?",
13 | "Wie alt bist du?",
14 | "Was ist das Beste Hosting Unternehmen?",
15 | "Was ist der Beste Music Bot?",
16 | ]
17 | /**
18 | * [] === ["asdasd","213124","purple"] //array[0] --> asdasd | array[1] --> 213124 | array[2] --> purple
19 | */
20 | var counter = 0;
21 | message.author.send(fragen[counter]).then(msg => {
22 | msg.channel.awaitMessages(m => m.author.id === message.author.id, { max: 1, time: 120*1000, errors: ['time'] })
23 | .then(collected => {
24 | antworten.push(collected.first().content);
25 | counter++;
26 | message.author.send(fragen[counter]).then(msg => {
27 | msg.channel.awaitMessages(m => m.author.id === message.author.id, { max: 1, time: 120*1000, errors: ['time'] })
28 | .then(collected => {
29 | antworten.push(collected.first().content);
30 | counter++;
31 | message.author.send(fragen[counter]).then(msg => {
32 | msg.channel.awaitMessages(m => m.author.id === message.author.id, { max: 1, time: 120*1000, errors: ['time'] })
33 | .then(collected => {
34 | antworten.push(collected.first().content);
35 | counter++;
36 | message.author.send(fragen[counter]).then(msg => {
37 | msg.channel.awaitMessages(m => m.author.id === message.author.id, { max: 1, time: 120*1000, errors: ['time'] })
38 | .then(collected => {
39 | antworten.push(collected.first().content);
40 | counter++;
41 | ende_apply();
42 | })
43 | .catch(collected => {
44 | msg.channel.send('Looks like nobody got the answer this time.');
45 | });
46 | })
47 | })
48 | .catch(collected => {
49 | msg.channel.send('Looks like nobody got the answer this time.');
50 | });
51 | })
52 | })
53 | .catch(collected => {
54 | msg.channel.send('Looks like nobody got the answer this time.');
55 | });
56 | })
57 | })
58 | .catch(collected => {
59 | msg.channel.send('Looks like nobody got the answer this time.');
60 | });
61 | })
62 | function ende_apply(){
63 | const embed = new MessageEmbed()
64 | .setColor("RED")
65 | .setTitle(`${message.author.tag} hat sich beworben!`)
66 | .setTimestamp()
67 | .setThumbnail(message.member.user.displayAvatarURL({dynamic: true}))
68 | .setDescription(`${message.author}`)
69 | for(let i = 0; i < antworten.length; i++){
70 | embed.addField(fragen[i], "> " + antworten[i]);
71 | }
72 | message.guild.channels.cache.get("797043865567625308").send(embed)
73 | }
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/Tutorial-10/commands/info/help.js:
--------------------------------------------------------------------------------
1 | const { MessageEmbed } = require("discord.js");
2 | const { stripIndents } = require("common-tags");
3 | const config = require("../../config.json");
4 | module.exports = {
5 | name: "help",
6 | aliases: ["h", "cmds"],
7 | category: "info",
8 | description: "Returns all Commands, or one specific Command information",
9 | usage: "[command], [aliases], [command ]",
10 | run: async (client,message,args) => {
11 | if(args[0]){
12 | return getCMD(client,message,args[0]);
13 | }
14 | else{
15 | return getAll(client, message);
16 | }
17 | }
18 | }
19 |
20 | function getAll(client,message){
21 | const embed = new MessageEmbed()
22 | .setColor("ORANGE")
23 | .setThumbnail(client.user.displayAvatarURL())
24 | .setTitle("HELP MENU")
25 | .addField("**__BOT BY:__**", `
26 | >>> <@442355791412854784> \`Tomato#6966\` [\`Website\`](https://musicium.eu)
27 | `)
28 | .setFooter(`TO see command descriptions and inforamtion, type: ${config.prefix}help [CMD NAME]`, client.user.displayAvatarURL())
29 | const commands = (category) => {
30 | return client.commands.filter(cmd => cmd.category === category)
31 | .map(cmd => `\`${cmd.name}\``).join(", ")
32 | }
33 | const info = client.categories.map(cat => stripIndents`**__${cat[0].toUpperCase() + cat.slice(1)}__**\n> ${commands(cat)}`)
34 | .reduce((string, category) => string + "\n" + category);
35 | return message.channel.send(embed.setDescription(info))
36 | }
37 | function getCMD(client,message,input){
38 | const embed = new MessageEmbed()
39 | const cmd = client.commands.get(input.toLowerCase()) || client.commands.get(client.aliases.get(input.toLowerCase()))
40 | let info = `No Information found for command **${input.toLowerCase()}**`;
41 | if(!cmd){
42 | return message.channel.send(embed.setColor("RED").setDescription(info));
43 | }
44 | info = "";
45 | if(cmd.name) info += `**Command name**: \`${cmd.name}\`\n`
46 | if(cmd.aliases) info += `**Aliases**: \`${cmd.aliases.map(a => `${a}`).join("\`, \`")}\`\n`
47 | if(cmd.description) info += `**Description**: \`${cmd.description}\`\n`
48 | if(cmd.usage) {
49 | info += `\n**Usage**: \`${cmd.usage}\``;
50 | embed.setFooter("Syntax: <> = required, [] = optional");
51 | }
52 | return message.channel.send(embed.setColor("ORANGE").setDescription(info))
53 | }
--------------------------------------------------------------------------------
/Tutorial-10/commands/info/ping.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: "ping",
3 | aliases: ["latency"],
4 | category: "info",
5 | description: "Returns latency and API ping",
6 | run: async (client, message, args) => {
7 | const msg = await message.channel.send(`🏓 Pinging....`);
8 | msg.edit(`🏓 Pong!
9 | Ping is ${Math.round(client.ws.ping)}ms`);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Tutorial-10/commands/info/uptime.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: "uptime",
3 | aliases: ["uptime"],
4 | category: "info",
5 | description: "Returns the duration of how long the Bot is online",
6 | usage: "[command], [aliases]",
7 | run: async (client,message,args) => {
8 | function duration(ms) {
9 | const sec = Math.floor(ms / 1000 % 60).toString();
10 | const min = Math.floor(ms / (60*1000) % 60).toString();
11 | const hrs = Math.floor(ms / (60*60*1000) % 60).toString();
12 | const days = Math.floor(ms / (24*60*60*1000) % 60).toString();
13 | return `\`${days} Days\`, \`${hrs} Hours\`, \`${min} Minutes\`, \`${sec} Seconds\``
14 | }
15 | message.reply(`:white_check_mark: **${client.user.username}** is since ${duration(client.uptime)} online`);
16 | }
17 | }
--------------------------------------------------------------------------------
/Tutorial-10/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "token": "NzQ4MDk2MTcwNjk3NTU1OTY5.X0Yc2g.UCeXobxlEqRLb4XHWsRZD6TuUFg",
3 | "prefix": "!"
4 | }
--------------------------------------------------------------------------------
/Tutorial-10/handlers/command.js:
--------------------------------------------------------------------------------
1 | const { readdirSync } = require("fs");
2 | const ascii = require("ascii-table");
3 | let table = new ascii("Commands");
4 | table.setHeading("Command", "Load status");
5 | console.log("Welcome to SERVICE HANDLER // By https://x10-gaming.eu/service/dc // Discord: Tomato#6966")
6 | module.exports = (client) => {
7 | readdirSync("./commands/").forEach(dir => {
8 | const commands = readdirSync(`./commands/${dir}/`).filter(file => file.endsWith(".js"));
9 | for (let file of commands) {
10 | let pull = require(`../commands/${dir}/${file}`);
11 | if (pull.name) {
12 | client.commands.set(pull.name, pull);
13 | table.addRow(file, 'Ready');
14 | } else {
15 | table.addRow(file, `error -> missing a help.name, or help.name is not a string.`);
16 | continue;
17 | }
18 | if (pull.aliases && Array.isArray(pull.aliases)) pull.aliases.forEach(alias => client.aliases.set(alias, pull.name));
19 | }
20 | });
21 | console.log(table.toString());
22 | console.log("Welcome to SERVICE HANDLER // By https://x10-gaming.eu/service/dc // Discord: Tomato#6966")
23 | console.log("Logging into the BOT...");
24 | }
25 |
--------------------------------------------------------------------------------
/Tutorial-10/index.js:
--------------------------------------------------------------------------------
1 | //Modules
2 | const { Client, Collection } = require("discord.js");
3 | const config = require("./config.json");
4 | const fs = require("fs");
5 | const discord = require("discord.js");
6 | const client = new Client({
7 | disableEveryone: true
8 | , partials: ['MESSAGE', 'CHANNEL', 'REACTION'] });
9 |
10 | client.commands = new Collection();
11 | client.aliases = new Collection();
12 |
13 | client.categories = fs.readdirSync("./commands/");
14 |
15 | ["command"].forEach(handler => {
16 | require(`./handlers/${handler}`)(client);
17 | });
18 |
19 |
20 | let i = 0;
21 | var STATUSTEXT = [
22 | "1", //index == 0
23 | "2", //index == 1
24 | "3", //index == 2
25 | "4" //index == 3
26 | ];
27 | client.on("ready", () => {
28 | console.log("Bot is ready");
29 | //INIT
30 | client.user.setActivity("STATUSTEXT", { type: "STREAMING", url: "https://twitch.tv/#" })
31 | //LOOP
32 | setInterval(()=>{
33 | const index = Math.floor(i);
34 | if(index == 0 )client.user.setActivity(STATUSTEXT[index], { type: "STREAMING", url: "https://twitch.tv/#" })
35 | else if(index == 1 )client.user.setActivity(STATUSTEXT[index], { type: "PLAYING"})
36 | else if(index == 2 )client.user.setActivity(STATUSTEXT[index], { type: "WATCHING"})
37 | else if(index == 3 )client.user.setActivity(STATUSTEXT[index], { type: "LISTENING"})
38 | else client.user.setActivity(STATUSTEXT[index], { type: "PLAYING"})
39 | i++;
40 | if(i===STATUSTEXT.length) i -= STATUSTEXT.length;
41 | }, 5*1000)
42 |
43 | })
44 |
45 |
46 |
47 |
48 |
49 | client.on("message", async message => {
50 | const prefix = (config.prefix);
51 | if (message.author.bot) return;
52 | if (!message.guild) return;
53 |
54 | if (!message.content.startsWith(prefix)) return;
55 |
56 | const args = message.content.slice(prefix.length).trim().split(/ +/g);
57 | const cmd = args.shift().toLowerCase();
58 |
59 | if (cmd.length === 0) return;
60 |
61 | let command = client.commands.get(cmd);
62 | if (!command) command = client.commands.get(client.aliases.get(cmd));
63 |
64 |
65 | if (command)
66 | command.run(client, message, args);
67 |
68 | });
69 |
70 | client.login(config.token);
--------------------------------------------------------------------------------
/Tutorial-10/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "tutorial-9",
3 | "version": "1.0.0",
4 | "lockfileVersion": 1,
5 | "requires": true,
6 | "dependencies": {
7 | "@discordjs/collection": {
8 | "version": "0.1.6",
9 | "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.1.6.tgz",
10 | "integrity": "sha512-utRNxnd9kSS2qhyivo9lMlt5qgAUasH2gb7BEOn6p0efFh24gjGomHzWKMAPn2hEReOPQZCJaRKoURwRotKucQ=="
11 | },
12 | "@discordjs/form-data": {
13 | "version": "3.0.1",
14 | "resolved": "https://registry.npmjs.org/@discordjs/form-data/-/form-data-3.0.1.tgz",
15 | "integrity": "sha512-ZfFsbgEXW71Rw/6EtBdrP5VxBJy4dthyC0tpQKGKmYFImlmmrykO14Za+BiIVduwjte0jXEBlhSKf0MWbFp9Eg==",
16 | "requires": {
17 | "asynckit": "^0.4.0",
18 | "combined-stream": "^1.0.8",
19 | "mime-types": "^2.1.12"
20 | }
21 | },
22 | "abort-controller": {
23 | "version": "3.0.0",
24 | "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz",
25 | "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==",
26 | "requires": {
27 | "event-target-shim": "^5.0.0"
28 | }
29 | },
30 | "ascii-table": {
31 | "version": "0.0.9",
32 | "resolved": "https://registry.npmjs.org/ascii-table/-/ascii-table-0.0.9.tgz",
33 | "integrity": "sha1-BqZgTWpV1L9BqaR9mHLXp42jHnM="
34 | },
35 | "asynckit": {
36 | "version": "0.4.0",
37 | "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
38 | "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
39 | },
40 | "combined-stream": {
41 | "version": "1.0.8",
42 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
43 | "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
44 | "requires": {
45 | "delayed-stream": "~1.0.0"
46 | }
47 | },
48 | "common-tags": {
49 | "version": "1.8.0",
50 | "resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.0.tgz",
51 | "integrity": "sha512-6P6g0uetGpW/sdyUy/iQQCbFF0kWVMSIVSyYz7Zgjcgh8mgw8PQzDNZeyZ5DQ2gM7LBoZPHmnjz8rUthkBG5tw=="
52 | },
53 | "delayed-stream": {
54 | "version": "1.0.0",
55 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
56 | "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
57 | },
58 | "discord.js": {
59 | "version": "12.5.1",
60 | "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-12.5.1.tgz",
61 | "integrity": "sha512-VwZkVaUAIOB9mKdca0I5MefPMTQJTNg0qdgi1huF3iwsFwJ0L5s/Y69AQe+iPmjuV6j9rtKoG0Ta0n9vgEIL6w==",
62 | "requires": {
63 | "@discordjs/collection": "^0.1.6",
64 | "@discordjs/form-data": "^3.0.1",
65 | "abort-controller": "^3.0.0",
66 | "node-fetch": "^2.6.1",
67 | "prism-media": "^1.2.2",
68 | "setimmediate": "^1.0.5",
69 | "tweetnacl": "^1.0.3",
70 | "ws": "^7.3.1"
71 | }
72 | },
73 | "event-target-shim": {
74 | "version": "5.0.1",
75 | "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
76 | "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ=="
77 | },
78 | "mime-db": {
79 | "version": "1.45.0",
80 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.45.0.tgz",
81 | "integrity": "sha512-CkqLUxUk15hofLoLyljJSrukZi8mAtgd+yE5uO4tqRZsdsAJKv0O+rFMhVDRJgozy+yG6md5KwuXhD4ocIoP+w=="
82 | },
83 | "mime-types": {
84 | "version": "2.1.28",
85 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.28.tgz",
86 | "integrity": "sha512-0TO2yJ5YHYr7M2zzT7gDU1tbwHxEUWBCLt0lscSNpcdAfFyJOVEpRYNS7EXVcTLNj/25QO8gulHC5JtTzSE2UQ==",
87 | "requires": {
88 | "mime-db": "1.45.0"
89 | }
90 | },
91 | "moment": {
92 | "version": "2.29.1",
93 | "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
94 | "integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ=="
95 | },
96 | "node-fetch": {
97 | "version": "2.6.1",
98 | "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
99 | "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
100 | },
101 | "prism-media": {
102 | "version": "1.2.3",
103 | "resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.2.3.tgz",
104 | "integrity": "sha512-fSrR66n0l6roW9Rx4rSLMyTPTjRTiXy5RVqDOurACQ6si1rKHHKDU5gwBJoCsIV0R3o9gi+K50akl/qyw1C74A=="
105 | },
106 | "setimmediate": {
107 | "version": "1.0.5",
108 | "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz",
109 | "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU="
110 | },
111 | "tweetnacl": {
112 | "version": "1.0.3",
113 | "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz",
114 | "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw=="
115 | },
116 | "ws": {
117 | "version": "7.4.2",
118 | "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.2.tgz",
119 | "integrity": "sha512-T4tewALS3+qsrpGI/8dqNMLIVdq/g/85U98HPMa6F0m6xTbvhXU6RCQLqPH3+SlomNV/LdY6RXEbBpMH6EOJnA=="
120 | }
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/Tutorial-10/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "tutorial-9",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "dependencies": {
7 | "ascii-table": "0.0.9",
8 | "common-tags": "^1.8.0",
9 | "discord.js": "^12.5.1",
10 | "moment": "^2.29.1",
11 | "node-fetch": "^2.6.1"
12 | },
13 | "devDependencies": {},
14 | "scripts": {
15 | "test": "echo \"Error: no test specified\" && exit 1"
16 | },
17 | "author": "",
18 | "license": "ISC"
19 | }
20 |
--------------------------------------------------------------------------------
/Tutorial-11/commands/fun/say.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = {
3 | name: "say",
4 | category: "fun",
5 | aliases: ["say"],
6 | description: "Resends the message",
7 | run: async (client, message, args) => {
8 | message.channel.send(args.join(" "))
9 | }
10 | }
--------------------------------------------------------------------------------
/Tutorial-11/commands/info/apply.js:
--------------------------------------------------------------------------------
1 | const { MessageEmbed } = require("discord.js");
2 | const config = require("../../config.json");
3 | module.exports = {
4 | name: "apply",
5 | aliases: [""],
6 | category: "info",
7 | description: "Apply for this TEAM",
8 | usage: "[command], [aliases], [command ]",
9 | run: async (client,message,args) => {
10 | var antworten = [];
11 | var fragen = [
12 | "Wie heißt du?",
13 | "Wie alt bist du?",
14 | "Was ist das Beste Hosting Unternehmen?",
15 | "Was ist der Beste Music Bot?",
16 | ]
17 | /**
18 | * [] === ["asdasd","213124","purple"] //array[0] --> asdasd | array[1] --> 213124 | array[2] --> purple
19 | */
20 | var counter = 0;
21 | message.author.send(fragen[counter]).then(msg => {
22 | msg.channel.awaitMessages(m => m.author.id === message.author.id, { max: 1, time: 120*1000, errors: ['time'] })
23 | .then(collected => {
24 | antworten.push(collected.first().content);
25 | counter++;
26 | message.author.send(fragen[counter]).then(msg => {
27 | msg.channel.awaitMessages(m => m.author.id === message.author.id, { max: 1, time: 120*1000, errors: ['time'] })
28 | .then(collected => {
29 | antworten.push(collected.first().content);
30 | counter++;
31 | message.author.send(fragen[counter]).then(msg => {
32 | msg.channel.awaitMessages(m => m.author.id === message.author.id, { max: 1, time: 120*1000, errors: ['time'] })
33 | .then(collected => {
34 | antworten.push(collected.first().content);
35 | counter++;
36 | message.author.send(fragen[counter]).then(msg => {
37 | msg.channel.awaitMessages(m => m.author.id === message.author.id, { max: 1, time: 120*1000, errors: ['time'] })
38 | .then(collected => {
39 | antworten.push(collected.first().content);
40 | counter++;
41 | ende_apply();
42 | })
43 | .catch(collected => {
44 | msg.channel.send('Looks like nobody got the answer this time.');
45 | });
46 | })
47 | })
48 | .catch(collected => {
49 | msg.channel.send('Looks like nobody got the answer this time.');
50 | });
51 | })
52 | })
53 | .catch(collected => {
54 | msg.channel.send('Looks like nobody got the answer this time.');
55 | });
56 | })
57 | })
58 | .catch(collected => {
59 | msg.channel.send('Looks like nobody got the answer this time.');
60 | });
61 | })
62 | function ende_apply(){
63 | const embed = new MessageEmbed()
64 | .setColor("RED")
65 | .setTitle(`${message.author.tag} hat sich beworben!`)
66 | .setTimestamp()
67 | .setThumbnail(message.member.user.displayAvatarURL({dynamic: true}))
68 | .setDescription(`${message.author}`)
69 | for(let i = 0; i < antworten.length; i++){
70 | embed.addField(fragen[i], "> " + antworten[i]);
71 | }
72 | message.guild.channels.cache.get("797043865567625308").send(embed)
73 | }
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/Tutorial-11/commands/info/help.js:
--------------------------------------------------------------------------------
1 | const { MessageEmbed } = require("discord.js");
2 | const { stripIndents } = require("common-tags");
3 | const config = require("../../config.json");
4 | module.exports = {
5 | name: "help",
6 | aliases: ["h", "cmds"],
7 | category: "info",
8 | description: "Returns all Commands, or one specific Command information",
9 | usage: "[command], [aliases], [command ]",
10 | run: async (client,message,args) => {
11 | if(args[0]){
12 | return getCMD(client,message,args[0]);
13 | }
14 | else{
15 | return getAll(client, message);
16 | }
17 | }
18 | }
19 |
20 | function getAll(client,message){
21 | const embed = new MessageEmbed()
22 | .setColor("ORANGE")
23 | .setThumbnail(client.user.displayAvatarURL())
24 | .setTitle("HELP MENU")
25 | .addField("**__BOT BY:__**", `
26 | >>> <@442355791412854784> \`Tomato#6966\` [\`Website\`](https://musicium.eu)
27 | `)
28 | .setFooter(`TO see command descriptions and inforamtion, type: ${config.prefix}help [CMD NAME]`, client.user.displayAvatarURL())
29 | const commands = (category) => {
30 | return client.commands.filter(cmd => cmd.category === category)
31 | .map(cmd => `\`${cmd.name}\``).join(", ")
32 | }
33 | const info = client.categories.map(cat => stripIndents`**__${cat[0].toUpperCase() + cat.slice(1)}__**\n> ${commands(cat)}`)
34 | .reduce((string, category) => string + "\n" + category);
35 | return message.channel.send(embed.setDescription(info))
36 | }
37 | function getCMD(client,message,input){
38 | const embed = new MessageEmbed()
39 | const cmd = client.commands.get(input.toLowerCase()) || client.commands.get(client.aliases.get(input.toLowerCase()))
40 | let info = `No Information found for command **${input.toLowerCase()}**`;
41 | if(!cmd){
42 | return message.channel.send(embed.setColor("RED").setDescription(info));
43 | }
44 | info = "";
45 | if(cmd.name) info += `**Command name**: \`${cmd.name}\`\n`
46 | if(cmd.aliases) info += `**Aliases**: \`${cmd.aliases.map(a => `${a}`).join("\`, \`")}\`\n`
47 | if(cmd.description) info += `**Description**: \`${cmd.description}\`\n`
48 | if(cmd.usage) {
49 | info += `\n**Usage**: \`${cmd.usage}\``;
50 | embed.setFooter("Syntax: <> = required, [] = optional");
51 | }
52 | return message.channel.send(embed.setColor("ORANGE").setDescription(info))
53 | }
--------------------------------------------------------------------------------
/Tutorial-11/commands/info/ping.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: "ping",
3 | aliases: ["latency"],
4 | category: "info",
5 | description: "Returns latency and API ping",
6 | run: async (client, message, args) => {
7 | const msg = await message.channel.send(`🏓 Pinging....`);
8 | msg.edit(`🏓 Pong!
9 | Ping is ${Math.round(client.ws.ping)}ms`);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Tutorial-11/commands/info/uptime.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: "uptime",
3 | aliases: ["uptime"],
4 | category: "info",
5 | description: "Returns the duration of how long the Bot is online",
6 | usage: "[command], [aliases]",
7 | run: async (client,message,args) => {
8 | function duration(ms) {
9 | const sec = Math.floor(ms / 1000 % 60).toString();
10 | const min = Math.floor(ms / (60*1000) % 60).toString();
11 | const hrs = Math.floor(ms / (60*60*1000) % 60).toString();
12 | const days = Math.floor(ms / (24*60*60*1000) % 60).toString();
13 | return `\`${days} Days\`, \`${hrs} Hours\`, \`${min} Minutes\`, \`${sec} Seconds\``
14 | }
15 | message.reply(`:white_check_mark: **${client.user.username}** is since ${duration(client.uptime)} online`);
16 | }
17 | }
--------------------------------------------------------------------------------
/Tutorial-11/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "token": "NzQ4MDk2MTcwNjk3NTU1OTY5.X0Yc2g.h_buxFRttZtmX4oAzcjPR26Irnw",
3 | "prefix": "!"
4 | }
--------------------------------------------------------------------------------
/Tutorial-11/handlers/command.js:
--------------------------------------------------------------------------------
1 | const { readdirSync } = require("fs");
2 | const ascii = require("ascii-table");
3 | let table = new ascii("Commands");
4 | table.setHeading("Command", "Load status");
5 | console.log("Welcome to SERVICE HANDLER // By https://x10-gaming.eu/service/dc // Discord: Tomato#6966")
6 | module.exports = (client) => {
7 | readdirSync("./commands/").forEach(dir => {
8 | const commands = readdirSync(`./commands/${dir}/`).filter(file => file.endsWith(".js"));
9 | for (let file of commands) {
10 | let pull = require(`../commands/${dir}/${file}`);
11 | if (pull.name) {
12 | client.commands.set(pull.name, pull);
13 | table.addRow(file, 'Ready');
14 | } else {
15 | table.addRow(file, `error -> missing a help.name, or help.name is not a string.`);
16 | continue;
17 | }
18 | if (pull.aliases && Array.isArray(pull.aliases)) pull.aliases.forEach(alias => client.aliases.set(alias, pull.name));
19 | }
20 | });
21 | console.log(table.toString());
22 | console.log("Welcome to SERVICE HANDLER // By https://x10-gaming.eu/service/dc // Discord: Tomato#6966")
23 | console.log("Logging into the BOT...");
24 | }
25 |
--------------------------------------------------------------------------------
/Tutorial-11/index.js:
--------------------------------------------------------------------------------
1 | //Modules
2 | const { Client, Collection } = require("discord.js");
3 | const config = require("./config.json");
4 | const fs = require("fs");
5 | const discord = require("discord.js");
6 | const client = new Client({partials: ['MESSAGE', 'CHANNEL', 'REACTION'] });
7 |
8 | client.commands = new Collection();
9 | client.aliases = new Collection();
10 |
11 | client.applies = require("quick.db");
12 |
13 | client.categories = fs.readdirSync("./commands/");
14 |
15 | ["command"].forEach(handler => {
16 | require(`./handlers/${handler}`)(client);
17 | });
18 |
19 | client.on("messageReactionAdd", async (reaction, user) => {
20 | if(reaction.message.partial) await reaction.message.fetch();
21 | if(reaction.partial) await reaction.fetch()
22 | if(user.bot) return;
23 | if(!reaction.message.guild ) return;
24 |
25 |
26 | if(reaction.message.id === "803715067928510465"){
27 | if(client.applies.get(user.id))
28 | {
29 | return user.send("DU HAST DICH BEI UNS SCHON BEWORBEN!")
30 | }
31 | else{
32 | client.applies.set(user.id, true);
33 | }
34 | apply(reaction, user);
35 | }
36 | if(reaction.message.channel.parent && reaction.message.channel.parent.id === "803719111992541224"){
37 | if(reaction.emoji.name === "✅"){
38 | let userid = client.applies.get(reaction.message.id);
39 | let theuser = reaction.message.guild.members.cache.get(userid)
40 | theuser.send("DU WURDEST ANGENOMMEN")
41 | }
42 | if(reaction.emoji.name === "❌"){
43 | let userid = client.applies.get(reaction.message.id);
44 | let theuser = reaction.message.guild.members.cache.get(userid)
45 | theuser.send("DU WURDEST ABGELEHNT")
46 | }
47 | }
48 |
49 |
50 |
51 | })
52 |
53 | var antworten = [];
54 | var fragen = [
55 | "Wie heißt du?",
56 | "Wie alt bist du?",
57 | "Was ist das Beste Hosting Unternehmen?",
58 | "Was ist der Beste Music Bot?",
59 | ]
60 | const embed = new discord.MessageEmbed()
61 | .setColor("YELLOW")
62 | .setTitle("A NEW QUESTION")
63 | function apply(reaction, user){
64 | var counter = 0;
65 | user.send(embed.setDescription(fragen[counter])).then(msg => {
66 | msg.channel.awaitMessages(m => m.author.id === user.id, { max: 1, time: 120*1000, errors: ['time'] })
67 | .then(collected => {
68 | antworten.push(collected.first().content);
69 | counter++;
70 | user.send(embed.setDescription(fragen[counter])).then(msg => {
71 | msg.channel.awaitMessages(m => m.author.id === user.id, { max: 1, time: 120*1000, errors: ['time'] })
72 | .then(collected => {
73 | antworten.push(collected.first().content);
74 | counter++;
75 | user.send(embed.setDescription(fragen[counter])).then(msg => {
76 | msg.channel.awaitMessages(m => m.author.id === user.id, { max: 1, time: 120*1000, errors: ['time'] })
77 | .then(collected => {
78 | antworten.push(collected.first().content);
79 | counter++;
80 | user.send(embed.setDescription(fragen[counter])).then(msg => {
81 | msg.channel.awaitMessages(m => m.author.id === user.id, { max: 1, time: 120*1000, errors: ['time'] })
82 | .then(collected => {
83 | antworten.push(collected.first().content);
84 | counter++;
85 | ende_apply(reaction,user);
86 | user.send(new discord.MessageEmbed()
87 | .setColor("GREEN")
88 | .setTitle(`Vielen Dank für deine Bewerbung!`)
89 | .setDescription(`<#${reaction.message.channel.id}>`))
90 | })
91 | .catch(error => {
92 | console.log(error)
93 | msg.channel.send('Looks like nobody got the answer this time.');
94 | });
95 | })
96 | })
97 | .catch(error => {
98 | console.log(error)
99 | msg.channel.send('Looks like nobody got the answer this time.');
100 | });
101 | })
102 | })
103 | .catch(error => {
104 | console.log(error)
105 | msg.channel.send('Looks like nobody got the answer this time.');
106 | });
107 | })
108 | })
109 | .catch(error => {
110 | console.log(error)
111 | msg.channel.send('Looks like nobody got the answer this time.');
112 | });
113 | })
114 | }
115 | function ende_apply(reaction,user){
116 | client.applies.set(user.id, true);
117 |
118 | const embed = new discord.MessageEmbed()
119 | .setColor("RED")
120 | .setTitle(`${user.tag} hat sich beworben!`)
121 | .setTimestamp()
122 | .setThumbnail(user.displayAvatarURL({dynamic: true}))
123 | .setDescription(`${user}`)
124 | for(let i = 0; i < antworten.length; i++){
125 | embed.addField(fragen[i], "> " + antworten[i]);
126 | }
127 | reaction.message.guild.channels.cache.get("797043865567625308").send(embed).then(msg => {
128 | msg.react("✅");
129 | msg.react("❌");
130 | client.applies.set(msg.id, user.id)})
131 | }
132 |
133 | let i = 0;
134 | var STATUSTEXT = [
135 | "1", //index == 0
136 | "2", //index == 1
137 | "3", //index == 2
138 | "4" //index == 3
139 | ];
140 | client.on("ready", () => {
141 |
142 | /** client.guilds.cache.get("748088208427974676")
143 | .channels.cache.get("803708066658910259")
144 | .messages.fetch("803715067928510465").then(msg => msg.react("🎟️"));
145 | */
146 |
147 | console.log("Bot is ready");
148 | //INIT
149 | client.user.setActivity("STATUSTEXT", { type: "STREAMING", url: "https://twitch.tv/#" })
150 | //LOOP
151 | setInterval(()=>{
152 | const index = Math.floor(i);
153 | if(index == 0 )client.user.setActivity(STATUSTEXT[index], { type: "STREAMING", url: "https://twitch.tv/#" })
154 | else if(index == 1 )client.user.setActivity(STATUSTEXT[index], { type: "PLAYING"})
155 | else if(index == 2 )client.user.setActivity(STATUSTEXT[index], { type: "WATCHING"})
156 | else if(index == 3 )client.user.setActivity(STATUSTEXT[index], { type: "LISTENING"})
157 | else client.user.setActivity(STATUSTEXT[index], { type: "PLAYING"})
158 | i++;
159 | if(i===STATUSTEXT.length) i -= STATUSTEXT.length;
160 | }, 5*1000)
161 |
162 | })
163 |
164 |
165 |
166 |
167 |
168 | client.on("message", async message => {
169 | const prefix = (config.prefix);
170 | if (message.author.bot) return;
171 | if (!message.guild) return;
172 |
173 | if (!message.content.startsWith(prefix)) return;
174 |
175 | const args = message.content.slice(prefix.length).trim().split(/ +/g);
176 | const cmd = args.shift().toLowerCase();
177 |
178 | if (cmd.length === 0) return;
179 |
180 | if(cmd === "delete"){
181 | if(!message.mentions.users.first()) return message.reply("PLEASE PING A USER")
182 | message.reply("SUCCESS!")
183 | client.applies.set(message.mentions.users.first().id, false);
184 | }
185 |
186 | let command = client.commands.get(cmd);
187 | if (!command) command = client.commands.get(client.aliases.get(cmd));
188 |
189 |
190 | if (command)
191 | command.run(client, message, args);
192 |
193 | });
194 |
195 | client.login(config.token);
--------------------------------------------------------------------------------
/Tutorial-11/json.sqlite:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tomato6966/discord-js-tutorial/4900f4b09afcb4e2195fdd63a04d18efb5e166df/Tutorial-11/json.sqlite
--------------------------------------------------------------------------------
/Tutorial-11/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "tutorial-9",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "dependencies": {
7 | "ascii-table": "0.0.9",
8 | "common-tags": "^1.8.0",
9 | "discord.js": "^12.5.1",
10 | "moment": "^2.29.1",
11 | "node-fetch": "^2.6.1",
12 | "quick.db": "^7.1.3"
13 | },
14 | "devDependencies": {},
15 | "scripts": {
16 | "test": "echo \"Error: no test specified\" && exit 1"
17 | },
18 | "author": "",
19 | "license": "ISC"
20 | }
21 |
--------------------------------------------------------------------------------
/Tutorial-2/commands/fun/embed.js:
--------------------------------------------------------------------------------
1 | const {MessageEmbed} =require("discord.js")
2 | module.exports = {
3 | name: "embed",
4 | category: "fun",
5 | aliases: [""],
6 | description: "Resends the message",
7 | run: async (client, message, args) => {
8 | /*
9 | const embed = new MessageEmbed()
10 | .setColor("#009933")
11 | .setTitle("TEST TITEL")
12 | .setImage("https://i.ytimg.com/vi/-ObdvMkCKws/maxresdefault.jpg")
13 | .setAuthor("AUTHOR LINE", "https://i.ytimg.com/vi/-ObdvMkCKws/maxresdefault.jpg" , "https://i.ytimg.com/vi/-ObdvMkCKws/maxresdefault.jpg")
14 | .setFooter("FOOTER LINE", "https://i.ytimg.com/vi/-ObdvMkCKws/maxresdefault.jpg")
15 | .setThumbnail("https://images-ext-2.discordapp.net/external/-3q8I8_FlXEgEXI3IBN42Qws-ddM3h9_KQ9ZnJ0uEYU/https/cdn.discordapp.com/avatars/789845410998779904/63f53def498998225feffe0ddded5428.webp")
16 | .setDescription(`Beschreibung
17 |
18 | <@442355791412854784>
19 | > Das ist ein markstrich
20 |
21 | **FETTER TEXT**
22 | ss`)
23 | .setTimestamp()
24 | .addField("FELD TITEL",`asdasdasdA
25 | SDA
26 | SDASDA
27 | SD`)
28 | .addField("FELD TITEL",`asdasdasdA
29 | SDA
30 | SDASDA
31 | SD`)
32 | .addField("\u200b",`\u200b`)
33 | .addField("FELD TITEL",`asdasdasdA
34 | SDA
35 | SDASDA
36 | SD`)
37 | .addField("FELD TITEL",`asdasdasdA
38 | SDA
39 | SDASDA
40 | SD`)
41 | .addField("\u200b",`\u200b`)*/
42 |
43 | const argsneu = message.content.slice(6).split("%&")
44 |
45 | const TITEL = argsneu[0];
46 | const BESCHREIBUNG = argsneu[1];
47 |
48 | const embed = new MessageEmbed()
49 | .setColor("RED")
50 | .setFooter("FOOTER LINE", "https://i.ytimg.com/vi/-ObdvMkCKws/maxresdefault.jpg")
51 | .setTimestamp()
52 | .setTitle(TITEL)
53 | .setDescription(BESCHREIBUNG)
54 |
55 | message.channel.send(embed)
56 |
57 | }
58 | }
--------------------------------------------------------------------------------
/Tutorial-2/commands/fun/say.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = {
3 | name: "say",
4 | category: "fun",
5 | aliases: ["say"],
6 | description: "Resends the message",
7 | run: async (client, message, args) => {
8 | message.channel.send(args.join(" "))
9 | }
10 | }
--------------------------------------------------------------------------------
/Tutorial-2/commands/info/help.js:
--------------------------------------------------------------------------------
1 | const { MessageEmbed } = require("discord.js");
2 | const { stripIndents } = require("common-tags");
3 | const config = require("../../config.json");
4 | module.exports = {
5 | name: "help",
6 | aliases: ["h", "cmds"],
7 | category: "info",
8 | description: "Returns all Commands, or one specific Command information",
9 | usage: "[command], [aliases], [command ]",
10 | run: async (client,message,args) => {
11 | if(args[0]){
12 | return getCMD(client,message,args[0]);
13 | }
14 | else{
15 | return getAll(client, message);
16 | }
17 | }
18 | }
19 |
20 | function getAll(client,message){
21 | const embed = new MessageEmbed()
22 | .setColor("ORANGE")
23 | .setThumbnail(client.user.displayAvatarURL())
24 | .setTitle("HELP MENU")
25 | .addField("**__BOT BY:__**", `
26 | >>> <@442355791412854784> \`Tomato#6966\` [\`Website\`](https://musicium.eu)
27 | `)
28 | .setFooter(`TO see command descriptions and inforamtion, type: ${config.prefix}help [CMD NAME]`, client.user.displayAvatarURL())
29 | const commands = (category) => {
30 | return client.commands.filter(cmd => cmd.category === category)
31 | .map(cmd => `\`${cmd.name}\``).join(", ")
32 | }
33 | const info = client.categories.map(cat => stripIndents`**__${cat[0].toUpperCase() + cat.slice(1)}__**\n> ${commands(cat)}`)
34 | .reduce((string, category) => string + "\n" + category);
35 | return message.channel.send(embed.setDescription(info))
36 | }
37 | function getCMD(client,message,input){
38 | const embed = new MessageEmbed()
39 | const cmd = client.commands.get(input.toLowerCase()) || client.commands.get(client.aliases.get(input.toLowerCase()))
40 | let info = `No Information found for command **${input.toLowerCase()}**`;
41 | if(!cmd){
42 | return message.channel.send(embed.setColor("RED").setDescription(info));
43 | }
44 | info = "";
45 | if(cmd.name) info += `**Command name**: \`${cmd.name}\`\n`
46 | if(cmd.aliases) info += `**Aliases**: ${cmd.aliases.map(a => `\`${a}\``).join(", ")}\n`
47 | if(cmd.description) info += `**Description**: \`${cmd.description}\`\n`
48 | if(cmd.usage) {
49 | info += `\n**Usage**: ${cmd.usage}`;
50 | embed.setFooter("Syntax: <> = required, [] = optional");
51 | }
52 | return message.channel.send(embed.setColor("ORANGE").setDescription(info))
53 | }
--------------------------------------------------------------------------------
/Tutorial-2/commands/info/ping.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: "ping",
3 | aliases: ["latency"],
4 | category: "info",
5 | description: "Returns latency and API ping",
6 | run: async (client, message, args) => {
7 | const msg = await message.channel.send(`🏓 Pinging....`);
8 | msg.edit(`🏓 Pong!
9 | Ping is ${Math.round(client.ws.ping)}ms`);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Tutorial-2/commands/info/uptime.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: "uptime",
3 | aliases: ["uptime"],
4 | category: "info",
5 | description: "Returns the duration of how long the Bot is online",
6 | usage: "[command], [aliases]",
7 | run: async (client,message,args) => {
8 | function duration(ms) {
9 | const sec = Math.floor(ms / 1000 % 60).toString();
10 | const min = Math.floor(ms / (60*1000) % 60).toString();
11 | const hrs = Math.floor(ms / (60*60*1000) % 60).toString();
12 | const days = Math.floor(ms / (24*60*60*1000) % 60).toString();
13 | return `\`${days} Days\`, \`${hrs} Hours\`, \`${min} Minutes\`, \`${sec} Seconds\``
14 | }
15 | message.reply(`:white_check_mark: **${client.user.username}** is since ${duration(client.uptime)} online`);
16 | }
17 | }
--------------------------------------------------------------------------------
/Tutorial-2/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "token": "Nzg5MDY0NDE4OTI2Mzk1NDEz.X9sngQ.VTVRbpYQ3wk586p82VUpq36LoG8",
3 | "prefix": "!"
4 | }
--------------------------------------------------------------------------------
/Tutorial-2/handlers/command.js:
--------------------------------------------------------------------------------
1 | const { readdirSync } = require("fs");
2 | const ascii = require("ascii-table");
3 | let table = new ascii("Commands");
4 | table.setHeading("Command", "Load status");
5 | console.log("Welcome to SERVICE HANDLER // By https://x10-gaming.eu/service/dc // Discord: Tomato#6966")
6 | module.exports = (client) => {
7 | readdirSync("./commands/").forEach(dir => {
8 | const commands = readdirSync(`./commands/${dir}/`).filter(file => file.endsWith(".js"));
9 | for (let file of commands) {
10 | let pull = require(`../commands/${dir}/${file}`);
11 | if (pull.name) {
12 | client.commands.set(pull.name, pull);
13 | table.addRow(file, 'Ready');
14 | } else {
15 | table.addRow(file, `error -> missing a help.name, or help.name is not a string.`);
16 | continue;
17 | }
18 | if (pull.aliases && Array.isArray(pull.aliases)) pull.aliases.forEach(alias => client.aliases.set(alias, pull.name));
19 | }
20 | });
21 | console.log(table.toString());
22 | console.log("Welcome to SERVICE HANDLER // By https://x10-gaming.eu/service/dc // Discord: Tomato#6966")
23 | console.log("Logging into the BOT...");
24 | }
25 |
--------------------------------------------------------------------------------
/Tutorial-2/index.js:
--------------------------------------------------------------------------------
1 | //Modules
2 | const { Client, Collection } = require("discord.js");
3 | const config = require("./config.json");
4 | const fs = require("fs");
5 |
6 | const client = new Client({
7 | disableEveryone: true
8 | , partials: ['MESSAGE', 'CHANNEL', 'REACTION'] });
9 |
10 | client.commands = new Collection();
11 | client.aliases = new Collection();
12 |
13 | client.categories = fs.readdirSync("./commands/");
14 |
15 | ["command"].forEach(handler => {
16 | require(`./handlers/${handler}`)(client);
17 | });
18 |
19 | client.on("ready", () => {
20 | console.log(`Discord Bot is online!`);
21 | });
22 |
23 | client.on("message", async message => {
24 | const prefix = (config.prefix);
25 | if (message.author.bot) return;
26 | if (!message.guild) return;
27 |
28 | if (!message.content.startsWith(prefix)) return;
29 |
30 | const args = message.content.slice(prefix.length).trim().split(/ +/g);
31 | const cmd = args.shift().toLowerCase();
32 |
33 | if (cmd.length === 0) return;
34 |
35 | let command = client.commands.get(cmd);
36 | if (!command) command = client.commands.get(client.aliases.get(cmd));
37 |
38 |
39 | if (command)
40 | command.run(client, message, args);
41 |
42 | });
43 |
44 | client.login(config.token);
--------------------------------------------------------------------------------
/Tutorial-2/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "requires": true,
3 | "lockfileVersion": 1,
4 | "dependencies": {
5 | "@discordjs/collection": {
6 | "version": "0.1.6",
7 | "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.1.6.tgz",
8 | "integrity": "sha512-utRNxnd9kSS2qhyivo9lMlt5qgAUasH2gb7BEOn6p0efFh24gjGomHzWKMAPn2hEReOPQZCJaRKoURwRotKucQ=="
9 | },
10 | "@discordjs/form-data": {
11 | "version": "3.0.1",
12 | "resolved": "https://registry.npmjs.org/@discordjs/form-data/-/form-data-3.0.1.tgz",
13 | "integrity": "sha512-ZfFsbgEXW71Rw/6EtBdrP5VxBJy4dthyC0tpQKGKmYFImlmmrykO14Za+BiIVduwjte0jXEBlhSKf0MWbFp9Eg==",
14 | "requires": {
15 | "asynckit": "^0.4.0",
16 | "combined-stream": "^1.0.8",
17 | "mime-types": "^2.1.12"
18 | }
19 | },
20 | "@sindresorhus/is": {
21 | "version": "4.0.0",
22 | "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.0.0.tgz",
23 | "integrity": "sha512-FyD2meJpDPjyNQejSjvnhpgI/azsQkA4lGbuu5BQZfjvJ9cbRZXzeWL2HceCekW4lixO9JPesIIQkSoLjeJHNQ=="
24 | },
25 | "@szmarczak/http-timer": {
26 | "version": "4.0.5",
27 | "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.5.tgz",
28 | "integrity": "sha512-PyRA9sm1Yayuj5OIoJ1hGt2YISX45w9WcFbh6ddT0Z/0yaFxOtGLInr4jUfU1EAFVs0Yfyfev4RNwBlUaHdlDQ==",
29 | "requires": {
30 | "defer-to-connect": "^2.0.0"
31 | }
32 | },
33 | "@types/cacheable-request": {
34 | "version": "6.0.1",
35 | "resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.1.tgz",
36 | "integrity": "sha512-ykFq2zmBGOCbpIXtoVbz4SKY5QriWPh3AjyU4G74RYbtt5yOc5OfaY75ftjg7mikMOla1CTGpX3lLbuJh8DTrQ==",
37 | "requires": {
38 | "@types/http-cache-semantics": "*",
39 | "@types/keyv": "*",
40 | "@types/node": "*",
41 | "@types/responselike": "*"
42 | }
43 | },
44 | "@types/http-cache-semantics": {
45 | "version": "4.0.0",
46 | "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.0.tgz",
47 | "integrity": "sha512-c3Xy026kOF7QOTn00hbIllV1dLR9hG9NkSrLQgCVs8NF6sBU+VGWjD3wLPhmh1TYAc7ugCFsvHYMN4VcBN1U1A=="
48 | },
49 | "@types/keyv": {
50 | "version": "3.1.1",
51 | "resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.1.tgz",
52 | "integrity": "sha512-MPtoySlAZQ37VoLaPcTHCu1RWJ4llDkULYZIzOYxlhxBqYPB0RsRlmMU0R6tahtFe27mIdkHV+551ZWV4PLmVw==",
53 | "requires": {
54 | "@types/node": "*"
55 | }
56 | },
57 | "@types/node": {
58 | "version": "14.14.14",
59 | "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.14.tgz",
60 | "integrity": "sha512-UHnOPWVWV1z+VV8k6L1HhG7UbGBgIdghqF3l9Ny9ApPghbjICXkUJSd/b9gOgQfjM1r+37cipdw/HJ3F6ICEnQ=="
61 | },
62 | "@types/responselike": {
63 | "version": "1.0.0",
64 | "resolved": "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.0.tgz",
65 | "integrity": "sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA==",
66 | "requires": {
67 | "@types/node": "*"
68 | }
69 | },
70 | "abort-controller": {
71 | "version": "3.0.0",
72 | "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz",
73 | "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==",
74 | "requires": {
75 | "event-target-shim": "^5.0.0"
76 | }
77 | },
78 | "ascii-table": {
79 | "version": "0.0.9",
80 | "resolved": "https://registry.npmjs.org/ascii-table/-/ascii-table-0.0.9.tgz",
81 | "integrity": "sha1-BqZgTWpV1L9BqaR9mHLXp42jHnM="
82 | },
83 | "asynckit": {
84 | "version": "0.4.0",
85 | "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
86 | "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
87 | },
88 | "cacheable-lookup": {
89 | "version": "5.0.4",
90 | "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz",
91 | "integrity": "sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA=="
92 | },
93 | "cacheable-request": {
94 | "version": "7.0.1",
95 | "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.1.tgz",
96 | "integrity": "sha512-lt0mJ6YAnsrBErpTMWeu5kl/tg9xMAWjavYTN6VQXM1A/teBITuNcccXsCxF0tDQQJf9DfAaX5O4e0zp0KlfZw==",
97 | "requires": {
98 | "clone-response": "^1.0.2",
99 | "get-stream": "^5.1.0",
100 | "http-cache-semantics": "^4.0.0",
101 | "keyv": "^4.0.0",
102 | "lowercase-keys": "^2.0.0",
103 | "normalize-url": "^4.1.0",
104 | "responselike": "^2.0.0"
105 | }
106 | },
107 | "clone-response": {
108 | "version": "1.0.2",
109 | "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz",
110 | "integrity": "sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws=",
111 | "requires": {
112 | "mimic-response": "^1.0.0"
113 | }
114 | },
115 | "combined-stream": {
116 | "version": "1.0.8",
117 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
118 | "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
119 | "requires": {
120 | "delayed-stream": "~1.0.0"
121 | }
122 | },
123 | "common-tags": {
124 | "version": "1.8.0",
125 | "resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.0.tgz",
126 | "integrity": "sha512-6P6g0uetGpW/sdyUy/iQQCbFF0kWVMSIVSyYz7Zgjcgh8mgw8PQzDNZeyZ5DQ2gM7LBoZPHmnjz8rUthkBG5tw=="
127 | },
128 | "decompress-response": {
129 | "version": "6.0.0",
130 | "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz",
131 | "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==",
132 | "requires": {
133 | "mimic-response": "^3.1.0"
134 | },
135 | "dependencies": {
136 | "mimic-response": {
137 | "version": "3.1.0",
138 | "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz",
139 | "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ=="
140 | }
141 | }
142 | },
143 | "defer-to-connect": {
144 | "version": "2.0.0",
145 | "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.0.tgz",
146 | "integrity": "sha512-bYL2d05vOSf1JEZNx5vSAtPuBMkX8K9EUutg7zlKvTqKXHt7RhWJFbmd7qakVuf13i+IkGmp6FwSsONOf6VYIg=="
147 | },
148 | "delayed-stream": {
149 | "version": "1.0.0",
150 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
151 | "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
152 | },
153 | "discord.js": {
154 | "version": "12.5.1",
155 | "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-12.5.1.tgz",
156 | "integrity": "sha512-VwZkVaUAIOB9mKdca0I5MefPMTQJTNg0qdgi1huF3iwsFwJ0L5s/Y69AQe+iPmjuV6j9rtKoG0Ta0n9vgEIL6w==",
157 | "requires": {
158 | "@discordjs/collection": "^0.1.6",
159 | "@discordjs/form-data": "^3.0.1",
160 | "abort-controller": "^3.0.0",
161 | "node-fetch": "^2.6.1",
162 | "prism-media": "^1.2.2",
163 | "setimmediate": "^1.0.5",
164 | "tweetnacl": "^1.0.3",
165 | "ws": "^7.3.1"
166 | }
167 | },
168 | "end-of-stream": {
169 | "version": "1.4.4",
170 | "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz",
171 | "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==",
172 | "requires": {
173 | "once": "^1.4.0"
174 | }
175 | },
176 | "event-target-shim": {
177 | "version": "5.0.1",
178 | "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
179 | "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ=="
180 | },
181 | "get-stream": {
182 | "version": "5.2.0",
183 | "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz",
184 | "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==",
185 | "requires": {
186 | "pump": "^3.0.0"
187 | }
188 | },
189 | "got": {
190 | "version": "11.8.1",
191 | "resolved": "https://registry.npmjs.org/got/-/got-11.8.1.tgz",
192 | "integrity": "sha512-9aYdZL+6nHmvJwHALLwKSUZ0hMwGaJGYv3hoPLPgnT8BoBXm1SjnZeky+91tfwJaDzun2s4RsBRy48IEYv2q2Q==",
193 | "requires": {
194 | "@sindresorhus/is": "^4.0.0",
195 | "@szmarczak/http-timer": "^4.0.5",
196 | "@types/cacheable-request": "^6.0.1",
197 | "@types/responselike": "^1.0.0",
198 | "cacheable-lookup": "^5.0.3",
199 | "cacheable-request": "^7.0.1",
200 | "decompress-response": "^6.0.0",
201 | "http2-wrapper": "^1.0.0-beta.5.2",
202 | "lowercase-keys": "^2.0.0",
203 | "p-cancelable": "^2.0.0",
204 | "responselike": "^2.0.0"
205 | }
206 | },
207 | "http-cache-semantics": {
208 | "version": "4.1.0",
209 | "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz",
210 | "integrity": "sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ=="
211 | },
212 | "http2-wrapper": {
213 | "version": "1.0.0-beta.5.2",
214 | "resolved": "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-1.0.0-beta.5.2.tgz",
215 | "integrity": "sha512-xYz9goEyBnC8XwXDTuC/MZ6t+MrKVQZOk4s7+PaDkwIsQd8IwqvM+0M6bA/2lvG8GHXcPdf+MejTUeO2LCPCeQ==",
216 | "requires": {
217 | "quick-lru": "^5.1.1",
218 | "resolve-alpn": "^1.0.0"
219 | }
220 | },
221 | "json-buffer": {
222 | "version": "3.0.1",
223 | "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz",
224 | "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ=="
225 | },
226 | "keyv": {
227 | "version": "4.0.3",
228 | "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.0.3.tgz",
229 | "integrity": "sha512-zdGa2TOpSZPq5mU6iowDARnMBZgtCqJ11dJROFi6tg6kTn4nuUdU09lFyLFSaHrWqpIJ+EBq4E8/Dc0Vx5vLdA==",
230 | "requires": {
231 | "json-buffer": "3.0.1"
232 | }
233 | },
234 | "lowercase-keys": {
235 | "version": "2.0.0",
236 | "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz",
237 | "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA=="
238 | },
239 | "mime-types": {
240 | "version": "2.1.27",
241 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz",
242 | "integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==",
243 | "requires": {
244 | "mime-db": "1.44.0"
245 | },
246 | "dependencies": {
247 | "mime-db": {
248 | "version": "1.44.0",
249 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz",
250 | "integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg=="
251 | }
252 | }
253 | },
254 | "mimic-response": {
255 | "version": "1.0.1",
256 | "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz",
257 | "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ=="
258 | },
259 | "node-fetch": {
260 | "version": "2.6.1",
261 | "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
262 | "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
263 | },
264 | "normalize-url": {
265 | "version": "4.5.0",
266 | "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.0.tgz",
267 | "integrity": "sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ=="
268 | },
269 | "once": {
270 | "version": "1.4.0",
271 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
272 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
273 | "requires": {
274 | "wrappy": "1"
275 | }
276 | },
277 | "p-cancelable": {
278 | "version": "2.0.0",
279 | "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-2.0.0.tgz",
280 | "integrity": "sha512-wvPXDmbMmu2ksjkB4Z3nZWTSkJEb9lqVdMaCKpZUGJG9TMiNp9XcbG3fn9fPKjem04fJMJnXoyFPk2FmgiaiNg=="
281 | },
282 | "prism-media": {
283 | "version": "1.2.3",
284 | "resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.2.3.tgz",
285 | "integrity": "sha512-fSrR66n0l6roW9Rx4rSLMyTPTjRTiXy5RVqDOurACQ6si1rKHHKDU5gwBJoCsIV0R3o9gi+K50akl/qyw1C74A=="
286 | },
287 | "pump": {
288 | "version": "3.0.0",
289 | "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz",
290 | "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==",
291 | "requires": {
292 | "end-of-stream": "^1.1.0",
293 | "once": "^1.3.1"
294 | }
295 | },
296 | "quick-lru": {
297 | "version": "5.1.1",
298 | "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz",
299 | "integrity": "sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA=="
300 | },
301 | "resolve-alpn": {
302 | "version": "1.0.0",
303 | "resolved": "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.0.0.tgz",
304 | "integrity": "sha512-rTuiIEqFmGxne4IovivKSDzld2lWW9QCjqv80SYjPgf+gS35eaCAjaP54CCwGAwBtnCsvNLYtqxe1Nw+i6JEmA=="
305 | },
306 | "responselike": {
307 | "version": "2.0.0",
308 | "resolved": "https://registry.npmjs.org/responselike/-/responselike-2.0.0.tgz",
309 | "integrity": "sha512-xH48u3FTB9VsZw7R+vvgaKeLKzT6jOogbQhEe/jewwnZgzPcnyWui2Av6JpoYZF/91uueC+lqhWqeURw5/qhCw==",
310 | "requires": {
311 | "lowercase-keys": "^2.0.0"
312 | }
313 | },
314 | "setimmediate": {
315 | "version": "1.0.5",
316 | "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz",
317 | "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU="
318 | },
319 | "tweetnacl": {
320 | "version": "1.0.3",
321 | "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz",
322 | "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw=="
323 | },
324 | "wrappy": {
325 | "version": "1.0.2",
326 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
327 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
328 | },
329 | "ws": {
330 | "version": "7.4.1",
331 | "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.1.tgz",
332 | "integrity": "sha512-pTsP8UAfhy3sk1lSk/O/s4tjD0CRwvMnzvwr4OKGX7ZvqZtUyx4KIJB5JWbkykPoc55tixMGgTNoh3k4FkNGFQ=="
333 | }
334 | }
335 | }
336 |
--------------------------------------------------------------------------------
/Tutorial-3/commands/fun/say.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = {
3 | name: "say",
4 | category: "fun",
5 | aliases: ["say"],
6 | description: "Resends the message",
7 | run: async (client, message, args) => {
8 | message.channel.send(args.join(" "))
9 | }
10 | }
--------------------------------------------------------------------------------
/Tutorial-3/commands/info/help.js:
--------------------------------------------------------------------------------
1 | const { MessageEmbed } = require("discord.js");
2 | const { stripIndents } = require("common-tags");
3 | const config = require("../../config.json");
4 | module.exports = {
5 | name: "help",
6 | aliases: ["h", "cmds"],
7 | category: "info",
8 | description: "Returns all Commands, or one specific Command information",
9 | usage: "[command], [aliases], [command ]",
10 | run: async (client,message,args) => {
11 | if(args[0]){
12 | return getCMD(client,message,args[0]);
13 | }
14 | else{
15 | return getAll(client, message);
16 | }
17 | }
18 | }
19 |
20 | function getAll(client,message){
21 | const embed = new MessageEmbed()
22 | .setColor("ORANGE")
23 | .setThumbnail(client.user.displayAvatarURL())
24 | .setTitle("HELP MENU")
25 | .addField("**__BOT BY:__**", `
26 | >>> <@442355791412854784> \`Tomato#6966\` [\`Website\`](https://musicium.eu)
27 | `)
28 | .setFooter(`TO see command descriptions and inforamtion, type: ${config.prefix}help [CMD NAME]`, client.user.displayAvatarURL())
29 | const commands = (category) => {
30 | return client.commands.filter(cmd => cmd.category === category)
31 | .map(cmd => `\`${cmd.name}\``).join(", ")
32 | }
33 | const info = client.categories.map(cat => stripIndents`**__${cat[0].toUpperCase() + cat.slice(1)}__**\n> ${commands(cat)}`)
34 | .reduce((string, category) => string + "\n" + category);
35 | return message.channel.send(embed.setDescription(info))
36 | }
37 | function getCMD(client,message,input){
38 | const embed = new MessageEmbed()
39 | const cmd = client.commands.get(input.toLowerCase()) || client.commands.get(client.aliases.get(input.toLowerCase()))
40 | let info = `No Information found for command **${input.toLowerCase()}**`;
41 | if(!cmd){
42 | return message.channel.send(embed.setColor("RED").setDescription(info));
43 | }
44 | info = "";
45 | if(cmd.name) info += `**Command name**: \`${cmd.name}\`\n`
46 | if(cmd.aliases) info += `**Aliases**: \`${cmd.aliases.map(a => `${a}`).join("\`, \`")}\`\n`
47 | if(cmd.description) info += `**Description**: \`${cmd.description}\`\n`
48 | if(cmd.usage) {
49 | info += `\n**Usage**: \`${cmd.usage}\``;
50 | embed.setFooter("Syntax: <> = required, [] = optional");
51 | }
52 | return message.channel.send(embed.setColor("ORANGE").setDescription(info))
53 | }
--------------------------------------------------------------------------------
/Tutorial-3/commands/info/ping.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: "ping",
3 | aliases: ["latency"],
4 | category: "info",
5 | description: "Returns latency and API ping",
6 | run: async (client, message, args) => {
7 | const msg = await message.channel.send(`🏓 Pinging....`);
8 | msg.edit(`🏓 Pong!
9 | Ping is ${Math.round(client.ws.ping)}ms`);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Tutorial-3/commands/info/uptime.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: "uptime",
3 | aliases: ["uptime"],
4 | category: "info",
5 | description: "Returns the duration of how long the Bot is online",
6 | usage: "[command], [aliases]",
7 | run: async (client,message,args) => {
8 | function duration(ms) {
9 | const sec = Math.floor(ms / 1000 % 60).toString();
10 | const min = Math.floor(ms / (60*1000) % 60).toString();
11 | const hrs = Math.floor(ms / (60*60*1000) % 60).toString();
12 | const days = Math.floor(ms / (24*60*60*1000) % 60).toString();
13 | return `\`${days} Days\`, \`${hrs} Hours\`, \`${min} Minutes\`, \`${sec} Seconds\``
14 | }
15 | message.reply(`:white_check_mark: **${client.user.username}** is since ${duration(client.uptime)} online`);
16 | }
17 | }
--------------------------------------------------------------------------------
/Tutorial-3/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "token": "Nzg5MDY0NDE4OTI2Mzk1NDEz.X9sngQ.U5qyICMqSQWQgZsMZxWF3lj9l3U",
3 | "prefix": "!"
4 | }
--------------------------------------------------------------------------------
/Tutorial-3/handlers/command.js:
--------------------------------------------------------------------------------
1 | const { readdirSync } = require("fs");
2 | const ascii = require("ascii-table");
3 | let table = new ascii("Commands");
4 | table.setHeading("Command", "Load status");
5 | console.log("Welcome to SERVICE HANDLER // By https://x10-gaming.eu/service/dc // Discord: Tomato#6966")
6 | module.exports = (client) => {
7 | readdirSync("./commands/").forEach(dir => {
8 | const commands = readdirSync(`./commands/${dir}/`).filter(file => file.endsWith(".js"));
9 | for (let file of commands) {
10 | let pull = require(`../commands/${dir}/${file}`);
11 | if (pull.name) {
12 | client.commands.set(pull.name, pull);
13 | table.addRow(file, 'Ready');
14 | } else {
15 | table.addRow(file, `error -> missing a help.name, or help.name is not a string.`);
16 | continue;
17 | }
18 | if (pull.aliases && Array.isArray(pull.aliases)) pull.aliases.forEach(alias => client.aliases.set(alias, pull.name));
19 | }
20 | });
21 | console.log(table.toString());
22 | console.log("Welcome to SERVICE HANDLER // By https://x10-gaming.eu/service/dc // Discord: Tomato#6966")
23 | console.log("Logging into the BOT...");
24 | }
25 |
--------------------------------------------------------------------------------
/Tutorial-3/index.js:
--------------------------------------------------------------------------------
1 | //Modules
2 | const { Client, Collection } = require("discord.js");
3 | const config = require("./config.json");
4 | const fs = require("fs");
5 | const discord = require("discord.js");
6 | const client = new Client({
7 | disableEveryone: true
8 | , partials: ['MESSAGE', 'CHANNEL', 'REACTION'] });
9 |
10 | client.commands = new Collection();
11 | client.aliases = new Collection();
12 |
13 | client.categories = fs.readdirSync("./commands/");
14 |
15 | ["command"].forEach(handler => {
16 | require(`./handlers/${handler}`)(client);
17 | });
18 |
19 |
20 |
21 | client.on("ready", () => {
22 | console.log("Bot is ready");
23 | //INIT
24 | client.user.setActivity("TESTING THE BOT", { type: "PLAYING" })
25 |
26 | })
27 |
28 |
29 |
30 |
31 |
32 | client.on("message", async message => {
33 | const prefix = (config.prefix);
34 | if (message.author.bot) return;
35 | if (!message.guild) return;
36 |
37 | if (!message.content.startsWith(prefix)) return;
38 |
39 | const args = message.content.slice(prefix.length).trim().split(/ +/g);
40 | const cmd = args.shift().toLowerCase();
41 |
42 | if (cmd.length === 0) return;
43 |
44 | let command = client.commands.get(cmd);
45 | if (!command) command = client.commands.get(client.aliases.get(cmd));
46 |
47 |
48 | if (command)
49 | command.run(client, message, args);
50 |
51 | });
52 |
53 | client.login(config.token);
--------------------------------------------------------------------------------
/Tutorial-4/commands/fun/say.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = {
3 | name: "say",
4 | category: "fun",
5 | aliases: ["say"],
6 | description: "Resends the message",
7 | run: async (client, message, args) => {
8 | message.channel.send(args.join(" "))
9 | }
10 | }
--------------------------------------------------------------------------------
/Tutorial-4/commands/info/help.js:
--------------------------------------------------------------------------------
1 | const { MessageEmbed } = require("discord.js");
2 | const { stripIndents } = require("common-tags");
3 | const config = require("../../config.json");
4 | module.exports = {
5 | name: "help",
6 | aliases: ["h", "cmds"],
7 | category: "info",
8 | description: "Returns all Commands, or one specific Command information",
9 | usage: "[command], [aliases], [command ]",
10 | run: async (client,message,args) => {
11 | if(args[0]){
12 | return getCMD(client,message,args[0]);
13 | }
14 | else{
15 | return getAll(client, message);
16 | }
17 | }
18 | }
19 |
20 | function getAll(client,message){
21 | const embed = new MessageEmbed()
22 | .setColor("ORANGE")
23 | .setThumbnail(client.user.displayAvatarURL())
24 | .setTitle("HELP MENU")
25 | .addField("**__BOT BY:__**", `
26 | >>> <@442355791412854784> \`Tomato#6966\` [\`Website\`](https://musicium.eu)
27 | `)
28 | .setFooter(`TO see command descriptions and inforamtion, type: ${config.prefix}help [CMD NAME]`, client.user.displayAvatarURL())
29 | const commands = (category) => {
30 | return client.commands.filter(cmd => cmd.category === category)
31 | .map(cmd => `\`${cmd.name}\``).join(", ")
32 | }
33 | const info = client.categories.map(cat => stripIndents`**__${cat[0].toUpperCase() + cat.slice(1)}__**\n> ${commands(cat)}`)
34 | .reduce((string, category) => string + "\n" + category);
35 | return message.channel.send(embed.setDescription(info))
36 | }
37 | function getCMD(client,message,input){
38 | const embed = new MessageEmbed()
39 | const cmd = client.commands.get(input.toLowerCase()) || client.commands.get(client.aliases.get(input.toLowerCase()))
40 | let info = `No Information found for command **${input.toLowerCase()}**`;
41 | if(!cmd){
42 | return message.channel.send(embed.setColor("RED").setDescription(info));
43 | }
44 | info = "";
45 | if(cmd.name) info += `**Command name**: \`${cmd.name}\`\n`
46 | if(cmd.aliases) info += `**Aliases**: \`${cmd.aliases.map(a => `${a}`).join("\`, \`")}\`\n`
47 | if(cmd.description) info += `**Description**: \`${cmd.description}\`\n`
48 | if(cmd.usage) {
49 | info += `\n**Usage**: \`${cmd.usage}\``;
50 | embed.setFooter("Syntax: <> = required, [] = optional");
51 | }
52 | return message.channel.send(embed.setColor("ORANGE").setDescription(info))
53 | }
--------------------------------------------------------------------------------
/Tutorial-4/commands/info/ping.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: "ping",
3 | aliases: ["latency"],
4 | category: "info",
5 | description: "Returns latency and API ping",
6 | run: async (client, message, args) => {
7 | const msg = await message.channel.send(`🏓 Pinging....`);
8 | msg.edit(`🏓 Pong!
9 | Ping is ${Math.round(client.ws.ping)}ms`);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Tutorial-4/commands/info/uptime.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: "uptime",
3 | aliases: ["uptime"],
4 | category: "info",
5 | description: "Returns the duration of how long the Bot is online",
6 | usage: "[command], [aliases]",
7 | run: async (client,message,args) => {
8 | function duration(ms) {
9 | const sec = Math.floor(ms / 1000 % 60).toString();
10 | const min = Math.floor(ms / (60*1000) % 60).toString();
11 | const hrs = Math.floor(ms / (60*60*1000) % 60).toString();
12 | const days = Math.floor(ms / (24*60*60*1000) % 60).toString();
13 | return `\`${days} Days\`, \`${hrs} Hours\`, \`${min} Minutes\`, \`${sec} Seconds\``
14 | }
15 | message.reply(`:white_check_mark: **${client.user.username}** is since ${duration(client.uptime)} online`);
16 | }
17 | }
--------------------------------------------------------------------------------
/Tutorial-4/commands/user/avatar.js:
--------------------------------------------------------------------------------
1 | const { MessageEmbed } = require("discord.js");
2 | module.exports = {
3 | name: "avatar",
4 | category: "user",
5 | aliases: [""],
6 | description: "Sends the Avatar of the User",
7 | run: async (client, message, args) => {
8 | let user = message.mentions.users.first() || message.author;
9 | let avatar = user.displayAvatarURL({dynamic: true});
10 | //message.channel.send(avatar);
11 | let embed = new MessageEmbed()
12 | .setColor("RANDOM")
13 | .setTitle(`${user.tag}'s Avatar`)
14 | .setURL(avatar)
15 | .setFooter(client.user.username, message.guild.iconURL())
16 | .setImage(avatar)
17 | message.channel.send(embed)
18 | }
19 | }
--------------------------------------------------------------------------------
/Tutorial-4/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "token": "Nzg5MDY0NDE4OTI2Mzk1NDEz.X9sngQ.U5qyICMqSQWQgZsMZxWF3lj9l3U",
3 | "prefix": "!"
4 | }
--------------------------------------------------------------------------------
/Tutorial-4/handlers/command.js:
--------------------------------------------------------------------------------
1 | const { readdirSync } = require("fs");
2 | const ascii = require("ascii-table");
3 | let table = new ascii("Commands");
4 | table.setHeading("Command", "Load status");
5 | console.log("Welcome to SERVICE HANDLER // By https://x10-gaming.eu/service/dc // Discord: Tomato#6966")
6 | module.exports = (client) => {
7 | readdirSync("./commands/").forEach(dir => {
8 | const commands = readdirSync(`./commands/${dir}/`).filter(file => file.endsWith(".js"));
9 | for (let file of commands) {
10 | let pull = require(`../commands/${dir}/${file}`);
11 | if (pull.name) {
12 | client.commands.set(pull.name, pull);
13 | table.addRow(file, 'Ready');
14 | } else {
15 | table.addRow(file, `error -> missing a help.name, or help.name is not a string.`);
16 | continue;
17 | }
18 | if (pull.aliases && Array.isArray(pull.aliases)) pull.aliases.forEach(alias => client.aliases.set(alias, pull.name));
19 | }
20 | });
21 | console.log(table.toString());
22 | console.log("Welcome to SERVICE HANDLER // By https://x10-gaming.eu/service/dc // Discord: Tomato#6966")
23 | console.log("Logging into the BOT...");
24 | }
25 |
--------------------------------------------------------------------------------
/Tutorial-4/index.js:
--------------------------------------------------------------------------------
1 | //Modules
2 | const { Client, Collection } = require("discord.js");
3 | const config = require("./config.json");
4 | const fs = require("fs");
5 | const discord = require("discord.js");
6 | const client = new Client({
7 | disableEveryone: true
8 | , partials: ['MESSAGE', 'CHANNEL', 'REACTION'] });
9 |
10 | client.commands = new Collection();
11 | client.aliases = new Collection();
12 |
13 | client.categories = fs.readdirSync("./commands/");
14 |
15 | ["command"].forEach(handler => {
16 | require(`./handlers/${handler}`)(client);
17 | });
18 |
19 |
20 | let i = 0;
21 | var STATUSTEXT = [
22 | "1", //index == 0
23 | "2", //index == 1
24 | "3", //index == 2
25 | "4" //index == 3
26 | ];
27 | client.on("ready", () => {
28 | console.log("Bot is ready");
29 | //INIT
30 | client.user.setActivity("STATUSTEXT", { type: "STREAMING", url: "https://twitch.tv/#" })
31 | //LOOP
32 | setInterval(()=>{
33 | const index = Math.floor(i);
34 | if(index == 0 )client.user.setActivity(STATUSTEXT[index], { type: "STREAMING", url: "https://twitch.tv/#" })
35 | else if(index == 1 )client.user.setActivity(STATUSTEXT[index], { type: "PLAYING"})
36 | else if(index == 2 )client.user.setActivity(STATUSTEXT[index], { type: "WATCHING"})
37 | else if(index == 3 )client.user.setActivity(STATUSTEXT[index], { type: "LISTENING"})
38 | else client.user.setActivity(STATUSTEXT[index], { type: "PLAYING"})
39 | i++;
40 | if(i===STATUSTEXT.length) i -= STATUSTEXT.length;
41 | }, 5*1000)
42 |
43 | })
44 |
45 |
46 |
47 |
48 |
49 | client.on("message", async message => {
50 | const prefix = (config.prefix);
51 | if (message.author.bot) return;
52 | if (!message.guild) return;
53 |
54 | if (!message.content.startsWith(prefix)) return;
55 |
56 | const args = message.content.slice(prefix.length).trim().split(/ +/g);
57 | const cmd = args.shift().toLowerCase();
58 |
59 | if (cmd.length === 0) return;
60 |
61 | let command = client.commands.get(cmd);
62 | if (!command) command = client.commands.get(client.aliases.get(cmd));
63 |
64 |
65 | if (command)
66 | command.run(client, message, args);
67 |
68 | });
69 |
70 | client.login(config.token);
--------------------------------------------------------------------------------
/Tutorial-4/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "requires": true,
3 | "lockfileVersion": 1,
4 | "dependencies": {
5 | "@discordjs/collection": {
6 | "version": "0.1.6",
7 | "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.1.6.tgz",
8 | "integrity": "sha512-utRNxnd9kSS2qhyivo9lMlt5qgAUasH2gb7BEOn6p0efFh24gjGomHzWKMAPn2hEReOPQZCJaRKoURwRotKucQ=="
9 | },
10 | "@discordjs/form-data": {
11 | "version": "3.0.1",
12 | "resolved": "https://registry.npmjs.org/@discordjs/form-data/-/form-data-3.0.1.tgz",
13 | "integrity": "sha512-ZfFsbgEXW71Rw/6EtBdrP5VxBJy4dthyC0tpQKGKmYFImlmmrykO14Za+BiIVduwjte0jXEBlhSKf0MWbFp9Eg==",
14 | "requires": {
15 | "asynckit": "^0.4.0",
16 | "combined-stream": "^1.0.8",
17 | "mime-types": "^2.1.12"
18 | }
19 | },
20 | "@sindresorhus/is": {
21 | "version": "4.0.0",
22 | "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.0.0.tgz",
23 | "integrity": "sha512-FyD2meJpDPjyNQejSjvnhpgI/azsQkA4lGbuu5BQZfjvJ9cbRZXzeWL2HceCekW4lixO9JPesIIQkSoLjeJHNQ=="
24 | },
25 | "@szmarczak/http-timer": {
26 | "version": "4.0.5",
27 | "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.5.tgz",
28 | "integrity": "sha512-PyRA9sm1Yayuj5OIoJ1hGt2YISX45w9WcFbh6ddT0Z/0yaFxOtGLInr4jUfU1EAFVs0Yfyfev4RNwBlUaHdlDQ==",
29 | "requires": {
30 | "defer-to-connect": "^2.0.0"
31 | }
32 | },
33 | "@types/cacheable-request": {
34 | "version": "6.0.1",
35 | "resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.1.tgz",
36 | "integrity": "sha512-ykFq2zmBGOCbpIXtoVbz4SKY5QriWPh3AjyU4G74RYbtt5yOc5OfaY75ftjg7mikMOla1CTGpX3lLbuJh8DTrQ==",
37 | "requires": {
38 | "@types/http-cache-semantics": "*",
39 | "@types/keyv": "*",
40 | "@types/node": "*",
41 | "@types/responselike": "*"
42 | }
43 | },
44 | "@types/http-cache-semantics": {
45 | "version": "4.0.0",
46 | "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.0.tgz",
47 | "integrity": "sha512-c3Xy026kOF7QOTn00hbIllV1dLR9hG9NkSrLQgCVs8NF6sBU+VGWjD3wLPhmh1TYAc7ugCFsvHYMN4VcBN1U1A=="
48 | },
49 | "@types/keyv": {
50 | "version": "3.1.1",
51 | "resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.1.tgz",
52 | "integrity": "sha512-MPtoySlAZQ37VoLaPcTHCu1RWJ4llDkULYZIzOYxlhxBqYPB0RsRlmMU0R6tahtFe27mIdkHV+551ZWV4PLmVw==",
53 | "requires": {
54 | "@types/node": "*"
55 | }
56 | },
57 | "@types/node": {
58 | "version": "14.14.14",
59 | "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.14.tgz",
60 | "integrity": "sha512-UHnOPWVWV1z+VV8k6L1HhG7UbGBgIdghqF3l9Ny9ApPghbjICXkUJSd/b9gOgQfjM1r+37cipdw/HJ3F6ICEnQ=="
61 | },
62 | "@types/responselike": {
63 | "version": "1.0.0",
64 | "resolved": "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.0.tgz",
65 | "integrity": "sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA==",
66 | "requires": {
67 | "@types/node": "*"
68 | }
69 | },
70 | "abort-controller": {
71 | "version": "3.0.0",
72 | "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz",
73 | "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==",
74 | "requires": {
75 | "event-target-shim": "^5.0.0"
76 | }
77 | },
78 | "ascii-table": {
79 | "version": "0.0.9",
80 | "resolved": "https://registry.npmjs.org/ascii-table/-/ascii-table-0.0.9.tgz",
81 | "integrity": "sha1-BqZgTWpV1L9BqaR9mHLXp42jHnM="
82 | },
83 | "asynckit": {
84 | "version": "0.4.0",
85 | "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
86 | "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
87 | },
88 | "cacheable-lookup": {
89 | "version": "5.0.4",
90 | "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz",
91 | "integrity": "sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA=="
92 | },
93 | "cacheable-request": {
94 | "version": "7.0.1",
95 | "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.1.tgz",
96 | "integrity": "sha512-lt0mJ6YAnsrBErpTMWeu5kl/tg9xMAWjavYTN6VQXM1A/teBITuNcccXsCxF0tDQQJf9DfAaX5O4e0zp0KlfZw==",
97 | "requires": {
98 | "clone-response": "^1.0.2",
99 | "get-stream": "^5.1.0",
100 | "http-cache-semantics": "^4.0.0",
101 | "keyv": "^4.0.0",
102 | "lowercase-keys": "^2.0.0",
103 | "normalize-url": "^4.1.0",
104 | "responselike": "^2.0.0"
105 | }
106 | },
107 | "clone-response": {
108 | "version": "1.0.2",
109 | "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz",
110 | "integrity": "sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws=",
111 | "requires": {
112 | "mimic-response": "^1.0.0"
113 | }
114 | },
115 | "combined-stream": {
116 | "version": "1.0.8",
117 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
118 | "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
119 | "requires": {
120 | "delayed-stream": "~1.0.0"
121 | }
122 | },
123 | "common-tags": {
124 | "version": "1.8.0",
125 | "resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.0.tgz",
126 | "integrity": "sha512-6P6g0uetGpW/sdyUy/iQQCbFF0kWVMSIVSyYz7Zgjcgh8mgw8PQzDNZeyZ5DQ2gM7LBoZPHmnjz8rUthkBG5tw=="
127 | },
128 | "decompress-response": {
129 | "version": "6.0.0",
130 | "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz",
131 | "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==",
132 | "requires": {
133 | "mimic-response": "^3.1.0"
134 | },
135 | "dependencies": {
136 | "mimic-response": {
137 | "version": "3.1.0",
138 | "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz",
139 | "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ=="
140 | }
141 | }
142 | },
143 | "defer-to-connect": {
144 | "version": "2.0.0",
145 | "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.0.tgz",
146 | "integrity": "sha512-bYL2d05vOSf1JEZNx5vSAtPuBMkX8K9EUutg7zlKvTqKXHt7RhWJFbmd7qakVuf13i+IkGmp6FwSsONOf6VYIg=="
147 | },
148 | "delayed-stream": {
149 | "version": "1.0.0",
150 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
151 | "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
152 | },
153 | "discord.js": {
154 | "version": "12.5.1",
155 | "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-12.5.1.tgz",
156 | "integrity": "sha512-VwZkVaUAIOB9mKdca0I5MefPMTQJTNg0qdgi1huF3iwsFwJ0L5s/Y69AQe+iPmjuV6j9rtKoG0Ta0n9vgEIL6w==",
157 | "requires": {
158 | "@discordjs/collection": "^0.1.6",
159 | "@discordjs/form-data": "^3.0.1",
160 | "abort-controller": "^3.0.0",
161 | "node-fetch": "^2.6.1",
162 | "prism-media": "^1.2.2",
163 | "setimmediate": "^1.0.5",
164 | "tweetnacl": "^1.0.3",
165 | "ws": "^7.3.1"
166 | }
167 | },
168 | "end-of-stream": {
169 | "version": "1.4.4",
170 | "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz",
171 | "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==",
172 | "requires": {
173 | "once": "^1.4.0"
174 | }
175 | },
176 | "event-target-shim": {
177 | "version": "5.0.1",
178 | "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
179 | "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ=="
180 | },
181 | "get-stream": {
182 | "version": "5.2.0",
183 | "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz",
184 | "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==",
185 | "requires": {
186 | "pump": "^3.0.0"
187 | }
188 | },
189 | "http-cache-semantics": {
190 | "version": "4.1.0",
191 | "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz",
192 | "integrity": "sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ=="
193 | },
194 | "json-buffer": {
195 | "version": "3.0.1",
196 | "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz",
197 | "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ=="
198 | },
199 | "keyv": {
200 | "version": "4.0.3",
201 | "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.0.3.tgz",
202 | "integrity": "sha512-zdGa2TOpSZPq5mU6iowDARnMBZgtCqJ11dJROFi6tg6kTn4nuUdU09lFyLFSaHrWqpIJ+EBq4E8/Dc0Vx5vLdA==",
203 | "requires": {
204 | "json-buffer": "3.0.1"
205 | }
206 | },
207 | "lowercase-keys": {
208 | "version": "2.0.0",
209 | "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz",
210 | "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA=="
211 | },
212 | "mime-db": {
213 | "version": "1.45.0",
214 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.45.0.tgz",
215 | "integrity": "sha512-CkqLUxUk15hofLoLyljJSrukZi8mAtgd+yE5uO4tqRZsdsAJKv0O+rFMhVDRJgozy+yG6md5KwuXhD4ocIoP+w=="
216 | },
217 | "mime-types": {
218 | "version": "2.1.28",
219 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.28.tgz",
220 | "integrity": "sha512-0TO2yJ5YHYr7M2zzT7gDU1tbwHxEUWBCLt0lscSNpcdAfFyJOVEpRYNS7EXVcTLNj/25QO8gulHC5JtTzSE2UQ==",
221 | "requires": {
222 | "mime-db": "1.45.0"
223 | }
224 | },
225 | "mimic-response": {
226 | "version": "1.0.1",
227 | "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz",
228 | "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ=="
229 | },
230 | "node-fetch": {
231 | "version": "2.6.1",
232 | "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
233 | "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
234 | },
235 | "normalize-url": {
236 | "version": "4.5.0",
237 | "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.0.tgz",
238 | "integrity": "sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ=="
239 | },
240 | "once": {
241 | "version": "1.4.0",
242 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
243 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
244 | "requires": {
245 | "wrappy": "1"
246 | }
247 | },
248 | "prism-media": {
249 | "version": "1.2.3",
250 | "resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.2.3.tgz",
251 | "integrity": "sha512-fSrR66n0l6roW9Rx4rSLMyTPTjRTiXy5RVqDOurACQ6si1rKHHKDU5gwBJoCsIV0R3o9gi+K50akl/qyw1C74A=="
252 | },
253 | "pump": {
254 | "version": "3.0.0",
255 | "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz",
256 | "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==",
257 | "requires": {
258 | "end-of-stream": "^1.1.0",
259 | "once": "^1.3.1"
260 | }
261 | },
262 | "responselike": {
263 | "version": "2.0.0",
264 | "resolved": "https://registry.npmjs.org/responselike/-/responselike-2.0.0.tgz",
265 | "integrity": "sha512-xH48u3FTB9VsZw7R+vvgaKeLKzT6jOogbQhEe/jewwnZgzPcnyWui2Av6JpoYZF/91uueC+lqhWqeURw5/qhCw==",
266 | "requires": {
267 | "lowercase-keys": "^2.0.0"
268 | }
269 | },
270 | "setimmediate": {
271 | "version": "1.0.5",
272 | "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz",
273 | "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU="
274 | },
275 | "tweetnacl": {
276 | "version": "1.0.3",
277 | "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz",
278 | "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw=="
279 | },
280 | "wrappy": {
281 | "version": "1.0.2",
282 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
283 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
284 | },
285 | "ws": {
286 | "version": "7.4.2",
287 | "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.2.tgz",
288 | "integrity": "sha512-T4tewALS3+qsrpGI/8dqNMLIVdq/g/85U98HPMa6F0m6xTbvhXU6RCQLqPH3+SlomNV/LdY6RXEbBpMH6EOJnA=="
289 | }
290 | }
291 | }
292 |
--------------------------------------------------------------------------------
/Tutorial-5/commands/fun/say.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = {
3 | name: "say",
4 | category: "fun",
5 | aliases: ["say"],
6 | description: "Resends the message",
7 | run: async (client, message, args) => {
8 | message.channel.send(args.join(" "))
9 | }
10 | }
--------------------------------------------------------------------------------
/Tutorial-5/commands/info/help.js:
--------------------------------------------------------------------------------
1 | const { MessageEmbed } = require("discord.js");
2 | const { stripIndents } = require("common-tags");
3 | const config = require("../../config.json");
4 | module.exports = {
5 | name: "help",
6 | aliases: ["h", "cmds"],
7 | category: "info",
8 | description: "Returns all Commands, or one specific Command information",
9 | usage: "[command], [aliases], [command ]",
10 | run: async (client,message,args) => {
11 | if(args[0]){
12 | return getCMD(client,message,args[0]);
13 | }
14 | else{
15 | return getAll(client, message);
16 | }
17 | }
18 | }
19 |
20 | function getAll(client,message){
21 | const embed = new MessageEmbed()
22 | .setColor("ORANGE")
23 | .setThumbnail(client.user.displayAvatarURL())
24 | .setTitle("HELP MENU")
25 | .addField("**__BOT BY:__**", `
26 | >>> <@442355791412854784> \`Tomato#6966\` [\`Website\`](https://musicium.eu)
27 | `)
28 | .setFooter(`TO see command descriptions and inforamtion, type: ${config.prefix}help [CMD NAME]`, client.user.displayAvatarURL())
29 | const commands = (category) => {
30 | return client.commands.filter(cmd => cmd.category === category)
31 | .map(cmd => `\`${cmd.name}\``).join(", ")
32 | }
33 | const info = client.categories.map(cat => stripIndents`**__${cat[0].toUpperCase() + cat.slice(1)}__**\n> ${commands(cat)}`)
34 | .reduce((string, category) => string + "\n" + category);
35 | return message.channel.send(embed.setDescription(info))
36 | }
37 | function getCMD(client,message,input){
38 | const embed = new MessageEmbed()
39 | const cmd = client.commands.get(input.toLowerCase()) || client.commands.get(client.aliases.get(input.toLowerCase()))
40 | let info = `No Information found for command **${input.toLowerCase()}**`;
41 | if(!cmd){
42 | return message.channel.send(embed.setColor("RED").setDescription(info));
43 | }
44 | info = "";
45 | if(cmd.name) info += `**Command name**: \`${cmd.name}\`\n`
46 | if(cmd.aliases) info += `**Aliases**: \`${cmd.aliases.map(a => `${a}`).join("\`, \`")}\`\n`
47 | if(cmd.description) info += `**Description**: \`${cmd.description}\`\n`
48 | if(cmd.usage) {
49 | info += `\n**Usage**: \`${cmd.usage}\``;
50 | embed.setFooter("Syntax: <> = required, [] = optional");
51 | }
52 | return message.channel.send(embed.setColor("ORANGE").setDescription(info))
53 | }
--------------------------------------------------------------------------------
/Tutorial-5/commands/info/ping.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: "ping",
3 | aliases: ["latency"],
4 | category: "info",
5 | description: "Returns latency and API ping",
6 | run: async (client, message, args) => {
7 | const msg = await message.channel.send(`🏓 Pinging....`);
8 | msg.edit(`🏓 Pong!
9 | Ping is ${Math.round(client.ws.ping)}ms`);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Tutorial-5/commands/info/uptime.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: "uptime",
3 | aliases: ["uptime"],
4 | category: "info",
5 | description: "Returns the duration of how long the Bot is online",
6 | usage: "[command], [aliases]",
7 | run: async (client,message,args) => {
8 | function duration(ms) {
9 | const sec = Math.floor(ms / 1000 % 60).toString();
10 | const min = Math.floor(ms / (60*1000) % 60).toString();
11 | const hrs = Math.floor(ms / (60*60*1000) % 60).toString();
12 | const days = Math.floor(ms / (24*60*60*1000) % 60).toString();
13 | return `\`${days} Days\`, \`${hrs} Hours\`, \`${min} Minutes\`, \`${sec} Seconds\``
14 | }
15 | message.reply(`:white_check_mark: **${client.user.username}** is since ${duration(client.uptime)} online`);
16 | }
17 | }
--------------------------------------------------------------------------------
/Tutorial-5/commands/user/userinfo.js:
--------------------------------------------------------------------------------
1 | const { MessageEmbed } = require("discord.js");
2 | module.exports = {
3 | name: "userinfo",
4 | category: "user",
5 | aliases: ["uinfo"],
6 | description: "Sends the Information of the User",
7 | run: async (client, message, args) => {
8 | let user = message.mentions.users.first() || message.author;
9 | let member = message.guild.members.cache.get(user.id);
10 |
11 | let embed = new MessageEmbed()
12 | .setColor("GREEN")
13 | .setAuthor("Userinformation über: " + user.tag, user.displayAvatarURL({dynamic: true}))
14 | .setThumbnail(user.displayAvatarURL({dynamic: true}))
15 | .setFooter(client.user.username, message.guild.iconURL())
16 | .addField("TAG:", `\`${user.tag}\`, ${user}`,true)
17 | .addField("ID:", `\`${user.id}\``,true)
18 | .addField("Is a BOT:", `\`${user.bot}\``,true)
19 | .addField("Joined Discord:", `\`${user.createdAt}\``,true)
20 | .addField("Presence:", `\`${user.presence.activities[0].state}\``,true)
21 | .addField("Status:", `\`${user.presence.status}\``,true)
22 | .addField("ROLLEN:", `<@&${member._roles.join("> | <@&")}>`,true)
23 |
24 | //.addField("ID:", `\`${user.id}\``,true)
25 | message.channel.send(embed)
26 | }
27 | }
--------------------------------------------------------------------------------
/Tutorial-5/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "token": "Nzg5MDY0NDE4OTI2Mzk1NDEz.X9sngQ.U5qyICMqSQWQgZsMZxWF3lj9l3U",
3 | "prefix": "!"
4 | }
--------------------------------------------------------------------------------
/Tutorial-5/handlers/command.js:
--------------------------------------------------------------------------------
1 | const { readdirSync } = require("fs");
2 | const ascii = require("ascii-table");
3 | let table = new ascii("Commands");
4 | table.setHeading("Command", "Load status");
5 | console.log("Welcome to SERVICE HANDLER // By https://x10-gaming.eu/service/dc // Discord: Tomato#6966")
6 | module.exports = (client) => {
7 | readdirSync("./commands/").forEach(dir => {
8 | const commands = readdirSync(`./commands/${dir}/`).filter(file => file.endsWith(".js"));
9 | for (let file of commands) {
10 | let pull = require(`../commands/${dir}/${file}`);
11 | if (pull.name) {
12 | client.commands.set(pull.name, pull);
13 | table.addRow(file, 'Ready');
14 | } else {
15 | table.addRow(file, `error -> missing a help.name, or help.name is not a string.`);
16 | continue;
17 | }
18 | if (pull.aliases && Array.isArray(pull.aliases)) pull.aliases.forEach(alias => client.aliases.set(alias, pull.name));
19 | }
20 | });
21 | console.log(table.toString());
22 | console.log("Welcome to SERVICE HANDLER // By https://x10-gaming.eu/service/dc // Discord: Tomato#6966")
23 | console.log("Logging into the BOT...");
24 | }
25 |
--------------------------------------------------------------------------------
/Tutorial-5/index.js:
--------------------------------------------------------------------------------
1 | //Modules
2 | const { Client, Collection } = require("discord.js");
3 | const config = require("./config.json");
4 | const fs = require("fs");
5 | const discord = require("discord.js");
6 | const client = new Client({
7 | disableEveryone: true
8 | , partials: ['MESSAGE', 'CHANNEL', 'REACTION'] });
9 |
10 | client.commands = new Collection();
11 | client.aliases = new Collection();
12 |
13 | client.categories = fs.readdirSync("./commands/");
14 |
15 | ["command"].forEach(handler => {
16 | require(`./handlers/${handler}`)(client);
17 | });
18 |
19 |
20 | let i = 0;
21 | var STATUSTEXT = [
22 | "1", //index == 0
23 | "2", //index == 1
24 | "3", //index == 2
25 | "4" //index == 3
26 | ];
27 | client.on("ready", () => {
28 | console.log("Bot is ready");
29 | //INIT
30 | client.user.setActivity("STATUSTEXT", { type: "STREAMING", url: "https://twitch.tv/#" })
31 | //LOOP
32 | setInterval(()=>{
33 | const index = Math.floor(i);
34 | if(index == 0 )client.user.setActivity(STATUSTEXT[index], { type: "STREAMING", url: "https://twitch.tv/#" })
35 | else if(index == 1 )client.user.setActivity(STATUSTEXT[index], { type: "PLAYING"})
36 | else if(index == 2 )client.user.setActivity(STATUSTEXT[index], { type: "WATCHING"})
37 | else if(index == 3 )client.user.setActivity(STATUSTEXT[index], { type: "LISTENING"})
38 | else client.user.setActivity(STATUSTEXT[index], { type: "PLAYING"})
39 | i++;
40 | if(i===STATUSTEXT.length) i -= STATUSTEXT.length;
41 | }, 5*1000)
42 |
43 | })
44 |
45 |
46 |
47 |
48 |
49 | client.on("message", async message => {
50 | const prefix = (config.prefix);
51 | if (message.author.bot) return;
52 | if (!message.guild) return;
53 |
54 | if (!message.content.startsWith(prefix)) return;
55 |
56 | const args = message.content.slice(prefix.length).trim().split(/ +/g);
57 | const cmd = args.shift().toLowerCase();
58 |
59 | if (cmd.length === 0) return;
60 |
61 | let command = client.commands.get(cmd);
62 | if (!command) command = client.commands.get(client.aliases.get(cmd));
63 |
64 |
65 | if (command)
66 | command.run(client, message, args);
67 |
68 | });
69 |
70 | client.login(config.token);
--------------------------------------------------------------------------------
/Tutorial-5/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "requires": true,
3 | "lockfileVersion": 1,
4 | "dependencies": {
5 | "@discordjs/collection": {
6 | "version": "0.1.6",
7 | "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.1.6.tgz",
8 | "integrity": "sha512-utRNxnd9kSS2qhyivo9lMlt5qgAUasH2gb7BEOn6p0efFh24gjGomHzWKMAPn2hEReOPQZCJaRKoURwRotKucQ=="
9 | },
10 | "@discordjs/form-data": {
11 | "version": "3.0.1",
12 | "resolved": "https://registry.npmjs.org/@discordjs/form-data/-/form-data-3.0.1.tgz",
13 | "integrity": "sha512-ZfFsbgEXW71Rw/6EtBdrP5VxBJy4dthyC0tpQKGKmYFImlmmrykO14Za+BiIVduwjte0jXEBlhSKf0MWbFp9Eg==",
14 | "requires": {
15 | "asynckit": "^0.4.0",
16 | "combined-stream": "^1.0.8",
17 | "mime-types": "^2.1.12"
18 | }
19 | },
20 | "@sindresorhus/is": {
21 | "version": "4.0.0",
22 | "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.0.0.tgz",
23 | "integrity": "sha512-FyD2meJpDPjyNQejSjvnhpgI/azsQkA4lGbuu5BQZfjvJ9cbRZXzeWL2HceCekW4lixO9JPesIIQkSoLjeJHNQ=="
24 | },
25 | "@szmarczak/http-timer": {
26 | "version": "4.0.5",
27 | "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.5.tgz",
28 | "integrity": "sha512-PyRA9sm1Yayuj5OIoJ1hGt2YISX45w9WcFbh6ddT0Z/0yaFxOtGLInr4jUfU1EAFVs0Yfyfev4RNwBlUaHdlDQ==",
29 | "requires": {
30 | "defer-to-connect": "^2.0.0"
31 | }
32 | },
33 | "@types/cacheable-request": {
34 | "version": "6.0.1",
35 | "resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.1.tgz",
36 | "integrity": "sha512-ykFq2zmBGOCbpIXtoVbz4SKY5QriWPh3AjyU4G74RYbtt5yOc5OfaY75ftjg7mikMOla1CTGpX3lLbuJh8DTrQ==",
37 | "requires": {
38 | "@types/http-cache-semantics": "*",
39 | "@types/keyv": "*",
40 | "@types/node": "*",
41 | "@types/responselike": "*"
42 | }
43 | },
44 | "@types/http-cache-semantics": {
45 | "version": "4.0.0",
46 | "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.0.tgz",
47 | "integrity": "sha512-c3Xy026kOF7QOTn00hbIllV1dLR9hG9NkSrLQgCVs8NF6sBU+VGWjD3wLPhmh1TYAc7ugCFsvHYMN4VcBN1U1A=="
48 | },
49 | "@types/keyv": {
50 | "version": "3.1.1",
51 | "resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.1.tgz",
52 | "integrity": "sha512-MPtoySlAZQ37VoLaPcTHCu1RWJ4llDkULYZIzOYxlhxBqYPB0RsRlmMU0R6tahtFe27mIdkHV+551ZWV4PLmVw==",
53 | "requires": {
54 | "@types/node": "*"
55 | }
56 | },
57 | "@types/node": {
58 | "version": "14.14.14",
59 | "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.14.tgz",
60 | "integrity": "sha512-UHnOPWVWV1z+VV8k6L1HhG7UbGBgIdghqF3l9Ny9ApPghbjICXkUJSd/b9gOgQfjM1r+37cipdw/HJ3F6ICEnQ=="
61 | },
62 | "@types/responselike": {
63 | "version": "1.0.0",
64 | "resolved": "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.0.tgz",
65 | "integrity": "sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA==",
66 | "requires": {
67 | "@types/node": "*"
68 | }
69 | },
70 | "abort-controller": {
71 | "version": "3.0.0",
72 | "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz",
73 | "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==",
74 | "requires": {
75 | "event-target-shim": "^5.0.0"
76 | }
77 | },
78 | "ascii-table": {
79 | "version": "0.0.9",
80 | "resolved": "https://registry.npmjs.org/ascii-table/-/ascii-table-0.0.9.tgz",
81 | "integrity": "sha1-BqZgTWpV1L9BqaR9mHLXp42jHnM="
82 | },
83 | "asynckit": {
84 | "version": "0.4.0",
85 | "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
86 | "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
87 | },
88 | "cacheable-lookup": {
89 | "version": "5.0.4",
90 | "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz",
91 | "integrity": "sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA=="
92 | },
93 | "cacheable-request": {
94 | "version": "7.0.1",
95 | "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.1.tgz",
96 | "integrity": "sha512-lt0mJ6YAnsrBErpTMWeu5kl/tg9xMAWjavYTN6VQXM1A/teBITuNcccXsCxF0tDQQJf9DfAaX5O4e0zp0KlfZw==",
97 | "requires": {
98 | "clone-response": "^1.0.2",
99 | "get-stream": "^5.1.0",
100 | "http-cache-semantics": "^4.0.0",
101 | "keyv": "^4.0.0",
102 | "lowercase-keys": "^2.0.0",
103 | "normalize-url": "^4.1.0",
104 | "responselike": "^2.0.0"
105 | }
106 | },
107 | "clone-response": {
108 | "version": "1.0.2",
109 | "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz",
110 | "integrity": "sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws=",
111 | "requires": {
112 | "mimic-response": "^1.0.0"
113 | }
114 | },
115 | "combined-stream": {
116 | "version": "1.0.8",
117 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
118 | "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
119 | "requires": {
120 | "delayed-stream": "~1.0.0"
121 | }
122 | },
123 | "common-tags": {
124 | "version": "1.8.0",
125 | "resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.0.tgz",
126 | "integrity": "sha512-6P6g0uetGpW/sdyUy/iQQCbFF0kWVMSIVSyYz7Zgjcgh8mgw8PQzDNZeyZ5DQ2gM7LBoZPHmnjz8rUthkBG5tw=="
127 | },
128 | "decompress-response": {
129 | "version": "6.0.0",
130 | "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz",
131 | "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==",
132 | "requires": {
133 | "mimic-response": "^3.1.0"
134 | },
135 | "dependencies": {
136 | "mimic-response": {
137 | "version": "3.1.0",
138 | "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz",
139 | "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ=="
140 | }
141 | }
142 | },
143 | "defer-to-connect": {
144 | "version": "2.0.0",
145 | "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.0.tgz",
146 | "integrity": "sha512-bYL2d05vOSf1JEZNx5vSAtPuBMkX8K9EUutg7zlKvTqKXHt7RhWJFbmd7qakVuf13i+IkGmp6FwSsONOf6VYIg=="
147 | },
148 | "delayed-stream": {
149 | "version": "1.0.0",
150 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
151 | "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
152 | },
153 | "discord.js": {
154 | "version": "12.5.1",
155 | "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-12.5.1.tgz",
156 | "integrity": "sha512-VwZkVaUAIOB9mKdca0I5MefPMTQJTNg0qdgi1huF3iwsFwJ0L5s/Y69AQe+iPmjuV6j9rtKoG0Ta0n9vgEIL6w==",
157 | "requires": {
158 | "@discordjs/collection": "^0.1.6",
159 | "@discordjs/form-data": "^3.0.1",
160 | "abort-controller": "^3.0.0",
161 | "node-fetch": "^2.6.1",
162 | "prism-media": "^1.2.2",
163 | "setimmediate": "^1.0.5",
164 | "tweetnacl": "^1.0.3",
165 | "ws": "^7.3.1"
166 | }
167 | },
168 | "end-of-stream": {
169 | "version": "1.4.4",
170 | "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz",
171 | "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==",
172 | "requires": {
173 | "once": "^1.4.0"
174 | }
175 | },
176 | "event-target-shim": {
177 | "version": "5.0.1",
178 | "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
179 | "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ=="
180 | },
181 | "get-stream": {
182 | "version": "5.2.0",
183 | "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz",
184 | "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==",
185 | "requires": {
186 | "pump": "^3.0.0"
187 | }
188 | },
189 | "http-cache-semantics": {
190 | "version": "4.1.0",
191 | "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz",
192 | "integrity": "sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ=="
193 | },
194 | "json-buffer": {
195 | "version": "3.0.1",
196 | "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz",
197 | "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ=="
198 | },
199 | "keyv": {
200 | "version": "4.0.3",
201 | "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.0.3.tgz",
202 | "integrity": "sha512-zdGa2TOpSZPq5mU6iowDARnMBZgtCqJ11dJROFi6tg6kTn4nuUdU09lFyLFSaHrWqpIJ+EBq4E8/Dc0Vx5vLdA==",
203 | "requires": {
204 | "json-buffer": "3.0.1"
205 | }
206 | },
207 | "lowercase-keys": {
208 | "version": "2.0.0",
209 | "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz",
210 | "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA=="
211 | },
212 | "mime-db": {
213 | "version": "1.45.0",
214 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.45.0.tgz",
215 | "integrity": "sha512-CkqLUxUk15hofLoLyljJSrukZi8mAtgd+yE5uO4tqRZsdsAJKv0O+rFMhVDRJgozy+yG6md5KwuXhD4ocIoP+w=="
216 | },
217 | "mime-types": {
218 | "version": "2.1.28",
219 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.28.tgz",
220 | "integrity": "sha512-0TO2yJ5YHYr7M2zzT7gDU1tbwHxEUWBCLt0lscSNpcdAfFyJOVEpRYNS7EXVcTLNj/25QO8gulHC5JtTzSE2UQ==",
221 | "requires": {
222 | "mime-db": "1.45.0"
223 | }
224 | },
225 | "mimic-response": {
226 | "version": "1.0.1",
227 | "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz",
228 | "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ=="
229 | },
230 | "node-fetch": {
231 | "version": "2.6.1",
232 | "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
233 | "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
234 | },
235 | "normalize-url": {
236 | "version": "4.5.0",
237 | "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.0.tgz",
238 | "integrity": "sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ=="
239 | },
240 | "once": {
241 | "version": "1.4.0",
242 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
243 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
244 | "requires": {
245 | "wrappy": "1"
246 | }
247 | },
248 | "prism-media": {
249 | "version": "1.2.3",
250 | "resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.2.3.tgz",
251 | "integrity": "sha512-fSrR66n0l6roW9Rx4rSLMyTPTjRTiXy5RVqDOurACQ6si1rKHHKDU5gwBJoCsIV0R3o9gi+K50akl/qyw1C74A=="
252 | },
253 | "pump": {
254 | "version": "3.0.0",
255 | "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz",
256 | "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==",
257 | "requires": {
258 | "end-of-stream": "^1.1.0",
259 | "once": "^1.3.1"
260 | }
261 | },
262 | "responselike": {
263 | "version": "2.0.0",
264 | "resolved": "https://registry.npmjs.org/responselike/-/responselike-2.0.0.tgz",
265 | "integrity": "sha512-xH48u3FTB9VsZw7R+vvgaKeLKzT6jOogbQhEe/jewwnZgzPcnyWui2Av6JpoYZF/91uueC+lqhWqeURw5/qhCw==",
266 | "requires": {
267 | "lowercase-keys": "^2.0.0"
268 | }
269 | },
270 | "setimmediate": {
271 | "version": "1.0.5",
272 | "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz",
273 | "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU="
274 | },
275 | "tweetnacl": {
276 | "version": "1.0.3",
277 | "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz",
278 | "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw=="
279 | },
280 | "wrappy": {
281 | "version": "1.0.2",
282 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
283 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
284 | },
285 | "ws": {
286 | "version": "7.4.2",
287 | "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.2.tgz",
288 | "integrity": "sha512-T4tewALS3+qsrpGI/8dqNMLIVdq/g/85U98HPMa6F0m6xTbvhXU6RCQLqPH3+SlomNV/LdY6RXEbBpMH6EOJnA=="
289 | }
290 | }
291 | }
292 |
--------------------------------------------------------------------------------
/Tutorial-6/commands/fun/say.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = {
3 | name: "say",
4 | category: "fun",
5 | aliases: ["say"],
6 | description: "Resends the message",
7 | run: async (client, message, args) => {
8 | message.channel.send(args.join(" "))
9 | }
10 | }
--------------------------------------------------------------------------------
/Tutorial-6/commands/info/help.js:
--------------------------------------------------------------------------------
1 | const { MessageEmbed } = require("discord.js");
2 | const { stripIndents } = require("common-tags");
3 | const config = require("../../config.json");
4 | module.exports = {
5 | name: "help",
6 | aliases: ["h", "cmds"],
7 | category: "info",
8 | description: "Returns all Commands, or one specific Command information",
9 | usage: "[command], [aliases], [command ]",
10 | run: async (client,message,args) => {
11 | if(args[0]){
12 | return getCMD(client,message,args[0]);
13 | }
14 | else{
15 | return getAll(client, message);
16 | }
17 | }
18 | }
19 |
20 | function getAll(client,message){
21 | const embed = new MessageEmbed()
22 | .setColor("ORANGE")
23 | .setThumbnail(client.user.displayAvatarURL())
24 | .setTitle("HELP MENU")
25 | .addField("**__BOT BY:__**", `
26 | >>> <@442355791412854784> \`Tomato#6966\` [\`Website\`](https://musicium.eu)
27 | `)
28 | .setFooter(`TO see command descriptions and inforamtion, type: ${config.prefix}help [CMD NAME]`, client.user.displayAvatarURL())
29 | const commands = (category) => {
30 | return client.commands.filter(cmd => cmd.category === category)
31 | .map(cmd => `\`${cmd.name}\``).join(", ")
32 | }
33 | const info = client.categories.map(cat => stripIndents`**__${cat[0].toUpperCase() + cat.slice(1)}__**\n> ${commands(cat)}`)
34 | .reduce((string, category) => string + "\n" + category);
35 | return message.channel.send(embed.setDescription(info))
36 | }
37 | function getCMD(client,message,input){
38 | const embed = new MessageEmbed()
39 | const cmd = client.commands.get(input.toLowerCase()) || client.commands.get(client.aliases.get(input.toLowerCase()))
40 | let info = `No Information found for command **${input.toLowerCase()}**`;
41 | if(!cmd){
42 | return message.channel.send(embed.setColor("RED").setDescription(info));
43 | }
44 | info = "";
45 | if(cmd.name) info += `**Command name**: \`${cmd.name}\`\n`
46 | if(cmd.aliases) info += `**Aliases**: \`${cmd.aliases.map(a => `${a}`).join("\`, \`")}\`\n`
47 | if(cmd.description) info += `**Description**: \`${cmd.description}\`\n`
48 | if(cmd.usage) {
49 | info += `\n**Usage**: \`${cmd.usage}\``;
50 | embed.setFooter("Syntax: <> = required, [] = optional");
51 | }
52 | return message.channel.send(embed.setColor("ORANGE").setDescription(info))
53 | }
--------------------------------------------------------------------------------
/Tutorial-6/commands/info/ping.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: "ping",
3 | aliases: ["latency"],
4 | category: "info",
5 | description: "Returns latency and API ping",
6 | run: async (client, message, args) => {
7 | const msg = await message.channel.send(`🏓 Pinging....`);
8 | msg.edit(`🏓 Pong!
9 | Ping is ${Math.round(client.ws.ping)}ms`);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Tutorial-6/commands/info/uptime.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: "uptime",
3 | aliases: ["uptime"],
4 | category: "info",
5 | description: "Returns the duration of how long the Bot is online",
6 | usage: "[command], [aliases]",
7 | run: async (client,message,args) => {
8 | function duration(ms) {
9 | const sec = Math.floor(ms / 1000 % 60).toString();
10 | const min = Math.floor(ms / (60*1000) % 60).toString();
11 | const hrs = Math.floor(ms / (60*60*1000) % 60).toString();
12 | const days = Math.floor(ms / (24*60*60*1000) % 60).toString();
13 | return `\`${days} Days\`, \`${hrs} Hours\`, \`${min} Minutes\`, \`${sec} Seconds\``
14 | }
15 | message.reply(`:white_check_mark: **${client.user.username}** is since ${duration(client.uptime)} online`);
16 | }
17 | }
--------------------------------------------------------------------------------
/Tutorial-6/commands/user/addrole.js:
--------------------------------------------------------------------------------
1 | const { MessageEmbed } = require("discord.js");
2 | module.exports = {
3 | name: "addrole",
4 | category: "user",
5 | aliases: ["addrole"],
6 | description: "Sends the Avatar of the User",
7 | run: async (client, message, args) => {
8 | let user = message.mentions.users.first();
9 | if(!user) return message.reply("PLEASE PING A USER");
10 | if(user.id === message.author.id) return message.reply("U cannot add a Role to yourself");
11 | let member = message.guild.members.cache.get(user.id);
12 | let Role = message.mentions.roles.first();
13 | if(!Role) message.reply("PLEASE PING A ROLE")
14 | try{
15 | member.roles.add(Role)
16 | message.channel.send(`${user.tag} has got the Role: \`${Role.id}\``)
17 | }catch{
18 | message.channel.send(`Konnte ${user.tag} nicht die Rolle geben: \`${Role.id}\``)
19 | }
20 |
21 |
22 | }
23 | }
--------------------------------------------------------------------------------
/Tutorial-6/commands/user/removerole.js:
--------------------------------------------------------------------------------
1 | const { MessageEmbed } = require("discord.js");
2 | module.exports = {
3 | name: "removerole",
4 | category: "user",
5 | aliases: ["removerole"],
6 | description: "Removes the Role of a Pinged User",
7 | run: async (client, message, args) => {
8 | let user = message.mentions.users.first();
9 | if(!user) return message.reply("PLEASE PING A USER");
10 | if(user.id === message.author.id) return message.reply("U cannot remove a Role to yourself");
11 | let member = message.guild.members.cache.get(user.id);
12 | let Role = message.mentions.roles.first();
13 | if(!Role) message.reply("PLEASE PING A ROLE")
14 | try{
15 | member.roles.remove(Role)
16 | message.channel.send(`${user.tag} has lost the Role: \`${Role.id}\``)
17 | }catch{
18 | message.channel.send(`Konnte ${user.tag} nicht die Rolle wegnehmen: \`${Role.id}\``)
19 | }
20 |
21 |
22 | }
23 | }
--------------------------------------------------------------------------------
/Tutorial-6/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "token": "Nzg5MDY0NDE4OTI2Mzk1NDEz.X9sngQ.U5qyICMqSQWQgZsMZxWF3lj9l3U",
3 | "prefix": "!"
4 | }
--------------------------------------------------------------------------------
/Tutorial-6/handlers/command.js:
--------------------------------------------------------------------------------
1 | const { readdirSync } = require("fs");
2 | const ascii = require("ascii-table");
3 | let table = new ascii("Commands");
4 | table.setHeading("Command", "Load status");
5 | console.log("Welcome to SERVICE HANDLER // By https://x10-gaming.eu/service/dc // Discord: Tomato#6966")
6 | module.exports = (client) => {
7 | readdirSync("./commands/").forEach(dir => {
8 | const commands = readdirSync(`./commands/${dir}/`).filter(file => file.endsWith(".js"));
9 | for (let file of commands) {
10 | let pull = require(`../commands/${dir}/${file}`);
11 | if (pull.name) {
12 | client.commands.set(pull.name, pull);
13 | table.addRow(file, 'Ready');
14 | } else {
15 | table.addRow(file, `error -> missing a help.name, or help.name is not a string.`);
16 | continue;
17 | }
18 | if (pull.aliases && Array.isArray(pull.aliases)) pull.aliases.forEach(alias => client.aliases.set(alias, pull.name));
19 | }
20 | });
21 | console.log(table.toString());
22 | console.log("Welcome to SERVICE HANDLER // By https://x10-gaming.eu/service/dc // Discord: Tomato#6966")
23 | console.log("Logging into the BOT...");
24 | }
25 |
--------------------------------------------------------------------------------
/Tutorial-6/index.js:
--------------------------------------------------------------------------------
1 | //Modules
2 | const { Client, Collection } = require("discord.js");
3 | const config = require("./config.json");
4 | const fs = require("fs");
5 | const discord = require("discord.js");
6 | const client = new Client({
7 | disableEveryone: true
8 | , partials: ['MESSAGE', 'CHANNEL', 'REACTION'] });
9 |
10 | client.commands = new Collection();
11 | client.aliases = new Collection();
12 |
13 | client.categories = fs.readdirSync("./commands/");
14 |
15 | ["command"].forEach(handler => {
16 | require(`./handlers/${handler}`)(client);
17 | });
18 |
19 |
20 | let i = 0;
21 | var STATUSTEXT = [
22 | "1", //index == 0
23 | "2", //index == 1
24 | "3", //index == 2
25 | "4" //index == 3
26 | ];
27 | client.on("ready", () => {
28 | console.log("Bot is ready");
29 | //INIT
30 | client.user.setActivity("STATUSTEXT", { type: "STREAMING", url: "https://twitch.tv/#" })
31 | //LOOP
32 | setInterval(()=>{
33 | const index = Math.floor(i);
34 | if(index == 0 )client.user.setActivity(STATUSTEXT[index], { type: "STREAMING", url: "https://twitch.tv/#" })
35 | else if(index == 1 )client.user.setActivity(STATUSTEXT[index], { type: "PLAYING"})
36 | else if(index == 2 )client.user.setActivity(STATUSTEXT[index], { type: "WATCHING"})
37 | else if(index == 3 )client.user.setActivity(STATUSTEXT[index], { type: "LISTENING"})
38 | else client.user.setActivity(STATUSTEXT[index], { type: "PLAYING"})
39 | i++;
40 | if(i===STATUSTEXT.length) i -= STATUSTEXT.length;
41 | }, 5*1000)
42 |
43 | })
44 |
45 |
46 |
47 |
48 |
49 | client.on("message", async message => {
50 | const prefix = (config.prefix);
51 | if (message.author.bot) return;
52 | if (!message.guild) return;
53 |
54 | if (!message.content.startsWith(prefix)) return;
55 |
56 | const args = message.content.slice(prefix.length).trim().split(/ +/g);
57 | const cmd = args.shift().toLowerCase();
58 |
59 | if (cmd.length === 0) return;
60 |
61 | let command = client.commands.get(cmd);
62 | if (!command) command = client.commands.get(client.aliases.get(cmd));
63 |
64 |
65 | if (command)
66 | command.run(client, message, args);
67 |
68 | });
69 |
70 | client.login(config.token);
--------------------------------------------------------------------------------
/Tutorial-6/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "requires": true,
3 | "lockfileVersion": 1,
4 | "dependencies": {
5 | "@discordjs/collection": {
6 | "version": "0.1.6",
7 | "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.1.6.tgz",
8 | "integrity": "sha512-utRNxnd9kSS2qhyivo9lMlt5qgAUasH2gb7BEOn6p0efFh24gjGomHzWKMAPn2hEReOPQZCJaRKoURwRotKucQ=="
9 | },
10 | "@discordjs/form-data": {
11 | "version": "3.0.1",
12 | "resolved": "https://registry.npmjs.org/@discordjs/form-data/-/form-data-3.0.1.tgz",
13 | "integrity": "sha512-ZfFsbgEXW71Rw/6EtBdrP5VxBJy4dthyC0tpQKGKmYFImlmmrykO14Za+BiIVduwjte0jXEBlhSKf0MWbFp9Eg==",
14 | "requires": {
15 | "asynckit": "^0.4.0",
16 | "combined-stream": "^1.0.8",
17 | "mime-types": "^2.1.12"
18 | }
19 | },
20 | "@sindresorhus/is": {
21 | "version": "4.0.0",
22 | "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.0.0.tgz",
23 | "integrity": "sha512-FyD2meJpDPjyNQejSjvnhpgI/azsQkA4lGbuu5BQZfjvJ9cbRZXzeWL2HceCekW4lixO9JPesIIQkSoLjeJHNQ=="
24 | },
25 | "@szmarczak/http-timer": {
26 | "version": "4.0.5",
27 | "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.5.tgz",
28 | "integrity": "sha512-PyRA9sm1Yayuj5OIoJ1hGt2YISX45w9WcFbh6ddT0Z/0yaFxOtGLInr4jUfU1EAFVs0Yfyfev4RNwBlUaHdlDQ==",
29 | "requires": {
30 | "defer-to-connect": "^2.0.0"
31 | }
32 | },
33 | "@types/cacheable-request": {
34 | "version": "6.0.1",
35 | "resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.1.tgz",
36 | "integrity": "sha512-ykFq2zmBGOCbpIXtoVbz4SKY5QriWPh3AjyU4G74RYbtt5yOc5OfaY75ftjg7mikMOla1CTGpX3lLbuJh8DTrQ==",
37 | "requires": {
38 | "@types/http-cache-semantics": "*",
39 | "@types/keyv": "*",
40 | "@types/node": "*",
41 | "@types/responselike": "*"
42 | }
43 | },
44 | "@types/http-cache-semantics": {
45 | "version": "4.0.0",
46 | "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.0.tgz",
47 | "integrity": "sha512-c3Xy026kOF7QOTn00hbIllV1dLR9hG9NkSrLQgCVs8NF6sBU+VGWjD3wLPhmh1TYAc7ugCFsvHYMN4VcBN1U1A=="
48 | },
49 | "@types/keyv": {
50 | "version": "3.1.1",
51 | "resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.1.tgz",
52 | "integrity": "sha512-MPtoySlAZQ37VoLaPcTHCu1RWJ4llDkULYZIzOYxlhxBqYPB0RsRlmMU0R6tahtFe27mIdkHV+551ZWV4PLmVw==",
53 | "requires": {
54 | "@types/node": "*"
55 | }
56 | },
57 | "@types/node": {
58 | "version": "14.14.14",
59 | "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.14.tgz",
60 | "integrity": "sha512-UHnOPWVWV1z+VV8k6L1HhG7UbGBgIdghqF3l9Ny9ApPghbjICXkUJSd/b9gOgQfjM1r+37cipdw/HJ3F6ICEnQ=="
61 | },
62 | "@types/responselike": {
63 | "version": "1.0.0",
64 | "resolved": "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.0.tgz",
65 | "integrity": "sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA==",
66 | "requires": {
67 | "@types/node": "*"
68 | }
69 | },
70 | "abort-controller": {
71 | "version": "3.0.0",
72 | "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz",
73 | "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==",
74 | "requires": {
75 | "event-target-shim": "^5.0.0"
76 | }
77 | },
78 | "ascii-table": {
79 | "version": "0.0.9",
80 | "resolved": "https://registry.npmjs.org/ascii-table/-/ascii-table-0.0.9.tgz",
81 | "integrity": "sha1-BqZgTWpV1L9BqaR9mHLXp42jHnM="
82 | },
83 | "asynckit": {
84 | "version": "0.4.0",
85 | "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
86 | "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
87 | },
88 | "cacheable-lookup": {
89 | "version": "5.0.4",
90 | "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz",
91 | "integrity": "sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA=="
92 | },
93 | "cacheable-request": {
94 | "version": "7.0.1",
95 | "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.1.tgz",
96 | "integrity": "sha512-lt0mJ6YAnsrBErpTMWeu5kl/tg9xMAWjavYTN6VQXM1A/teBITuNcccXsCxF0tDQQJf9DfAaX5O4e0zp0KlfZw==",
97 | "requires": {
98 | "clone-response": "^1.0.2",
99 | "get-stream": "^5.1.0",
100 | "http-cache-semantics": "^4.0.0",
101 | "keyv": "^4.0.0",
102 | "lowercase-keys": "^2.0.0",
103 | "normalize-url": "^4.1.0",
104 | "responselike": "^2.0.0"
105 | }
106 | },
107 | "clone-response": {
108 | "version": "1.0.2",
109 | "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz",
110 | "integrity": "sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws=",
111 | "requires": {
112 | "mimic-response": "^1.0.0"
113 | }
114 | },
115 | "combined-stream": {
116 | "version": "1.0.8",
117 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
118 | "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
119 | "requires": {
120 | "delayed-stream": "~1.0.0"
121 | }
122 | },
123 | "common-tags": {
124 | "version": "1.8.0",
125 | "resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.0.tgz",
126 | "integrity": "sha512-6P6g0uetGpW/sdyUy/iQQCbFF0kWVMSIVSyYz7Zgjcgh8mgw8PQzDNZeyZ5DQ2gM7LBoZPHmnjz8rUthkBG5tw=="
127 | },
128 | "decompress-response": {
129 | "version": "6.0.0",
130 | "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz",
131 | "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==",
132 | "requires": {
133 | "mimic-response": "^3.1.0"
134 | },
135 | "dependencies": {
136 | "mimic-response": {
137 | "version": "3.1.0",
138 | "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz",
139 | "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ=="
140 | }
141 | }
142 | },
143 | "defer-to-connect": {
144 | "version": "2.0.0",
145 | "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.0.tgz",
146 | "integrity": "sha512-bYL2d05vOSf1JEZNx5vSAtPuBMkX8K9EUutg7zlKvTqKXHt7RhWJFbmd7qakVuf13i+IkGmp6FwSsONOf6VYIg=="
147 | },
148 | "delayed-stream": {
149 | "version": "1.0.0",
150 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
151 | "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
152 | },
153 | "discord.js": {
154 | "version": "12.5.1",
155 | "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-12.5.1.tgz",
156 | "integrity": "sha512-VwZkVaUAIOB9mKdca0I5MefPMTQJTNg0qdgi1huF3iwsFwJ0L5s/Y69AQe+iPmjuV6j9rtKoG0Ta0n9vgEIL6w==",
157 | "requires": {
158 | "@discordjs/collection": "^0.1.6",
159 | "@discordjs/form-data": "^3.0.1",
160 | "abort-controller": "^3.0.0",
161 | "node-fetch": "^2.6.1",
162 | "prism-media": "^1.2.2",
163 | "setimmediate": "^1.0.5",
164 | "tweetnacl": "^1.0.3",
165 | "ws": "^7.3.1"
166 | }
167 | },
168 | "end-of-stream": {
169 | "version": "1.4.4",
170 | "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz",
171 | "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==",
172 | "requires": {
173 | "once": "^1.4.0"
174 | }
175 | },
176 | "event-target-shim": {
177 | "version": "5.0.1",
178 | "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
179 | "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ=="
180 | },
181 | "get-stream": {
182 | "version": "5.2.0",
183 | "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz",
184 | "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==",
185 | "requires": {
186 | "pump": "^3.0.0"
187 | }
188 | },
189 | "http-cache-semantics": {
190 | "version": "4.1.0",
191 | "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz",
192 | "integrity": "sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ=="
193 | },
194 | "json-buffer": {
195 | "version": "3.0.1",
196 | "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz",
197 | "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ=="
198 | },
199 | "keyv": {
200 | "version": "4.0.3",
201 | "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.0.3.tgz",
202 | "integrity": "sha512-zdGa2TOpSZPq5mU6iowDARnMBZgtCqJ11dJROFi6tg6kTn4nuUdU09lFyLFSaHrWqpIJ+EBq4E8/Dc0Vx5vLdA==",
203 | "requires": {
204 | "json-buffer": "3.0.1"
205 | }
206 | },
207 | "lowercase-keys": {
208 | "version": "2.0.0",
209 | "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz",
210 | "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA=="
211 | },
212 | "mime-db": {
213 | "version": "1.45.0",
214 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.45.0.tgz",
215 | "integrity": "sha512-CkqLUxUk15hofLoLyljJSrukZi8mAtgd+yE5uO4tqRZsdsAJKv0O+rFMhVDRJgozy+yG6md5KwuXhD4ocIoP+w=="
216 | },
217 | "mime-types": {
218 | "version": "2.1.28",
219 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.28.tgz",
220 | "integrity": "sha512-0TO2yJ5YHYr7M2zzT7gDU1tbwHxEUWBCLt0lscSNpcdAfFyJOVEpRYNS7EXVcTLNj/25QO8gulHC5JtTzSE2UQ==",
221 | "requires": {
222 | "mime-db": "1.45.0"
223 | }
224 | },
225 | "mimic-response": {
226 | "version": "1.0.1",
227 | "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz",
228 | "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ=="
229 | },
230 | "node-fetch": {
231 | "version": "2.6.1",
232 | "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
233 | "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
234 | },
235 | "normalize-url": {
236 | "version": "4.5.0",
237 | "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.0.tgz",
238 | "integrity": "sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ=="
239 | },
240 | "once": {
241 | "version": "1.4.0",
242 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
243 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
244 | "requires": {
245 | "wrappy": "1"
246 | }
247 | },
248 | "prism-media": {
249 | "version": "1.2.3",
250 | "resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.2.3.tgz",
251 | "integrity": "sha512-fSrR66n0l6roW9Rx4rSLMyTPTjRTiXy5RVqDOurACQ6si1rKHHKDU5gwBJoCsIV0R3o9gi+K50akl/qyw1C74A=="
252 | },
253 | "pump": {
254 | "version": "3.0.0",
255 | "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz",
256 | "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==",
257 | "requires": {
258 | "end-of-stream": "^1.1.0",
259 | "once": "^1.3.1"
260 | }
261 | },
262 | "responselike": {
263 | "version": "2.0.0",
264 | "resolved": "https://registry.npmjs.org/responselike/-/responselike-2.0.0.tgz",
265 | "integrity": "sha512-xH48u3FTB9VsZw7R+vvgaKeLKzT6jOogbQhEe/jewwnZgzPcnyWui2Av6JpoYZF/91uueC+lqhWqeURw5/qhCw==",
266 | "requires": {
267 | "lowercase-keys": "^2.0.0"
268 | }
269 | },
270 | "setimmediate": {
271 | "version": "1.0.5",
272 | "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz",
273 | "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU="
274 | },
275 | "tweetnacl": {
276 | "version": "1.0.3",
277 | "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz",
278 | "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw=="
279 | },
280 | "wrappy": {
281 | "version": "1.0.2",
282 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
283 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
284 | },
285 | "ws": {
286 | "version": "7.4.2",
287 | "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.2.tgz",
288 | "integrity": "sha512-T4tewALS3+qsrpGI/8dqNMLIVdq/g/85U98HPMa6F0m6xTbvhXU6RCQLqPH3+SlomNV/LdY6RXEbBpMH6EOJnA=="
289 | }
290 | }
291 | }
292 |
--------------------------------------------------------------------------------
/Tutorial-7/commands/fun/say.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = {
3 | name: "say",
4 | category: "fun",
5 | aliases: ["say"],
6 | description: "Resends the message",
7 | run: async (client, message, args) => {
8 | message.channel.send(args.join(" "))
9 | }
10 | }
--------------------------------------------------------------------------------
/Tutorial-7/commands/info/help.js:
--------------------------------------------------------------------------------
1 | const { MessageEmbed } = require("discord.js");
2 | const { stripIndents } = require("common-tags");
3 | const config = require("../../config.json");
4 | module.exports = {
5 | name: "help",
6 | aliases: ["h", "cmds"],
7 | category: "info",
8 | description: "Returns all Commands, or one specific Command information",
9 | usage: "[command], [aliases], [command ]",
10 | run: async (client,message,args) => {
11 | if(args[0]){
12 | return getCMD(client,message,args[0]);
13 | }
14 | else{
15 | return getAll(client, message);
16 | }
17 | }
18 | }
19 |
20 | function getAll(client,message){
21 | const embed = new MessageEmbed()
22 | .setColor("ORANGE")
23 | .setThumbnail(client.user.displayAvatarURL())
24 | .setTitle("HELP MENU")
25 | .addField("**__BOT BY:__**", `
26 | >>> <@442355791412854784> \`Tomato#6966\` [\`Website\`](https://musicium.eu)
27 | `)
28 | .setFooter(`TO see command descriptions and inforamtion, type: ${config.prefix}help [CMD NAME]`, client.user.displayAvatarURL())
29 | const commands = (category) => {
30 | return client.commands.filter(cmd => cmd.category === category)
31 | .map(cmd => `\`${cmd.name}\``).join(", ")
32 | }
33 | const info = client.categories.map(cat => stripIndents`**__${cat[0].toUpperCase() + cat.slice(1)}__**\n> ${commands(cat)}`)
34 | .reduce((string, category) => string + "\n" + category);
35 | return message.channel.send(embed.setDescription(info))
36 | }
37 | function getCMD(client,message,input){
38 | const embed = new MessageEmbed()
39 | const cmd = client.commands.get(input.toLowerCase()) || client.commands.get(client.aliases.get(input.toLowerCase()))
40 | let info = `No Information found for command **${input.toLowerCase()}**`;
41 | if(!cmd){
42 | return message.channel.send(embed.setColor("RED").setDescription(info));
43 | }
44 | info = "";
45 | if(cmd.name) info += `**Command name**: \`${cmd.name}\`\n`
46 | if(cmd.aliases) info += `**Aliases**: \`${cmd.aliases.map(a => `${a}`).join("\`, \`")}\`\n`
47 | if(cmd.description) info += `**Description**: \`${cmd.description}\`\n`
48 | if(cmd.usage) {
49 | info += `\n**Usage**: \`${cmd.usage}\``;
50 | embed.setFooter("Syntax: <> = required, [] = optional");
51 | }
52 | return message.channel.send(embed.setColor("ORANGE").setDescription(info))
53 | }
--------------------------------------------------------------------------------
/Tutorial-7/commands/info/ping.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: "ping",
3 | aliases: ["latency"],
4 | category: "info",
5 | description: "Returns latency and API ping",
6 | run: async (client, message, args) => {
7 | const msg = await message.channel.send(`🏓 Pinging....`);
8 | msg.edit(`🏓 Pong!
9 | Ping is ${Math.round(client.ws.ping)}ms`);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Tutorial-7/commands/info/uptime.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: "uptime",
3 | aliases: ["uptime"],
4 | category: "info",
5 | description: "Returns the duration of how long the Bot is online",
6 | usage: "[command], [aliases]",
7 | run: async (client,message,args) => {
8 | function duration(ms) {
9 | const sec = Math.floor(ms / 1000 % 60).toString();
10 | const min = Math.floor(ms / (60*1000) % 60).toString();
11 | const hrs = Math.floor(ms / (60*60*1000) % 60).toString();
12 | const days = Math.floor(ms / (24*60*60*1000) % 60).toString();
13 | return `\`${days} Days\`, \`${hrs} Hours\`, \`${min} Minutes\`, \`${sec} Seconds\``
14 | }
15 | message.reply(`:white_check_mark: **${client.user.username}** is since ${duration(client.uptime)} online`);
16 | }
17 | }
--------------------------------------------------------------------------------
/Tutorial-7/commands/user/ban.js:
--------------------------------------------------------------------------------
1 | const { MessageEmbed } = require("discord.js");
2 | module.exports = {
3 | name: "ban",
4 | category: "user",
5 | aliases: ["ban"],
6 | description: "Bans a Member",
7 | run: async (client, message, args) => {
8 | let user = message.mentions.users.first();
9 | if(!user) return message.reply("PLEASE PING A USER");
10 | if(user.id === message.author.id) return message.reply("U cannot ban yourself");
11 | let member = message.guild.members.cache.get(user.id);
12 | if(!message.member.hasPermission("ADMINISTRATOR")) return message.reply("DU BIST KEIN ADMIN! nutze diesen cmd nicht!")
13 | if(!member.bannable) return message.channel.send("Konnte den User nicht bannen!");
14 | try{
15 | member.ban();
16 | message.channel.send("SUCCESSFULLY, banned: " + user.tag)
17 | }catch{
18 | message.channel.send("Konnte den User nicht bannen!")
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Tutorial-7/commands/user/kick.js:
--------------------------------------------------------------------------------
1 | const { MessageEmbed } = require("discord.js");
2 | module.exports = {
3 | name: "kick",
4 | category: "user",
5 | aliases: ["kick"],
6 | description: "Kicks a member",
7 | run: async (client, message, args) => {
8 | let user = message.mentions.users.first();
9 | if(!user) return message.reply("PLEASE PING A USER");
10 | if(user.id === message.author.id) return message.reply("U cannot kick yourself");
11 | let member = message.guild.members.cache.get(user.id);
12 | if(!message.member.hasPermission("ADMINISTRATOR")) return message.reply("DU BIST KEIN ADMIN! nutze diesen cmd nicht!")
13 | if(!member.kickable) return message.channel.send("Konnte den User nicht kicken!");
14 | try{
15 | member.kick();
16 | message.channel.send("SUCCESSFULLY, kicked: " + user.tag)
17 | }catch{
18 | message.channel.send("Konnte den User nicht kicken!")
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Tutorial-7/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "token": "Nzg5MDY0NDE4OTI2Mzk1NDEz.X9sngQ.U5qyICMqSQWQgZsMZxWF3lj9l3U",
3 | "prefix": "!"
4 | }
--------------------------------------------------------------------------------
/Tutorial-7/handlers/command.js:
--------------------------------------------------------------------------------
1 | const { readdirSync } = require("fs");
2 | const ascii = require("ascii-table");
3 | let table = new ascii("Commands");
4 | table.setHeading("Command", "Load status");
5 | console.log("Welcome to SERVICE HANDLER // By https://x10-gaming.eu/service/dc // Discord: Tomato#6966")
6 | module.exports = (client) => {
7 | readdirSync("./commands/").forEach(dir => {
8 | const commands = readdirSync(`./commands/${dir}/`).filter(file => file.endsWith(".js"));
9 | for (let file of commands) {
10 | let pull = require(`../commands/${dir}/${file}`);
11 | if (pull.name) {
12 | client.commands.set(pull.name, pull);
13 | table.addRow(file, 'Ready');
14 | } else {
15 | table.addRow(file, `error -> missing a help.name, or help.name is not a string.`);
16 | continue;
17 | }
18 | if (pull.aliases && Array.isArray(pull.aliases)) pull.aliases.forEach(alias => client.aliases.set(alias, pull.name));
19 | }
20 | });
21 | console.log(table.toString());
22 | console.log("Welcome to SERVICE HANDLER // By https://x10-gaming.eu/service/dc // Discord: Tomato#6966")
23 | console.log("Logging into the BOT...");
24 | }
25 |
--------------------------------------------------------------------------------
/Tutorial-7/index.js:
--------------------------------------------------------------------------------
1 | //Modules
2 | const { Client, Collection } = require("discord.js");
3 | const config = require("./config.json");
4 | const fs = require("fs");
5 | const discord = require("discord.js");
6 | const client = new Client({
7 | disableEveryone: true
8 | , partials: ['MESSAGE', 'CHANNEL', 'REACTION'] });
9 |
10 | client.commands = new Collection();
11 | client.aliases = new Collection();
12 |
13 | client.categories = fs.readdirSync("./commands/");
14 |
15 | ["command"].forEach(handler => {
16 | require(`./handlers/${handler}`)(client);
17 | });
18 |
19 |
20 | let i = 0;
21 | var STATUSTEXT = [
22 | "1", //index == 0
23 | "2", //index == 1
24 | "3", //index == 2
25 | "4" //index == 3
26 | ];
27 | client.on("ready", () => {
28 | console.log("Bot is ready");
29 | //INIT
30 | client.user.setActivity("STATUSTEXT", { type: "STREAMING", url: "https://twitch.tv/#" })
31 | //LOOP
32 | setInterval(()=>{
33 | const index = Math.floor(i);
34 | if(index == 0 )client.user.setActivity(STATUSTEXT[index], { type: "STREAMING", url: "https://twitch.tv/#" })
35 | else if(index == 1 )client.user.setActivity(STATUSTEXT[index], { type: "PLAYING"})
36 | else if(index == 2 )client.user.setActivity(STATUSTEXT[index], { type: "WATCHING"})
37 | else if(index == 3 )client.user.setActivity(STATUSTEXT[index], { type: "LISTENING"})
38 | else client.user.setActivity(STATUSTEXT[index], { type: "PLAYING"})
39 | i++;
40 | if(i===STATUSTEXT.length) i -= STATUSTEXT.length;
41 | }, 5*1000)
42 |
43 | })
44 |
45 |
46 |
47 |
48 |
49 | client.on("message", async message => {
50 | const prefix = (config.prefix);
51 | if (message.author.bot) return;
52 | if (!message.guild) return;
53 |
54 | if (!message.content.startsWith(prefix)) return;
55 |
56 | const args = message.content.slice(prefix.length).trim().split(/ +/g);
57 | const cmd = args.shift().toLowerCase();
58 |
59 | if (cmd.length === 0) return;
60 |
61 | let command = client.commands.get(cmd);
62 | if (!command) command = client.commands.get(client.aliases.get(cmd));
63 |
64 |
65 | if (command)
66 | command.run(client, message, args);
67 |
68 | });
69 |
70 | client.login(config.token);
--------------------------------------------------------------------------------
/Tutorial-7/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "requires": true,
3 | "lockfileVersion": 1,
4 | "dependencies": {
5 | "@discordjs/collection": {
6 | "version": "0.1.6",
7 | "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.1.6.tgz",
8 | "integrity": "sha512-utRNxnd9kSS2qhyivo9lMlt5qgAUasH2gb7BEOn6p0efFh24gjGomHzWKMAPn2hEReOPQZCJaRKoURwRotKucQ=="
9 | },
10 | "@discordjs/form-data": {
11 | "version": "3.0.1",
12 | "resolved": "https://registry.npmjs.org/@discordjs/form-data/-/form-data-3.0.1.tgz",
13 | "integrity": "sha512-ZfFsbgEXW71Rw/6EtBdrP5VxBJy4dthyC0tpQKGKmYFImlmmrykO14Za+BiIVduwjte0jXEBlhSKf0MWbFp9Eg==",
14 | "requires": {
15 | "asynckit": "^0.4.0",
16 | "combined-stream": "^1.0.8",
17 | "mime-types": "^2.1.12"
18 | }
19 | },
20 | "@sindresorhus/is": {
21 | "version": "4.0.0",
22 | "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.0.0.tgz",
23 | "integrity": "sha512-FyD2meJpDPjyNQejSjvnhpgI/azsQkA4lGbuu5BQZfjvJ9cbRZXzeWL2HceCekW4lixO9JPesIIQkSoLjeJHNQ=="
24 | },
25 | "@szmarczak/http-timer": {
26 | "version": "4.0.5",
27 | "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.5.tgz",
28 | "integrity": "sha512-PyRA9sm1Yayuj5OIoJ1hGt2YISX45w9WcFbh6ddT0Z/0yaFxOtGLInr4jUfU1EAFVs0Yfyfev4RNwBlUaHdlDQ==",
29 | "requires": {
30 | "defer-to-connect": "^2.0.0"
31 | }
32 | },
33 | "@types/cacheable-request": {
34 | "version": "6.0.1",
35 | "resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.1.tgz",
36 | "integrity": "sha512-ykFq2zmBGOCbpIXtoVbz4SKY5QriWPh3AjyU4G74RYbtt5yOc5OfaY75ftjg7mikMOla1CTGpX3lLbuJh8DTrQ==",
37 | "requires": {
38 | "@types/http-cache-semantics": "*",
39 | "@types/keyv": "*",
40 | "@types/node": "*",
41 | "@types/responselike": "*"
42 | }
43 | },
44 | "@types/http-cache-semantics": {
45 | "version": "4.0.0",
46 | "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.0.tgz",
47 | "integrity": "sha512-c3Xy026kOF7QOTn00hbIllV1dLR9hG9NkSrLQgCVs8NF6sBU+VGWjD3wLPhmh1TYAc7ugCFsvHYMN4VcBN1U1A=="
48 | },
49 | "@types/keyv": {
50 | "version": "3.1.1",
51 | "resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.1.tgz",
52 | "integrity": "sha512-MPtoySlAZQ37VoLaPcTHCu1RWJ4llDkULYZIzOYxlhxBqYPB0RsRlmMU0R6tahtFe27mIdkHV+551ZWV4PLmVw==",
53 | "requires": {
54 | "@types/node": "*"
55 | }
56 | },
57 | "@types/node": {
58 | "version": "14.14.14",
59 | "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.14.tgz",
60 | "integrity": "sha512-UHnOPWVWV1z+VV8k6L1HhG7UbGBgIdghqF3l9Ny9ApPghbjICXkUJSd/b9gOgQfjM1r+37cipdw/HJ3F6ICEnQ=="
61 | },
62 | "@types/responselike": {
63 | "version": "1.0.0",
64 | "resolved": "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.0.tgz",
65 | "integrity": "sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA==",
66 | "requires": {
67 | "@types/node": "*"
68 | }
69 | },
70 | "abort-controller": {
71 | "version": "3.0.0",
72 | "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz",
73 | "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==",
74 | "requires": {
75 | "event-target-shim": "^5.0.0"
76 | }
77 | },
78 | "ascii-table": {
79 | "version": "0.0.9",
80 | "resolved": "https://registry.npmjs.org/ascii-table/-/ascii-table-0.0.9.tgz",
81 | "integrity": "sha1-BqZgTWpV1L9BqaR9mHLXp42jHnM="
82 | },
83 | "asynckit": {
84 | "version": "0.4.0",
85 | "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
86 | "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
87 | },
88 | "cacheable-lookup": {
89 | "version": "5.0.4",
90 | "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz",
91 | "integrity": "sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA=="
92 | },
93 | "cacheable-request": {
94 | "version": "7.0.1",
95 | "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.1.tgz",
96 | "integrity": "sha512-lt0mJ6YAnsrBErpTMWeu5kl/tg9xMAWjavYTN6VQXM1A/teBITuNcccXsCxF0tDQQJf9DfAaX5O4e0zp0KlfZw==",
97 | "requires": {
98 | "clone-response": "^1.0.2",
99 | "get-stream": "^5.1.0",
100 | "http-cache-semantics": "^4.0.0",
101 | "keyv": "^4.0.0",
102 | "lowercase-keys": "^2.0.0",
103 | "normalize-url": "^4.1.0",
104 | "responselike": "^2.0.0"
105 | }
106 | },
107 | "clone-response": {
108 | "version": "1.0.2",
109 | "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz",
110 | "integrity": "sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws=",
111 | "requires": {
112 | "mimic-response": "^1.0.0"
113 | }
114 | },
115 | "combined-stream": {
116 | "version": "1.0.8",
117 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
118 | "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
119 | "requires": {
120 | "delayed-stream": "~1.0.0"
121 | }
122 | },
123 | "common-tags": {
124 | "version": "1.8.0",
125 | "resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.0.tgz",
126 | "integrity": "sha512-6P6g0uetGpW/sdyUy/iQQCbFF0kWVMSIVSyYz7Zgjcgh8mgw8PQzDNZeyZ5DQ2gM7LBoZPHmnjz8rUthkBG5tw=="
127 | },
128 | "decompress-response": {
129 | "version": "6.0.0",
130 | "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz",
131 | "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==",
132 | "requires": {
133 | "mimic-response": "^3.1.0"
134 | },
135 | "dependencies": {
136 | "mimic-response": {
137 | "version": "3.1.0",
138 | "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz",
139 | "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ=="
140 | }
141 | }
142 | },
143 | "defer-to-connect": {
144 | "version": "2.0.0",
145 | "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.0.tgz",
146 | "integrity": "sha512-bYL2d05vOSf1JEZNx5vSAtPuBMkX8K9EUutg7zlKvTqKXHt7RhWJFbmd7qakVuf13i+IkGmp6FwSsONOf6VYIg=="
147 | },
148 | "delayed-stream": {
149 | "version": "1.0.0",
150 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
151 | "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
152 | },
153 | "discord.js": {
154 | "version": "12.5.1",
155 | "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-12.5.1.tgz",
156 | "integrity": "sha512-VwZkVaUAIOB9mKdca0I5MefPMTQJTNg0qdgi1huF3iwsFwJ0L5s/Y69AQe+iPmjuV6j9rtKoG0Ta0n9vgEIL6w==",
157 | "requires": {
158 | "@discordjs/collection": "^0.1.6",
159 | "@discordjs/form-data": "^3.0.1",
160 | "abort-controller": "^3.0.0",
161 | "node-fetch": "^2.6.1",
162 | "prism-media": "^1.2.2",
163 | "setimmediate": "^1.0.5",
164 | "tweetnacl": "^1.0.3",
165 | "ws": "^7.3.1"
166 | }
167 | },
168 | "end-of-stream": {
169 | "version": "1.4.4",
170 | "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz",
171 | "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==",
172 | "requires": {
173 | "once": "^1.4.0"
174 | }
175 | },
176 | "event-target-shim": {
177 | "version": "5.0.1",
178 | "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
179 | "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ=="
180 | },
181 | "get-stream": {
182 | "version": "5.2.0",
183 | "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz",
184 | "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==",
185 | "requires": {
186 | "pump": "^3.0.0"
187 | }
188 | },
189 | "http-cache-semantics": {
190 | "version": "4.1.0",
191 | "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz",
192 | "integrity": "sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ=="
193 | },
194 | "json-buffer": {
195 | "version": "3.0.1",
196 | "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz",
197 | "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ=="
198 | },
199 | "keyv": {
200 | "version": "4.0.3",
201 | "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.0.3.tgz",
202 | "integrity": "sha512-zdGa2TOpSZPq5mU6iowDARnMBZgtCqJ11dJROFi6tg6kTn4nuUdU09lFyLFSaHrWqpIJ+EBq4E8/Dc0Vx5vLdA==",
203 | "requires": {
204 | "json-buffer": "3.0.1"
205 | }
206 | },
207 | "lowercase-keys": {
208 | "version": "2.0.0",
209 | "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz",
210 | "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA=="
211 | },
212 | "mime-db": {
213 | "version": "1.45.0",
214 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.45.0.tgz",
215 | "integrity": "sha512-CkqLUxUk15hofLoLyljJSrukZi8mAtgd+yE5uO4tqRZsdsAJKv0O+rFMhVDRJgozy+yG6md5KwuXhD4ocIoP+w=="
216 | },
217 | "mime-types": {
218 | "version": "2.1.28",
219 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.28.tgz",
220 | "integrity": "sha512-0TO2yJ5YHYr7M2zzT7gDU1tbwHxEUWBCLt0lscSNpcdAfFyJOVEpRYNS7EXVcTLNj/25QO8gulHC5JtTzSE2UQ==",
221 | "requires": {
222 | "mime-db": "1.45.0"
223 | }
224 | },
225 | "mimic-response": {
226 | "version": "1.0.1",
227 | "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz",
228 | "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ=="
229 | },
230 | "node-fetch": {
231 | "version": "2.6.1",
232 | "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
233 | "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
234 | },
235 | "normalize-url": {
236 | "version": "4.5.0",
237 | "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.0.tgz",
238 | "integrity": "sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ=="
239 | },
240 | "once": {
241 | "version": "1.4.0",
242 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
243 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
244 | "requires": {
245 | "wrappy": "1"
246 | }
247 | },
248 | "prism-media": {
249 | "version": "1.2.3",
250 | "resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.2.3.tgz",
251 | "integrity": "sha512-fSrR66n0l6roW9Rx4rSLMyTPTjRTiXy5RVqDOurACQ6si1rKHHKDU5gwBJoCsIV0R3o9gi+K50akl/qyw1C74A=="
252 | },
253 | "pump": {
254 | "version": "3.0.0",
255 | "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz",
256 | "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==",
257 | "requires": {
258 | "end-of-stream": "^1.1.0",
259 | "once": "^1.3.1"
260 | }
261 | },
262 | "responselike": {
263 | "version": "2.0.0",
264 | "resolved": "https://registry.npmjs.org/responselike/-/responselike-2.0.0.tgz",
265 | "integrity": "sha512-xH48u3FTB9VsZw7R+vvgaKeLKzT6jOogbQhEe/jewwnZgzPcnyWui2Av6JpoYZF/91uueC+lqhWqeURw5/qhCw==",
266 | "requires": {
267 | "lowercase-keys": "^2.0.0"
268 | }
269 | },
270 | "setimmediate": {
271 | "version": "1.0.5",
272 | "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz",
273 | "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU="
274 | },
275 | "tweetnacl": {
276 | "version": "1.0.3",
277 | "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz",
278 | "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw=="
279 | },
280 | "wrappy": {
281 | "version": "1.0.2",
282 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
283 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
284 | },
285 | "ws": {
286 | "version": "7.4.2",
287 | "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.2.tgz",
288 | "integrity": "sha512-T4tewALS3+qsrpGI/8dqNMLIVdq/g/85U98HPMa6F0m6xTbvhXU6RCQLqPH3+SlomNV/LdY6RXEbBpMH6EOJnA=="
289 | }
290 | }
291 | }
292 |
--------------------------------------------------------------------------------
/Tutorial-8/commands/fun/say.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = {
3 | name: "say",
4 | category: "fun",
5 | aliases: ["say"],
6 | description: "Resends the message",
7 | run: async (client, message, args) => {
8 | message.channel.send(args.join(" "))
9 | }
10 | }
--------------------------------------------------------------------------------
/Tutorial-8/commands/info/help.js:
--------------------------------------------------------------------------------
1 | const { MessageEmbed } = require("discord.js");
2 | const { stripIndents } = require("common-tags");
3 | const config = require("../../config.json");
4 | module.exports = {
5 | name: "help",
6 | aliases: ["h", "cmds"],
7 | category: "info",
8 | description: "Returns all Commands, or one specific Command information",
9 | usage: "[command], [aliases], [command ]",
10 | run: async (client,message,args) => {
11 | if(args[0]){
12 | return getCMD(client,message,args[0]);
13 | }
14 | else{
15 | return getAll(client, message);
16 | }
17 | }
18 | }
19 |
20 | function getAll(client,message){
21 | const embed = new MessageEmbed()
22 | .setColor("ORANGE")
23 | .setThumbnail(client.user.displayAvatarURL())
24 | .setTitle("HELP MENU")
25 | .addField("**__BOT BY:__**", `
26 | >>> <@442355791412854784> \`Tomato#6966\` [\`Website\`](https://musicium.eu)
27 | `)
28 | .setFooter(`TO see command descriptions and inforamtion, type: ${config.prefix}help [CMD NAME]`, client.user.displayAvatarURL())
29 | const commands = (category) => {
30 | return client.commands.filter(cmd => cmd.category === category)
31 | .map(cmd => `\`${cmd.name}\``).join(", ")
32 | }
33 | const info = client.categories.map(cat => stripIndents`**__${cat[0].toUpperCase() + cat.slice(1)}__**\n> ${commands(cat)}`)
34 | .reduce((string, category) => string + "\n" + category);
35 | return message.channel.send(embed.setDescription(info))
36 | }
37 | function getCMD(client,message,input){
38 | const embed = new MessageEmbed()
39 | const cmd = client.commands.get(input.toLowerCase()) || client.commands.get(client.aliases.get(input.toLowerCase()))
40 | let info = `No Information found for command **${input.toLowerCase()}**`;
41 | if(!cmd){
42 | return message.channel.send(embed.setColor("RED").setDescription(info));
43 | }
44 | info = "";
45 | if(cmd.name) info += `**Command name**: \`${cmd.name}\`\n`
46 | if(cmd.aliases) info += `**Aliases**: \`${cmd.aliases.map(a => `${a}`).join("\`, \`")}\`\n`
47 | if(cmd.description) info += `**Description**: \`${cmd.description}\`\n`
48 | if(cmd.usage) {
49 | info += `\n**Usage**: \`${cmd.usage}\``;
50 | embed.setFooter("Syntax: <> = required, [] = optional");
51 | }
52 | return message.channel.send(embed.setColor("ORANGE").setDescription(info))
53 | }
--------------------------------------------------------------------------------
/Tutorial-8/commands/info/ping.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: "ping",
3 | aliases: ["latency"],
4 | category: "info",
5 | description: "Returns latency and API ping",
6 | run: async (client, message, args) => {
7 | const msg = await message.channel.send(`🏓 Pinging....`);
8 | msg.edit(`🏓 Pong!
9 | Ping is ${Math.round(client.ws.ping)}ms`);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Tutorial-8/commands/info/uptime.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: "uptime",
3 | aliases: ["uptime"],
4 | category: "info",
5 | description: "Returns the duration of how long the Bot is online",
6 | usage: "[command], [aliases]",
7 | run: async (client,message,args) => {
8 | function duration(ms) {
9 | const sec = Math.floor(ms / 1000 % 60).toString();
10 | const min = Math.floor(ms / (60*1000) % 60).toString();
11 | const hrs = Math.floor(ms / (60*60*1000) % 60).toString();
12 | const days = Math.floor(ms / (24*60*60*1000) % 60).toString();
13 | return `\`${days} Days\`, \`${hrs} Hours\`, \`${min} Minutes\`, \`${sec} Seconds\``
14 | }
15 | message.reply(`:white_check_mark: **${client.user.username}** is since ${duration(client.uptime)} online`);
16 | }
17 | }
--------------------------------------------------------------------------------
/Tutorial-8/commands/user/addrole.js:
--------------------------------------------------------------------------------
1 | const { MessageEmbed } = require("discord.js");
2 | module.exports = {
3 | name: "addrole",
4 | category: "user",
5 | aliases: ["addrole"],
6 | description: "Sends the Avatar of the User",
7 | run: async (client, message, args) => {
8 | //-1 0 1
9 | //!addrole @User ROLLE
10 | let user = message.mentions.users.first();
11 | let member = message.guild.members.cache.get(user.id);
12 | if(!args[1]) return message.reply("Bitte füge eine ROllenamen hinzu")
13 | let role_from_txt = args.slice(1).join(" ").toLowerCase();
14 | let role = message.guild.roles.cache.find(role => role.name.toLowerCase() == role_from_txt) || message.guild.roles.cache.get(role_from_txt);
15 | if(!role) return message.reply("Role not found...")
16 |
17 | try{
18 | member.roles.add(role.id)
19 | return message.reply(`${user} now has the role: ${role.name}`)
20 | }catch (error) {
21 | console.log(error)
22 | return message.reply("something went wrong")
23 | }
24 |
25 | }
26 | }
--------------------------------------------------------------------------------
/Tutorial-8/commands/user/removerole.js:
--------------------------------------------------------------------------------
1 | const { MessageEmbed } = require("discord.js");
2 | module.exports = {
3 | name: "removerole",
4 | category: "user",
5 | aliases: ["removerole"],
6 | description: "Removes the Role of a Pinged User",
7 | run: async (client, message, args) => {
8 | let user = message.mentions.users.first();
9 | if(!user) return message.reply("PLEASE PING A USER");
10 | if(user.id === message.author.id) return message.reply("U cannot remove a Role to yourself");
11 | let member = message.guild.members.cache.get(user.id);
12 | let Role = message.mentions.roles.first();
13 | if(!Role) message.reply("PLEASE PING A ROLE")
14 | try{
15 | member.roles.remove(Role)
16 | message.channel.send(`${user.tag} has lost the Role: \`${Role.id}\``)
17 | }catch{
18 | message.channel.send(`Konnte ${user.tag} nicht die Rolle wegnehmen: \`${Role.id}\``)
19 | }
20 |
21 |
22 | }
23 | }
--------------------------------------------------------------------------------
/Tutorial-8/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "token": "Nzg5MDY0NDE4O33333333333.333333.sPkef8ZvN4xXuKmza5HN0GoFB0c",
3 | "prefix": "!"
4 | }
--------------------------------------------------------------------------------
/Tutorial-8/handlers/command.js:
--------------------------------------------------------------------------------
1 | const { readdirSync } = require("fs");
2 | const ascii = require("ascii-table");
3 | let table = new ascii("Commands");
4 | table.setHeading("Command", "Load status");
5 | console.log("Welcome to SERVICE HANDLER // By https://x10-gaming.eu/service/dc // Discord: Tomato#6966")
6 | module.exports = (client) => {
7 | readdirSync("./commands/").forEach(dir => {
8 | const commands = readdirSync(`./commands/${dir}/`).filter(file => file.endsWith(".js"));
9 | for (let file of commands) {
10 | let pull = require(`../commands/${dir}/${file}`);
11 | if (pull.name) {
12 | client.commands.set(pull.name, pull);
13 | table.addRow(file, 'Ready');
14 | } else {
15 | table.addRow(file, `error -> missing a help.name, or help.name is not a string.`);
16 | continue;
17 | }
18 | if (pull.aliases && Array.isArray(pull.aliases)) pull.aliases.forEach(alias => client.aliases.set(alias, pull.name));
19 | }
20 | });
21 | console.log(table.toString());
22 | console.log("Welcome to SERVICE HANDLER // By https://x10-gaming.eu/service/dc // Discord: Tomato#6966")
23 | console.log("Logging into the BOT...");
24 | }
25 |
--------------------------------------------------------------------------------
/Tutorial-8/index.js:
--------------------------------------------------------------------------------
1 | //Modules
2 | const { Client, Collection } = require("discord.js");
3 | const config = require("./config.json");
4 | const fs = require("fs");
5 | const discord = require("discord.js");
6 | const client = new Client({
7 | disableEveryone: true
8 | , partials: ['MESSAGE', 'CHANNEL', 'REACTION'] });
9 |
10 | client.commands = new Collection();
11 | client.aliases = new Collection();
12 |
13 | client.categories = fs.readdirSync("./commands/");
14 |
15 | ["command"].forEach(handler => {
16 | require(`./handlers/${handler}`)(client);
17 | });
18 |
19 |
20 | let i = 0;
21 | var STATUSTEXT = [
22 | "1", //index == 0
23 | "2", //index == 1
24 | "3", //index == 2
25 | "4" //index == 3
26 | ];
27 | client.on("ready", () => {
28 | console.log("Bot is ready");
29 | //INIT
30 | client.user.setActivity("STATUSTEXT", { type: "STREAMING", url: "https://twitch.tv/#" })
31 | //LOOP
32 | setInterval(()=>{
33 | const index = Math.floor(i);
34 | if(index == 0 )client.user.setActivity(STATUSTEXT[index], { type: "STREAMING", url: "https://twitch.tv/#" })
35 | else if(index == 1 )client.user.setActivity(STATUSTEXT[index], { type: "PLAYING"})
36 | else if(index == 2 )client.user.setActivity(STATUSTEXT[index], { type: "WATCHING"})
37 | else if(index == 3 )client.user.setActivity(STATUSTEXT[index], { type: "LISTENING"})
38 | else client.user.setActivity(STATUSTEXT[index], { type: "PLAYING"})
39 | i++;
40 | if(i===STATUSTEXT.length) i -= STATUSTEXT.length;
41 | }, 5*1000)
42 |
43 | })
44 |
45 |
46 |
47 |
48 |
49 | client.on("message", async message => {
50 | const prefix = (config.prefix);
51 | if (message.author.bot) return;
52 | if (!message.guild) return;
53 |
54 | if (!message.content.startsWith(prefix)) return;
55 |
56 | const args = message.content.slice(prefix.length).trim().split(/ +/g);
57 | const cmd = args.shift().toLowerCase();
58 |
59 | if (cmd.length === 0) return;
60 |
61 | let command = client.commands.get(cmd);
62 | if (!command) command = client.commands.get(client.aliases.get(cmd));
63 |
64 |
65 | if (command)
66 | command.run(client, message, args);
67 |
68 | });
69 |
70 | client.login(config.token);
--------------------------------------------------------------------------------
/Tutorial-8/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "requires": true,
3 | "lockfileVersion": 1,
4 | "dependencies": {
5 | "@discordjs/collection": {
6 | "version": "0.1.6",
7 | "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.1.6.tgz",
8 | "integrity": "sha512-utRNxnd9kSS2qhyivo9lMlt5qgAUasH2gb7BEOn6p0efFh24gjGomHzWKMAPn2hEReOPQZCJaRKoURwRotKucQ=="
9 | },
10 | "@discordjs/form-data": {
11 | "version": "3.0.1",
12 | "resolved": "https://registry.npmjs.org/@discordjs/form-data/-/form-data-3.0.1.tgz",
13 | "integrity": "sha512-ZfFsbgEXW71Rw/6EtBdrP5VxBJy4dthyC0tpQKGKmYFImlmmrykO14Za+BiIVduwjte0jXEBlhSKf0MWbFp9Eg==",
14 | "requires": {
15 | "asynckit": "^0.4.0",
16 | "combined-stream": "^1.0.8",
17 | "mime-types": "^2.1.12"
18 | }
19 | },
20 | "@sindresorhus/is": {
21 | "version": "4.0.0",
22 | "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.0.0.tgz",
23 | "integrity": "sha512-FyD2meJpDPjyNQejSjvnhpgI/azsQkA4lGbuu5BQZfjvJ9cbRZXzeWL2HceCekW4lixO9JPesIIQkSoLjeJHNQ=="
24 | },
25 | "@szmarczak/http-timer": {
26 | "version": "4.0.5",
27 | "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.5.tgz",
28 | "integrity": "sha512-PyRA9sm1Yayuj5OIoJ1hGt2YISX45w9WcFbh6ddT0Z/0yaFxOtGLInr4jUfU1EAFVs0Yfyfev4RNwBlUaHdlDQ==",
29 | "requires": {
30 | "defer-to-connect": "^2.0.0"
31 | }
32 | },
33 | "@types/cacheable-request": {
34 | "version": "6.0.1",
35 | "resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.1.tgz",
36 | "integrity": "sha512-ykFq2zmBGOCbpIXtoVbz4SKY5QriWPh3AjyU4G74RYbtt5yOc5OfaY75ftjg7mikMOla1CTGpX3lLbuJh8DTrQ==",
37 | "requires": {
38 | "@types/http-cache-semantics": "*",
39 | "@types/keyv": "*",
40 | "@types/node": "*",
41 | "@types/responselike": "*"
42 | }
43 | },
44 | "@types/http-cache-semantics": {
45 | "version": "4.0.0",
46 | "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.0.tgz",
47 | "integrity": "sha512-c3Xy026kOF7QOTn00hbIllV1dLR9hG9NkSrLQgCVs8NF6sBU+VGWjD3wLPhmh1TYAc7ugCFsvHYMN4VcBN1U1A=="
48 | },
49 | "@types/keyv": {
50 | "version": "3.1.1",
51 | "resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.1.tgz",
52 | "integrity": "sha512-MPtoySlAZQ37VoLaPcTHCu1RWJ4llDkULYZIzOYxlhxBqYPB0RsRlmMU0R6tahtFe27mIdkHV+551ZWV4PLmVw==",
53 | "requires": {
54 | "@types/node": "*"
55 | }
56 | },
57 | "@types/node": {
58 | "version": "14.14.14",
59 | "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.14.tgz",
60 | "integrity": "sha512-UHnOPWVWV1z+VV8k6L1HhG7UbGBgIdghqF3l9Ny9ApPghbjICXkUJSd/b9gOgQfjM1r+37cipdw/HJ3F6ICEnQ=="
61 | },
62 | "@types/responselike": {
63 | "version": "1.0.0",
64 | "resolved": "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.0.tgz",
65 | "integrity": "sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA==",
66 | "requires": {
67 | "@types/node": "*"
68 | }
69 | },
70 | "abort-controller": {
71 | "version": "3.0.0",
72 | "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz",
73 | "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==",
74 | "requires": {
75 | "event-target-shim": "^5.0.0"
76 | }
77 | },
78 | "ascii-table": {
79 | "version": "0.0.9",
80 | "resolved": "https://registry.npmjs.org/ascii-table/-/ascii-table-0.0.9.tgz",
81 | "integrity": "sha1-BqZgTWpV1L9BqaR9mHLXp42jHnM="
82 | },
83 | "asynckit": {
84 | "version": "0.4.0",
85 | "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
86 | "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
87 | },
88 | "cacheable-lookup": {
89 | "version": "5.0.4",
90 | "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz",
91 | "integrity": "sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA=="
92 | },
93 | "cacheable-request": {
94 | "version": "7.0.1",
95 | "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.1.tgz",
96 | "integrity": "sha512-lt0mJ6YAnsrBErpTMWeu5kl/tg9xMAWjavYTN6VQXM1A/teBITuNcccXsCxF0tDQQJf9DfAaX5O4e0zp0KlfZw==",
97 | "requires": {
98 | "clone-response": "^1.0.2",
99 | "get-stream": "^5.1.0",
100 | "http-cache-semantics": "^4.0.0",
101 | "keyv": "^4.0.0",
102 | "lowercase-keys": "^2.0.0",
103 | "normalize-url": "^4.1.0",
104 | "responselike": "^2.0.0"
105 | }
106 | },
107 | "clone-response": {
108 | "version": "1.0.2",
109 | "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz",
110 | "integrity": "sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws=",
111 | "requires": {
112 | "mimic-response": "^1.0.0"
113 | }
114 | },
115 | "combined-stream": {
116 | "version": "1.0.8",
117 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
118 | "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
119 | "requires": {
120 | "delayed-stream": "~1.0.0"
121 | }
122 | },
123 | "common-tags": {
124 | "version": "1.8.0",
125 | "resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.0.tgz",
126 | "integrity": "sha512-6P6g0uetGpW/sdyUy/iQQCbFF0kWVMSIVSyYz7Zgjcgh8mgw8PQzDNZeyZ5DQ2gM7LBoZPHmnjz8rUthkBG5tw=="
127 | },
128 | "decompress-response": {
129 | "version": "6.0.0",
130 | "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz",
131 | "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==",
132 | "requires": {
133 | "mimic-response": "^3.1.0"
134 | },
135 | "dependencies": {
136 | "mimic-response": {
137 | "version": "3.1.0",
138 | "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz",
139 | "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ=="
140 | }
141 | }
142 | },
143 | "defer-to-connect": {
144 | "version": "2.0.0",
145 | "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.0.tgz",
146 | "integrity": "sha512-bYL2d05vOSf1JEZNx5vSAtPuBMkX8K9EUutg7zlKvTqKXHt7RhWJFbmd7qakVuf13i+IkGmp6FwSsONOf6VYIg=="
147 | },
148 | "delayed-stream": {
149 | "version": "1.0.0",
150 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
151 | "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
152 | },
153 | "discord.js": {
154 | "version": "12.5.1",
155 | "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-12.5.1.tgz",
156 | "integrity": "sha512-VwZkVaUAIOB9mKdca0I5MefPMTQJTNg0qdgi1huF3iwsFwJ0L5s/Y69AQe+iPmjuV6j9rtKoG0Ta0n9vgEIL6w==",
157 | "requires": {
158 | "@discordjs/collection": "^0.1.6",
159 | "@discordjs/form-data": "^3.0.1",
160 | "abort-controller": "^3.0.0",
161 | "node-fetch": "^2.6.1",
162 | "prism-media": "^1.2.2",
163 | "setimmediate": "^1.0.5",
164 | "tweetnacl": "^1.0.3",
165 | "ws": "^7.3.1"
166 | }
167 | },
168 | "end-of-stream": {
169 | "version": "1.4.4",
170 | "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz",
171 | "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==",
172 | "requires": {
173 | "once": "^1.4.0"
174 | }
175 | },
176 | "event-target-shim": {
177 | "version": "5.0.1",
178 | "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
179 | "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ=="
180 | },
181 | "get-stream": {
182 | "version": "5.2.0",
183 | "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz",
184 | "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==",
185 | "requires": {
186 | "pump": "^3.0.0"
187 | }
188 | },
189 | "http-cache-semantics": {
190 | "version": "4.1.0",
191 | "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz",
192 | "integrity": "sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ=="
193 | },
194 | "json-buffer": {
195 | "version": "3.0.1",
196 | "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz",
197 | "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ=="
198 | },
199 | "keyv": {
200 | "version": "4.0.3",
201 | "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.0.3.tgz",
202 | "integrity": "sha512-zdGa2TOpSZPq5mU6iowDARnMBZgtCqJ11dJROFi6tg6kTn4nuUdU09lFyLFSaHrWqpIJ+EBq4E8/Dc0Vx5vLdA==",
203 | "requires": {
204 | "json-buffer": "3.0.1"
205 | }
206 | },
207 | "lowercase-keys": {
208 | "version": "2.0.0",
209 | "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz",
210 | "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA=="
211 | },
212 | "mime-db": {
213 | "version": "1.45.0",
214 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.45.0.tgz",
215 | "integrity": "sha512-CkqLUxUk15hofLoLyljJSrukZi8mAtgd+yE5uO4tqRZsdsAJKv0O+rFMhVDRJgozy+yG6md5KwuXhD4ocIoP+w=="
216 | },
217 | "mime-types": {
218 | "version": "2.1.28",
219 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.28.tgz",
220 | "integrity": "sha512-0TO2yJ5YHYr7M2zzT7gDU1tbwHxEUWBCLt0lscSNpcdAfFyJOVEpRYNS7EXVcTLNj/25QO8gulHC5JtTzSE2UQ==",
221 | "requires": {
222 | "mime-db": "1.45.0"
223 | }
224 | },
225 | "mimic-response": {
226 | "version": "1.0.1",
227 | "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz",
228 | "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ=="
229 | },
230 | "node-fetch": {
231 | "version": "2.6.1",
232 | "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
233 | "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
234 | },
235 | "normalize-url": {
236 | "version": "4.5.0",
237 | "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.0.tgz",
238 | "integrity": "sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ=="
239 | },
240 | "once": {
241 | "version": "1.4.0",
242 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
243 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
244 | "requires": {
245 | "wrappy": "1"
246 | }
247 | },
248 | "prism-media": {
249 | "version": "1.2.3",
250 | "resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.2.3.tgz",
251 | "integrity": "sha512-fSrR66n0l6roW9Rx4rSLMyTPTjRTiXy5RVqDOurACQ6si1rKHHKDU5gwBJoCsIV0R3o9gi+K50akl/qyw1C74A=="
252 | },
253 | "pump": {
254 | "version": "3.0.0",
255 | "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz",
256 | "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==",
257 | "requires": {
258 | "end-of-stream": "^1.1.0",
259 | "once": "^1.3.1"
260 | }
261 | },
262 | "responselike": {
263 | "version": "2.0.0",
264 | "resolved": "https://registry.npmjs.org/responselike/-/responselike-2.0.0.tgz",
265 | "integrity": "sha512-xH48u3FTB9VsZw7R+vvgaKeLKzT6jOogbQhEe/jewwnZgzPcnyWui2Av6JpoYZF/91uueC+lqhWqeURw5/qhCw==",
266 | "requires": {
267 | "lowercase-keys": "^2.0.0"
268 | }
269 | },
270 | "setimmediate": {
271 | "version": "1.0.5",
272 | "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz",
273 | "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU="
274 | },
275 | "tweetnacl": {
276 | "version": "1.0.3",
277 | "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz",
278 | "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw=="
279 | },
280 | "wrappy": {
281 | "version": "1.0.2",
282 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
283 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
284 | },
285 | "ws": {
286 | "version": "7.4.2",
287 | "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.2.tgz",
288 | "integrity": "sha512-T4tewALS3+qsrpGI/8dqNMLIVdq/g/85U98HPMa6F0m6xTbvhXU6RCQLqPH3+SlomNV/LdY6RXEbBpMH6EOJnA=="
289 | }
290 | }
291 | }
292 |
--------------------------------------------------------------------------------
/Tutorial-9/commands/fun/say.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = {
3 | name: "say",
4 | category: "fun",
5 | aliases: ["say"],
6 | description: "Resends the message",
7 | run: async (client, message, args) => {
8 | message.channel.send(args.join(" "))
9 | }
10 | }
--------------------------------------------------------------------------------
/Tutorial-9/commands/info/help.js:
--------------------------------------------------------------------------------
1 | const { MessageEmbed } = require("discord.js");
2 | const { stripIndents } = require("common-tags");
3 | const config = require("../../config.json");
4 | module.exports = {
5 | name: "help",
6 | aliases: ["h", "cmds"],
7 | category: "info",
8 | description: "Returns all Commands, or one specific Command information",
9 | usage: "[command], [aliases], [command ]",
10 | run: async (client,message,args) => {
11 | if(args[0]){
12 | return getCMD(client,message,args[0]);
13 | }
14 | else{
15 | return getAll(client, message);
16 | }
17 | }
18 | }
19 |
20 | function getAll(client,message){
21 | const embed = new MessageEmbed()
22 | .setColor("ORANGE")
23 | .setThumbnail(client.user.displayAvatarURL())
24 | .setTitle("HELP MENU")
25 | .addField("**__BOT BY:__**", `
26 | >>> <@442355791412854784> \`Tomato#6966\` [\`Website\`](https://musicium.eu)
27 | `)
28 | .setFooter(`TO see command descriptions and inforamtion, type: ${config.prefix}help [CMD NAME]`, client.user.displayAvatarURL())
29 | const commands = (category) => {
30 | return client.commands.filter(cmd => cmd.category === category)
31 | .map(cmd => `\`${cmd.name}\``).join(", ")
32 | }
33 | const info = client.categories.map(cat => stripIndents`**__${cat[0].toUpperCase() + cat.slice(1)}__**\n> ${commands(cat)}`)
34 | .reduce((string, category) => string + "\n" + category);
35 | return message.channel.send(embed.setDescription(info))
36 | }
37 | function getCMD(client,message,input){
38 | const embed = new MessageEmbed()
39 | const cmd = client.commands.get(input.toLowerCase()) || client.commands.get(client.aliases.get(input.toLowerCase()))
40 | let info = `No Information found for command **${input.toLowerCase()}**`;
41 | if(!cmd){
42 | return message.channel.send(embed.setColor("RED").setDescription(info));
43 | }
44 | info = "";
45 | if(cmd.name) info += `**Command name**: \`${cmd.name}\`\n`
46 | if(cmd.aliases) info += `**Aliases**: \`${cmd.aliases.map(a => `${a}`).join("\`, \`")}\`\n`
47 | if(cmd.description) info += `**Description**: \`${cmd.description}\`\n`
48 | if(cmd.usage) {
49 | info += `\n**Usage**: \`${cmd.usage}\``;
50 | embed.setFooter("Syntax: <> = required, [] = optional");
51 | }
52 | return message.channel.send(embed.setColor("ORANGE").setDescription(info))
53 | }
--------------------------------------------------------------------------------
/Tutorial-9/commands/info/ping.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: "ping",
3 | aliases: ["latency"],
4 | category: "info",
5 | description: "Returns latency and API ping",
6 | run: async (client, message, args) => {
7 | const msg = await message.channel.send(`🏓 Pinging....`);
8 | msg.edit(`🏓 Pong!
9 | Ping is ${Math.round(client.ws.ping)}ms`);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Tutorial-9/commands/info/serverinfo.js:
--------------------------------------------------------------------------------
1 | const { MessageEmbed } = require("discord.js");
2 | const config = require("../../config.json");
3 | const moment = require("moment");
4 | const regions = {
5 | europe: "EUROPE",
6 | brazil: "BRAZIL",
7 | hongkong: "HONGKONG",
8 | germany: "GERMANY",
9 | russia: "RUSSIA",
10 | "US-CENTRAL": "US-CENTRAL",
11 | }
12 | module.exports = {
13 | name: "serverinfo",
14 | aliases: [""],
15 | category: "info",
16 | description: "Shows info of the current server",
17 | usage: "serverinfo",
18 | run: async (client, message, args) => {
19 | const emojis = message.guild.emojis.cache;
20 | const channels = message.guild.channels.cache;
21 | const members = message.guild.members.cache;
22 | const roles = message.guild.roles.cache.sort((a, b) => b.position - a.position).map(role => role.toString());
23 |
24 | const embed = new MessageEmbed()
25 | .setColor("#004422")
26 | .setTitle(message.guild.name + " Serverinformation")
27 | .setThumbnail(message.guild.iconURL({dynamic: true}))
28 | .addField(`Server Owner`, `${message.guild.owner.user.tag}`,true)//NAME#1234
29 | .addField(`Region`, `${regions[message.guild.region]}`,true)
30 | .addField(`Time Created`, `${moment(message.guild.createdTimestamp).format("LT")} ${moment(message.guild.createdTimestamp).format("LL")} ${moment(message.guild.createdTimestamp).fromNow()}`,true)
31 |
32 | .addField(`Boost Tier`, `${message.guild.premiumTier ? `Tier: ${message.guild.premiumTier}` : "NO BOOSTS"}`,true)
33 | .addField(`Channel Count`, `${channels.size}`,true)
34 | .addField(`Text Channels:`, `${channels.filter(ch => ch.type === "text").size}`,true)
35 |
36 | .addField(`Voice Channels:`, `${channels.filter(ch => ch.type === "voice").size}`,true)
37 | .addField(`Member Count`, `${message.guild.memberCount}`,true)
38 | .addField(`Humans`, `${members.filter(me => !me.user.bot).size}`,true)
39 |
40 | .addField(`Bots`, `${members.filter(me => me.user.bot).size}`,true)
41 | .addField(`Regular Emojis`, `${emojis.filter(emoji=> !emoji.animated).size}`,true)
42 | .addField(`Animated Emojis`, `${emojis.filter(emoji=> emoji.animated).size}`,true)
43 |
44 | .addField(`${roles.length} ROLES`, `${roles.length < 6 ? roles.join(", ") : roles.length > 6 ? trimArray(roles) : "NONE"}`,true)
45 | .setFooter("SERVERID: " + message.guild.id, message.guild.iconURL({dynamic: true}));
46 |
47 | message.channel.send(embed);
48 | }
49 | }
50 |
51 |
52 |
53 | function trimArray(arr, maxLength=10){
54 | if(arr.length > maxLength){
55 | const length = arr.length - maxLength;
56 | arr.push(`${length}, more...`)
57 | }
58 | return arr;
59 | }
--------------------------------------------------------------------------------
/Tutorial-9/commands/info/uptime.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: "uptime",
3 | aliases: ["uptime"],
4 | category: "info",
5 | description: "Returns the duration of how long the Bot is online",
6 | usage: "[command], [aliases]",
7 | run: async (client,message,args) => {
8 | function duration(ms) {
9 | const sec = Math.floor(ms / 1000 % 60).toString();
10 | const min = Math.floor(ms / (60*1000) % 60).toString();
11 | const hrs = Math.floor(ms / (60*60*1000) % 60).toString();
12 | const days = Math.floor(ms / (24*60*60*1000) % 60).toString();
13 | return `\`${days} Days\`, \`${hrs} Hours\`, \`${min} Minutes\`, \`${sec} Seconds\``
14 | }
15 | message.reply(`:white_check_mark: **${client.user.username}** is since ${duration(client.uptime)} online`);
16 | }
17 | }
--------------------------------------------------------------------------------
/Tutorial-9/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "token": "Nzg5MDY0NDE4OTI2Mzk1NDEz.X9sngQ.sPkef8ZvN4xXuKmza5HN0GoFB0c",
3 | "prefix": "!"
4 | }
--------------------------------------------------------------------------------
/Tutorial-9/handlers/command.js:
--------------------------------------------------------------------------------
1 | const { readdirSync } = require("fs");
2 | const ascii = require("ascii-table");
3 | let table = new ascii("Commands");
4 | table.setHeading("Command", "Load status");
5 | console.log("Welcome to SERVICE HANDLER // By https://x10-gaming.eu/service/dc // Discord: Tomato#6966")
6 | module.exports = (client) => {
7 | readdirSync("./commands/").forEach(dir => {
8 | const commands = readdirSync(`./commands/${dir}/`).filter(file => file.endsWith(".js"));
9 | for (let file of commands) {
10 | let pull = require(`../commands/${dir}/${file}`);
11 | if (pull.name) {
12 | client.commands.set(pull.name, pull);
13 | table.addRow(file, 'Ready');
14 | } else {
15 | table.addRow(file, `error -> missing a help.name, or help.name is not a string.`);
16 | continue;
17 | }
18 | if (pull.aliases && Array.isArray(pull.aliases)) pull.aliases.forEach(alias => client.aliases.set(alias, pull.name));
19 | }
20 | });
21 | console.log(table.toString());
22 | console.log("Welcome to SERVICE HANDLER // By https://x10-gaming.eu/service/dc // Discord: Tomato#6966")
23 | console.log("Logging into the BOT...");
24 | }
25 |
--------------------------------------------------------------------------------
/Tutorial-9/index.js:
--------------------------------------------------------------------------------
1 | //Modules
2 | const { Client, Collection } = require("discord.js");
3 | const config = require("./config.json");
4 | const fs = require("fs");
5 | const discord = require("discord.js");
6 | const client = new Client({
7 | disableEveryone: true
8 | , partials: ['MESSAGE', 'CHANNEL', 'REACTION'] });
9 |
10 | client.commands = new Collection();
11 | client.aliases = new Collection();
12 |
13 | client.categories = fs.readdirSync("./commands/");
14 |
15 | ["command"].forEach(handler => {
16 | require(`./handlers/${handler}`)(client);
17 | });
18 |
19 |
20 | let i = 0;
21 | var STATUSTEXT = [
22 | "1", //index == 0
23 | "2", //index == 1
24 | "3", //index == 2
25 | "4" //index == 3
26 | ];
27 | client.on("ready", () => {
28 | console.log("Bot is ready");
29 | //INIT
30 | client.user.setActivity("STATUSTEXT", { type: "STREAMING", url: "https://twitch.tv/#" })
31 | //LOOP
32 | setInterval(()=>{
33 | const index = Math.floor(i);
34 | if(index == 0 )client.user.setActivity(STATUSTEXT[index], { type: "STREAMING", url: "https://twitch.tv/#" })
35 | else if(index == 1 )client.user.setActivity(STATUSTEXT[index], { type: "PLAYING"})
36 | else if(index == 2 )client.user.setActivity(STATUSTEXT[index], { type: "WATCHING"})
37 | else if(index == 3 )client.user.setActivity(STATUSTEXT[index], { type: "LISTENING"})
38 | else client.user.setActivity(STATUSTEXT[index], { type: "PLAYING"})
39 | i++;
40 | if(i===STATUSTEXT.length) i -= STATUSTEXT.length;
41 | }, 5*1000)
42 |
43 | new Promise(resolve =>{
44 | setInterval(()=>{
45 | resolve(2);
46 | renamech();
47 | }, 2*1000)
48 | })
49 | })
50 |
51 | function renamech(){
52 | client.guilds.cache.get("789064772712792086").channels.cache.get("799062006878699581").setName("MEMBERS: " + client.guilds.cache.get("789064772712792086").memberCount)
53 | }
54 |
55 |
56 |
57 |
58 |
59 | client.on("message", async message => {
60 | const prefix = (config.prefix);
61 | if (message.author.bot) return;
62 | if (!message.guild) return;
63 |
64 | if (!message.content.startsWith(prefix)) return;
65 |
66 | const args = message.content.slice(prefix.length).trim().split(/ +/g);
67 | const cmd = args.shift().toLowerCase();
68 |
69 | if (cmd.length === 0) return;
70 |
71 | let command = client.commands.get(cmd);
72 | if (!command) command = client.commands.get(client.aliases.get(cmd));
73 |
74 |
75 | if (command)
76 | command.run(client, message, args);
77 |
78 | });
79 |
80 | client.login(config.token);
--------------------------------------------------------------------------------
/Tutorial-9/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "requires": true,
3 | "lockfileVersion": 1,
4 | "dependencies": {
5 | "@discordjs/collection": {
6 | "version": "0.1.6",
7 | "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.1.6.tgz",
8 | "integrity": "sha512-utRNxnd9kSS2qhyivo9lMlt5qgAUasH2gb7BEOn6p0efFh24gjGomHzWKMAPn2hEReOPQZCJaRKoURwRotKucQ=="
9 | },
10 | "@discordjs/form-data": {
11 | "version": "3.0.1",
12 | "resolved": "https://registry.npmjs.org/@discordjs/form-data/-/form-data-3.0.1.tgz",
13 | "integrity": "sha512-ZfFsbgEXW71Rw/6EtBdrP5VxBJy4dthyC0tpQKGKmYFImlmmrykO14Za+BiIVduwjte0jXEBlhSKf0MWbFp9Eg==",
14 | "requires": {
15 | "asynckit": "^0.4.0",
16 | "combined-stream": "^1.0.8",
17 | "mime-types": "^2.1.12"
18 | }
19 | },
20 | "@sindresorhus/is": {
21 | "version": "4.0.0",
22 | "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.0.0.tgz",
23 | "integrity": "sha512-FyD2meJpDPjyNQejSjvnhpgI/azsQkA4lGbuu5BQZfjvJ9cbRZXzeWL2HceCekW4lixO9JPesIIQkSoLjeJHNQ=="
24 | },
25 | "@szmarczak/http-timer": {
26 | "version": "4.0.5",
27 | "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.5.tgz",
28 | "integrity": "sha512-PyRA9sm1Yayuj5OIoJ1hGt2YISX45w9WcFbh6ddT0Z/0yaFxOtGLInr4jUfU1EAFVs0Yfyfev4RNwBlUaHdlDQ==",
29 | "requires": {
30 | "defer-to-connect": "^2.0.0"
31 | }
32 | },
33 | "@types/cacheable-request": {
34 | "version": "6.0.1",
35 | "resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.1.tgz",
36 | "integrity": "sha512-ykFq2zmBGOCbpIXtoVbz4SKY5QriWPh3AjyU4G74RYbtt5yOc5OfaY75ftjg7mikMOla1CTGpX3lLbuJh8DTrQ==",
37 | "requires": {
38 | "@types/http-cache-semantics": "*",
39 | "@types/keyv": "*",
40 | "@types/node": "*",
41 | "@types/responselike": "*"
42 | }
43 | },
44 | "@types/http-cache-semantics": {
45 | "version": "4.0.0",
46 | "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.0.tgz",
47 | "integrity": "sha512-c3Xy026kOF7QOTn00hbIllV1dLR9hG9NkSrLQgCVs8NF6sBU+VGWjD3wLPhmh1TYAc7ugCFsvHYMN4VcBN1U1A=="
48 | },
49 | "@types/keyv": {
50 | "version": "3.1.1",
51 | "resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.1.tgz",
52 | "integrity": "sha512-MPtoySlAZQ37VoLaPcTHCu1RWJ4llDkULYZIzOYxlhxBqYPB0RsRlmMU0R6tahtFe27mIdkHV+551ZWV4PLmVw==",
53 | "requires": {
54 | "@types/node": "*"
55 | }
56 | },
57 | "@types/node": {
58 | "version": "14.14.14",
59 | "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.14.tgz",
60 | "integrity": "sha512-UHnOPWVWV1z+VV8k6L1HhG7UbGBgIdghqF3l9Ny9ApPghbjICXkUJSd/b9gOgQfjM1r+37cipdw/HJ3F6ICEnQ=="
61 | },
62 | "@types/responselike": {
63 | "version": "1.0.0",
64 | "resolved": "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.0.tgz",
65 | "integrity": "sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA==",
66 | "requires": {
67 | "@types/node": "*"
68 | }
69 | },
70 | "abort-controller": {
71 | "version": "3.0.0",
72 | "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz",
73 | "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==",
74 | "requires": {
75 | "event-target-shim": "^5.0.0"
76 | }
77 | },
78 | "ascii-table": {
79 | "version": "0.0.9",
80 | "resolved": "https://registry.npmjs.org/ascii-table/-/ascii-table-0.0.9.tgz",
81 | "integrity": "sha1-BqZgTWpV1L9BqaR9mHLXp42jHnM="
82 | },
83 | "asynckit": {
84 | "version": "0.4.0",
85 | "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
86 | "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
87 | },
88 | "cacheable-lookup": {
89 | "version": "5.0.4",
90 | "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz",
91 | "integrity": "sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA=="
92 | },
93 | "cacheable-request": {
94 | "version": "7.0.1",
95 | "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.1.tgz",
96 | "integrity": "sha512-lt0mJ6YAnsrBErpTMWeu5kl/tg9xMAWjavYTN6VQXM1A/teBITuNcccXsCxF0tDQQJf9DfAaX5O4e0zp0KlfZw==",
97 | "requires": {
98 | "clone-response": "^1.0.2",
99 | "get-stream": "^5.1.0",
100 | "http-cache-semantics": "^4.0.0",
101 | "keyv": "^4.0.0",
102 | "lowercase-keys": "^2.0.0",
103 | "normalize-url": "^4.1.0",
104 | "responselike": "^2.0.0"
105 | }
106 | },
107 | "clone-response": {
108 | "version": "1.0.2",
109 | "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz",
110 | "integrity": "sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws=",
111 | "requires": {
112 | "mimic-response": "^1.0.0"
113 | }
114 | },
115 | "combined-stream": {
116 | "version": "1.0.8",
117 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
118 | "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
119 | "requires": {
120 | "delayed-stream": "~1.0.0"
121 | }
122 | },
123 | "common-tags": {
124 | "version": "1.8.0",
125 | "resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.0.tgz",
126 | "integrity": "sha512-6P6g0uetGpW/sdyUy/iQQCbFF0kWVMSIVSyYz7Zgjcgh8mgw8PQzDNZeyZ5DQ2gM7LBoZPHmnjz8rUthkBG5tw=="
127 | },
128 | "decompress-response": {
129 | "version": "6.0.0",
130 | "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz",
131 | "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==",
132 | "requires": {
133 | "mimic-response": "^3.1.0"
134 | },
135 | "dependencies": {
136 | "mimic-response": {
137 | "version": "3.1.0",
138 | "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz",
139 | "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ=="
140 | }
141 | }
142 | },
143 | "defer-to-connect": {
144 | "version": "2.0.0",
145 | "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.0.tgz",
146 | "integrity": "sha512-bYL2d05vOSf1JEZNx5vSAtPuBMkX8K9EUutg7zlKvTqKXHt7RhWJFbmd7qakVuf13i+IkGmp6FwSsONOf6VYIg=="
147 | },
148 | "delayed-stream": {
149 | "version": "1.0.0",
150 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
151 | "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
152 | },
153 | "discord.js": {
154 | "version": "12.5.1",
155 | "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-12.5.1.tgz",
156 | "integrity": "sha512-VwZkVaUAIOB9mKdca0I5MefPMTQJTNg0qdgi1huF3iwsFwJ0L5s/Y69AQe+iPmjuV6j9rtKoG0Ta0n9vgEIL6w==",
157 | "requires": {
158 | "@discordjs/collection": "^0.1.6",
159 | "@discordjs/form-data": "^3.0.1",
160 | "abort-controller": "^3.0.0",
161 | "node-fetch": "^2.6.1",
162 | "prism-media": "^1.2.2",
163 | "setimmediate": "^1.0.5",
164 | "tweetnacl": "^1.0.3",
165 | "ws": "^7.3.1"
166 | }
167 | },
168 | "end-of-stream": {
169 | "version": "1.4.4",
170 | "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz",
171 | "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==",
172 | "requires": {
173 | "once": "^1.4.0"
174 | }
175 | },
176 | "event-target-shim": {
177 | "version": "5.0.1",
178 | "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
179 | "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ=="
180 | },
181 | "get-stream": {
182 | "version": "5.2.0",
183 | "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz",
184 | "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==",
185 | "requires": {
186 | "pump": "^3.0.0"
187 | }
188 | },
189 | "http-cache-semantics": {
190 | "version": "4.1.0",
191 | "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz",
192 | "integrity": "sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ=="
193 | },
194 | "json-buffer": {
195 | "version": "3.0.1",
196 | "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz",
197 | "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ=="
198 | },
199 | "keyv": {
200 | "version": "4.0.3",
201 | "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.0.3.tgz",
202 | "integrity": "sha512-zdGa2TOpSZPq5mU6iowDARnMBZgtCqJ11dJROFi6tg6kTn4nuUdU09lFyLFSaHrWqpIJ+EBq4E8/Dc0Vx5vLdA==",
203 | "requires": {
204 | "json-buffer": "3.0.1"
205 | }
206 | },
207 | "lowercase-keys": {
208 | "version": "2.0.0",
209 | "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz",
210 | "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA=="
211 | },
212 | "mime-db": {
213 | "version": "1.45.0",
214 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.45.0.tgz",
215 | "integrity": "sha512-CkqLUxUk15hofLoLyljJSrukZi8mAtgd+yE5uO4tqRZsdsAJKv0O+rFMhVDRJgozy+yG6md5KwuXhD4ocIoP+w=="
216 | },
217 | "mime-types": {
218 | "version": "2.1.28",
219 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.28.tgz",
220 | "integrity": "sha512-0TO2yJ5YHYr7M2zzT7gDU1tbwHxEUWBCLt0lscSNpcdAfFyJOVEpRYNS7EXVcTLNj/25QO8gulHC5JtTzSE2UQ==",
221 | "requires": {
222 | "mime-db": "1.45.0"
223 | }
224 | },
225 | "mimic-response": {
226 | "version": "1.0.1",
227 | "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz",
228 | "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ=="
229 | },
230 | "moment": {
231 | "version": "2.29.1",
232 | "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
233 | "integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ=="
234 | },
235 | "node-fetch": {
236 | "version": "2.6.1",
237 | "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
238 | "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
239 | },
240 | "normalize-url": {
241 | "version": "4.5.0",
242 | "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.0.tgz",
243 | "integrity": "sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ=="
244 | },
245 | "once": {
246 | "version": "1.4.0",
247 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
248 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
249 | "requires": {
250 | "wrappy": "1"
251 | }
252 | },
253 | "prism-media": {
254 | "version": "1.2.3",
255 | "resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.2.3.tgz",
256 | "integrity": "sha512-fSrR66n0l6roW9Rx4rSLMyTPTjRTiXy5RVqDOurACQ6si1rKHHKDU5gwBJoCsIV0R3o9gi+K50akl/qyw1C74A=="
257 | },
258 | "pump": {
259 | "version": "3.0.0",
260 | "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz",
261 | "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==",
262 | "requires": {
263 | "end-of-stream": "^1.1.0",
264 | "once": "^1.3.1"
265 | }
266 | },
267 | "responselike": {
268 | "version": "2.0.0",
269 | "resolved": "https://registry.npmjs.org/responselike/-/responselike-2.0.0.tgz",
270 | "integrity": "sha512-xH48u3FTB9VsZw7R+vvgaKeLKzT6jOogbQhEe/jewwnZgzPcnyWui2Av6JpoYZF/91uueC+lqhWqeURw5/qhCw==",
271 | "requires": {
272 | "lowercase-keys": "^2.0.0"
273 | }
274 | },
275 | "setimmediate": {
276 | "version": "1.0.5",
277 | "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz",
278 | "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU="
279 | },
280 | "tweetnacl": {
281 | "version": "1.0.3",
282 | "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz",
283 | "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw=="
284 | },
285 | "wrappy": {
286 | "version": "1.0.2",
287 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
288 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
289 | },
290 | "ws": {
291 | "version": "7.4.2",
292 | "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.2.tgz",
293 | "integrity": "sha512-T4tewALS3+qsrpGI/8dqNMLIVdq/g/85U98HPMa6F0m6xTbvhXU6RCQLqPH3+SlomNV/LdY6RXEbBpMH6EOJnA=="
294 | }
295 | }
296 | }
297 |
--------------------------------------------------------------------------------
/Tutorial-9/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "tutorial-9",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "dependencies": {
7 | "discord.js": "^12.5.1",
8 | "moment": "^2.29.1",
9 | "node-fetch": "^2.6.1"
10 | },
11 | "devDependencies": {},
12 | "scripts": {
13 | "test": "echo \"Error: no test specified\" && exit 1"
14 | },
15 | "author": "",
16 | "license": "ISC"
17 | }
18 |
--------------------------------------------------------------------------------