Mee6discord przygotowania
This commit is contained in:
Binary file not shown.
67
index.js
Normal file
67
index.js
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
const discordjs = require("discord.js");
|
||||||
|
const fs = require("fs");
|
||||||
|
const { Tedis, TedisPool } = require("tedis");
|
||||||
|
require("dotenv").config();
|
||||||
|
|
||||||
|
const cl = new discordjs.Client({
|
||||||
|
intents: [
|
||||||
|
discordjs.Intents.FLAGS.GUILDS,
|
||||||
|
discordjs.Intents.FLAGS.GUILD_MESSAGES,
|
||||||
|
discordjs.Intents.FLAGS.GUILD_VOICE_STATES,
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
//Redis connect
|
||||||
|
const redis = new Tedis({
|
||||||
|
host: "127.0.0.1",
|
||||||
|
port: 6379,
|
||||||
|
password: process.env.REDIS_TOKEN,
|
||||||
|
});
|
||||||
|
cl.cfg = require("./cfg.json");
|
||||||
|
cl.cmds = new discordjs.Collection();
|
||||||
|
|
||||||
|
const cmdsFls = fs
|
||||||
|
.readdirSync(`./src/cmds`)
|
||||||
|
.filter((file) => file.endsWith(`.js`));
|
||||||
|
for (const Fl of cmdsFls) {
|
||||||
|
const cmd = require(`./src/cmds/${Fl}`);
|
||||||
|
console.log(`command: ` + cmd.name);
|
||||||
|
cl.cmds.set(cmd.name, cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
cl.on("messageCreate", (msg) => {
|
||||||
|
if (msg.author.bot) return;
|
||||||
|
if (!msg.content.startsWith(cl.cfg.prefix)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
const args = msg.content.slice(cl.cfg.prefix.length).trim().split(/ +/);
|
||||||
|
const cmdName = args.shift().toLowerCase();
|
||||||
|
|
||||||
|
if (!cl.cmds.has(cmdName)) return;
|
||||||
|
const cmd = cl.cmds.get(cmdName);
|
||||||
|
|
||||||
|
try {
|
||||||
|
cmd.execute(cl, msg, args);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(
|
||||||
|
`msgCommand error: ${cmdName} with args ${args} by ${msg.author.tag}\n--\n${error}\n--`
|
||||||
|
);
|
||||||
|
msg.reply(
|
||||||
|
`An error occured while trying to execute ${cmdName} with args ${args}`
|
||||||
|
);
|
||||||
|
console.log(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log(`msgCommand: ${cmdName + args} by ${msg.author.tag}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
cl.once("ready", () => {
|
||||||
|
console.clear();
|
||||||
|
console.log(`bot ready; logged in as ${cl.user.tag}\n--`);
|
||||||
|
cl.user.setActivity(".pomoc", { type: "LISTENING" });
|
||||||
|
});
|
||||||
|
cl.login(process.env.TOKEN); // here comes the boooy
|
||||||
|
// hello boy
|
||||||
|
// welcome
|
||||||
|
// there he is
|
||||||
|
// he is here
|
||||||
51
package-lock.json
generated
51
package-lock.json
generated
@@ -18,6 +18,7 @@
|
|||||||
"ffmpeg-static": "^4.4.0",
|
"ffmpeg-static": "^4.4.0",
|
||||||
"libsodium-wrappers": "^0.7.9",
|
"libsodium-wrappers": "^0.7.9",
|
||||||
"nodemon": "^2.0.13",
|
"nodemon": "^2.0.13",
|
||||||
|
"tedis": "^0.1.12",
|
||||||
"ytdl-core": "^4.9.2",
|
"ytdl-core": "^4.9.2",
|
||||||
"ytsr": "^3.5.3"
|
"ytsr": "^3.5.3"
|
||||||
},
|
},
|
||||||
@@ -1392,14 +1393,22 @@
|
|||||||
"integrity": "sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A=="
|
"integrity": "sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A=="
|
||||||
},
|
},
|
||||||
"node_modules/node-fetch": {
|
"node_modules/node-fetch": {
|
||||||
"version": "2.6.5",
|
"version": "2.6.7",
|
||||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.5.tgz",
|
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
|
||||||
"integrity": "sha512-mmlIVHJEu5rnIxgEgez6b9GgWXbkZj5YZ7fx+2r94a2E+Uirsp6HsPTPlomfdHtpt/B0cdKviwkoaM6pyvUOpQ==",
|
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"whatwg-url": "^5.0.0"
|
"whatwg-url": "^5.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "4.x || >=6.0.0"
|
"node": "4.x || >=6.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"encoding": "^0.1.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"encoding": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/nodemon": {
|
"node_modules/nodemon": {
|
||||||
@@ -1833,6 +1842,14 @@
|
|||||||
"node": ">= 10"
|
"node": ">= 10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/tedis": {
|
||||||
|
"version": "0.1.12",
|
||||||
|
"resolved": "https://registry.npmjs.org/tedis/-/tedis-0.1.12.tgz",
|
||||||
|
"integrity": "sha512-bxOKYWvdF1WsjkBYIfeO+2+xZuiqHmikqTTYPm3j/FYFpxQsX2JTBh6fFSlH6jDiCL4lfPcS2woIdD3FHopS/Q==",
|
||||||
|
"dependencies": {
|
||||||
|
"uuid": "^3.3.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/tiny-typed-emitter": {
|
"node_modules/tiny-typed-emitter": {
|
||||||
"version": "2.1.0",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/tiny-typed-emitter/-/tiny-typed-emitter-2.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/tiny-typed-emitter/-/tiny-typed-emitter-2.1.0.tgz",
|
||||||
@@ -1980,6 +1997,15 @@
|
|||||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||||
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
|
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
|
||||||
},
|
},
|
||||||
|
"node_modules/uuid": {
|
||||||
|
"version": "3.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
|
||||||
|
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
|
||||||
|
"deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",
|
||||||
|
"bin": {
|
||||||
|
"uuid": "bin/uuid"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/vali-date": {
|
"node_modules/vali-date": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/vali-date/-/vali-date-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/vali-date/-/vali-date-1.0.0.tgz",
|
||||||
@@ -3143,9 +3169,9 @@
|
|||||||
"integrity": "sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A=="
|
"integrity": "sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A=="
|
||||||
},
|
},
|
||||||
"node-fetch": {
|
"node-fetch": {
|
||||||
"version": "2.6.5",
|
"version": "2.6.7",
|
||||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.5.tgz",
|
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
|
||||||
"integrity": "sha512-mmlIVHJEu5rnIxgEgez6b9GgWXbkZj5YZ7fx+2r94a2E+Uirsp6HsPTPlomfdHtpt/B0cdKviwkoaM6pyvUOpQ==",
|
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"whatwg-url": "^5.0.0"
|
"whatwg-url": "^5.0.0"
|
||||||
}
|
}
|
||||||
@@ -3467,6 +3493,14 @@
|
|||||||
"yallist": "^4.0.0"
|
"yallist": "^4.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"tedis": {
|
||||||
|
"version": "0.1.12",
|
||||||
|
"resolved": "https://registry.npmjs.org/tedis/-/tedis-0.1.12.tgz",
|
||||||
|
"integrity": "sha512-bxOKYWvdF1WsjkBYIfeO+2+xZuiqHmikqTTYPm3j/FYFpxQsX2JTBh6fFSlH6jDiCL4lfPcS2woIdD3FHopS/Q==",
|
||||||
|
"requires": {
|
||||||
|
"uuid": "^3.3.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"tiny-typed-emitter": {
|
"tiny-typed-emitter": {
|
||||||
"version": "2.1.0",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/tiny-typed-emitter/-/tiny-typed-emitter-2.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/tiny-typed-emitter/-/tiny-typed-emitter-2.1.0.tgz",
|
||||||
@@ -3583,6 +3617,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||||
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
|
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
|
||||||
},
|
},
|
||||||
|
"uuid": {
|
||||||
|
"version": "3.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
|
||||||
|
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A=="
|
||||||
|
},
|
||||||
"vali-date": {
|
"vali-date": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/vali-date/-/vali-date-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/vali-date/-/vali-date-1.0.0.tgz",
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
"ffmpeg-static": "^4.4.0",
|
"ffmpeg-static": "^4.4.0",
|
||||||
"libsodium-wrappers": "^0.7.9",
|
"libsodium-wrappers": "^0.7.9",
|
||||||
"nodemon": "^2.0.13",
|
"nodemon": "^2.0.13",
|
||||||
|
"tedis": "^0.1.12",
|
||||||
"ytdl-core": "^4.9.2",
|
"ytdl-core": "^4.9.2",
|
||||||
"ytsr": "^3.5.3"
|
"ytsr": "^3.5.3"
|
||||||
}
|
}
|
||||||
|
|||||||
4
queres/badge_id.sql
Normal file
4
queres/badge_id.sql
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
SELECT badges.badge_id + 1 AS new_id
|
||||||
|
FROM badges
|
||||||
|
ORDER BY badge_id
|
||||||
|
DESC LIMIT 1
|
||||||
5
queres/user_badges.sql
Normal file
5
queres/user_badges.sql
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
SELECT badges.badge_id
|
||||||
|
FROM users
|
||||||
|
JOIN given_badges ON given_badges.user_id = users.user_id
|
||||||
|
JOIN badges ON given_badges.badge_id = badges.badge_id
|
||||||
|
WHERE users.user_id = 'JEBAĆ'
|
||||||
0
src/cmds/batch.js
Normal file
0
src/cmds/batch.js
Normal file
6
src/cmds/odznaki.js
Normal file
6
src/cmds/odznaki.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
module.exports = {
|
||||||
|
name: "odznaki",
|
||||||
|
execute(cl, msg) {
|
||||||
|
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'ping',
|
name: "ping",
|
||||||
execute(cl, msg) {
|
execute(cl, msg) {
|
||||||
const embed = {
|
const embed = {
|
||||||
color: cl.cfg.hexBlue,
|
color: cl.cfg.hexBlue,
|
||||||
@@ -8,7 +8,7 @@ module.exports = {
|
|||||||
text: `Komenda wywołana przez ${msg.author.tag}`,
|
text: `Komenda wywołana przez ${msg.author.tag}`,
|
||||||
icon_url: cl.cfg.iconurl,
|
icon_url: cl.cfg.iconurl,
|
||||||
},
|
},
|
||||||
title: 'Pong!',
|
title: "Pong!",
|
||||||
description: `Ping jednostronny wynosi ${
|
description: `Ping jednostronny wynosi ${
|
||||||
Date.now() - msg.createdTimestamp
|
Date.now() - msg.createdTimestamp
|
||||||
}ms.`,
|
}ms.`,
|
||||||
|
|||||||
@@ -1,50 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
name: 'play',
|
|
||||||
execute(cl, msg, args) {
|
|
||||||
const ytdl = require('ytdl-core');
|
|
||||||
const ytsr = require('ytsr');
|
|
||||||
const path = require('path');
|
|
||||||
const discord = require('discord.js');
|
|
||||||
const fs = require('fs')
|
|
||||||
const { joinVoiceChannel, createAudioPlayer, createAudioResource } = require('@discordjs/voice');
|
|
||||||
let connection;
|
|
||||||
let aplay;
|
|
||||||
let queue;
|
|
||||||
|
|
||||||
function link(msg) {
|
|
||||||
let request = msg.content.slice(path.basename(__filename).length + cl.cfg.prefix.length - 3);
|
|
||||||
if (request.trim() == "") {
|
|
||||||
msg.reply("Dej link albo tagi albo weź i spierdalaj");
|
|
||||||
} else if (request.trim().startsWith("https")) {
|
|
||||||
request = request.trim()
|
|
||||||
if (ytdl.validateURL(request)) {
|
|
||||||
msg.reply("Poprawny link");
|
|
||||||
let linked = './sound/' + msg.member.voice.channel.id + '.mp4'
|
|
||||||
ytdl(request).pipe(fs.createWriteStream(linked));
|
|
||||||
return linked;
|
|
||||||
} else {
|
|
||||||
msg.reply("Kurwo wenecka daj prawdziwy link a nie jaja sobie robisz");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
msg.reply("Szukasz:" + request);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!connection) {
|
|
||||||
let vChannel = msg.member.voice.channel;
|
|
||||||
connection = joinVoiceChannel({
|
|
||||||
channelId: vChannel.id,
|
|
||||||
guildId: vChannel.guild.id,
|
|
||||||
adapterCreator: vChannel.guild.voiceAdapterCreator,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
aplay = createAudioPlayer();
|
|
||||||
link(msg);
|
|
||||||
let song = createAudioResource('./sound/' + msg.member.voice.channel.id + '.mp4');
|
|
||||||
aplay.play(song);
|
|
||||||
connection.subscribe(aplay);
|
|
||||||
aplay.on('error', error => {
|
|
||||||
console.error(error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
4
src/cmds/profil.js
Normal file
4
src/cmds/profil.js
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
module.exports = {
|
||||||
|
name: "profil",
|
||||||
|
execute(cl, msg) {},
|
||||||
|
};
|
||||||
4
src/cmds/ranking.js
Normal file
4
src/cmds/ranking.js
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
module.exports = {
|
||||||
|
name: "ranking",
|
||||||
|
execute(cl, msg) {},
|
||||||
|
};
|
||||||
58
src/index.js
58
src/index.js
@@ -1,58 +0,0 @@
|
|||||||
const discordjs = require('discord.js');
|
|
||||||
const fs = require('fs');
|
|
||||||
require('dotenv').config();
|
|
||||||
|
|
||||||
const cl = new discordjs.Client({
|
|
||||||
intents: [
|
|
||||||
discordjs.Intents.FLAGS.GUILDS,
|
|
||||||
discordjs.Intents.FLAGS.GUILD_MESSAGES,
|
|
||||||
discordjs.Intents.FLAGS.GUILD_VOICE_STATES,
|
|
||||||
],
|
|
||||||
});
|
|
||||||
cl.cfg = require('./cfg.json');
|
|
||||||
cl.cmds = new discordjs.Collection();
|
|
||||||
|
|
||||||
const cmdsFls = fs
|
|
||||||
.readdirSync(`./src/cmds`)
|
|
||||||
.filter((file) => file.endsWith(`.js`));
|
|
||||||
for (const Fl of cmdsFls) {
|
|
||||||
const cmd = require(`./cmds/${Fl}`);
|
|
||||||
console.log(`command: ` + cmd.name);
|
|
||||||
cl.cmds.set(cmd.name, cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
cl.on('messageCreate', (msg) => {
|
|
||||||
if (!msg.content.startsWith(cl.cfg.prefix) || msg.author.bot) return;
|
|
||||||
|
|
||||||
const args = msg.content.slice(cl.cfg.prefix.length).trim().split(/ +/);
|
|
||||||
const cmdName = args.shift().toLowerCase();
|
|
||||||
|
|
||||||
if (!cl.cmds.has(cmdName)) return;
|
|
||||||
const cmd = cl.cmds.get(cmdName);
|
|
||||||
|
|
||||||
try {
|
|
||||||
cmd.execute(cl, msg, args);
|
|
||||||
} catch (error) {
|
|
||||||
console.error(
|
|
||||||
`msgCommand error: ${cmdName} with args ${args} by ${msg.author.tag}\n--\n${error}\n--`
|
|
||||||
);
|
|
||||||
msg.reply(
|
|
||||||
`An error occured while trying to execute ${cmdName} with args ${args}`
|
|
||||||
);
|
|
||||||
console.log(error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
console.log(`msgCommand: ${cmdName + args} by ${msg.author.tag}`);
|
|
||||||
});
|
|
||||||
|
|
||||||
cl.once('ready', () => {
|
|
||||||
console.clear();
|
|
||||||
console.log(`bot ready; logged in as ${cl.user.tag}\n--`);
|
|
||||||
cl.user.setActivity('.pomoc', { type: 'LISTENING' });
|
|
||||||
});
|
|
||||||
|
|
||||||
cl.login(process.env.token); // here comes the boooy
|
|
||||||
// hello boy
|
|
||||||
// welcome
|
|
||||||
// there he is
|
|
||||||
// he is here
|
|
||||||
Reference in New Issue
Block a user