PEPPERBOT VOICE CHAT CAPABILITY
This commit is contained in:
parent
7d5d32fec1
commit
b92fe05718
11 changed files with 265 additions and 50 deletions
|
@ -17,6 +17,10 @@ clean up p/vileimagery, its horrendous
|
||||||
|
|
||||||
**_Note:_** _versions before this were not uploaded to the repo, this is not the first version._
|
**_Note:_** _versions before this were not uploaded to the repo, this is not the first version._
|
||||||
|
|
||||||
|
1.11 - added PEPPERBOT VOICE CHAT CAPABILITY
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
1.10 - changed all requires to imports
|
1.10 - changed all requires to imports
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
55
package-lock.json
generated
55
package-lock.json
generated
|
@ -9,10 +9,12 @@
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@discordjs/voice": "^0.16.0",
|
||||||
"discord.js": "^14.13.0",
|
"discord.js": "^14.13.0",
|
||||||
"discord.js-collector": "^1.8.9",
|
"discord.js-collector": "^1.8.9",
|
||||||
"dotenv": "^16.3.1",
|
"dotenv": "^16.3.1",
|
||||||
"emoji-regex": "^10.2.1",
|
"emoji-regex": "^10.2.1",
|
||||||
|
"libsodium-wrappers": "^0.7.13",
|
||||||
"regex": "^0.1.1"
|
"regex": "^0.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -93,6 +95,21 @@
|
||||||
"node": ">=16.11.0"
|
"node": ">=16.11.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@discordjs/voice": {
|
||||||
|
"version": "0.16.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@discordjs/voice/-/voice-0.16.0.tgz",
|
||||||
|
"integrity": "sha512-ToGCvHD1cBscuW3p+C7zOF5+L7MJmU4GjdOARfNk9mkHyFFZq4grK+Sxr3QXKbp27DtfDBc9uqD4GUOYgxngfA==",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/ws": "^8.5.4",
|
||||||
|
"discord-api-types": "^0.37.37",
|
||||||
|
"prism-media": "^1.3.5",
|
||||||
|
"tslib": "^2.5.0",
|
||||||
|
"ws": "^8.13.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16.9.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@discordjs/ws": {
|
"node_modules/@discordjs/ws": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/@discordjs/ws/-/ws-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/@discordjs/ws/-/ws-1.0.1.tgz",
|
||||||
|
@ -526,6 +543,19 @@
|
||||||
"resolved": "https://registry.npmjs.org/lex-parser/-/lex-parser-0.1.4.tgz",
|
"resolved": "https://registry.npmjs.org/lex-parser/-/lex-parser-0.1.4.tgz",
|
||||||
"integrity": "sha512-DuAEISsr1H4LOpmFLkyMc8YStiRWZCO8hMsoXAXSbgyfvs2WQhSt0+/FBv3ZU/JBFZMGcE+FWzEBSzwUU7U27w=="
|
"integrity": "sha512-DuAEISsr1H4LOpmFLkyMc8YStiRWZCO8hMsoXAXSbgyfvs2WQhSt0+/FBv3ZU/JBFZMGcE+FWzEBSzwUU7U27w=="
|
||||||
},
|
},
|
||||||
|
"node_modules/libsodium": {
|
||||||
|
"version": "0.7.13",
|
||||||
|
"resolved": "https://registry.npmjs.org/libsodium/-/libsodium-0.7.13.tgz",
|
||||||
|
"integrity": "sha512-mK8ju0fnrKXXfleL53vtp9xiPq5hKM0zbDQtcxQIsSmxNgSxqCj6R7Hl9PkrNe2j29T4yoDaF7DJLK9/i5iWUw=="
|
||||||
|
},
|
||||||
|
"node_modules/libsodium-wrappers": {
|
||||||
|
"version": "0.7.13",
|
||||||
|
"resolved": "https://registry.npmjs.org/libsodium-wrappers/-/libsodium-wrappers-0.7.13.tgz",
|
||||||
|
"integrity": "sha512-kasvDsEi/r1fMzKouIDv7B8I6vNmknXwGiYodErGuESoFTohGSKZplFtVxZqHaoQ217AynyIFgnOVRitpHs0Qw==",
|
||||||
|
"dependencies": {
|
||||||
|
"libsodium": "^0.7.13"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/lodash": {
|
"node_modules/lodash": {
|
||||||
"version": "4.17.21",
|
"version": "4.17.21",
|
||||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||||
|
@ -1061,6 +1091,18 @@
|
||||||
"resolved": "https://registry.npmjs.org/@discordjs/util/-/util-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/@discordjs/util/-/util-1.0.1.tgz",
|
||||||
"integrity": "sha512-d0N2yCxB8r4bn00/hvFZwM7goDcUhtViC5un4hPj73Ba4yrChLSJD8fy7Ps5jpTLg1fE9n4K0xBLc1y9WGwSsA=="
|
"integrity": "sha512-d0N2yCxB8r4bn00/hvFZwM7goDcUhtViC5un4hPj73Ba4yrChLSJD8fy7Ps5jpTLg1fE9n4K0xBLc1y9WGwSsA=="
|
||||||
},
|
},
|
||||||
|
"@discordjs/voice": {
|
||||||
|
"version": "0.16.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@discordjs/voice/-/voice-0.16.0.tgz",
|
||||||
|
"integrity": "sha512-ToGCvHD1cBscuW3p+C7zOF5+L7MJmU4GjdOARfNk9mkHyFFZq4grK+Sxr3QXKbp27DtfDBc9uqD4GUOYgxngfA==",
|
||||||
|
"requires": {
|
||||||
|
"@types/ws": "^8.5.4",
|
||||||
|
"discord-api-types": "^0.37.37",
|
||||||
|
"prism-media": "^1.3.5",
|
||||||
|
"tslib": "^2.5.0",
|
||||||
|
"ws": "^8.13.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"@discordjs/ws": {
|
"@discordjs/ws": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/@discordjs/ws/-/ws-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/@discordjs/ws/-/ws-1.0.1.tgz",
|
||||||
|
@ -1380,6 +1422,19 @@
|
||||||
"resolved": "https://registry.npmjs.org/lex-parser/-/lex-parser-0.1.4.tgz",
|
"resolved": "https://registry.npmjs.org/lex-parser/-/lex-parser-0.1.4.tgz",
|
||||||
"integrity": "sha512-DuAEISsr1H4LOpmFLkyMc8YStiRWZCO8hMsoXAXSbgyfvs2WQhSt0+/FBv3ZU/JBFZMGcE+FWzEBSzwUU7U27w=="
|
"integrity": "sha512-DuAEISsr1H4LOpmFLkyMc8YStiRWZCO8hMsoXAXSbgyfvs2WQhSt0+/FBv3ZU/JBFZMGcE+FWzEBSzwUU7U27w=="
|
||||||
},
|
},
|
||||||
|
"libsodium": {
|
||||||
|
"version": "0.7.13",
|
||||||
|
"resolved": "https://registry.npmjs.org/libsodium/-/libsodium-0.7.13.tgz",
|
||||||
|
"integrity": "sha512-mK8ju0fnrKXXfleL53vtp9xiPq5hKM0zbDQtcxQIsSmxNgSxqCj6R7Hl9PkrNe2j29T4yoDaF7DJLK9/i5iWUw=="
|
||||||
|
},
|
||||||
|
"libsodium-wrappers": {
|
||||||
|
"version": "0.7.13",
|
||||||
|
"resolved": "https://registry.npmjs.org/libsodium-wrappers/-/libsodium-wrappers-0.7.13.tgz",
|
||||||
|
"integrity": "sha512-kasvDsEi/r1fMzKouIDv7B8I6vNmknXwGiYodErGuESoFTohGSKZplFtVxZqHaoQ217AynyIFgnOVRitpHs0Qw==",
|
||||||
|
"requires": {
|
||||||
|
"libsodium": "^0.7.13"
|
||||||
|
}
|
||||||
|
},
|
||||||
"lodash": {
|
"lodash": {
|
||||||
"version": "4.17.21",
|
"version": "4.17.21",
|
||||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||||
|
|
|
@ -11,10 +11,12 @@
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@discordjs/voice": "^0.16.0",
|
||||||
"discord.js": "^14.13.0",
|
"discord.js": "^14.13.0",
|
||||||
"discord.js-collector": "^1.8.9",
|
"discord.js-collector": "^1.8.9",
|
||||||
"dotenv": "^16.3.1",
|
"dotenv": "^16.3.1",
|
||||||
"emoji-regex": "^10.2.1",
|
"emoji-regex": "^10.2.1",
|
||||||
|
"libsodium-wrappers": "^0.7.13",
|
||||||
"regex": "^0.1.1"
|
"regex": "^0.1.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
export default {
|
export default {
|
||||||
name: "openpepper",
|
name: "git",
|
||||||
description: "posts open pepper repo",
|
description: "posts open pepper repo",
|
||||||
arguments: "none",
|
arguments: "none",
|
||||||
execute(message, args) {
|
execute(message, args) {
|
||||||
message.reply("https://git.reidlab.online/ayeuhugyu/OpenPepper");
|
message.reply("https://git.reidlab.online/ayeuhugyu/PepperBot");
|
||||||
},
|
},
|
||||||
};
|
};
|
26
src/commands/joinvc.js
Normal file
26
src/commands/joinvc.js
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
import { joinVoiceChannel } from "@discordjs/voice";
|
||||||
|
import * as dotenv from "dotenv";
|
||||||
|
dotenv.config();
|
||||||
|
|
||||||
|
const guildId = process.env.GUILD_ID;
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "joinvc",
|
||||||
|
description: "joins the vc that the user is currently in",
|
||||||
|
arguments: "none",
|
||||||
|
execute(message, args) {
|
||||||
|
if (message.member.voice.channel) {
|
||||||
|
let voiceState = message.member.voice;
|
||||||
|
|
||||||
|
let connection = joinVoiceChannel({
|
||||||
|
channelId: voiceState.channelId,
|
||||||
|
guildId: voiceState.guild.id,
|
||||||
|
adapterCreator: voiceState.guild.voiceAdapterCreator,
|
||||||
|
});
|
||||||
|
|
||||||
|
message.reply(`connected to <#${voiceState.channelId}>`);
|
||||||
|
} else {
|
||||||
|
message.reply("u aint connected to a voice channel blud 😂😂😂");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
16
src/commands/leavevc.js
Normal file
16
src/commands/leavevc.js
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
import { getVoiceConnection } from "@discordjs/voice";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "leavevc",
|
||||||
|
description: "leaves vc that user is currently in",
|
||||||
|
arguments: "none",
|
||||||
|
execute(message, args) {
|
||||||
|
if (getVoiceConnection(message.guild.id)) {
|
||||||
|
const connection = getVoiceConnection(message.guild.id);
|
||||||
|
connection.destroy();
|
||||||
|
message.reply(`left voice channel <#${connection.joinConfig.channelId}>`);
|
||||||
|
} else {
|
||||||
|
message.reply("im not connected to a voice channel here mf");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
103
src/commands/soundboard.js
Normal file
103
src/commands/soundboard.js
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
import {
|
||||||
|
createAudioPlayer,
|
||||||
|
createAudioResource,
|
||||||
|
getVoiceConnection,
|
||||||
|
joinVoiceChannel,
|
||||||
|
} from "@discordjs/voice";
|
||||||
|
import fs from "fs";
|
||||||
|
import * as dotenv from "dotenv";
|
||||||
|
dotenv.config();
|
||||||
|
|
||||||
|
const prefix = process.env.PREFIX;
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "soundboard",
|
||||||
|
description: "plays specified sound file",
|
||||||
|
arguments: "file",
|
||||||
|
execute(message, args) {
|
||||||
|
const audioPlayer = createAudioPlayer();
|
||||||
|
let proposedfilename = message.content.slice(
|
||||||
|
prefix.length + this.name.length + 1
|
||||||
|
);
|
||||||
|
const files = fs.readdirSync("resources/soundboard");
|
||||||
|
let file;
|
||||||
|
let lsmode = false;
|
||||||
|
let stopmode = false;
|
||||||
|
|
||||||
|
let possibleFilenames = {
|
||||||
|
regular: proposedfilename,
|
||||||
|
spaced: proposedfilename.replaceAll(" ", "_"),
|
||||||
|
spacedmp3: proposedfilename.replaceAll(" ", "_") + ".mp3",
|
||||||
|
mp3: proposedfilename + ".mp3",
|
||||||
|
spacedogg: proposedfilename.replaceAll(" ", "_") + ".ogg",
|
||||||
|
ogg: proposedfilename + ".ogg",
|
||||||
|
spacedwav: proposedfilename.replaceAll(" ", "_") + ".wav",
|
||||||
|
wav: proposedfilename + ".wav",
|
||||||
|
spacedwebm: proposedfilename.replaceAll(" ", "_") + ".webm",
|
||||||
|
webm: proposedfilename + ".webm",
|
||||||
|
};
|
||||||
|
for (const value of Object.values(possibleFilenames)) {
|
||||||
|
if (files.includes(value)) {
|
||||||
|
file = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (proposedfilename === "ls") {
|
||||||
|
fs.writeFileSync("resources/soundboard/ls.txt", "");
|
||||||
|
lsmode = true;
|
||||||
|
for (let file = 0; file < files.length; file++) {
|
||||||
|
if (files[file] !== "ls.txt") {
|
||||||
|
fs.appendFileSync("resources/soundboard/ls.txt", `${files[file]}\n`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (proposedfilename === "stop") {
|
||||||
|
let connection = getVoiceConnection(message.guild.id);
|
||||||
|
connection.subscribe(audioPlayer);
|
||||||
|
audioPlayer.stop();
|
||||||
|
message.reply("stopped audio playback");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!file && !lsmode && !stopmode) {
|
||||||
|
message.reply(
|
||||||
|
"unable to find your file in the soundboard folder put `ls` as your args to upload a file of all names. try replacing spaces with _s. you proposed: " +
|
||||||
|
proposedfilename
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!lsmode) {
|
||||||
|
const audioResource = createAudioResource(`resources/soundboard/${file}`);
|
||||||
|
|
||||||
|
let connection = getVoiceConnection(message.guild.id);
|
||||||
|
if (!connection) {
|
||||||
|
if (message.member.voice.channel) {
|
||||||
|
let voiceState = message.member.voice;
|
||||||
|
|
||||||
|
let connection = joinVoiceChannel({
|
||||||
|
channelId: voiceState.channelId,
|
||||||
|
guildId: voiceState.guild.id,
|
||||||
|
adapterCreator: voiceState.guild.voiceAdapterCreator,
|
||||||
|
});
|
||||||
|
|
||||||
|
message.reply(`connected to <#${voiceState.channelId}>`);
|
||||||
|
} else {
|
||||||
|
message.reply(
|
||||||
|
"the bot is not in a voice channel so a sound cannot be played, and you are not in a voice channel so it can't auto join. IDIOT!"
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
connection = getVoiceConnection(message.guild.id);
|
||||||
|
connection.subscribe(audioPlayer);
|
||||||
|
audioPlayer.play(audioResource);
|
||||||
|
} else {
|
||||||
|
message.channel.send({
|
||||||
|
files: [
|
||||||
|
{
|
||||||
|
attachment: "resources/soundboard/ls.txt",
|
||||||
|
name: "ls.txt",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
|
@ -2,12 +2,14 @@ import { default as guildMemberAdd } from "./guildMemberAdd.js";
|
||||||
import { default as messageCreate } from "./messageCreate.js";
|
import { default as messageCreate } from "./messageCreate.js";
|
||||||
import { default as messageDelete } from "./messageDelete.js";
|
import { default as messageDelete } from "./messageDelete.js";
|
||||||
import { default as ready } from "./ready.js";
|
import { default as ready } from "./ready.js";
|
||||||
|
import { default as interactionCreate } from "./interactionCreate.js";
|
||||||
|
|
||||||
const events = {
|
const events = {
|
||||||
guildMemberAdd,
|
guildMemberAdd,
|
||||||
messageCreate,
|
messageCreate,
|
||||||
messageDelete,
|
messageDelete,
|
||||||
ready,
|
ready,
|
||||||
|
interactionCreate,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default events;
|
export default events;
|
||||||
|
|
3
src/events/interactionCreate.js
Normal file
3
src/events/interactionCreate.js
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export default function (interaction) {
|
||||||
|
interaction.reply("stop fucking interacting");
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
import { GatewayIntentBits, Partials, Client } from "discord.js";
|
import { GatewayIntentBits, Partials, Client } from "discord.js";
|
||||||
import events from "./events/importEvents.js";
|
import events from "./events/importEvents.js";
|
||||||
|
import register from "./register-commands.js";
|
||||||
|
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
intents: [
|
intents: [
|
||||||
|
@ -8,6 +9,7 @@ const client = new Client({
|
||||||
GatewayIntentBits.GuildMessages,
|
GatewayIntentBits.GuildMessages,
|
||||||
GatewayIntentBits.MessageContent,
|
GatewayIntentBits.MessageContent,
|
||||||
GatewayIntentBits.DirectMessages,
|
GatewayIntentBits.DirectMessages,
|
||||||
|
GatewayIntentBits.GuildVoiceStates,
|
||||||
],
|
],
|
||||||
partials: [Partials.Message, Partials.Channel],
|
partials: [Partials.Message, Partials.Channel],
|
||||||
});
|
});
|
||||||
|
@ -28,4 +30,10 @@ client.on("messageCreate", async (message) => {
|
||||||
events.messageCreate(message, client);
|
events.messageCreate(message, client);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
client.on("interactionCreate", (interaction) => {
|
||||||
|
events.interactionCreate(interaction);
|
||||||
|
});
|
||||||
|
|
||||||
|
register();
|
||||||
|
|
||||||
client.login(process.env.TOKEN);
|
client.login(process.env.TOKEN);
|
||||||
|
|
|
@ -1,52 +1,48 @@
|
||||||
require('dotenv').config();
|
import dotenv from "dotenv";
|
||||||
const { REST, Routes, ApplicationCommandOptionType } = require('discord.js');
|
import fs from "fs";
|
||||||
|
dotenv.config();
|
||||||
|
import {
|
||||||
|
REST,
|
||||||
|
Routes,
|
||||||
|
ApplicationCommandOptionType,
|
||||||
|
SlashCommandBuilder,
|
||||||
|
} from "discord.js";
|
||||||
|
|
||||||
export const commands = [
|
let commands = [];
|
||||||
|
|
||||||
|
const commandFiles = fs
|
||||||
|
.readdirSync("src/commands/")
|
||||||
|
.filter((file) => file.endsWith(".js"));
|
||||||
|
|
||||||
|
async () => {
|
||||||
|
for (const file of commandFiles) {
|
||||||
|
const command = await import(`./commands/${file}`);
|
||||||
|
commands.push(
|
||||||
|
`
|
||||||
{
|
{
|
||||||
name: 'say',
|
name: "${command.name}",
|
||||||
description: 'forces bot to say message',
|
description: "${command.description}"
|
||||||
options: [
|
|
||||||
{
|
|
||||||
name: 'message',
|
|
||||||
description: 'the message',
|
|
||||||
type: ApplicationCommandOptionType.String,
|
|
||||||
required: true
|
|
||||||
}
|
}
|
||||||
]
|
`.toJSON()
|
||||||
},
|
);
|
||||||
{
|
|
||||||
name: 'administer',
|
|
||||||
description: 'administer.',
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
name: 'password',
|
|
||||||
description: 'the protections.',
|
|
||||||
type: ApplicationCommandOptionType.String,
|
|
||||||
required: true
|
|
||||||
}
|
}
|
||||||
]
|
};
|
||||||
},
|
console.log(commands);
|
||||||
{
|
|
||||||
name: 'commands',
|
|
||||||
description: 'sends a command list',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'test',
|
|
||||||
description: 'test command',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const rest = new REST({ version: '10' }).setToken(process.env.TOKEN);
|
const rest = new REST().setToken(process.env.TOKEN);
|
||||||
|
|
||||||
(async () => {
|
export default async () => {
|
||||||
try {
|
try {
|
||||||
await rest.put(
|
await rest.put(
|
||||||
Routes.applicationGuildCommands(process.env.CLIENT_ID, process.env.GUILD_ID),
|
Routes.applicationGuildCommands(
|
||||||
|
process.env.CLIENT_ID,
|
||||||
|
process.env.GUILD_ID
|
||||||
|
),
|
||||||
{ body: commands }
|
{ body: commands }
|
||||||
)
|
);
|
||||||
|
|
||||||
console.log("slash commands registered")
|
console.log("slash commands registered");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
})();
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue