Merge master
This commit is contained in:
commit
1518d58e25
53 changed files with 289 additions and 320 deletions
|
@ -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,7 +1,7 @@
|
|||
import { APIEmbed, ImageFormat } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage } from "../../../pluginUtils";
|
||||
import { UnknownUser, renderUserUsername } from "../../../utils";
|
||||
import { UnknownUser, renderUsername } from "../../../utils";
|
||||
import { utilityCmd } from "../types";
|
||||
|
||||
export const AvatarCmd = utilityCmd({
|
||||
|
@ -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, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { renderUserUsername } from "../../../utils";
|
||||
import { renderUsername } from "../../../utils";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
import { utilityCmd } from "../types";
|
||||
|
||||
|
@ -43,7 +43,7 @@ export const VcdisconnectCmd = utilityCmd({
|
|||
sendSuccessMessage(
|
||||
pluginData,
|
||||
msg.channel,
|
||||
`**${renderUserUsername(args.member.user)}** disconnected from **${channel.name}**`,
|
||||
`**${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, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { channelMentionRegex, isSnowflake, renderUserUsername, simpleClosestStringMatch } from "../../../utils";
|
||||
import { channelMentionRegex, isSnowflake, renderUsername, simpleClosestStringMatch } from "../../../utils";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
import { utilityCmd } from "../types";
|
||||
|
||||
|
@ -80,11 +80,7 @@ export const VcmoveCmd = utilityCmd({
|
|||
newChannel: channel,
|
||||
});
|
||||
|
||||
sendSuccessMessage(
|
||||
pluginData,
|
||||
msg.channel,
|
||||
`**${renderUserUsername(args.member.user)}** moved to **${channel.name}**`,
|
||||
);
|
||||
sendSuccessMessage(pluginData, msg.channel, `**${renderUsername(args.member)}** moved to **${channel.name}**`);
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -157,7 +153,7 @@ export const VcmoveAllCmd = utilityCmd({
|
|||
sendErrorMessage(
|
||||
pluginData,
|
||||
msg.channel,
|
||||
`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;
|
||||
|
@ -172,11 +168,7 @@ export const VcmoveAllCmd = utilityCmd({
|
|||
sendErrorMessage(pluginData, msg.channel, "Unknown error when trying to move members");
|
||||
return;
|
||||
}
|
||||
sendErrorMessage(
|
||||
pluginData,
|
||||
msg.channel,
|
||||
`Failed to move ${renderUserUsername(currMember.user)} (${currMember.id})`,
|
||||
);
|
||||
sendErrorMessage(pluginData, msg.channel, `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>**` : ""}
|
||||
|
|
|
@ -6,7 +6,10 @@ import { UtilityPluginType } from "../types";
|
|||
|
||||
const MENTION_ICON = "https://cdn.discordapp.com/attachments/705009450855039042/839284872152481792/mention.png";
|
||||
|
||||
export async function getRoleInfoEmbed(pluginData: GuildPluginData<UtilityPluginType>, role: Role): Promise<APIEmbed> {
|
||||
export async function getRoleInfoEmbed(
|
||||
pluginData: GuildPluginData<UtilityPluginType>,
|
||||
role: Role,
|
||||
): Promise<APIEmbed> {
|
||||
const embed: EmbedWith<"fields" | "author" | "color"> = {
|
||||
fields: [],
|
||||
author: {
|
||||
|
|
|
@ -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}**
|
||||
|
|
|
@ -4,7 +4,10 @@ import { snowflakeToTimestamp } from "../../../utils/snowflakeToTimestamp";
|
|||
|
||||
const SNOWFLAKE_ICON = "https://cdn.discordapp.com/attachments/740650744830623756/742020790471491668/snowflake.png";
|
||||
|
||||
export async function getSnowflakeInfoEmbed(snowflake: string, showUnknownWarning = false): Promise<APIEmbed> {
|
||||
export async function getSnowflakeInfoEmbed(
|
||||
snowflake: string,
|
||||
showUnknownWarning = false,
|
||||
): Promise<APIEmbed> {
|
||||
const embed: EmbedWith<"fields" | "author"> = {
|
||||
fields: [],
|
||||
author: {
|
||||
|
|
|
@ -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,15 +14,7 @@ import { ArgsFromSignatureOrArray, GuildPluginData } from "knub";
|
|||
import moment from "moment-timezone";
|
||||
import { RegExpRunner, allowTimeout } from "../../RegExpRunner";
|
||||
import { getBaseUrl, sendErrorMessage } from "../../pluginUtils";
|
||||
import {
|
||||
InvalidRegexError,
|
||||
MINUTES,
|
||||
inputPatternToRegExp,
|
||||
multiSorter,
|
||||
renderUserUsername,
|
||||
sorter,
|
||||
trimLines,
|
||||
} from "../../utils";
|
||||
import { MINUTES, multiSorter, renderUsername, sorter, trimLines } from "../../utils";
|
||||
import { asyncFilter } from "../../utils/async";
|
||||
import { hasDiscordPermissions } from "../../utils/hasDiscordPermissions";
|
||||
import { banSearchSignature } from "./commands/BanSearchCmd";
|
||||
|
@ -388,7 +380,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;
|
||||
|
@ -455,7 +447,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;
|
||||
});
|
||||
|
@ -499,10 +491,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;
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue