mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-14 13:55:03 +00:00
Merge branch 'master' of github.com:ZeppelinBot/Zeppelin into feat/application-commands
This commit is contained in:
commit
2c0e4b37ca
235 changed files with 3464 additions and 4799 deletions
|
@ -5,7 +5,6 @@ import { GuildCases } from "../../data/GuildCases";
|
|||
import { GuildLogs } from "../../data/GuildLogs";
|
||||
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
|
||||
import { Supporters } from "../../data/Supporters";
|
||||
import { makeIoTsConfigParser } from "../../pluginUtils";
|
||||
import { discardRegExpRunner, getRegExpRunner } from "../../regExpRunners";
|
||||
import { CommonPlugin } from "../Common/CommonPlugin";
|
||||
import { LogsPlugin } from "../Logs/LogsPlugin";
|
||||
|
@ -43,7 +42,7 @@ import { getUserInfoEmbed } from "./functions/getUserInfoEmbed";
|
|||
import { hasPermission } from "./functions/hasPermission";
|
||||
import { activeReloads } from "./guildReloads";
|
||||
import { refreshMembersIfNeeded } from "./refreshMembers";
|
||||
import { ConfigSchema, UtilityPluginType } from "./types";
|
||||
import { UtilityPluginType, zUtilityConfig } from "./types";
|
||||
|
||||
const defaultOptions: PluginOptions<UtilityPluginType> = {
|
||||
config: {
|
||||
|
@ -118,11 +117,11 @@ export const UtilityPlugin = zeppelinGuildPlugin<UtilityPluginType>()({
|
|||
showInDocs: true,
|
||||
info: {
|
||||
prettyName: "Utility",
|
||||
configSchema: ConfigSchema,
|
||||
configSchema: zUtilityConfig,
|
||||
},
|
||||
|
||||
dependencies: () => [TimeAndDatePlugin, ModActionsPlugin, LogsPlugin],
|
||||
configParser: makeIoTsConfigParser(ConfigSchema),
|
||||
configParser: (input) => zUtilityConfig.parse(input),
|
||||
defaultOptions,
|
||||
|
||||
// prettier-ignore
|
||||
|
|
|
@ -100,8 +100,8 @@ export const AboutCmd = utilityCmd({
|
|||
}
|
||||
|
||||
// Use the bot avatar as the embed image
|
||||
if (pluginData.client.user!.avatarURL()) {
|
||||
aboutEmbed.thumbnail = { url: pluginData.client.user!.avatarURL()! };
|
||||
if (pluginData.client.user!.displayAvatarURL()) {
|
||||
aboutEmbed.thumbnail = { url: pluginData.client.user!.displayAvatarURL()! };
|
||||
}
|
||||
|
||||
msg.channel.send({ embeds: [aboutEmbed] });
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { APIEmbed, ImageFormat } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { UnknownUser, renderUserUsername } from "../../../utils";
|
||||
import { UnknownUser, renderUsername } from "../../../utils";
|
||||
import { CommonPlugin } from "../../Common/CommonPlugin";
|
||||
import { utilityCmd } from "../types";
|
||||
|
||||
|
@ -10,17 +10,17 @@ export const AvatarCmd = utilityCmd({
|
|||
permission: "can_avatar",
|
||||
|
||||
signature: {
|
||||
user: ct.resolvedUserLoose({ required: false }),
|
||||
user: ct.resolvedMember({ required: false }) || ct.resolvedUserLoose({ required: false }),
|
||||
},
|
||||
|
||||
async run({ message: msg, args, pluginData }) {
|
||||
const user = args.user || msg.author;
|
||||
const user = args.user ?? msg.member ?? msg.author;
|
||||
if (!(user instanceof UnknownUser)) {
|
||||
const embed: APIEmbed = {
|
||||
image: {
|
||||
url: user.displayAvatarURL({ extension: ImageFormat.PNG, size: 2048 }),
|
||||
},
|
||||
title: `Avatar of ${renderUserUsername(user)}:`,
|
||||
title: `Avatar of ${renderUsername(user)}:`,
|
||||
};
|
||||
msg.channel.send({ embeds: [embed] });
|
||||
} else {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { helpers } from "knub";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { renderUserUsername } from "../../../utils";
|
||||
import { renderUsername } from "../../../utils";
|
||||
import { utilityCmd } from "../types";
|
||||
|
||||
const { getMemberLevel } = helpers;
|
||||
|
@ -18,6 +18,6 @@ export const LevelCmd = utilityCmd({
|
|||
run({ message, args, pluginData }) {
|
||||
const member = args.member || message.member;
|
||||
const level = getMemberLevel(pluginData, member);
|
||||
message.channel.send(`The permission level of ${renderUserUsername(member.user)} is **${level}**`);
|
||||
message.channel.send(`The permission level of ${renderUsername(member)} is **${level}**`);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -15,7 +15,7 @@ export const searchCmdSignature = {
|
|||
export: ct.switchOption({ def: false, shortcut: "e" }),
|
||||
ids: ct.switchOption(),
|
||||
regex: ct.switchOption({ def: false, shortcut: "re" }),
|
||||
"status-search": ct.switchOption({ def: false, shortcut: "ss" }),
|
||||
// "status-search": ct.switchOption({ def: false, shortcut: "ss" }),
|
||||
};
|
||||
|
||||
export const SearchCmd = utilityCmd({
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { VoiceChannel } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { canActOn } from "../../../pluginUtils";
|
||||
import { renderUserUsername } from "../../../utils";
|
||||
import { renderUsername } from "../../../utils";
|
||||
import { CommonPlugin } from "../../Common/CommonPlugin";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
import { utilityCmd } from "../types";
|
||||
|
@ -43,6 +43,6 @@ export const VcdisconnectCmd = utilityCmd({
|
|||
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendSuccessMessage(msg, `**${renderUserUsername(args.member.user)}** disconnected from **${channel.name}**`);
|
||||
.sendSuccessMessage(msg, `**${renderUsername(args.member)}** disconnected from **${channel.name}**`);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { ChannelType, Snowflake, VoiceChannel } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { canActOn } from "../../../pluginUtils";
|
||||
import { channelMentionRegex, isSnowflake, renderUserUsername, simpleClosestStringMatch } from "../../../utils";
|
||||
import { channelMentionRegex, isSnowflake, renderUsername, simpleClosestStringMatch } from "../../../utils";
|
||||
import { CommonPlugin } from "../../Common/CommonPlugin";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
import { utilityCmd } from "../types";
|
||||
|
@ -83,7 +83,7 @@ export const VcmoveCmd = utilityCmd({
|
|||
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendSuccessMessage(msg, `**${renderUserUsername(args.member.user)}** moved to **${channel.name}**`);
|
||||
.sendSuccessMessage(msg, `**${renderUsername(args.member)}** moved to **${channel.name}**`);
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -157,7 +157,7 @@ export const VcmoveAllCmd = utilityCmd({
|
|||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(
|
||||
msg,
|
||||
`Failed to move ${renderUserUsername(currMember.user)} (${currMember.id}): You cannot act on this member`,
|
||||
`Failed to move ${renderUsername(currMember)} (${currMember.id}): You cannot act on this member`,
|
||||
);
|
||||
errAmt++;
|
||||
continue;
|
||||
|
@ -174,7 +174,7 @@ export const VcmoveAllCmd = utilityCmd({
|
|||
}
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(msg, `Failed to move ${renderUserUsername(currMember.user)} (${currMember.id})`);
|
||||
.sendErrorMessage(msg, `Failed to move ${renderUsername(currMember)} (${currMember.id})`);
|
||||
errAmt++;
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ const PRIVATE_THREAD_ICON =
|
|||
const FORUM_CHANNEL_ICON =
|
||||
"https://cdn.discordapp.com/attachments/740650744830623756/1091681253364875294/forum-channel-icon.png";
|
||||
|
||||
const MEDIA_CHANNEL_ICON = "https://cdn.discordapp.com/attachments/876134205229252658/1178335624940490792/media.png";
|
||||
|
||||
export async function getChannelInfoEmbed(
|
||||
pluginData: GuildPluginData<UtilityPluginType>,
|
||||
channelId: string,
|
||||
|
@ -41,6 +43,7 @@ export async function getChannelInfoEmbed(
|
|||
[ChannelType.PrivateThread]: PRIVATE_THREAD_ICON,
|
||||
[ChannelType.AnnouncementThread]: PUBLIC_THREAD_ICON,
|
||||
[ChannelType.GuildForum]: FORUM_CHANNEL_ICON,
|
||||
[ChannelType.GuildMedia]: MEDIA_CHANNEL_ICON,
|
||||
}[channel.type] ?? TEXT_CHANNEL_ICON;
|
||||
|
||||
const channelType =
|
||||
|
@ -55,6 +58,7 @@ export async function getChannelInfoEmbed(
|
|||
[ChannelType.AnnouncementThread]: "News Thread channel",
|
||||
[ChannelType.GuildDirectory]: "Hub channel",
|
||||
[ChannelType.GuildForum]: "Forum channel",
|
||||
[ChannelType.GuildMedia]: "Media channel",
|
||||
}[channel.type] ?? "Channel";
|
||||
|
||||
embed.author = {
|
||||
|
|
|
@ -85,7 +85,7 @@ export async function getInviteInfoEmbed(
|
|||
embed.fields.push({
|
||||
name: preEmbedPadding + "Invite creator",
|
||||
value: trimLines(`
|
||||
Name: **${renderUsername(invite.inviter.username, invite.inviter.discriminator)}**
|
||||
Name: **${renderUsername(invite.inviter)}**
|
||||
ID: \`${invite.inviter.id}\`
|
||||
Mention: <@!${invite.inviter.id}>
|
||||
`),
|
||||
|
|
|
@ -67,7 +67,7 @@ export async function getMessageInfoEmbed(
|
|||
embed.fields.push({
|
||||
name: preEmbedPadding + "Author information",
|
||||
value: trimLines(`
|
||||
Name: **${renderUsername(message.author.username, message.author.discriminator)}**
|
||||
Name: **${renderUsername(message.author)}**
|
||||
ID: \`${message.author.id}\`
|
||||
Created: **<t:${Math.round(message.author.createdTimestamp / 1000)}:R>**
|
||||
${authorJoinedAtTS ? `Joined: **<t:${Math.round(authorJoinedAtTS / 1000)}:R>**` : ""}
|
||||
|
|
|
@ -148,12 +148,16 @@ export async function getServerInfoEmbed(
|
|||
const textChannels = thisServer.channels.cache.filter((channel) => channel.type === ChannelType.GuildText);
|
||||
const voiceChannels = thisServer.channels.cache.filter((channel) => channel.type === ChannelType.GuildVoice);
|
||||
const forumChannels = thisServer.channels.cache.filter((channel) => channel.type === ChannelType.GuildForum);
|
||||
const mediaChannels = thisServer.channels.cache.filter((channel) => channel.type === ChannelType.GuildMedia);
|
||||
const threadChannelsText = thisServer.channels.cache.filter(
|
||||
(channel) => channel.isThread() && channel.parent?.type !== ChannelType.GuildForum,
|
||||
);
|
||||
const threadChannelsForums = thisServer.channels.cache.filter(
|
||||
(channel) => channel.isThread() && channel.parent?.type === ChannelType.GuildForum,
|
||||
);
|
||||
const threadChannelsMedia = thisServer.channels.cache.filter(
|
||||
(channel) => channel.isThread() && channel.parent?.type === ChannelType.GuildMedia,
|
||||
);
|
||||
const announcementChannels = thisServer.channels.cache.filter(
|
||||
(channel) => channel.type === ChannelType.GuildAnnouncement,
|
||||
);
|
||||
|
@ -168,6 +172,7 @@ export async function getServerInfoEmbed(
|
|||
Categories: **${categories.size}**
|
||||
Text: **${textChannels.size}** (**${threadChannelsText.size} threads**)
|
||||
Forums: **${forumChannels.size}** (**${threadChannelsForums.size} threads**)
|
||||
Media: **${mediaChannels.size}** (**${threadChannelsMedia.size} threads**)
|
||||
Announcement: **${announcementChannels.size}**
|
||||
Voice: **${voiceChannels.size}**
|
||||
Stage: **${stageChannels.size}**
|
||||
|
|
|
@ -39,10 +39,10 @@ export async function getUserInfoEmbed(
|
|||
};
|
||||
|
||||
embed.author = {
|
||||
name: `${user.bot ? "Bot" : "User"}: ${renderUsername(user.username, user.discriminator)}`,
|
||||
name: `${user.bot ? "Bot" : "User"}: ${renderUsername(user)}`,
|
||||
};
|
||||
|
||||
const avatarURL = user.displayAvatarURL();
|
||||
const avatarURL = (member ?? user).displayAvatarURL();
|
||||
embed.author.icon_url = avatarURL;
|
||||
|
||||
if (compact) {
|
||||
|
@ -68,9 +68,8 @@ export async function getUserInfoEmbed(
|
|||
}
|
||||
|
||||
const userInfoLines = [`ID: \`${user.id}\``, `Username: **${user.username}**`];
|
||||
if (user.discriminator !== "0") {
|
||||
userInfoLines.push(`Discriminator: **${user.discriminator}**`);
|
||||
}
|
||||
if (user.discriminator !== "0") userInfoLines.push(`Discriminator: **${user.discriminator}**`);
|
||||
if (user.globalName) userInfoLines.push(`Display Name: **${user.globalName}**`);
|
||||
userInfoLines.push(`Created: **<t:${Math.round(user.createdTimestamp / 1000)}:R>**`);
|
||||
userInfoLines.push(`Mention: <@!${user.id}>`);
|
||||
|
||||
|
|
|
@ -14,10 +14,17 @@ import { ArgsFromSignatureOrArray, GuildPluginData } from "knub";
|
|||
import moment from "moment-timezone";
|
||||
import { RegExpRunner, allowTimeout } from "../../RegExpRunner";
|
||||
import { getBaseUrl } from "../../pluginUtils";
|
||||
import { MINUTES, multiSorter, renderUserUsername, sorter, trimLines } from "../../utils";
|
||||
import {
|
||||
InvalidRegexError,
|
||||
MINUTES,
|
||||
inputPatternToRegExp,
|
||||
multiSorter,
|
||||
renderUsername,
|
||||
sorter,
|
||||
trimLines,
|
||||
} from "../../utils";
|
||||
import { asyncFilter } from "../../utils/async";
|
||||
import { hasDiscordPermissions } from "../../utils/hasDiscordPermissions";
|
||||
import { InvalidRegexError, inputPatternToRegExp } from "../../validatorUtils";
|
||||
import { CommonPlugin } from "../Common/CommonPlugin";
|
||||
import { banSearchSignature } from "./commands/BanSearchCmd";
|
||||
import { searchCmdSignature } from "./commands/SearchCmd";
|
||||
|
@ -382,7 +389,7 @@ async function performMemberSearch(
|
|||
return true;
|
||||
}
|
||||
|
||||
const fullUsername = renderUserUsername(member.user);
|
||||
const fullUsername = renderUsername(member);
|
||||
if (await execRegExp(queryRegex, fullUsername).catch(allowTimeout)) return true;
|
||||
|
||||
return false;
|
||||
|
@ -449,7 +456,7 @@ async function performBanSearch(
|
|||
|
||||
const execRegExp = getOptimizedRegExpRunner(pluginData, isSafeRegex);
|
||||
matchingBans = await asyncFilter(matchingBans, async (user) => {
|
||||
const fullUsername = renderUserUsername(user);
|
||||
const fullUsername = renderUsername(user);
|
||||
if (await execRegExp(queryRegex, fullUsername).catch(allowTimeout)) return true;
|
||||
return false;
|
||||
});
|
||||
|
@ -493,10 +500,10 @@ function formatSearchResultList(members: Array<GuildMember | User>): string {
|
|||
const paddedId = member.id.padEnd(longestId, " ");
|
||||
let line;
|
||||
if (member instanceof GuildMember) {
|
||||
line = `${paddedId} ${renderUserUsername(member.user)}`;
|
||||
line = `${paddedId} ${renderUsername(member)}`;
|
||||
if (member.nickname) line += ` (${member.nickname})`;
|
||||
} else {
|
||||
line = `${paddedId} ${member.tag}`;
|
||||
line = `${paddedId} ${renderUsername(member)}`;
|
||||
}
|
||||
return line;
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as t from "io-ts";
|
||||
import { BasePluginType, guildPluginEventListener, guildPluginMessageCommand } from "knub";
|
||||
import z from "zod";
|
||||
import { RegExpRunner } from "../../RegExpRunner";
|
||||
import { GuildArchives } from "../../data/GuildArchives";
|
||||
import { GuildCases } from "../../data/GuildCases";
|
||||
|
@ -7,39 +7,38 @@ import { GuildLogs } from "../../data/GuildLogs";
|
|||
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
|
||||
import { Supporters } from "../../data/Supporters";
|
||||
|
||||
export const ConfigSchema = t.type({
|
||||
can_roles: t.boolean,
|
||||
can_level: t.boolean,
|
||||
can_search: t.boolean,
|
||||
can_clean: t.boolean,
|
||||
can_info: t.boolean,
|
||||
can_server: t.boolean,
|
||||
can_inviteinfo: t.boolean,
|
||||
can_channelinfo: t.boolean,
|
||||
can_messageinfo: t.boolean,
|
||||
can_userinfo: t.boolean,
|
||||
can_roleinfo: t.boolean,
|
||||
can_emojiinfo: t.boolean,
|
||||
can_snowflake: t.boolean,
|
||||
can_reload_guild: t.boolean,
|
||||
can_nickname: t.boolean,
|
||||
can_ping: t.boolean,
|
||||
can_source: t.boolean,
|
||||
can_vcmove: t.boolean,
|
||||
can_vckick: t.boolean,
|
||||
can_help: t.boolean,
|
||||
can_about: t.boolean,
|
||||
can_context: t.boolean,
|
||||
can_jumbo: t.boolean,
|
||||
jumbo_size: t.Integer,
|
||||
can_avatar: t.boolean,
|
||||
info_on_single_result: t.boolean,
|
||||
autojoin_threads: t.boolean,
|
||||
export const zUtilityConfig = z.strictObject({
|
||||
can_roles: z.boolean(),
|
||||
can_level: z.boolean(),
|
||||
can_search: z.boolean(),
|
||||
can_clean: z.boolean(),
|
||||
can_info: z.boolean(),
|
||||
can_server: z.boolean(),
|
||||
can_inviteinfo: z.boolean(),
|
||||
can_channelinfo: z.boolean(),
|
||||
can_messageinfo: z.boolean(),
|
||||
can_userinfo: z.boolean(),
|
||||
can_roleinfo: z.boolean(),
|
||||
can_emojiinfo: z.boolean(),
|
||||
can_snowflake: z.boolean(),
|
||||
can_reload_guild: z.boolean(),
|
||||
can_nickname: z.boolean(),
|
||||
can_ping: z.boolean(),
|
||||
can_source: z.boolean(),
|
||||
can_vcmove: z.boolean(),
|
||||
can_vckick: z.boolean(),
|
||||
can_help: z.boolean(),
|
||||
can_about: z.boolean(),
|
||||
can_context: z.boolean(),
|
||||
can_jumbo: z.boolean(),
|
||||
jumbo_size: z.number(),
|
||||
can_avatar: z.boolean(),
|
||||
info_on_single_result: z.boolean(),
|
||||
autojoin_threads: z.boolean(),
|
||||
});
|
||||
export type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
|
||||
|
||||
export interface UtilityPluginType extends BasePluginType {
|
||||
config: TConfigSchema;
|
||||
config: z.infer<typeof zUtilityConfig>;
|
||||
state: {
|
||||
logs: GuildLogs;
|
||||
cases: GuildCases;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue