attempt upgrade to discord.js 13

This commit is contained in:
Lamp 2022-01-03 20:40:43 -08:00
parent c8e3353fe2
commit ca719a52e5
12 changed files with 307 additions and 310 deletions

View File

@ -106,7 +106,7 @@ global.commands = {
dClient.on('local_message', async message => {
dClient.on('messageCreate', async message => {
if (!message.content.startsWith('!')) return;
if (message.author.id === dClient.user.id) return;
@ -140,7 +140,7 @@ dClient.on('local_message', async message => {
},
(err) => {
message.reply(`:warning: An error occured: \`\`\`\n${err.stack}\n\`\`\`<@281134216115257344>`);
console.error(err.stack);
handleError(err);
}
)
});

View File

@ -3,14 +3,12 @@ global.testmode = process.env.TEST ? true : false;
module.exports = {
"DISCORD_TOKEN": process.env.DISCORD_TOKEN,
"DATABASE_URL": testmode ? "postgres://localhost/k4t" : process.env.DATABASE_URL,
"MONGODB_URI": testmode ? "mongodb://localhost/k4t" : process.env.MONGODB_URI,
"webhooks": {
"welcome": process.env.WEBHOOK_WELCOME.split("/"),
"error": process.env.WEBHOOK_ERROR.split("/"),
"ddp": process.env.WEBHOOK_DDP.split("/"),
"pinboard": process.env.WEBHOOK_PINBOARD.split("/")
"welcome": process.env.WEBHOOK_WELCOME,
"error": process.env.WEBHOOK_ERROR,
"ddp": process.env.WEBHOOK_DDP,
"pinboard": process.env.WEBHOOK_PINBOARD
},
"opID": "707359017252683896",

View File

@ -13,9 +13,9 @@ module.exports = function createWSMessageCollector(output) { // output func must
// gzip the data & send to output callback
async function save(callback){
fs.readFile(filepath, (err, file) => {
if (err) return console.error(err);
if (err) return handleError(err);
zlib.gzip(file, async function(err, data){
if (err) return console.error(err);
if (err) return handleError(err);
var thisStartDate = startDate, thisEndDate = new Date();
fs.writeFileSync(filepath, '');
size = 0;

View File

@ -1,10 +1,8 @@
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0; //TODO fix
var WebSocket = require('ws');
var Discord = require('discord.js');
var createWsMessageCollector = require('./datacollector');
var webhook = new Discord.WebhookClient(config.webhooks.ddp[0], config.webhooks.ddp[1], {disableMentions:'all'});
var webhook = new Discord.WebhookClient({url: config.webhooks.ddp});
var ws;
var wasConnected = false;
@ -42,7 +40,7 @@ var collectWsMessage = createWsMessageCollector(async function(data, startDate,
myId = transmission.id;
}*/
});
ws.on("error", error => console.error(error));
ws.on("error", error => handleError(error));
ws.on("close", () => {
if (wasConnected) send2discord("**Disconnected**");
wasConnected = false;
@ -51,16 +49,16 @@ var collectWsMessage = createWsMessageCollector(async function(data, startDate,
})();
function send2discord(message) {
webhook.send(message, {split:{char:'',maxLength:2000}});
webhook.send(message.substring(0,2000));
}
function send2ddp(message) {
if (ws.readyState == WebSocket.OPEN) ws.send(JSON.stringify({type:"chat",message}));
}
dClient.on("local_message", message => {
dClient.on("messageCreate", message => {
if (message.channel.id != "508890674138054667" || message.author.bot) return;
var x = message.cleanContent;
if (message.attachments.first()) x += " " + message.attachments.first().url;
if (message.attachments.size > 0) x += ' ' + message.attachments.map(a => a.url).join(' ');
send2ddp(`\u034f${message.member.displayName}#${message.author.discriminator}: ${x}`);
});

View File

@ -1,40 +0,0 @@
dClient.on("guildMemberAdd", async function(member){
if (member.guild.id == config.guildID)
this.emit("local_guildMemberAdd", member);
});
dClient.on("guildMemberRemove", async function(member){
if (member.guild.id == config.guildID)
this.emit("local_guildMemberRemove", member);
});
dClient.on("guildMemberUpdate", async function(oldMember, newMember){
if (newMember.guild.id == config.guildID)
this.emit("local_guildMemberUpdate", oldMember, newMember);
});
dClient.on("message", async function(message){
if (message.guild && message.guild.id == config.guildID)
this.emit("local_message", message);
});
dClient.on("messageUpdate", async function(oldMessage, newMessage){
if (newMessage.guild && newMessage.guild.id == config.guildID)
this.emit("local_messageUpdate", oldMessage, newMessage);
});
dClient.on("messageDelete", async function(message){
if (message.guild && message.guild.id == config.guildID)
this.emit("local_messageDelete", message);
});
dClient.on("presenceUpdate", async function(oldPresence, newPresence){
if (newPresence.member && newPresence.member.guild.id == config.guildID)
this.emit("local_presenceUpdate", oldPresence, newPresence);
});
dClient.on("voiceStateUpdate", async function(oldState, newState){
if (newState.guild.id == config.guildID)
this.emit("local_voiceStateUpdate", oldState, newState);
});
dClient.on("emojiDelete", async function(emoji){
if (emoji.guild.id == config.guildID)
this.emit("local_emojiDelete", emoji);
});
dClient.on("messageReactionAdd", async function(messageReaction, user){
if (messageReaction.message.guild.id == config.guildID)
this.emit("local_messageReactionAdd", messageReaction, user);
});

22
main.js
View File

@ -5,22 +5,26 @@ if (config.testmode) console.log('TEST MODE');
global.exitHook = require('async-exit-hook');
global.Discord = require('discord.js');
global.fs = require('fs');
global.dClient = new Discord.Client({ disableMentions: 'everyone', restRequestTimeout: 5*60*1000 });
global.dClient = new Discord.Client({
intents: 32767,
allowedMentions: 'none',
restRequestTimeout: 5*60*1000
});
// error handling
{
let webhook = new Discord.WebhookClient(config.webhooks.error[0], config.webhooks.error[1]);
global.onError = function logError(error, title) {
let webhook = new Discord.WebhookClient({url: config.webhooks.error});
global.handleError = function logError(error, title) {
let msg = error && (error.stack || error.message || error);
console.error(title + ':\n', msg);
console.error(title + ':\n' + msg);
try {
webhook.send(`${title ? `**${title}:**` : ""}\`\`\`\n${msg}\n\`\`\``).catch(()=>{});
} catch(e) {}
}
process.on('unhandledRejection', error => onError(error, "Unhandled Rejection"));
exitHook.uncaughtExceptionHandler(error => onError(error, "Uncaught Exception"));
dClient.on('error', error => onError(error, "Discord Client Error"));
dClient.on('warn', error => onError(error, "Discord Client Warning"));
process.on('unhandledRejection', error => handleError(error, "Unhandled Rejection"));
exitHook.uncaughtExceptionHandler(error => handleError(error, "Uncaught Exception"));
dClient.on('error', error => handleError(error, "Discord Client Error"));
dClient.on('warn', error => handleError(error, "Discord Client Warning"));
}
@ -28,9 +32,7 @@ dClient.login(config.DISCORD_TOKEN);
dClient.once('ready', () => {
console.log('Discord Client Ready');
dClient.defaultGuild = dClient.guilds.resolve(config.guildID);
require('./local_events');
require('./commands');
require('./mppbridger');
require('./misc');

105
misc.js
View File

@ -1,93 +1,50 @@
// join/leave
(async function(){
var webhook = new Discord.WebhookClient(config.webhooks.welcome[0], config.webhooks.welcome[1]);
dClient.on('local_guildMemberAdd', async member => {
var webhook = new Discord.WebhookClient({url: config.webhooks.welcome});
dClient.on('guildMemberAdd', async member => {
if (member.guild.id != config.guildID) return;
let username = member.user.username.toLowerCase().includes('clyde') ? member.user.username.replace(/C/g,'Q').replace(/c/g,'q') : member.user.username;
webhook.send(`${member} joined.`, {username, avatarURL: member.user.displayAvatarURL({format:'png',size:2048}), disableMentions:'everyone'});
webhook.send(`${member} joined.`, {username, avatarURL: member.user.displayAvatarURL({format:'png',size:2048})});
});
dClient.on('local_guildMemberRemove', async member => {
dClient.on('guildMemberRemove', async member => {
if (member.guild.id != config.guildID) return;
let username = member.user.username.toLowerCase().includes('clyde') ? member.user.username.replace(/C/g,'Q').replace(/c/g,'q') : member.user.username;
webhook.send(`${member.user.tag} left.`, {username, avatarURL: member.user.displayAvatarURL({format:'png',size:2048}), disableMentions:'everyone'});
webhook.send(`${member.user.tag} left.`, {username, avatarURL: member.user.displayAvatarURL({format:'png',size:2048})});
});
})();
// view deleted channels
(async function(){
var vcid = config.channels.view_deleted_channels;
var rid = config.roles.viewing_deleted_channels;
dClient.on('local_voiceStateUpdate', async (oldState, newState) => {
if (oldState.channelID != vcid && newState.channelID == vcid) {
dClient.on('voiceStateUpdate', async (oldState, newState) => {
if (oldState.channelId != config.channels.view_deleted_channels && newState.channelId == config.channels.view_deleted_channels) {
// member joined the channel
newState.member.roles.add(newState.member.guild.roles.resolve(rid));
} else if (oldState.channelID == vcid && newState.channelID != vcid) {
newState.member.roles.add(config.roles.viewing_deleted_channels);
} else if (oldState.channelId == config.channels.view_deleted_channels && newState.channelId != config.channels.view_deleted_channels) {
// member left the channel
newState.member.roles.remove(newState.member.guild.roles.resolve(rid));
newState.member.roles.remove(config.roles.viewing_deleted_channels);
}
});
})();
// prevent identical display names
/*{
let onName = async function(member){
let names = member.guild.members.map(m => m.name);
if (names.includes(member.displayName)) {
let nam = member.displayName.split(' ');
let num = nam.pop();
if (isNaN(num)) {
nam.push(num);
num = "2";
} else {
num = String(++num);
}
nam = nam.substr(0, num.length-1);
await member.setNickname(`${nam} ${num}`);
}
}
dClient.on("local_guildMemberUpdate", async (oldMember, newMember) => {
if (oldMember.displayName != newMember.displayName) onName(newMember);
});
}*/// didn't work D:
// arrange bots at bottom of list
(async function(){
let prefix = "\u17b5";
let onNick = async member => {
if (member.guild.id != config.guildID) return;
if (member.user.bot && !member.displayName.startsWith(prefix))
await member.setNickname(`${prefix}${member.displayName}`.substr(0,32));
await member.setNickname(`${prefix}${member.displayName}`.substring(0,32));
};
dClient.on('local_guildMemberAdd', onNick);
dClient.on('local_guildMemberUpdate', async (oldMember, newMember) => {
dClient.on('guildMemberAdd', onNick);
dClient.on('guildMemberUpdate', async (oldMember, newMember) => {
if (newMember.displayName != oldMember.displayName) await onNick(newMember);
});
})();
// prevent identical display names
/*(async function(){
dClient.on("local_guildMemberUpdate", async (oldMember, newMember) => {
//var displayNames = newMember.guild.members.map(m => m.displayName);
//if (newMember.nickname && displayNames.includes(newMember.nickname)) newMember.setNickname('');
//else if (displayNames.includes(newMember.displayName)) newMember.setNickname(`${newMember.displayName}_`.substr(0,32));
for (let thisMember of newMember.guild.members) {
thisMember = thisMember[1];
if (thisMember.id == newMember.id) continue; //THIS WAS SUPPOSED TO MAKE IT NOT REPEATEDLY CHANGE YOUR NAME!
if (newMember.nickname == thisMember.displayName) {
newMember.setNickname('');
break;
}
else if (newMember.displayName == thisMember.displayName) {
newMember.setNickname(`${newMember.displayName}_`.substr(0,32));
break;
}
}
});
})();*/
// persistent emojis
dClient.on("local_emojiDelete", async emoji => {
dClient.on("emojiDelete", async emoji => {
console.log("emoji deleted:", emoji.name, emoji.url);
if (global.disableEmojiProtection) return;
if (emoji.name.toLowerCase().includes('delete')) return;
@ -107,32 +64,10 @@ dClient.on("local_emojiDelete", async emoji => {
});
// pinboard // this was removed but no harm leaving it working ¯\_(ツ)_/¯
(async function(){
var webhook = new Discord.WebhookClient(config.webhooks.pinboard[0], config.webhooks.pinboard[1]);
dClient.on("local_messageReactionAdd", async (messageReaction, user) => {
if (!(messageReaction.emoji.name == "📌" || messageReaction.emoji.name == "📍")) return;
if (!(user.id == messageReaction.message.author.id || messageReaction.message.guild.members.resolve(user.id).hasPermission('MANAGE_MESSAGES'))) return;// if message is theirs or user is mod
var message = messageReaction.message;
await webhook.send(`https://discordapp.com/channels/${message.guild.id}/${message.channel.id}/${message.id}`, {embeds:[{
color: (message.member && message.member.displayColor) || undefined,
author: {
name: (message.member && message.member.displayName) || message.author.username,
icon_url: message.author.avatarURL({format:'png'})
},
description: message.content,
timestamp: message.createdAt,
image: (message.attachments.first() && message.attachments.first().width) ? {url:message.attachments.first().url} : undefined,
footer: {
text: `#${message.channel.name}`
}
}]});
});
})();
// allow anyone to pin a message via reaction
dClient.on("local_messageReactionAdd", async (messageReaction) => {
// todo need enable partials for it to work on old messages
dClient.on("messageReactionAdd", async (messageReaction) => {
if (messageReaction.guild.id != config.guildID) return;
if (messageReaction.emoji.name == "📌" || messageReaction.emoji.name == "📍")
await messageReaction.message.pin();
});

View File

@ -3,26 +3,34 @@ var Client = require('./lib/Client.js');
global.createMPPbridge = async function createMPPbridge({room, channel, uri}) {
channel = dClient.channels.resolve(channel);
var webhooks = await channel.fetchWebhooks();
var webhook = webhooks.first() || await channel.createWebhook("sdfadffg");
var webhook = webhooks.filter(w => w.token).first() || await channel.createWebhook("sdfadffg");
// discord message sending
{
{ // discord message sending
let msgBuffer = [];
function _dSend(msg, embed) {
if (!msg && !embed) return console.warn("wtf send empty messag");
if (webhook && !config.testmode) {
function _dSend(options) {
if (options.content.length > 2000) {
options.attachments ||= [];
options.attachments.push(new Discord.MessageAttachment(Buffer.from(options.content), "message.txt"));
delete options.content;
}
let username = gClient.channel && gClient.channel._id || room;
if (username.length > 32) username = username.substr(0,31) + '…';
else if (username.length < 2) username = undefined;
webhook.send(msg, {username, embed, split:{char:''}}).catch(error => {
console.error(`webhook fail in ${channel.id}: ${error.message}`);
channel.send(msg, {embed, split:{char:''}}).catch(error => console.error(`send fail in ${channel.id} after webhook send fail: ${error.message}`));
if (username.length > 80) username = username.substr(0,79) + '…';
webhook.send(Object.assign(options, {username})).catch(error => {
handleError(error, `webhook fail in ${channel.id}`);
channel.send(options).catch(error => handleError(error, `send fail in ${channel.id} after webhook send fail`));
});
}
else channel.send(msg, {embed, split:{char:''}}).catch(error => console.error(`send fail in ${channel.id}: ${error.message}`));
function dSend(msg, options) {
if (arguments.length == 1) options = msg;
else {
options ||= {};
options.content = msg;
}
function dSend(msg) {
msgBuffer.push(msg);
msgBuffer.push(options);
}
setInterval(()=>{
if (msgBuffer.length == 0) return;
@ -46,7 +54,7 @@ global.createMPPbridge = async function createMPPbridge({room, channel, uri}) {
let lastError;
gClient.on("error", error => {
console.error(`[${uri}][${room}]`, error.message);
handleError(error, `[${uri}][${room}]`);
error = error.toString();
if (lastError != error) {
dSend(`**${error.toString()}**`);
@ -156,10 +164,10 @@ global.createMPPbridge = async function createMPPbridge({room, channel, uri}) {
// on notifications
gClient.on('notification', async msg => {
// show notification
_dSend(undefined, {
dSend({embeds:[{
title: msg.title,
description: msg.text || msg.html
});
}]});
// handle bans
if (msg.text && (msg.text.startsWith('Banned from "'+room+'"') || msg.text.startsWith('Currently banned from "'+room+'"'))) {
@ -213,7 +221,7 @@ global.createMPPbridge = async function createMPPbridge({room, channel, uri}) {
try {
bridge.client = await createMPPbridge(bridge);
} catch(e) {
console.error(error.message, JSON.stringify(bridge));
handleError(error, JSON.stringify(bridge));
}
}
})();

352
package-lock.json generated
View File

@ -6,21 +6,75 @@
"": {
"dependencies": {
"async-exit-hook": "^2.0.1",
"discord.js": "^12.5.3",
"discord.js": "^13.5.0",
"dotenv": "^8.2.0",
"socketcluster-client": "^14.2.2",
"ws": "^3.3.2"
}
},
"node_modules/@discordjs/collection": {
"version": "0.1.6",
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.1.6.tgz",
"integrity": "sha512-utRNxnd9kSS2qhyivo9lMlt5qgAUasH2gb7BEOn6p0efFh24gjGomHzWKMAPn2hEReOPQZCJaRKoURwRotKucQ=="
"node_modules/@discordjs/builders": {
"version": "0.11.0",
"resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.11.0.tgz",
"integrity": "sha512-ZTB8yJdJKrKlq44dpWkNUrAtEJEq0gqpb7ASdv4vmq6/mZal5kOv312hQ56I/vxwMre+VIkoHquNUAfnTbiYtg==",
"dependencies": {
"@sindresorhus/is": "^4.2.0",
"discord-api-types": "^0.26.0",
"ts-mixer": "^6.0.0",
"tslib": "^2.3.1",
"zod": "^3.11.6"
},
"node_modules/@discordjs/form-data": {
"engines": {
"node": ">=16.0.0",
"npm": ">=7.0.0"
}
},
"node_modules/@discordjs/collection": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.4.0.tgz",
"integrity": "sha512-zmjq+l/rV35kE6zRrwe8BHqV78JvIh2ybJeZavBi5NySjWXqN3hmmAKg7kYMMXSeiWtSsMoZ/+MQi0DiQWy2lw==",
"engines": {
"node": ">=16.0.0",
"npm": ">=7.0.0"
}
},
"node_modules/@sapphire/async-queue": {
"version": "1.1.9",
"resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.1.9.tgz",
"integrity": "sha512-CbXaGwwlEMq+l1TRu01FJCvySJ1CEFKFclHT48nIfNeZXaAAmmwwy7scUKmYHPUa3GhoMp6Qr1B3eAJux6XgOQ==",
"engines": {
"node": ">=v14.0.0",
"npm": ">=7.0.0"
}
},
"node_modules/@sindresorhus/is": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.2.0.tgz",
"integrity": "sha512-VkE3KLBmJwcCaVARtQpfuKcKv8gcBmUubrfHGF84dXuuW6jgsRYxPtzcIhPyK9WAPpRt2/xY6zkD9MnRaJzSyw==",
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sindresorhus/is?sponsor=1"
}
},
"node_modules/@types/node": {
"version": "17.0.7",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.7.tgz",
"integrity": "sha512-1QUk+WAUD4t8iR+Oj+UgI8oJa6yyxaB8a8pHaC8uqM6RrS1qbL7bf3Pwl5rHv0psm2CuDErgho6v5N+G+5fwtQ=="
},
"node_modules/@types/node-fetch": {
"version": "2.5.12",
"resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.12.tgz",
"integrity": "sha512-MKgC4dlq4kKNa/mYrwpKfzQMB5X3ee5U6fSprkKpToBqBmX4nFZL9cW5jl6sWn+xpRJ7ypWh2yyqqr8UUCstSw==",
"dependencies": {
"@types/node": "*",
"form-data": "^3.0.0"
}
},
"node_modules/@types/node-fetch/node_modules/form-data": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/@discordjs/form-data/-/form-data-3.0.1.tgz",
"integrity": "sha512-ZfFsbgEXW71Rw/6EtBdrP5VxBJy4dthyC0tpQKGKmYFImlmmrykO14Za+BiIVduwjte0jXEBlhSKf0MWbFp9Eg==",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz",
"integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==",
"dependencies": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
@ -30,15 +84,12 @@
"node": ">= 6"
}
},
"node_modules/abort-controller": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz",
"integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==",
"node_modules/@types/ws": {
"version": "8.2.2",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.2.2.tgz",
"integrity": "sha512-NOn5eIcgWLOo6qW8AcuLZ7G8PycXu0xTxxkS6Q18VWFxgPUSOwV0pBj2a/4viNZVu25i7RIB7GttdkAIUUXOOg==",
"dependencies": {
"event-target-shim": "^5.0.0"
},
"engines": {
"node": ">=6.5"
"@types/node": "*"
}
},
"node_modules/async-exit-hook": {
@ -105,31 +156,40 @@
"node": ">=0.4.0"
}
},
"node_modules/discord-api-types": {
"version": "0.26.1",
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.26.1.tgz",
"integrity": "sha512-T5PdMQ+Y1MEECYMV5wmyi9VEYPagEDEi4S0amgsszpWY0VB9JJ/hEvM6BgLhbdnKky4gfmZEXtEEtojN8ZKJQQ==",
"engines": {
"node": ">=12"
}
},
"node_modules/discord.js": {
"version": "12.5.3",
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-12.5.3.tgz",
"integrity": "sha512-D3nkOa/pCkNyn6jLZnAiJApw2N9XrIsXUAdThf01i7yrEuqUmDGc7/CexVWwEcgbQR97XQ+mcnqJpmJ/92B4Aw==",
"deprecated": "no longer supported",
"version": "13.5.0",
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-13.5.0.tgz",
"integrity": "sha512-K+ZcB0f+wA1ZzDhz3hlaAi4Ap7jSvVEUZ+U29T4DMoiNNUv22F4vu1byrOq8GyyLLDFiZ3iSudea0MvSHu3fQA==",
"dependencies": {
"@discordjs/collection": "^0.1.6",
"@discordjs/form-data": "^3.0.1",
"abort-controller": "^3.0.0",
"@discordjs/builders": "^0.11.0",
"@discordjs/collection": "^0.4.0",
"@sapphire/async-queue": "^1.1.9",
"@types/node-fetch": "^2.5.12",
"@types/ws": "^8.2.2",
"discord-api-types": "^0.26.0",
"form-data": "^4.0.0",
"node-fetch": "^2.6.1",
"prism-media": "^1.2.9",
"setimmediate": "^1.0.5",
"tweetnacl": "^1.0.3",
"ws": "^7.4.4"
"ws": "^8.4.0"
},
"engines": {
"node": ">=12.0.0"
"node": ">=16.6.0",
"npm": ">=7.0.0"
}
},
"node_modules/discord.js/node_modules/ws": {
"version": "7.5.3",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.3.tgz",
"integrity": "sha512-kQ/dHIzuLrS6Je9+uv81ueZomEwH0qVYstcAQ4/Z93K8zeko9gtAbttJWzoC5ukqXY1PpoouV3+VSOqEAFt5wg==",
"version": "8.4.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.4.0.tgz",
"integrity": "sha512-IHVsKe2pjajSUIl4KYMQOdlyliovpEPquKkqbwswulszzI7r0SfQrxnXdWAEqOlDCLrVSJzo+O1hAwdog2sKSQ==",
"engines": {
"node": ">=8.3.0"
"node": ">=10.0.0"
},
"peerDependencies": {
"bufferutil": "^4.0.1",
@ -152,10 +212,15 @@
"node": ">=8"
}
},
"node_modules/event-target-shim": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
"integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==",
"node_modules/form-data": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
"dependencies": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
},
"engines": {
"node": ">= 6"
}
@ -171,19 +236,19 @@
"integrity": "sha1-eYsP+X0bkqT9CEgPVa6k6dSdN78="
},
"node_modules/mime-db": {
"version": "1.49.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.49.0.tgz",
"integrity": "sha512-CIc8j9URtOVApSFCQIF+VBkX1RwXp/oMMOrqdyXSBXq5RWNEsRfyj1kiRnQgmNXmHxPoFIxOroKA3zcU9P+nAA==",
"version": "1.51.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz",
"integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "2.1.32",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.32.tgz",
"integrity": "sha512-hJGaVS4G4c9TSMYh2n6SQAGrC4RnfU+daP8G7cSCmaqNjiOoUY0VHCMS42pxnQmVF1GWwFhbHWn3RIxCqTmZ9A==",
"version": "2.1.34",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz",
"integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==",
"dependencies": {
"mime-db": "1.49.0"
"mime-db": "1.51.0"
},
"engines": {
"node": ">= 0.6"
@ -197,31 +262,6 @@
"node": "4.x || >=6.0.0"
}
},
"node_modules/prism-media": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.3.2.tgz",
"integrity": "sha512-L6UsGHcT6i4wrQhFF1aPK+MNYgjRqR2tUoIqEY+CG1NqVkMjPRKzS37j9f8GiYPlD6wG9ruBj+q5Ax+bH8Ik1g==",
"peerDependencies": {
"@discordjs/opus": "^0.5.0",
"ffmpeg-static": "^4.2.7 || ^3.0.0 || ^2.4.0",
"node-opus": "^0.3.3",
"opusscript": "^0.0.8"
},
"peerDependenciesMeta": {
"@discordjs/opus": {
"optional": true
},
"ffmpeg-static": {
"optional": true
},
"node-opus": {
"optional": true
},
"opusscript": {
"optional": true
}
}
},
"node_modules/querystring": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz",
@ -254,11 +294,6 @@
"resolved": "https://registry.npmjs.org/sc-formatter/-/sc-formatter-3.0.2.tgz",
"integrity": "sha512-9PbqYBpCq+OoEeRQ3QfFIGE6qwjjBcd2j7UjgDlhnZbtSnuGgHdcRklPKYGuYFH82V/dwd+AIpu8XvA1zqTd+A=="
},
"node_modules/setimmediate": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz",
"integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU="
},
"node_modules/socketcluster-client": {
"version": "14.3.2",
"resolved": "https://registry.npmjs.org/socketcluster-client/-/socketcluster-client-14.3.2.tgz",
@ -296,10 +331,15 @@
}
}
},
"node_modules/tweetnacl": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz",
"integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw=="
"node_modules/ts-mixer": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.0.tgz",
"integrity": "sha512-nXIb1fvdY5CBSrDIblLn73NW0qRDk5yJ0Sk1qPBF560OdJfQp9jhl+0tzcY09OZ9U+6GpeoI9RjwoIKFIoB9MQ=="
},
"node_modules/tslib": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
},
"node_modules/ultron": {
"version": "1.1.1",
@ -324,30 +364,76 @@
"safe-buffer": "~5.1.0",
"ultron": "~1.1.0"
}
},
"node_modules/zod": {
"version": "3.11.6",
"resolved": "https://registry.npmjs.org/zod/-/zod-3.11.6.tgz",
"integrity": "sha512-daZ80A81I3/9lIydI44motWe6n59kRBfNzTuS2bfzVh1nAXi667TOTWWtatxyG+fwgNUiagSj/CWZwRRbevJIg==",
"funding": {
"url": "https://github.com/sponsors/colinhacks"
}
}
},
"dependencies": {
"@discordjs/collection": {
"version": "0.1.6",
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.1.6.tgz",
"integrity": "sha512-utRNxnd9kSS2qhyivo9lMlt5qgAUasH2gb7BEOn6p0efFh24gjGomHzWKMAPn2hEReOPQZCJaRKoURwRotKucQ=="
"@discordjs/builders": {
"version": "0.11.0",
"resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.11.0.tgz",
"integrity": "sha512-ZTB8yJdJKrKlq44dpWkNUrAtEJEq0gqpb7ASdv4vmq6/mZal5kOv312hQ56I/vxwMre+VIkoHquNUAfnTbiYtg==",
"requires": {
"@sindresorhus/is": "^4.2.0",
"discord-api-types": "^0.26.0",
"ts-mixer": "^6.0.0",
"tslib": "^2.3.1",
"zod": "^3.11.6"
}
},
"@discordjs/form-data": {
"@discordjs/collection": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.4.0.tgz",
"integrity": "sha512-zmjq+l/rV35kE6zRrwe8BHqV78JvIh2ybJeZavBi5NySjWXqN3hmmAKg7kYMMXSeiWtSsMoZ/+MQi0DiQWy2lw=="
},
"@sapphire/async-queue": {
"version": "1.1.9",
"resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.1.9.tgz",
"integrity": "sha512-CbXaGwwlEMq+l1TRu01FJCvySJ1CEFKFclHT48nIfNeZXaAAmmwwy7scUKmYHPUa3GhoMp6Qr1B3eAJux6XgOQ=="
},
"@sindresorhus/is": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.2.0.tgz",
"integrity": "sha512-VkE3KLBmJwcCaVARtQpfuKcKv8gcBmUubrfHGF84dXuuW6jgsRYxPtzcIhPyK9WAPpRt2/xY6zkD9MnRaJzSyw=="
},
"@types/node": {
"version": "17.0.7",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.7.tgz",
"integrity": "sha512-1QUk+WAUD4t8iR+Oj+UgI8oJa6yyxaB8a8pHaC8uqM6RrS1qbL7bf3Pwl5rHv0psm2CuDErgho6v5N+G+5fwtQ=="
},
"@types/node-fetch": {
"version": "2.5.12",
"resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.12.tgz",
"integrity": "sha512-MKgC4dlq4kKNa/mYrwpKfzQMB5X3ee5U6fSprkKpToBqBmX4nFZL9cW5jl6sWn+xpRJ7ypWh2yyqqr8UUCstSw==",
"requires": {
"@types/node": "*",
"form-data": "^3.0.0"
},
"dependencies": {
"form-data": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/@discordjs/form-data/-/form-data-3.0.1.tgz",
"integrity": "sha512-ZfFsbgEXW71Rw/6EtBdrP5VxBJy4dthyC0tpQKGKmYFImlmmrykO14Za+BiIVduwjte0jXEBlhSKf0MWbFp9Eg==",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz",
"integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==",
"requires": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
}
}
}
},
"abort-controller": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz",
"integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==",
"@types/ws": {
"version": "8.2.2",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.2.2.tgz",
"integrity": "sha512-NOn5eIcgWLOo6qW8AcuLZ7G8PycXu0xTxxkS6Q18VWFxgPUSOwV0pBj2a/4viNZVu25i7RIB7GttdkAIUUXOOg==",
"requires": {
"event-target-shim": "^5.0.0"
"@types/node": "*"
}
},
"async-exit-hook": {
@ -402,25 +488,31 @@
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
},
"discord-api-types": {
"version": "0.26.1",
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.26.1.tgz",
"integrity": "sha512-T5PdMQ+Y1MEECYMV5wmyi9VEYPagEDEi4S0amgsszpWY0VB9JJ/hEvM6BgLhbdnKky4gfmZEXtEEtojN8ZKJQQ=="
},
"discord.js": {
"version": "12.5.3",
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-12.5.3.tgz",
"integrity": "sha512-D3nkOa/pCkNyn6jLZnAiJApw2N9XrIsXUAdThf01i7yrEuqUmDGc7/CexVWwEcgbQR97XQ+mcnqJpmJ/92B4Aw==",
"version": "13.5.0",
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-13.5.0.tgz",
"integrity": "sha512-K+ZcB0f+wA1ZzDhz3hlaAi4Ap7jSvVEUZ+U29T4DMoiNNUv22F4vu1byrOq8GyyLLDFiZ3iSudea0MvSHu3fQA==",
"requires": {
"@discordjs/collection": "^0.1.6",
"@discordjs/form-data": "^3.0.1",
"abort-controller": "^3.0.0",
"@discordjs/builders": "^0.11.0",
"@discordjs/collection": "^0.4.0",
"@sapphire/async-queue": "^1.1.9",
"@types/node-fetch": "^2.5.12",
"@types/ws": "^8.2.2",
"discord-api-types": "^0.26.0",
"form-data": "^4.0.0",
"node-fetch": "^2.6.1",
"prism-media": "^1.2.9",
"setimmediate": "^1.0.5",
"tweetnacl": "^1.0.3",
"ws": "^7.4.4"
"ws": "^8.4.0"
},
"dependencies": {
"ws": {
"version": "7.5.3",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.3.tgz",
"integrity": "sha512-kQ/dHIzuLrS6Je9+uv81ueZomEwH0qVYstcAQ4/Z93K8zeko9gtAbttJWzoC5ukqXY1PpoouV3+VSOqEAFt5wg==",
"version": "8.4.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.4.0.tgz",
"integrity": "sha512-IHVsKe2pjajSUIl4KYMQOdlyliovpEPquKkqbwswulszzI7r0SfQrxnXdWAEqOlDCLrVSJzo+O1hAwdog2sKSQ==",
"requires": {}
}
}
@ -430,10 +522,15 @@
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz",
"integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw=="
},
"event-target-shim": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
"integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ=="
"form-data": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
"requires": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
}
},
"ieee754": {
"version": "1.1.13",
@ -446,16 +543,16 @@
"integrity": "sha1-eYsP+X0bkqT9CEgPVa6k6dSdN78="
},
"mime-db": {
"version": "1.49.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.49.0.tgz",
"integrity": "sha512-CIc8j9URtOVApSFCQIF+VBkX1RwXp/oMMOrqdyXSBXq5RWNEsRfyj1kiRnQgmNXmHxPoFIxOroKA3zcU9P+nAA=="
"version": "1.51.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz",
"integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g=="
},
"mime-types": {
"version": "2.1.32",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.32.tgz",
"integrity": "sha512-hJGaVS4G4c9TSMYh2n6SQAGrC4RnfU+daP8G7cSCmaqNjiOoUY0VHCMS42pxnQmVF1GWwFhbHWn3RIxCqTmZ9A==",
"version": "2.1.34",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz",
"integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==",
"requires": {
"mime-db": "1.49.0"
"mime-db": "1.51.0"
}
},
"node-fetch": {
@ -463,12 +560,6 @@
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
},
"prism-media": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.3.2.tgz",
"integrity": "sha512-L6UsGHcT6i4wrQhFF1aPK+MNYgjRqR2tUoIqEY+CG1NqVkMjPRKzS37j9f8GiYPlD6wG9ruBj+q5Ax+bH8Ik1g==",
"requires": {}
},
"querystring": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz",
@ -497,11 +588,6 @@
"resolved": "https://registry.npmjs.org/sc-formatter/-/sc-formatter-3.0.2.tgz",
"integrity": "sha512-9PbqYBpCq+OoEeRQ3QfFIGE6qwjjBcd2j7UjgDlhnZbtSnuGgHdcRklPKYGuYFH82V/dwd+AIpu8XvA1zqTd+A=="
},
"setimmediate": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz",
"integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU="
},
"socketcluster-client": {
"version": "14.3.2",
"resolved": "https://registry.npmjs.org/socketcluster-client/-/socketcluster-client-14.3.2.tgz",
@ -527,10 +613,15 @@
}
}
},
"tweetnacl": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz",
"integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw=="
"ts-mixer": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.0.tgz",
"integrity": "sha512-nXIb1fvdY5CBSrDIblLn73NW0qRDk5yJ0Sk1qPBF560OdJfQp9jhl+0tzcY09OZ9U+6GpeoI9RjwoIKFIoB9MQ=="
},
"tslib": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
},
"ultron": {
"version": "1.1.1",
@ -551,6 +642,11 @@
"safe-buffer": "~5.1.0",
"ultron": "~1.1.0"
}
},
"zod": {
"version": "3.11.6",
"resolved": "https://registry.npmjs.org/zod/-/zod-3.11.6.tgz",
"integrity": "sha512-daZ80A81I3/9lIydI44motWe6n59kRBfNzTuS2bfzVh1nAXi667TOTWWtatxyG+fwgNUiagSj/CWZwRRbevJIg=="
}
}
}

View File

@ -1,7 +1,7 @@
{
"dependencies": {
"async-exit-hook": "^2.0.1",
"discord.js": "^12.5.3",
"discord.js": "^13.5.0",
"dotenv": "^8.2.0",
"socketcluster-client": "^14.2.2",
"ws": "^3.3.2"

View File

@ -23,7 +23,7 @@ class PRClient extends EventEmitter {
this.socket = socketCluster.connect(this.options);
this.socket.connect();
this.socket.on("error", (msg) => {
console.error(msg);
handleError(msg, "pr socket");
})
this.socket.on("connect", () => {
console.log("Connected!")

View File

@ -39,7 +39,7 @@ async function messagehandle(data) {
}
}
dClient.on("local_message", async message => {
dClient.on("messageCreate", async message => {
if (message.channel.id != "593943518351982603" || message.author.id == dClient.user.id) return;
if (!client.roomID) return;
client.socket.publish(client.roomID, {