3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 04:25:01 +00:00

some more patches thanks to ruby

Signed-off-by: GitHub <noreply@github.com>
This commit is contained in:
Tiago R 2023-11-26 14:53:54 +00:00
parent ba4a2b45b8
commit 10bb0b67bc
18 changed files with 69 additions and 52 deletions

View file

@ -1,7 +1,7 @@
import { APIEmbed, User } from "discord.js";
import { APIEmbed, GuildMember, User } from "discord.js";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage } from "../../../pluginUtils";
import { emptyEmbedValue, resolveUser, trimLines } from "../../../utils";
import { emptyEmbedValue, renderUsername, resolveMember, resolveUser, trimLines } from "../../../utils";
import { asyncMap } from "../../../utils/async";
import { createPaginatedMessage } from "../../../utils/createPaginatedMessage";
import { getChunkedEmbedFields } from "../../../utils/getChunkedEmbedFields";
@ -28,8 +28,10 @@ export const CasesModCmd = modActionsCmd({
async run({ pluginData, message: msg, args }) {
const modId = args.mod || msg.author.id;
const mod = await resolveUser(pluginData.client, modId);
const modName = mod instanceof User ? mod.tag : modId;
const mod =
(await resolveMember(pluginData.client, pluginData.guild, modId)) ||
(await resolveUser(pluginData.client, modId));
const modName = mod instanceof User ? renderUsername(mod) : modId;
const casesPlugin = pluginData.getPlugin(CasesPlugin);
const totalCases = await casesPlugin.getTotalCasesByMod(modId);
@ -57,7 +59,7 @@ export const CasesModCmd = modActionsCmd({
const embed = {
author: {
name: title,
icon_url: mod instanceof User ? mod.displayAvatarURL() : undefined,
icon_url: mod instanceof User || mod instanceof GuildMember ? mod.displayAvatarURL() : undefined,
},
fields: [
...getChunkedEmbedFields(emptyEmbedValue, lines.join("\n")),

View file

@ -1,9 +1,17 @@
import { APIEmbed, User } from "discord.js";
import { APIEmbed } from "discord.js";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { CaseTypes } from "../../../data/CaseTypes";
import { sendErrorMessage } from "../../../pluginUtils";
import { CasesPlugin } from "../../../plugins/Cases/CasesPlugin";
import { UnknownUser, chunkArray, emptyEmbedValue, renderUserUsername, resolveUser, trimLines } from "../../../utils";
import {
UnknownUser,
chunkArray,
emptyEmbedValue,
renderUsername,
resolveMember,
resolveUser,
trimLines,
} from "../../../utils";
import { asyncMap } from "../../../utils/async";
import { getChunkedEmbedFields } from "../../../utils/getChunkedEmbedFields";
import { getGuildPrefix } from "../../../utils/getGuildPrefix";
@ -35,8 +43,10 @@ export const CasesUserCmd = modActionsCmd({
],
async run({ pluginData, message: msg, args }) {
const user = await resolveUser(pluginData.client, args.user);
if (!user.id) {
const user =
(await resolveMember(pluginData.client, pluginData.guild, args.user)) ||
(await resolveUser(pluginData.client, args.user));
if (!user.id || user instanceof UnknownUser) {
sendErrorMessage(pluginData, msg.channel, `User not found`);
return;
}
@ -62,7 +72,7 @@ export const CasesUserCmd = modActionsCmd({
const hiddenCases = cases.filter((c) => c.is_hidden);
const userName =
user instanceof UnknownUser && cases.length ? cases[cases.length - 1].user_name : renderUserUsername(user);
user instanceof UnknownUser && cases.length ? cases[cases.length - 1].user_name : renderUsername(user);
if (cases.length === 0) {
msg.channel.send(`No cases found for **${userName}**`);
@ -123,7 +133,7 @@ export const CasesUserCmd = modActionsCmd({
lineChunks.length === 1
? `Cases for ${userName} (${lines.length} total)`
: `Cases ${chunkStart}${chunkEnd} of ${lines.length} for ${userName}`,
icon_url: user instanceof User ? user.displayAvatarURL() : undefined,
icon_url: user.displayAvatarURL(),
},
fields: [
...getChunkedEmbedFields(emptyEmbedValue, linesInChunk.join("\n")),