Merge branch 'omnibus' of https://github.com/keanuplayz/TravBot-v3 into omnibus

This commit is contained in:
WatDuhHekBro 2021-04-11 05:46:10 -05:00
commit 06e122931f
32 changed files with 89 additions and 72 deletions

View File

@ -30,7 +30,7 @@ export default new NamedCommand({
run: "Please provide a question.",
any: new Command({
description: "Question to ask the 8-ball.",
async run({send, message, channel, guild, author, member, client, args}) {
async run({send, message}) {
const sender = message.author;
send(`${random(responses)} <@${sender.id}>`);
}

View File

@ -31,7 +31,7 @@ export default new NamedCommand({
run: ":cookie: Here's a cookie!",
subcommands: {
all: new NamedCommand({
async run({send, message, channel, guild, author, member, client, args}) {
async run({send, author}) {
send(`${author} gave everybody a cookie!`);
}
})
@ -39,7 +39,7 @@ export default new NamedCommand({
id: "user",
user: new Command({
description: "User to give cookie to.",
async run({send, message, channel, guild, author, member, client, args}) {
async run({send, author, args}) {
const sender = author;
const mention: User = args[0];

View File

@ -34,7 +34,7 @@ export default new NamedCommand({
}),
any: new RestCommand({
description: "See how much money someone else has by using their username.",
async run({send, guild, channel, args, message, combined}) {
async run({send, guild, channel, combined}) {
if (isAuthorized(guild, channel)) {
const member = await getMemberByName(guild!, combined);
if (typeof member !== "string") send(getMoneyEmbed(member.user));

View File

@ -1,11 +1,11 @@
import {Command, NamedCommand, RestCommand} from "../../core";
import {NamedCommand, RestCommand} from "../../core";
import figlet from "figlet";
export default new NamedCommand({
description: "Generates a figlet of your input.",
run: "You have to provide input for me to create a figlet!",
any: new RestCommand({
async run({send, message, channel, guild, author, member, client, args, combined}) {
async run({send, combined}) {
return send(
figlet.textSync(combined, {
horizontalLayout: "full"

View File

@ -1,8 +1,8 @@
import {Command, NamedCommand} from "../../core";
import {NamedCommand} from "../../core";
export default new NamedCommand({
description: "Insult TravBot! >:D",
async run({send, message, channel, guild, author, member, client, args}) {
async run({send, channel, author}) {
channel.startTyping();
setTimeout(() => {
send(

View File

@ -1,9 +1,9 @@
import {Command, NamedCommand, CHANNEL_TYPE} from "../../core";
import {NamedCommand, CHANNEL_TYPE} from "../../core";
export default new NamedCommand({
description: "Chooses someone to love.",
channelType: CHANNEL_TYPE.GUILD,
async run({send, message, channel, guild, author, client, args}) {
async run({send, guild}) {
const member = guild!.members.cache.random();
send(`I love ${member.nickname ?? member.user.username}!`);
}

View File

@ -36,12 +36,12 @@ const endpoints: {sfw: {[key: string]: string}} = {
export default new NamedCommand({
description: "Provides you with a random image with the selected argument.",
async run({send, message, channel, guild, author, member, client, args}) {
async run({send}) {
send(`Please provide an image type. Available arguments:\n\`[${Object.keys(endpoints.sfw).join(", ")}]\`.`);
},
any: new Command({
description: "Image type to send.",
async run({send, message, channel, guild, author, member, client, args}) {
async run({send, args}) {
const arg = args[0];
if (!(arg in endpoints.sfw)) return send("Couldn't find that endpoint!");
let url = new URL(`https://nekos.life/api/v2${endpoints.sfw[arg]}`);

View File

@ -1,4 +1,4 @@
import {Command, NamedCommand} from "../../core";
import {NamedCommand} from "../../core";
import {random} from "../../lib";
const responses = [
@ -61,7 +61,7 @@ const responses = [
export default new NamedCommand({
description: "Sends random ok message.",
async run({send, message, channel, guild, author, member, client, args}) {
async run({send}) {
send(`ok ${random(responses)}`);
}
});

View File

@ -1,4 +1,4 @@
import {Command, NamedCommand, RestCommand} from "../../core";
import {NamedCommand, RestCommand} from "../../core";
import {getContent} from "../../lib";
import {URL} from "url";
@ -6,7 +6,7 @@ export default new NamedCommand({
description: "OwO-ifies the input.",
run: "You need to specify some text to owoify.",
any: new RestCommand({
async run({send, message, channel, guild, author, member, client, args, combined}) {
async run({send, combined}) {
let url = new URL(`https://nekos.life/api/v2/owoify?text=${combined}`);
const content = (await getContent(url.toString())) as any; // Apparently, the object in question is {owo: string}.
send(content.owo);

View File

@ -1,8 +1,8 @@
import {Command, NamedCommand} from "../../core";
import {NamedCommand} from "../../core";
export default new NamedCommand({
description: "Initiates a celebratory stream from the bot.",
async run({send, message, channel, guild, author, member, client, args}) {
async run({send, client}) {
send("This calls for a celebration!");
client.user!.setActivity({
type: "STREAMING",

View File

@ -1,5 +1,5 @@
import {MessageEmbed} from "discord.js";
import {Command, NamedCommand, RestCommand} from "../../core";
import {NamedCommand, RestCommand} from "../../core";
export default new NamedCommand({
description: "Create a poll.",
@ -7,7 +7,7 @@ export default new NamedCommand({
run: "Please provide a question.",
any: new RestCommand({
description: "Question for the poll.",
async run({send, message, channel, guild, author, member, client, args, combined}) {
async run({send, message, combined}) {
const embed = new MessageEmbed()
.setAuthor(
`Poll created by ${message.author.username}`,

View File

@ -4,7 +4,7 @@ import {Random} from "../../lib";
export default new NamedCommand({
description: "Ravioli ravioli...",
usage: "[number from 1 to 9]",
async run({send, message, channel, guild, author, member, client, args}) {
async run({send}) {
send({
embed: {
title: "Ravioli ravioli...",
@ -18,7 +18,7 @@ export default new NamedCommand({
});
},
number: new Command({
async run({send, message, channel, guild, author, member, client, args}) {
async run({send, args}) {
const arg: number = args[0];
if (arg >= 1 && arg <= 9) {

View File

@ -1,4 +1,4 @@
import {Command, NamedCommand, RestCommand} from "../../core";
import {NamedCommand, RestCommand} from "../../core";
const letters: {[letter: string]: string[]} = {
a: "aáàảãạâấầẩẫậăắằẳẵặ".split(""),
@ -34,7 +34,7 @@ let phrase = "I have no currently set phrase!";
export default new NamedCommand({
description: "Transforms your text into .",
usage: "thonk ([text])",
async run({send, message, channel, guild, author, member, client, args}) {
async run({send, author}) {
const msg = await send(transform(phrase));
msg.createReactionCollector(
(reaction, user) => {
@ -45,7 +45,7 @@ export default new NamedCommand({
);
},
any: new RestCommand({
async run({send, message, channel, guild, author, member, client, args, combined}) {
async run({send, author, combined}) {
const msg = await send(transform(combined));
msg.createReactionCollector(
(reaction, user) => {

View File

@ -1,4 +1,4 @@
import {Command, NamedCommand, RestCommand} from "../../core";
import {NamedCommand, RestCommand} from "../../core";
import {MessageEmbed} from "discord.js";
import urban from "relevant-urban";
@ -6,7 +6,7 @@ export default new NamedCommand({
description: "Gives you a definition of the inputted word.",
run: "Please input a word.",
any: new RestCommand({
async run({send, message, channel, guild, author, member, client, args, combined}) {
async run({send, combined}) {
// [Bug Fix]: Use encodeURIComponent() when emojis are used: "TypeError [ERR_UNESCAPED_CHARACTERS]: Request path contains unescaped characters"
urban(encodeURIComponent(combined))
.then((res) => {

View File

@ -1,4 +1,4 @@
import {Command, NamedCommand, RestCommand} from "../../core";
import {NamedCommand, RestCommand} from "../../core";
const vaporwave = (() => {
const map = new Map<string, string>();
@ -25,7 +25,7 @@ export default new NamedCommand({
description: "Transforms your text into .",
run: "You need to enter some text!",
any: new RestCommand({
async run({send, message, channel, guild, author, member, client, args, combined}) {
async run({send, combined}) {
const text = getVaporwaveText(combined);
if (text !== "") send(text);
else send("Make sure to enter at least one valid character.");

View File

@ -1,4 +1,4 @@
import {Command, NamedCommand, RestCommand} from "../../core";
import {NamedCommand, RestCommand} from "../../core";
import {MessageEmbed} from "discord.js";
import {find} from "weather-js";
@ -6,7 +6,7 @@ export default new NamedCommand({
description: "Shows weather info of specified location.",
run: "You need to provide a city.",
any: new RestCommand({
async run({send, message, channel, guild, author, member, client, args, combined}) {
async run({send, combined}) {
find(
{
search: combined,

View File

@ -43,7 +43,7 @@ const registry: {[id: string]: string} = {
export default new NamedCommand({
description: "Tells you who you or the specified user is.",
aliases: ["whoami"],
async run({send, message, channel, guild, author, member, client, args}) {
async run({send, author}) {
const id = author.id;
if (id in registry) {
@ -54,7 +54,7 @@ export default new NamedCommand({
},
id: "user",
user: new Command({
async run({send, message, channel, guild, author, member, client, args}) {
async run({send, args}) {
const user: User = args[0];
const id = user.id;
@ -67,7 +67,7 @@ export default new NamedCommand({
}),
any: new RestCommand({
channelType: CHANNEL_TYPE.GUILD,
async run({send, message, channel, guild, author, client, args, combined}) {
async run({send, guild, combined}) {
const member = await getMemberByName(guild!, combined);
if (typeof member !== "string") {

View File

@ -1,4 +1,4 @@
import {Command, NamedCommand, RestCommand} from "../../core";
import {NamedCommand, RestCommand} from "../../core";
import * as math from "mathjs";
import {MessageEmbed} from "discord.js";
@ -6,7 +6,7 @@ export default new NamedCommand({
description: "Calculates a specified math expression.",
run: "Please provide a calculation.",
any: new RestCommand({
async run({send, message, channel, guild, author, member, client, args, combined}) {
async run({send, combined}) {
let resp;
try {
resp = math.evaluate(combined);

View File

@ -1,4 +1,4 @@
import {Command, NamedCommand} from "../../core";
import {NamedCommand} from "../../core";
export default new NamedCommand({
description: "Gives you the Github link.",

View File

@ -1,11 +1,11 @@
import {Command, NamedCommand, RestCommand} from "../../core";
import {NamedCommand, RestCommand} from "../../core";
export default new NamedCommand({
description: "Renames current voice channel.",
usage: "<name>",
run: "Please provide a new voice channel name.",
any: new RestCommand({
async run({send, message, channel, guild, author, member, client, args, combined}) {
async run({send, message, combined}) {
const voiceChannel = message.member?.voice.channel;
if (!voiceChannel) return send("You are not in a voice channel.");

View File

@ -0,0 +1,17 @@
import {NamedCommand, RestCommand} from "../../core";
import {URL} from "url";
import {getContent} from "../../lib";
export default new NamedCommand({
description: "Provides you with info from the Discord.JS docs.",
run: "You need to specify a term to query the docs with.",
any: new RestCommand({
description: "What to query the docs with.",
async run({send, args}) {
var queryString = args[0];
let url = new URL(`https://djsdocs.sorta.moe/v2/embed?src=master&q=${queryString}`);
const content = await getContent(url.toString());
return send({embed: content});
}
})
});

View File

@ -1,4 +1,4 @@
import {Command, NamedCommand, RestCommand} from "../../core";
import {NamedCommand, RestCommand} from "../../core";
import {processEmoteQueryFormatted} from "./modules/emote-utils";
export default new NamedCommand({
@ -8,7 +8,7 @@ export default new NamedCommand({
any: new RestCommand({
description: "The emote(s) to send.",
usage: "<emotes...>",
async run({send, guild, channel, message, args}) {
async run({send, args}) {
const output = processEmoteQueryFormatted(args);
if (output.length > 0) send(output);
}

View File

@ -8,20 +8,20 @@ import moment, {utc} from "moment";
export default new NamedCommand({
description: "Command to provide all sorts of info about the current server, a user, etc.",
async run({send, message, channel, guild, author, member, client, args}) {
async run({send, author, member}) {
send(await getUserInfo(author, member));
},
subcommands: {
avatar: new NamedCommand({
description: "Shows your own, or another user's avatar.",
usage: "(<user>)",
async run({send, message, channel, guild, author, member, client, args}) {
async run({send, author}) {
send(author.displayAvatarURL({dynamic: true, size: 2048}));
},
id: "user",
user: new Command({
description: "Shows your own, or another user's avatar.",
async run({send, message, channel, guild, author, member, client, args}) {
async run({send, args}) {
send(
args[0].displayAvatarURL({
dynamic: true,
@ -33,7 +33,7 @@ export default new NamedCommand({
any: new RestCommand({
description: "Shows another user's avatar by searching their name",
channelType: CHANNEL_TYPE.GUILD,
async run({send, message, channel, guild, author, client, args, combined}) {
async run({send, guild, combined}) {
const member = await getMemberByName(guild!, combined);
if (typeof member !== "string") {
@ -51,7 +51,7 @@ export default new NamedCommand({
}),
bot: new NamedCommand({
description: "Displays info about the bot.",
async run({send, message, channel, guild, author, member, client, args}) {
async run({send, guild, client}) {
const core = os.cpus()[0];
const embed = new MessageEmbed()
.setColor(guild?.me?.displayHexColor || "BLUE")
@ -94,20 +94,20 @@ export default new NamedCommand({
description: "Displays info about the current guild or another guild.",
usage: "(<guild name>/<guild ID>)",
channelType: CHANNEL_TYPE.GUILD,
async run({send, message, channel, guild, author, member, client, args}) {
async run({send, guild}) {
send(await getGuildInfo(guild!, guild));
},
id: "guild",
guild: new Command({
description: "Display info about a guild by its ID.",
async run({send, message, channel, guild, author, member, client, args}) {
async run({send, guild, args}) {
const targetGuild = args[0] as Guild;
send(await getGuildInfo(targetGuild, guild));
}
}),
any: new RestCommand({
description: "Display info about a guild by finding its name.",
async run({send, message, channel, guild, author, member, client, args, combined}) {
async run({send, guild, combined}) {
const targetGuild = getGuildByName(combined);
if (typeof targetGuild !== "string") {
@ -122,7 +122,7 @@ export default new NamedCommand({
id: "user",
user: new Command({
description: "Displays info about mentioned user.",
async run({send, message, channel, guild, author, client, args}) {
async run({send, guild, args}) {
const user = args[0] as User;
// Transforms the User object into a GuildMember object of the current guild.
const member = guild?.members.resolve(args[0]);

View File

@ -1,8 +1,8 @@
import {Command, NamedCommand} from "../../core";
import {NamedCommand} from "../../core";
export default new NamedCommand({
description: "Gives you the invite link.",
async run({send, message, channel, guild, author, member, client, args}) {
async run({send, client, args}) {
send(
`https://discordapp.com/api/oauth2/authorize?client_id=${client.user!.id}&permissions=${
args[0] || 8

View File

@ -1,5 +1,5 @@
import {GuildEmoji, MessageEmbed, User} from "discord.js";
import {Command, NamedCommand, RestCommand, paginate, SendFunction} from "../../core";
import {NamedCommand, RestCommand, paginate, SendFunction} from "../../core";
import {split} from "../../lib";
import vm from "vm";
@ -8,13 +8,13 @@ const REGEX_TIMEOUT_MS = 1000;
export default new NamedCommand({
description: "Lists all emotes the bot has in it's registry,",
usage: "<regex pattern> (-flags)",
async run({send, message, channel, guild, author, member, client, args}) {
async run({send, author, client}) {
displayEmoteList(client.emojis.cache.array(), send, author);
},
any: new RestCommand({
description:
"Filters emotes by via a regular expression. Flags can be added by adding a dash at the end. For example, to do a case-insensitive search, do %prefix%lsemotes somepattern -i",
async run({send, message, channel, guild, author, member, client, args}) {
async run({send, author, client, args}) {
// If a guild ID is provided, filter all emotes by that guild (but only if there aren't any arguments afterward)
if (args.length === 1 && /^\d{17,}$/.test(args[0])) {
const guildID: string = args[0];

View File

@ -1,4 +1,4 @@
import {Command, NamedCommand, RestCommand} from "../../core";
import {NamedCommand, RestCommand} from "../../core";
import {Message, Channel, TextChannel} from "discord.js";
import {processEmoteQueryArray} from "./modules/emote-utils";
@ -8,7 +8,7 @@ export default new NamedCommand({
usage: 'react <emotes...> (<distance / message ID / "Copy ID" / "Copy Message Link">)',
run: "You need to enter some emotes first.",
any: new RestCommand({
async run({send, message, channel, guild, author, member, client, args}) {
async run({send, message, channel, guild, client, args}) {
let target: Message | undefined;
let distance = 1;

View File

@ -1,4 +1,4 @@
import {Command, NamedCommand, RestCommand} from "../../core";
import {NamedCommand, RestCommand} from "../../core";
export default new NamedCommand({
description: "Repeats your message.",
@ -6,7 +6,7 @@ export default new NamedCommand({
run: "Please provide a message for me to say!",
any: new RestCommand({
description: "Message to repeat.",
async run({send, message, channel, guild, author, member, client, args, combined}) {
async run({send, author, combined}) {
send(`*${author} says:*\n${combined}`);
}
})

View File

@ -1,4 +1,4 @@
import {Command, NamedCommand, CHANNEL_TYPE} from "../../core";
import {NamedCommand, CHANNEL_TYPE} from "../../core";
import {pluralise} from "../../lib";
import moment from "moment";
import {Collection, TextChannel} from "discord.js";
@ -9,7 +9,7 @@ export default new NamedCommand({
description:
"Scans all text channels in the current guild and returns the number of times each emoji specific to the guild has been used. Has a cooldown of 24 hours per guild.",
channelType: CHANNEL_TYPE.GUILD,
async run({send, message, channel, guild, author, member, client, args}) {
async run({send, message, channel, guild}) {
// Test if the command is on cooldown. This isn't the strictest cooldown possible, because in the event that the bot crashes, the cooldown will be reset. But for all intends and purposes, it's a good enough cooldown. It's a per-server cooldown.
const startTime = Date.now();
const cooldown = 86400000; // 24 hours
@ -185,7 +185,7 @@ export default new NamedCommand({
forcereset: new NamedCommand({
description: "Forces the cooldown timer to reset.",
permission: PERMISSIONS.BOT_SUPPORT,
async run({send, message, channel, guild, author, member, client, args}) {
async run({send, guild}) {
lastUsedTimestamps.set(guild!.id, 0);
send("Reset the cooldown on `scanemotes`.");
}

View File

@ -5,7 +5,7 @@ export default new NamedCommand({
description: "Shortens a given URL.",
run: "Please provide a URL.",
any: new Command({
async run({send, message, channel, guild, author, member, client, args}) {
async run({send, args}) {
https.get("https://is.gd/create.php?format=simple&url=" + encodeURIComponent(args[0]), function (res) {
var body = "";
res.on("data", function (chunk) {

View File

@ -1,9 +1,9 @@
import {Command, NamedCommand, RestCommand} from "../../core";
import {NamedCommand, RestCommand} from "../../core";
import {streamList} from "../../modules/streamNotifications";
export default new NamedCommand({
description: "Sets the description of your stream. You can embed links by writing `[some name](some link)`",
async run({send, message, channel, guild, author, member, client, args}) {
async run({send, author, member}) {
const userID = author.id;
if (streamList.has(userID)) {
@ -22,7 +22,7 @@ export default new NamedCommand({
}
},
any: new RestCommand({
async run({send, message, channel, guild, author, member, client, args, combined}) {
async run({send, author, member, combined}) {
const userID = author.id;
if (streamList.has(userID)) {

View File

@ -1,11 +1,11 @@
import {Command, NamedCommand, RestCommand} from "../../core";
import {NamedCommand, RestCommand} from "../../core";
import moment from "moment";
import {Storage} from "../../structures";
import {MessageEmbed} from "discord.js";
export default new NamedCommand({
description: "Keep and edit your personal todo list.",
async run({send, message, channel, guild, author, member, client, args}) {
async run({send, author}) {
const user = Storage.getUser(author.id);
const embed = new MessageEmbed().setTitle(`Todo list for ${author.tag}`).setColor("BLUE");
@ -23,7 +23,7 @@ export default new NamedCommand({
add: new NamedCommand({
run: "You need to specify a note to add.",
any: new RestCommand({
async run({send, message, channel, guild, author, member, client, args, combined}) {
async run({send, author, combined}) {
const user = Storage.getUser(author.id);
user.todoList[Date.now().toString()] = combined;
Storage.save();
@ -34,7 +34,7 @@ export default new NamedCommand({
remove: new NamedCommand({
run: "You need to specify a note to remove.",
any: new RestCommand({
async run({send, message, channel, guild, author, member, client, args, combined}) {
async run({send, author, combined}) {
const user = Storage.getUser(author.id);
let isFound = false;
@ -54,7 +54,7 @@ export default new NamedCommand({
})
}),
clear: new NamedCommand({
async run({send, message, channel, guild, author, member, client, args}) {
async run({send, author}) {
const user = Storage.getUser(author.id);
user.todoList = {};
Storage.save();

View File

@ -8,7 +8,7 @@ export default new NamedCommand({
any: new Command({
run: "You need to enter some text to translate.",
any: new RestCommand({
async run({send, message, channel, guild, author, member, client, args}) {
async run({send, args}) {
const lang = args[0];
const input = args.slice(1).join(" ");
translate(input, {