utility: fix up command missing empty arg checks and add reply support to charinfo
This commit is contained in:
parent
f2b7c49baf
commit
b087833972
1 changed files with 17 additions and 17 deletions
|
@ -6,7 +6,6 @@ const CATEGORY = "utility";
|
|||
|
||||
const sharp = require("sharp");
|
||||
const {Constants, VoiceChannel} = require("@projectdysnomia/dysnomia");
|
||||
const Endpoints = require("@projectdysnomia/dysnomia/lib/rest/Endpoints.js");
|
||||
|
||||
const {getOption} = require("../lib/interactionDispatcher.js");
|
||||
const {
|
||||
|
@ -578,7 +577,7 @@ avatar.callback = async function (msg, line, [user], {server, guild}) {
|
|||
};
|
||||
}
|
||||
} else {
|
||||
const guild = msg.channel.guild || hf.bot.guilds.get(msg.guildID);
|
||||
const guild = msg.channel.guild ?? hf.bot.guilds.get(msg.guildID);
|
||||
|
||||
const baseEmbed = {
|
||||
title: `Avatar for \`${formatUsername(msg.author)}\``,
|
||||
|
@ -785,9 +784,7 @@ lookupinvite.addAlias("inviteinfo");
|
|||
lookupinvite.addAlias("iinfo");
|
||||
lookupinvite.addAlias("ii");
|
||||
lookupinvite.callback = async function (msg, line) {
|
||||
if (!line || line == "") {
|
||||
return "No arguments passed.";
|
||||
}
|
||||
if (!line || line == "") return "Arguments required.";
|
||||
|
||||
line = line.replace(/(https?:\/\/)?discord(\.gg|(app)?.com\/invite)\//, "");
|
||||
|
||||
|
@ -1086,6 +1083,8 @@ flagdump.category = CATEGORY;
|
|||
flagdump.helpText = "Dumps Discord user flags.";
|
||||
flagdump.usage = "[flags or user mention]";
|
||||
flagdump.callback = async function (msg, line, [numOrMention], {id, list}) {
|
||||
if (!line || line == "") numOrMention = `<@${msg.author.id}>`;
|
||||
|
||||
const num = Number(numOrMention);
|
||||
if (list) {
|
||||
let allFlags = 0n;
|
||||
|
@ -1097,20 +1096,12 @@ flagdump.callback = async function (msg, line, [numOrMention], {id, list}) {
|
|||
} else if (/<@!?(\d+)>/.test(numOrMention) || !isNaN(id)) {
|
||||
const targetId = id ?? numOrMention.match(/<@!?(\d+)>/)?.[1];
|
||||
if (!targetId) return "Got null ID.";
|
||||
const guild = msg.channel.guild ?? hf.bot.guilds.get(msg.guildID);
|
||||
let user = guild && (await guild.fetchMembers({userIDs: [targetId]}));
|
||||
if (!user || !user[0]) {
|
||||
user = hf.bot.users.get(id);
|
||||
} else {
|
||||
user = user[0].user;
|
||||
}
|
||||
let user = hf.bot.users.get(id);
|
||||
|
||||
if (!user)
|
||||
user = await hf.bot.requestHandler.request(
|
||||
"GET",
|
||||
Endpoints.USER(id),
|
||||
true
|
||||
);
|
||||
user = await hf.bot.requestHandler
|
||||
.request("GET", `/users/${id}`, true)
|
||||
.catch(() => {});
|
||||
|
||||
if (!user) {
|
||||
return "Failed to get user.";
|
||||
|
@ -1141,6 +1132,8 @@ jumbo.addAlias("e");
|
|||
jumbo.addAlias("emote");
|
||||
jumbo.addAlias("emoji");
|
||||
jumbo.callback = async function (msg, line) {
|
||||
if (!line || line === "") return "Arguments required.";
|
||||
|
||||
if (CUSTOM_EMOTE_REGEX.test(line)) {
|
||||
const [_, animatedFlag, name, id] = line.match(CUSTOM_EMOTE_REGEX);
|
||||
const animated = animatedFlag === "a";
|
||||
|
@ -1272,6 +1265,13 @@ charinfo.helpText = "Get information about a set of characters.";
|
|||
charinfo.usage = "[characters]";
|
||||
charinfo.addAlias("char");
|
||||
charinfo.callback = async function (msg, line) {
|
||||
if (!line || (line == "" && msg.messageReference?.messageID)) {
|
||||
const reply = await msg.channel.getMessage(msg.messageReference.messageID);
|
||||
line = reply.content;
|
||||
}
|
||||
|
||||
if (!line || line == "") return "Arguments required.";
|
||||
|
||||
const names = await getNamesFromString(line);
|
||||
const chars = [...line];
|
||||
const lines = names
|
||||
|
|
Loading…
Reference in a new issue