misc: interaction commands
This commit is contained in:
parent
f0edc0f589
commit
f2b7c49baf
1 changed files with 112 additions and 1 deletions
|
@ -1,8 +1,12 @@
|
|||
const Command = require("../lib/command.js");
|
||||
const InteractionCommand = require("../lib/interactionCommand.js");
|
||||
const logger = require("../lib/logger.js");
|
||||
const CATEGORY = "misc";
|
||||
|
||||
const {ApplicationCommandOptionTypes} =
|
||||
require("@projectdysnomia/dysnomia").Constants;
|
||||
const {librex} = require("../../config.json");
|
||||
const {getOption} = require("../lib/interactionDispatcher.js");
|
||||
const {
|
||||
formatTime,
|
||||
hastebin,
|
||||
|
@ -52,6 +56,22 @@ yt.callback = async function (msg, line) {
|
|||
};
|
||||
hf.registerCommand(yt);
|
||||
|
||||
const ytInteraction = new InteractionCommand("youtube");
|
||||
ytInteraction.helpText = "Search Youtube";
|
||||
ytInteraction.options.search = {
|
||||
name: "search",
|
||||
type: ApplicationCommandOptionTypes.STRING,
|
||||
description: "Search query",
|
||||
required: true,
|
||||
default: "",
|
||||
};
|
||||
ytInteraction.callback = async function (interaction) {
|
||||
const search = getOption(interaction, ytInteraction, "search");
|
||||
|
||||
return yt.callback(interaction, search);
|
||||
};
|
||||
hf.registerCommand(ytInteraction);
|
||||
|
||||
const fyt = new Command("fyt");
|
||||
fyt.category = CATEGORY;
|
||||
fyt.helpText = "Search YouTube and take the first result.";
|
||||
|
@ -71,6 +91,22 @@ fyt.callback = async function (msg, line) {
|
|||
};
|
||||
hf.registerCommand(fyt);
|
||||
|
||||
const fytInteraction = new InteractionCommand("fyt");
|
||||
fytInteraction.helpText = "Search Youtube and take the first result.";
|
||||
fytInteraction.options.search = {
|
||||
name: "search",
|
||||
type: ApplicationCommandOptionTypes.STRING,
|
||||
description: "Search query",
|
||||
required: true,
|
||||
default: "",
|
||||
};
|
||||
fytInteraction.callback = async function (interaction) {
|
||||
const search = getOption(interaction, fytInteraction, "search");
|
||||
|
||||
return fyt.callback(interaction, search);
|
||||
};
|
||||
hf.registerCommand(fytInteraction);
|
||||
|
||||
const WA_NO_ANSWER = "<:ms_cross:503341994974773250> No answer.";
|
||||
|
||||
const wolfram = new Command("wolfram");
|
||||
|
@ -155,6 +191,30 @@ wolfram.callback = async function (msg, line, args, {verbose, v}) {
|
|||
};
|
||||
hf.registerCommand(wolfram);
|
||||
|
||||
const wolframInteraction = new InteractionCommand("wolfram");
|
||||
wolframInteraction.helpText = "Wolfram Alpha";
|
||||
wolframInteraction.options.query = {
|
||||
name: "query",
|
||||
type: ApplicationCommandOptionTypes.STRING,
|
||||
description: "What to query Wolfram Alpha for",
|
||||
required: true,
|
||||
default: "",
|
||||
};
|
||||
wolframInteraction.options.verbose = {
|
||||
name: "verbose",
|
||||
type: ApplicationCommandOptionTypes.STRING,
|
||||
description: "Verbose output",
|
||||
required: false,
|
||||
default: false,
|
||||
};
|
||||
wolframInteraction.callback = async function (interaction) {
|
||||
const query = getOption(interaction, wolframInteraction, "query");
|
||||
const verbose = getOption(interaction, wolframInteraction, "verbose");
|
||||
|
||||
return wolfram.callback(interaction, query, [query], {verbose});
|
||||
};
|
||||
hf.registerCommand(wolframInteraction);
|
||||
|
||||
const gimg = new Command("gimg");
|
||||
gimg.category = CATEGORY;
|
||||
gimg.helpText = "Search Google Images";
|
||||
|
@ -564,7 +624,7 @@ search.callback = async function (msg, line, args, {results = 2}) {
|
|||
|
||||
const encodedQuery = encodeURIComponent(query);
|
||||
|
||||
if (line.startsWith("!")) {
|
||||
if (query.startsWith("!")) {
|
||||
const url = `https://api.duckduckgo.com/?q=${encodedQuery}&format=json`;
|
||||
const res = await fetch(url);
|
||||
if (res.url != url) return res.url;
|
||||
|
@ -614,6 +674,32 @@ search.callback = async function (msg, line, args, {results = 2}) {
|
|||
};
|
||||
hf.registerCommand(search);
|
||||
|
||||
const searchInteraction = new InteractionCommand("search");
|
||||
searchInteraction.helpText = "Search, powered by LibreX";
|
||||
searchInteraction.options.query = {
|
||||
name: "query",
|
||||
type: ApplicationCommandOptionTypes.STRING,
|
||||
description: "What to search for",
|
||||
required: true,
|
||||
default: "",
|
||||
};
|
||||
searchInteraction.options.results = {
|
||||
name: "results",
|
||||
type: ApplicationCommandOptionTypes.INTEGER,
|
||||
description: "How many results to show",
|
||||
required: false,
|
||||
min_value: 1,
|
||||
max_value: 10,
|
||||
default: 2,
|
||||
};
|
||||
searchInteraction.callback = async function (interaction) {
|
||||
const query = getOption(interaction, searchInteraction, "query");
|
||||
const results = getOption(interaction, searchInteraction, "results");
|
||||
|
||||
return search.callback(interaction, query, [query], {results});
|
||||
};
|
||||
hf.registerCommand(searchInteraction);
|
||||
|
||||
const color = new Command("color");
|
||||
color.category = CATEGORY;
|
||||
color.helpText = "Show information on a color or get a random color";
|
||||
|
@ -699,6 +785,31 @@ color.callback = async function (msg, line, args, {truerandom}) {
|
|||
};
|
||||
hf.registerCommand(color);
|
||||
|
||||
const colorInteraction = new InteractionCommand("color");
|
||||
colorInteraction.helpText = "Show information on a color or get a random color";
|
||||
colorInteraction.options.input = {
|
||||
name: "input",
|
||||
type: ApplicationCommandOptionTypes.STRING,
|
||||
description: "Color to get info on",
|
||||
required: false,
|
||||
default: "",
|
||||
};
|
||||
colorInteraction.options.truerandom = {
|
||||
name: "truerandom",
|
||||
type: ApplicationCommandOptionTypes.BOOLEAN,
|
||||
description:
|
||||
"Should the random color give a 'true random' color instead of an adjust color",
|
||||
required: false,
|
||||
default: false,
|
||||
};
|
||||
colorInteraction.callback = async function (interaction) {
|
||||
const input = getOption(interaction, colorInteraction, "input");
|
||||
const truerandom = getOption(interaction, colorInteraction, "truerandom");
|
||||
|
||||
return color.callback(interaction, input, [input], {truerandom});
|
||||
};
|
||||
hf.registerCommand(colorInteraction);
|
||||
|
||||
function writeVarInt(value) {
|
||||
let buf = Buffer.alloc(0);
|
||||
|
||||
|
|
Loading…
Reference in a new issue