mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
chore: resolve lint errors
This commit is contained in:
parent
59c5176cbd
commit
77ab2718e7
17 changed files with 16 additions and 40 deletions
|
@ -203,7 +203,7 @@ if (env.DEBUG) {
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("Connecting to database");
|
logger.info("Connecting to database");
|
||||||
connect().then(async (connection) => {
|
connect().then(async () => {
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
partials: [Partials.User, Partials.Channel, Partials.GuildMember, Partials.Message, Partials.Reaction],
|
partials: [Partials.User, Partials.Channel, Partials.GuildMember, Partials.Message, Partials.Reaction],
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ export async function userInfoAction(
|
||||||
const utility = pluginData.getPlugin(UtilityPlugin);
|
const utility = pluginData.getPlugin(UtilityPlugin);
|
||||||
|
|
||||||
if (userCfg.can_use && (await utility.hasPermission(executingMember, interaction.channelId, "can_userinfo"))) {
|
if (userCfg.can_use && (await utility.hasPermission(executingMember, interaction.channelId, "can_userinfo"))) {
|
||||||
const embed = await utility.userInfo(interaction.targetId, interaction.user.id);
|
const embed = await utility.userInfo(interaction.targetId);
|
||||||
if (!embed) {
|
if (!embed) {
|
||||||
await interaction.followUp({ content: "Cannot info: internal error" });
|
await interaction.followUp({ content: "Cannot info: internal error" });
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { BasePluginType, CooldownManager, guildPluginEventListener } from "knub";
|
import { BasePluginType, CooldownManager, guildPluginEventListener } from "knub";
|
||||||
import { ZodString, z } from "zod";
|
import { z } from "zod";
|
||||||
import { RegExpRunner } from "../../RegExpRunner";
|
import { RegExpRunner } from "../../RegExpRunner";
|
||||||
import { GuildArchives } from "../../data/GuildArchives";
|
import { GuildArchives } from "../../data/GuildArchives";
|
||||||
import { GuildCases } from "../../data/GuildCases";
|
import { GuildCases } from "../../data/GuildCases";
|
||||||
|
|
|
@ -169,8 +169,8 @@ export const UtilityPlugin = zeppelinGuildPlugin<UtilityPluginType>()({
|
||||||
},
|
},
|
||||||
|
|
||||||
userInfo(pluginData) {
|
userInfo(pluginData) {
|
||||||
return (userId: Snowflake, requestMemberId?: Snowflake) => {
|
return (userId: Snowflake) => {
|
||||||
return getUserInfoEmbed(pluginData, userId, false, requestMemberId);
|
return getUserInfoEmbed(pluginData, userId, false);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ export const InfoCmd = utilityCmd({
|
||||||
const channelId = getChannelId(value);
|
const channelId = getChannelId(value);
|
||||||
const channel = channelId && pluginData.guild.channels.cache.get(channelId as Snowflake);
|
const channel = channelId && pluginData.guild.channels.cache.get(channelId as Snowflake);
|
||||||
if (channel) {
|
if (channel) {
|
||||||
const embed = await getChannelInfoEmbed(pluginData, channelId!, message.author.id);
|
const embed = await getChannelInfoEmbed(pluginData, channelId!);
|
||||||
if (embed) {
|
if (embed) {
|
||||||
message.channel.send({ embeds: [embed] });
|
message.channel.send({ embeds: [embed] });
|
||||||
return;
|
return;
|
||||||
|
@ -54,7 +54,7 @@ export const InfoCmd = utilityCmd({
|
||||||
if (userCfg.can_server) {
|
if (userCfg.can_server) {
|
||||||
const guild = await pluginData.client.guilds.fetch(value as Snowflake).catch(noop);
|
const guild = await pluginData.client.guilds.fetch(value as Snowflake).catch(noop);
|
||||||
if (guild) {
|
if (guild) {
|
||||||
const embed = await getServerInfoEmbed(pluginData, value, message.author.id);
|
const embed = await getServerInfoEmbed(pluginData, value);
|
||||||
if (embed) {
|
if (embed) {
|
||||||
message.channel.send({ embeds: [embed] });
|
message.channel.send({ embeds: [embed] });
|
||||||
return;
|
return;
|
||||||
|
@ -66,7 +66,7 @@ export const InfoCmd = utilityCmd({
|
||||||
if (userCfg.can_userinfo) {
|
if (userCfg.can_userinfo) {
|
||||||
const user = await resolveUser(pluginData.client, value);
|
const user = await resolveUser(pluginData.client, value);
|
||||||
if (user && userCfg.can_userinfo) {
|
if (user && userCfg.can_userinfo) {
|
||||||
const embed = await getUserInfoEmbed(pluginData, user.id, Boolean(args.compact), message.author.id);
|
const embed = await getUserInfoEmbed(pluginData, user.id, Boolean(args.compact));
|
||||||
if (embed) {
|
if (embed) {
|
||||||
message.channel.send({ embeds: [embed] });
|
message.channel.send({ embeds: [embed] });
|
||||||
return;
|
return;
|
||||||
|
@ -83,7 +83,6 @@ export const InfoCmd = utilityCmd({
|
||||||
pluginData,
|
pluginData,
|
||||||
messageTarget.channel.id,
|
messageTarget.channel.id,
|
||||||
messageTarget.messageId,
|
messageTarget.messageId,
|
||||||
message.author.id,
|
|
||||||
);
|
);
|
||||||
if (embed) {
|
if (embed) {
|
||||||
message.channel.send({ embeds: [embed] });
|
message.channel.send({ embeds: [embed] });
|
||||||
|
@ -112,7 +111,7 @@ export const InfoCmd = utilityCmd({
|
||||||
if (userCfg.can_server) {
|
if (userCfg.can_server) {
|
||||||
const serverPreview = await getGuildPreview(pluginData.client, value).catch(() => null);
|
const serverPreview = await getGuildPreview(pluginData.client, value).catch(() => null);
|
||||||
if (serverPreview) {
|
if (serverPreview) {
|
||||||
const embed = await getServerInfoEmbed(pluginData, value, message.author.id);
|
const embed = await getServerInfoEmbed(pluginData, value);
|
||||||
if (embed) {
|
if (embed) {
|
||||||
message.channel.send({ embeds: [embed] });
|
message.channel.send({ embeds: [embed] });
|
||||||
return;
|
return;
|
||||||
|
@ -125,7 +124,7 @@ export const InfoCmd = utilityCmd({
|
||||||
const roleId = getRoleId(value);
|
const roleId = getRoleId(value);
|
||||||
const role = roleId && pluginData.guild.roles.cache.get(roleId as Snowflake);
|
const role = roleId && pluginData.guild.roles.cache.get(roleId as Snowflake);
|
||||||
if (role) {
|
if (role) {
|
||||||
const embed = await getRoleInfoEmbed(pluginData, role, message.author.id);
|
const embed = await getRoleInfoEmbed(pluginData, role);
|
||||||
message.channel.send({ embeds: [embed] });
|
message.channel.send({ embeds: [embed] });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -145,7 +144,7 @@ export const InfoCmd = utilityCmd({
|
||||||
|
|
||||||
// 9. Arbitrary ID
|
// 9. Arbitrary ID
|
||||||
if (isValidSnowflake(value) && userCfg.can_snowflake) {
|
if (isValidSnowflake(value) && userCfg.can_snowflake) {
|
||||||
const embed = await getSnowflakeInfoEmbed(pluginData, value, true, message.author.id);
|
const embed = await getSnowflakeInfoEmbed(value, true);
|
||||||
message.channel.send({ embeds: [embed] });
|
message.channel.send({ embeds: [embed] });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ export const MessageInfoCmd = utilityCmd({
|
||||||
pluginData,
|
pluginData,
|
||||||
args.message.channel.id,
|
args.message.channel.id,
|
||||||
args.message.messageId,
|
args.message.messageId,
|
||||||
message.author.id,
|
|
||||||
);
|
);
|
||||||
if (!embed) {
|
if (!embed) {
|
||||||
sendErrorMessage(pluginData, message.channel, "Unknown message");
|
sendErrorMessage(pluginData, message.channel, "Unknown message");
|
||||||
|
|
|
@ -13,7 +13,7 @@ export const RoleInfoCmd = utilityCmd({
|
||||||
},
|
},
|
||||||
|
|
||||||
async run({ message, args, pluginData }) {
|
async run({ message, args, pluginData }) {
|
||||||
const embed = await getRoleInfoEmbed(pluginData, args.role, message.author.id);
|
const embed = await getRoleInfoEmbed(pluginData, args.role);
|
||||||
message.channel.send({ embeds: [embed] });
|
message.channel.send({ embeds: [embed] });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -15,7 +15,7 @@ export const ServerInfoCmd = utilityCmd({
|
||||||
|
|
||||||
async run({ message, pluginData, args }) {
|
async run({ message, pluginData, args }) {
|
||||||
const serverId = args.serverId || pluginData.guild.id;
|
const serverId = args.serverId || pluginData.guild.id;
|
||||||
const serverInfoEmbed = await getServerInfoEmbed(pluginData, serverId, message.author.id);
|
const serverInfoEmbed = await getServerInfoEmbed(pluginData, serverId);
|
||||||
if (!serverInfoEmbed) {
|
if (!serverInfoEmbed) {
|
||||||
sendErrorMessage(pluginData, message.channel, "Could not find information for that server");
|
sendErrorMessage(pluginData, message.channel, "Could not find information for that server");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -12,8 +12,8 @@ export const SnowflakeInfoCmd = utilityCmd({
|
||||||
id: ct.anyId(),
|
id: ct.anyId(),
|
||||||
},
|
},
|
||||||
|
|
||||||
async run({ message, args, pluginData }) {
|
async run({ message, args }) {
|
||||||
const embed = await getSnowflakeInfoEmbed(pluginData, args.id, false, message.author.id);
|
const embed = await getSnowflakeInfoEmbed(args.id, false);
|
||||||
message.channel.send({ embeds: [embed] });
|
message.channel.send({ embeds: [embed] });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -17,7 +17,7 @@ export const UserInfoCmd = utilityCmd({
|
||||||
|
|
||||||
async run({ message, args, pluginData }) {
|
async run({ message, args, pluginData }) {
|
||||||
const userId = args.user?.id || message.author.id;
|
const userId = args.user?.id || message.author.id;
|
||||||
const embed = await getUserInfoEmbed(pluginData, userId, args.compact, message.author.id);
|
const embed = await getUserInfoEmbed(pluginData, userId, args.compact);
|
||||||
if (!embed) {
|
if (!embed) {
|
||||||
sendErrorMessage(pluginData, message.channel, "User not found");
|
sendErrorMessage(pluginData, message.channel, "User not found");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -22,7 +22,6 @@ const FORUM_CHANNEL_ICON =
|
||||||
export async function getChannelInfoEmbed(
|
export async function getChannelInfoEmbed(
|
||||||
pluginData: GuildPluginData<UtilityPluginType>,
|
pluginData: GuildPluginData<UtilityPluginType>,
|
||||||
channelId: string,
|
channelId: string,
|
||||||
requestMemberId?: string,
|
|
||||||
): Promise<APIEmbed | null> {
|
): Promise<APIEmbed | null> {
|
||||||
const channel = pluginData.guild.channels.cache.get(channelId as Snowflake);
|
const channel = pluginData.guild.channels.cache.get(channelId as Snowflake);
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
|
|
|
@ -9,7 +9,6 @@ import {
|
||||||
trimEmptyLines,
|
trimEmptyLines,
|
||||||
trimLines,
|
trimLines,
|
||||||
} from "../../../utils";
|
} from "../../../utils";
|
||||||
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin";
|
|
||||||
import { UtilityPluginType } from "../types";
|
import { UtilityPluginType } from "../types";
|
||||||
|
|
||||||
const MESSAGE_ICON = "https://cdn.discordapp.com/attachments/740650744830623756/740685652152025088/message.png";
|
const MESSAGE_ICON = "https://cdn.discordapp.com/attachments/740650744830623756/740685652152025088/message.png";
|
||||||
|
@ -18,7 +17,6 @@ export async function getMessageInfoEmbed(
|
||||||
pluginData: GuildPluginData<UtilityPluginType>,
|
pluginData: GuildPluginData<UtilityPluginType>,
|
||||||
channelId: string,
|
channelId: string,
|
||||||
messageId: string,
|
messageId: string,
|
||||||
requestMemberId?: string,
|
|
||||||
): Promise<APIEmbed | null> {
|
): Promise<APIEmbed | null> {
|
||||||
const message = await (pluginData.guild.channels.resolve(channelId as Snowflake) as TextChannel).messages
|
const message = await (pluginData.guild.channels.resolve(channelId as Snowflake) as TextChannel).messages
|
||||||
.fetch(messageId as Snowflake)
|
.fetch(messageId as Snowflake)
|
||||||
|
@ -27,8 +25,6 @@ export async function getMessageInfoEmbed(
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const timeAndDate = pluginData.getPlugin(TimeAndDatePlugin);
|
|
||||||
|
|
||||||
const embed: EmbedWith<"fields" | "author"> = {
|
const embed: EmbedWith<"fields" | "author"> = {
|
||||||
fields: [],
|
fields: [],
|
||||||
author: {
|
author: {
|
||||||
|
|
|
@ -9,7 +9,6 @@ const MENTION_ICON = "https://cdn.discordapp.com/attachments/705009450855039042/
|
||||||
export async function getRoleInfoEmbed(
|
export async function getRoleInfoEmbed(
|
||||||
pluginData: GuildPluginData<UtilityPluginType>,
|
pluginData: GuildPluginData<UtilityPluginType>,
|
||||||
role: Role,
|
role: Role,
|
||||||
requestMemberId?: string,
|
|
||||||
): Promise<APIEmbed> {
|
): Promise<APIEmbed> {
|
||||||
const embed: EmbedWith<"fields" | "author" | "color"> = {
|
const embed: EmbedWith<"fields" | "author" | "color"> = {
|
||||||
fields: [],
|
fields: [],
|
||||||
|
|
|
@ -25,7 +25,6 @@ const prettifyFeature = (feature: string): string =>
|
||||||
export async function getServerInfoEmbed(
|
export async function getServerInfoEmbed(
|
||||||
pluginData: GuildPluginData<UtilityPluginType>,
|
pluginData: GuildPluginData<UtilityPluginType>,
|
||||||
serverId: string,
|
serverId: string,
|
||||||
requestMemberId?: string,
|
|
||||||
): Promise<APIEmbed | null> {
|
): Promise<APIEmbed | null> {
|
||||||
const thisServer = serverId === pluginData.guild.id ? pluginData.guild : null;
|
const thisServer = serverId === pluginData.guild.id ? pluginData.guild : null;
|
||||||
const [restGuild, guildPreview] = await Promise.all([
|
const [restGuild, guildPreview] = await Promise.all([
|
||||||
|
|
|
@ -1,16 +1,12 @@
|
||||||
import { APIEmbed } from "discord.js";
|
import { APIEmbed } from "discord.js";
|
||||||
import { GuildPluginData } from "knub";
|
|
||||||
import { EmbedWith, preEmbedPadding } from "../../../utils";
|
import { EmbedWith, preEmbedPadding } from "../../../utils";
|
||||||
import { snowflakeToTimestamp } from "../../../utils/snowflakeToTimestamp";
|
import { snowflakeToTimestamp } from "../../../utils/snowflakeToTimestamp";
|
||||||
import { UtilityPluginType } from "../types";
|
|
||||||
|
|
||||||
const SNOWFLAKE_ICON = "https://cdn.discordapp.com/attachments/740650744830623756/742020790471491668/snowflake.png";
|
const SNOWFLAKE_ICON = "https://cdn.discordapp.com/attachments/740650744830623756/742020790471491668/snowflake.png";
|
||||||
|
|
||||||
export async function getSnowflakeInfoEmbed(
|
export async function getSnowflakeInfoEmbed(
|
||||||
pluginData: GuildPluginData<UtilityPluginType>,
|
|
||||||
snowflake: string,
|
snowflake: string,
|
||||||
showUnknownWarning = false,
|
showUnknownWarning = false,
|
||||||
requestMemberId?: string,
|
|
||||||
): Promise<APIEmbed> {
|
): Promise<APIEmbed> {
|
||||||
const embed: EmbedWith<"fields" | "author"> = {
|
const embed: EmbedWith<"fields" | "author"> = {
|
||||||
fields: [],
|
fields: [],
|
||||||
|
|
|
@ -13,7 +13,6 @@ import {
|
||||||
trimLines,
|
trimLines,
|
||||||
UnknownUser,
|
UnknownUser,
|
||||||
} from "../../../utils";
|
} from "../../../utils";
|
||||||
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin";
|
|
||||||
import { UtilityPluginType } from "../types";
|
import { UtilityPluginType } from "../types";
|
||||||
|
|
||||||
const MAX_ROLES_TO_DISPLAY = 15;
|
const MAX_ROLES_TO_DISPLAY = 15;
|
||||||
|
@ -27,7 +26,6 @@ export async function getUserInfoEmbed(
|
||||||
pluginData: GuildPluginData<UtilityPluginType>,
|
pluginData: GuildPluginData<UtilityPluginType>,
|
||||||
userId: string,
|
userId: string,
|
||||||
compact = false,
|
compact = false,
|
||||||
requestMemberId?: string,
|
|
||||||
): Promise<APIEmbed | null> {
|
): Promise<APIEmbed | null> {
|
||||||
const user = await resolveUser(pluginData.client, userId);
|
const user = await resolveUser(pluginData.client, userId);
|
||||||
if (!user || user instanceof UnknownUser) {
|
if (!user || user instanceof UnknownUser) {
|
||||||
|
@ -40,8 +38,6 @@ export async function getUserInfoEmbed(
|
||||||
fields: [],
|
fields: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
const timeAndDate = pluginData.getPlugin(TimeAndDatePlugin);
|
|
||||||
|
|
||||||
embed.author = {
|
embed.author = {
|
||||||
name: `${user.bot ? "Bot" : "User"}: ${renderUsername(user.username, user.discriminator)}`,
|
name: `${user.bot ? "Bot" : "User"}: ${renderUsername(user.username, user.discriminator)}`,
|
||||||
};
|
};
|
||||||
|
|
|
@ -150,13 +150,6 @@ export type GroupDMInvite = Invite & {
|
||||||
type: typeof ChannelType.GroupDM;
|
type: typeof ChannelType.GroupDM;
|
||||||
};
|
};
|
||||||
|
|
||||||
function isBoundedString(str: unknown, min: number, max: number): str is string {
|
|
||||||
if (typeof str !== "string") {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return (str.length >= min && str.length <= max);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function zBoundedCharacters(min: number, max: number) {
|
export function zBoundedCharacters(min: number, max: number) {
|
||||||
return z.string().refine(str => {
|
return z.string().refine(str => {
|
||||||
const len = [...str].length; // Unicode aware character split
|
const len = [...str].length; // Unicode aware character split
|
||||||
|
|
Loading…
Add table
Reference in a new issue