by popular request (i kept forgetting) the latest version of pepperbot has been published. inclides new blacklist feature (for my own amusement,) random sound, and tons of bug fixes
This commit is contained in:
parent
8c595a9a01
commit
11a76b04ca
6 changed files with 67 additions and 50 deletions
|
@ -28,7 +28,8 @@ export default {
|
|||
filename.endsWith(".mp3") ||
|
||||
filename.endsWith(".wav") ||
|
||||
filename.endsWith(".ogg") ||
|
||||
filename.endsWith(".webm")
|
||||
filename.endsWith(".webm") ||
|
||||
filename.endsWith(".m4a")
|
||||
) {
|
||||
const filenameNoExtension = filename.split(".")[0];
|
||||
const files = fs.readdirSync("resources/soundboard");
|
||||
|
@ -95,7 +96,7 @@ export default {
|
|||
} else {
|
||||
action.reply(
|
||||
message,
|
||||
`invalid file extention; only \`mp3\`, \`wav\`, and \`ogg\` files are supported. \`${
|
||||
`invalid file extention; only \`mp3\`, \`wav\`, \`ogg\`, \`webm\`, and \`m4a\` files are supported. \`${
|
||||
filename.split(".")[1]
|
||||
}\` is not.`
|
||||
);
|
||||
|
|
|
@ -18,7 +18,7 @@ export default {
|
|||
throw "crash command executed";
|
||||
} else {
|
||||
action.reply(message, "UNAUTHORIZED");
|
||||
const path = require("path");
|
||||
return;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -34,6 +34,8 @@ export default {
|
|||
wav: proposedfilename + ".wav",
|
||||
spacedwebm: proposedfilename.replaceAll(" ", "_") + ".webm",
|
||||
webm: proposedfilename + ".webm",
|
||||
spacedm4a: proposedfilename.replaceAll(" ", "_") + ".m4a",
|
||||
m4a: proposedfilename + ".m4a",
|
||||
};
|
||||
for (const value of Object.values(possibleFilenames)) {
|
||||
if (files.includes(value)) {
|
||||
|
@ -63,6 +65,7 @@ export default {
|
|||
"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
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (!lsmode) {
|
||||
const audioResource = createAudioResource(`resources/soundboard/${file}`);
|
||||
|
@ -90,6 +93,7 @@ export default {
|
|||
connection = getVoiceConnection(message.guild.id);
|
||||
connection.subscribe(audioPlayer);
|
||||
audioPlayer.play(audioResource);
|
||||
action.reply(message, `playing \`${file}\``);
|
||||
} else {
|
||||
action.sendMessage(message.channelId, {
|
||||
files: [
|
||||
|
|
|
@ -30,13 +30,16 @@ function parseargs(string) {
|
|||
const prefix = process.env.PREFIX;
|
||||
|
||||
export default function (message, client) {
|
||||
const blacklistnosplit = fs.readFileSync("data/blacklisted.log", "utf8");
|
||||
const blacklist = blacklistnosplit.split("\n");
|
||||
|
||||
if (message.channel.type === 1) {
|
||||
log(
|
||||
"directmessages.log",
|
||||
message,
|
||||
import.meta.url,
|
||||
`direct message from ${message.author.username} (${message.author}) with:
|
||||
"${message.content}"`
|
||||
\`"${message.content}"\``
|
||||
);
|
||||
const channel = client.channels.cache.get("1148814162273763418");
|
||||
channel.send(
|
||||
|
@ -44,6 +47,10 @@ export default function (message, client) {
|
|||
);
|
||||
}
|
||||
if (!message.content.startsWith(prefix)) return;
|
||||
if (blacklist.includes(message.author.id)) {
|
||||
message.reply("blacklisted smh");
|
||||
return;
|
||||
}
|
||||
|
||||
const command = message.content
|
||||
.slice(prefix.length)
|
||||
|
@ -54,24 +61,16 @@ export default function (message, client) {
|
|||
|
||||
if (!commands.has(command)) {
|
||||
message.reply("idiot thats not a command");
|
||||
log(
|
||||
"failed.log",
|
||||
message,
|
||||
import.meta.url,
|
||||
`attempt to use invalid command: ${command} by: ${message.author.username} (${message.author})"`
|
||||
);
|
||||
}
|
||||
|
||||
if (commands.get(command)) {
|
||||
log(
|
||||
"commands.log",
|
||||
message,
|
||||
import.meta.url,
|
||||
`use of command: ${command} by: ${message.author.username} (\`${message.author}\`)"`,
|
||||
true
|
||||
);
|
||||
(async () => {
|
||||
commands.get(command).execute(message, args, client);
|
||||
})();
|
||||
return;
|
||||
}
|
||||
log(
|
||||
"commands.log",
|
||||
message,
|
||||
import.meta.url,
|
||||
`use of command: ${command} by: ${message.author.username} (\`${message.author}\`)"`,
|
||||
true
|
||||
);
|
||||
(async () => {
|
||||
commands.get(command).execute(message, args, client);
|
||||
})();
|
||||
}
|
||||
|
|
|
@ -4,17 +4,24 @@ import * as index from "../index.js";
|
|||
const client = index.client;
|
||||
|
||||
export async function sendMainMessage(message) {
|
||||
const channel = client.channels.cache.get("1148814162273763418");
|
||||
const msg = await channel.send(message.slice(0, 2000));
|
||||
return msg;
|
||||
try {
|
||||
const channel = client.channels.cache.get("1148814162273763418");
|
||||
const msg = await channel.send(message);
|
||||
return msg;
|
||||
} catch (err) {
|
||||
sendError(toString(err).slice(err.length - 1750, err.length));
|
||||
console.log(err);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export function sendError(message) {
|
||||
const channel = client.channels.cache.get("1148814162273763418");
|
||||
let msg;
|
||||
try {
|
||||
msg = channel.send(`**error:** ${message.slice(0, 1750)}`);
|
||||
msg = channel.send(`**error:** ${message}`);
|
||||
} catch (err) {
|
||||
sendError(err.rawError.message);
|
||||
console.log(err);
|
||||
return undefined;
|
||||
}
|
||||
|
@ -27,7 +34,13 @@ export function messageDelete(message) {
|
|||
return undefined;
|
||||
}
|
||||
if (message.deletable) {
|
||||
message.delete();
|
||||
try {
|
||||
message.delete();
|
||||
} catch (err) {
|
||||
sendError(err.rawError.message);
|
||||
console.log(err);
|
||||
return undefined;
|
||||
}
|
||||
} else {
|
||||
sendError(
|
||||
`unable to delete message: ${message.url}. most likely caused by invalid permissions`
|
||||
|
@ -39,33 +52,29 @@ export function messageDelete(message) {
|
|||
}
|
||||
}
|
||||
|
||||
export function sendMessage(channelId, message) {
|
||||
(async () => {
|
||||
const channel = client.channels.cache.get(channelId);
|
||||
let msg;
|
||||
if (channel) {
|
||||
try {
|
||||
msg = await channel.send(message.slice(0, 2000));
|
||||
return msg;
|
||||
} catch (err) {
|
||||
sendError(err.slice(err.length - 1750, err.length));
|
||||
console.log(err);
|
||||
return undefined;
|
||||
}
|
||||
} else {
|
||||
sendError(`unable to find channel: <#${channelId}>`);
|
||||
export async function sendMessage(channelId, message) {
|
||||
const channel = client.channels.cache.get(channelId);
|
||||
let msg;
|
||||
if (channel) {
|
||||
try {
|
||||
msg = await channel.send(message);
|
||||
return msg;
|
||||
} catch (err) {
|
||||
sendError(err.rawError.message);
|
||||
console.log(err);
|
||||
return undefined;
|
||||
}
|
||||
})();
|
||||
} else {
|
||||
sendError(`unable to find channel: <#${channelId}>`);
|
||||
}
|
||||
}
|
||||
|
||||
export function reply(triggerMessage, message) {
|
||||
export async function reply(triggerMessage, message) {
|
||||
try {
|
||||
(async () => {
|
||||
let msg = await triggerMessage.reply(message.slice(0, 2000));
|
||||
return msg;
|
||||
})();
|
||||
let msg = await triggerMessage.reply(message);
|
||||
return msg;
|
||||
} catch (err) {
|
||||
sendError(err.slice(err.length - 1750, err.length));
|
||||
sendError(err.rawError.message);
|
||||
console.log(err);
|
||||
return undefined;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue