added p/recent and p/rejoin/other fixes
This commit is contained in:
parent
963136bf74
commit
89b75481e9
12 changed files with 156 additions and 16 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,5 +1,4 @@
|
|||
.env
|
||||
src/logs
|
||||
node_modules/
|
||||
src/commands/cbrowser.js
|
||||
src/commands/cbrowser.disabled
|
||||
|
|
|
@ -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._
|
||||
|
||||
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.14 - added announcement system, bug fixes
|
||||
|
||||
---
|
||||
|
|
67
package-lock.json
generated
67
package-lock.json
generated
|
@ -14,6 +14,7 @@
|
|||
"discord.js-collector": "^1.8.9",
|
||||
"dotenv": "^16.3.1",
|
||||
"emoji-regex": "^10.2.1",
|
||||
"fs-extra": "^11.2.0",
|
||||
"libsodium-wrappers": "^0.7.13",
|
||||
"openai": "^4.17.0",
|
||||
"regex": "^0.1.1",
|
||||
|
@ -685,6 +686,19 @@
|
|||
"node": ">= 14"
|
||||
}
|
||||
},
|
||||
"node_modules/fs-extra": {
|
||||
"version": "11.2.0",
|
||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.2.0.tgz",
|
||||
"integrity": "sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw==",
|
||||
"dependencies": {
|
||||
"graceful-fs": "^4.2.0",
|
||||
"jsonfile": "^6.0.1",
|
||||
"universalify": "^2.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.14"
|
||||
}
|
||||
},
|
||||
"node_modules/getpass": {
|
||||
"version": "0.1.7",
|
||||
"resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz",
|
||||
|
@ -693,6 +707,11 @@
|
|||
"assert-plus": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/graceful-fs": {
|
||||
"version": "4.2.11",
|
||||
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
|
||||
"integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ=="
|
||||
},
|
||||
"node_modules/har-schema": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz",
|
||||
|
@ -816,6 +835,17 @@
|
|||
"resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
|
||||
"integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA=="
|
||||
},
|
||||
"node_modules/jsonfile": {
|
||||
"version": "6.1.0",
|
||||
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz",
|
||||
"integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==",
|
||||
"dependencies": {
|
||||
"universalify": "^2.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"graceful-fs": "^4.1.6"
|
||||
}
|
||||
},
|
||||
"node_modules/JSONSelect": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/JSONSelect/-/JSONSelect-0.4.0.tgz",
|
||||
|
@ -1485,6 +1515,14 @@
|
|||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
|
||||
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA=="
|
||||
},
|
||||
"node_modules/universalify": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz",
|
||||
"integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==",
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/uri-js": {
|
||||
"version": "4.4.1",
|
||||
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
|
||||
|
@ -2080,6 +2118,16 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"fs-extra": {
|
||||
"version": "11.2.0",
|
||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.2.0.tgz",
|
||||
"integrity": "sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw==",
|
||||
"requires": {
|
||||
"graceful-fs": "^4.2.0",
|
||||
"jsonfile": "^6.0.1",
|
||||
"universalify": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"getpass": {
|
||||
"version": "0.1.7",
|
||||
"resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz",
|
||||
|
@ -2088,6 +2136,11 @@
|
|||
"assert-plus": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"graceful-fs": {
|
||||
"version": "4.2.11",
|
||||
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
|
||||
"integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ=="
|
||||
},
|
||||
"har-schema": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz",
|
||||
|
@ -2188,6 +2241,15 @@
|
|||
"resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
|
||||
"integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA=="
|
||||
},
|
||||
"jsonfile": {
|
||||
"version": "6.1.0",
|
||||
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz",
|
||||
"integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==",
|
||||
"requires": {
|
||||
"graceful-fs": "^4.1.6",
|
||||
"universalify": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"JSONSelect": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/JSONSelect/-/JSONSelect-0.4.0.tgz",
|
||||
|
@ -2699,6 +2761,11 @@
|
|||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
|
||||
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA=="
|
||||
},
|
||||
"universalify": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz",
|
||||
"integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw=="
|
||||
},
|
||||
"uri-js": {
|
||||
"version": "4.4.1",
|
||||
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
"discord.js-collector": "^1.8.9",
|
||||
"dotenv": "^16.3.1",
|
||||
"emoji-regex": "^10.2.1",
|
||||
"fs-extra": "^11.2.0",
|
||||
"libsodium-wrappers": "^0.7.13",
|
||||
"openai": "^4.17.0",
|
||||
"regex": "^0.1.1",
|
||||
|
|
|
@ -30,7 +30,8 @@ export default {
|
|||
filename.endsWith(".ogg") ||
|
||||
filename.endsWith(".webm") ||
|
||||
filename.endsWith(".m4a") ||
|
||||
filename.endsWith(".mp4")
|
||||
filename.endsWith(".mp4") ||
|
||||
filename.endsWith(".midi")
|
||||
) {
|
||||
const filenameNoExtension = filename.split(".")[0];
|
||||
const files = fs.readdirSync("resources/soundboard");
|
||||
|
|
26
src/commands/recent.js
Normal file
26
src/commands/recent.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
import fs from "fs";
|
||||
import * as action from "../util/discordAction.js";
|
||||
|
||||
export default {
|
||||
name: "recent",
|
||||
description: "sends most recent deleted message",
|
||||
execute(message, args) {
|
||||
try {
|
||||
const recent = fs.readFileSync(
|
||||
`./logs/deletedmessages/${message.guild.id}.log`
|
||||
);
|
||||
} catch (err) {
|
||||
action.reply(
|
||||
message,
|
||||
"pepperbot has yet to log a deleted message in this server"
|
||||
);
|
||||
console.log(err);
|
||||
return;
|
||||
}
|
||||
const recent = fs.readFileSync(
|
||||
`../pepperbot/logs/deletedmessages/${message.guild.id}.log`,
|
||||
"utf8"
|
||||
);
|
||||
action.sendMessage(message.channelId, recent);
|
||||
},
|
||||
};
|
20
src/commands/rejoin.js
Normal file
20
src/commands/rejoin.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
import { getVoiceConnection } from "@discordjs/voice";
|
||||
import * as action from "../util/discordAction.js";
|
||||
|
||||
export default {
|
||||
name: "rejoin",
|
||||
description: "Rejoin the voice channel",
|
||||
execute(message, args) {
|
||||
const connection = getVoiceConnection(message.guild.id);
|
||||
if (connection) {
|
||||
try {
|
||||
connection.rejoin();
|
||||
action.reply(message, "remade voice connection");
|
||||
} catch (err) {
|
||||
action.sendError(err);
|
||||
}
|
||||
} else {
|
||||
action.reply(message, "no active voice connection in this guild");
|
||||
}
|
||||
},
|
||||
};
|
|
@ -36,6 +36,8 @@ export default {
|
|||
webm: proposedfilename + ".webm",
|
||||
spacedm4a: proposedfilename.replaceAll(" ", "_") + ".m4a",
|
||||
m4a: proposedfilename + ".m4a",
|
||||
spacedmp4: proposedfilename.replaceAll(" ", "_") + ".mp4",
|
||||
mp4: proposedfilename + ".mp4",
|
||||
};
|
||||
for (const value of Object.values(possibleFilenames)) {
|
||||
if (files.includes(value)) {
|
||||
|
|
|
@ -3,6 +3,7 @@ import { default as messageCreate } from "./messageCreate.js";
|
|||
import { default as messageDelete } from "./messageDelete.js";
|
||||
import { default as ready } from "./ready.js";
|
||||
import { default as interactionCreate } from "./interactionCreate.js";
|
||||
import { default as voiceStateUpdate } from "./voiceStateUpdate.js";
|
||||
|
||||
const events = {
|
||||
guildMemberAdd,
|
||||
|
@ -10,6 +11,7 @@ const events = {
|
|||
messageDelete,
|
||||
ready,
|
||||
interactionCreate,
|
||||
voiceStateUpdate,
|
||||
};
|
||||
|
||||
export default events;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import { default as log } from "../util/log.js";
|
||||
import fs from "fs";
|
||||
import fsextra from "fs-extra";
|
||||
|
||||
export default function (message) {
|
||||
try {
|
||||
|
@ -9,19 +11,14 @@ export default function (message) {
|
|||
`deleted message from ${message.author.username} (${message.author}) with: "${message.content}"`,
|
||||
true
|
||||
);
|
||||
} catch {
|
||||
function sendError(message) {
|
||||
const channel = client.channels.cache.get("1148814162273763418");
|
||||
let msg;
|
||||
try {
|
||||
msg = channel.send(`**error:** ${message}`);
|
||||
} catch (err) {
|
||||
sendError(err.rawError.message);
|
||||
console.log(err);
|
||||
return undefined;
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
sendError("undefined error");
|
||||
fsextra.ensureFileSync(
|
||||
`../pepperbot/logs/deletedmessages/${message.guild.id}.log`
|
||||
);
|
||||
fs.writeFileSync(
|
||||
`../pepperbot/logs/deletedmessages/${message.guild.id}.log`,
|
||||
message.content
|
||||
);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
|
|
17
src/events/voiceStateUpdate.js
Normal file
17
src/events/voiceStateUpdate.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
import { getVoiceConnection } from "@discordjs/voice";
|
||||
|
||||
export default async function (oldState, newState) {
|
||||
if ((oldState.channelId = getVoiceConnection(oldState.guild.id))) {
|
||||
if ((newState.channelId = undefined)) {
|
||||
let channel = await client.channels.cache.get(oldState.channelId);
|
||||
if (!channel) {
|
||||
console.log("unable to find voice channel");
|
||||
return;
|
||||
}
|
||||
memberCount = channel.members.size;
|
||||
if (MemberCount <= 1) {
|
||||
channel.leave();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -34,6 +34,10 @@ client.on("interactionCreate", (interaction) => {
|
|||
events.interactionCreate(interaction);
|
||||
});
|
||||
|
||||
client.on("voiceStateUpdate", (oldState, newState) => {
|
||||
events.voiceStateUpdate(oldState, newState);
|
||||
});
|
||||
|
||||
register();
|
||||
|
||||
client.login(process.env.TOKEN);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue