mainly just fixed voiceStateUpdate, some bugs

This commit is contained in:
ayeuhugyu 2024-01-03 16:50:55 -08:00
parent 921febf278
commit 8c18c71d09
4 changed files with 51 additions and 17 deletions

View file

@ -18,7 +18,8 @@ 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.15 - added p/recent and p/rejoin, p/recent sends the most recently deleted message, p/rejoin calls rejoin function on voice connections. also added some broken code for a voiceStateUpdate event but im too lazy to fix it so ill do that basically never. also deleted some useless line from .gitignore 1.15 - added p/recent and p/rejoin, p/recent sends the most recently deleted message, p/rejoin calls rejoin function on voice connections. also added some broken code for a voiceStateUpdate event but im too lazy to fix it so ill do that basically never. also deleted some useless line from .gitignore
1.15.1 - fixed exploit with recurring p/recents 1.15.1 - fixed exploit with recursive p/recents
1.15.2 - fixed voiceStateUpdate event, also errors now ping me (please don't abuse i will disable it if you do)
--- ---

View file

@ -1,16 +1,49 @@
import { getVoiceConnection } from "@discordjs/voice"; import { getVoiceConnection } from "@discordjs/voice";
export default async function (oldState, newState) { export default async function (oldState, newState, client) {
if ((oldState.channelId = getVoiceConnection(oldState.guild.id))) { if (oldState.channelId === null || typeof oldState.channelId == "undefined") {
if ((newState.channelId = undefined)) { console.log(`voice state update for joining vc, ignoring`);
let channel = await client.channels.cache.get(oldState.channelId);
if (!channel) {
console.log("unable to find voice channel ");
return; return;
} }
memberCount = channel.members.size; const guild = oldState.guild;
if (MemberCount <= 1) {
channel.leave(); let connection;
try {
connection = getVoiceConnection(guild.id);
} catch (err) {
console.log(err);
const debugchannel = client.channels.cache.get("1148814162273763418");
debugchannel.send(
"invalid voiceStateUpdate: no guild found. check console for details"
);
return;
}
if (connection) {
if (connection.joinConfig.channelId === oldState.channelId) {
if (newState.channelId !== undefined) {
console.log(
oldState.guild.members.cache.filter(
(member) =>
member.voice.channelId === connection.joinConfig.channelId
)
);
console.log(
oldState.guild.members.cache.filter(
(member) =>
member.voice.channelId === connection.joinConfig.channelId
).size
);
if (
guild.members.cache.filter(
(member) =>
member.voice.channelId === connection.joinConfig.channelId
).size <= 1
) {
connection.destroy();
console.log(
`destroyed voice connection for guild ${guild.id} in channel ${connection.joinConfig.channelId}`
);
}
} }
} }
} }

View file

@ -23,7 +23,7 @@ client.on("guildMemberAdd", (member) => {
}); });
client.on("messageDelete", async (message) => { client.on("messageDelete", async (message) => {
events.messageDelete(message); events.messageDelete(message, client);
}); });
client.on("messageCreate", async (message) => { client.on("messageCreate", async (message) => {
@ -31,11 +31,11 @@ client.on("messageCreate", async (message) => {
}); });
client.on("interactionCreate", (interaction) => { client.on("interactionCreate", (interaction) => {
events.interactionCreate(interaction); events.interactionCreate(interaction, client);
}); });
client.on("voiceStateUpdate", (oldState, newState) => { client.on("voiceStateUpdate", (oldState, newState) => {
events.voiceStateUpdate(oldState, newState); events.voiceStateUpdate(oldState, newState, client);
}); });
register(); register();

View file

@ -20,10 +20,10 @@ export function sendError(message) {
const channel = client.channels.cache.get("1148814162273763418"); const channel = client.channels.cache.get("1148814162273763418");
let msg; let msg;
try { try {
msg = channel.send(`**error:** ${message}`); msg = channel.send(`**error:** ${message}
<@440163494529073152> you fucked something`);
console.log(message); console.log(message);
} catch (err) { } catch (err) {
sendError(err.rawError.message);
console.log(err); console.log(err);
return undefined; return undefined;
} }