Voice connection shitfest edition

No działa tylko na papierze syf że szkoda gadać
This commit is contained in:
Stanislaw
2021-12-27 10:08:19 +01:00
parent face7875b9
commit 481a1f3f25
7 changed files with 3766 additions and 2554 deletions

6208
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,28 +1,36 @@
{ {
"name": "discord-bot", "name": "discord-bot",
"version": "1.0.0", "version": "1.0.0",
"description": "gractwo-bot is a Discord bot written in JavaScript, using node.js and discord.js.\r It has been created for and only serves the Gractwo Discord server. It is hosted using Heroku.", "description": "gractwo-bot is a Discord bot written in JavaScript, using node.js and discord.js.\r It has been created for and only serves the Gractwo Discord server. It is hosted using Heroku.",
"main": "src/index.js", "main": "src/index.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "start": "nodemon"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/Gractwo/discord-bot.git" "url": "git+https://github.com/Gractwo/discord-bot.git"
}, },
"author": "github.com/jakubmanczak", "author": "github.com/jakubmanczak",
"license": "UNLICENSED", "license": "UNLICENSED",
"bugs": { "bugs": {
"url": "https://github.com/Gractwo/discord-bot/issues" "url": "https://github.com/Gractwo/discord-bot/issues"
}, },
"homepage": "https://github.com/Gractwo/discord-bot#readme", "homepage": "https://github.com/Gractwo/discord-bot#readme",
"engines": { "engines": {
"node": ">=16.10.0", "node": ">=16.10.0",
"npm": ">=7.24.0" "npm": ">=7.24.0"
}, },
"dependencies": { "dependencies": {
"discord.js": "^13.1.0", "@discordjs/opus": "^0.5.3",
"dotenv": "^10.0.0", "@discordjs/voice": "^0.7.5",
"nodemon": "^2.0.13" "daemon": "^1.1.0",
} "discord.js": "^13.1.0",
"dotenv": "^10.0.0",
"ffmpeg": "^0.0.4",
"ffmpeg-static": "^4.4.0",
"libsodium-wrappers": "^0.7.9",
"nodemon": "^2.0.13",
"ytdl-core": "^4.9.2",
"ytsr": "^3.5.3"
}
} }

View File

@@ -13,11 +13,6 @@ module.exports = {
// not intended outside of specific scenarios // not intended outside of specific scenarios
let embed = { let embed = {
color: cl.cfg.hexBlue, color: cl.cfg.hexBlue,
// timestamp: new Date(),
// footer: {
// text: `Komenda wywołana przez ${msg.author.tag}`,
// icon_url: cl.cfg.iconurl,
// },
}; };
let readyMsg; let readyMsg;

46
src/cmds/play.js Normal file
View File

@@ -0,0 +1,46 @@
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 { 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");
return request;
} 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();
let song = createAudioResource('C:/Users/Stachu/Documents/GitHub/bot/src/sound/afro.mp3')
aplay.play(song);
connection.subscribe(aplay);
aplay.on('error', error => {
console.error(error);
});
}
}

View File

@@ -6,6 +6,7 @@ const cl = new discordjs.Client({
intents: [ intents: [
discordjs.Intents.FLAGS.GUILDS, discordjs.Intents.FLAGS.GUILDS,
discordjs.Intents.FLAGS.GUILD_MESSAGES, discordjs.Intents.FLAGS.GUILD_MESSAGES,
discordjs.Intents.FLAGS.GUILD_VOICE_STATES,
], ],
}); });
cl.cfg = require('./cfg.json'); cl.cfg = require('./cfg.json');

BIN
src/sound/afro.mp3 Normal file

Binary file not shown.

BIN
src/sound/gospel.mp3 Normal file

Binary file not shown.