commit
392e7fc56e
66 changed files with 142 additions and 212 deletions
|
@ -1,6 +1,6 @@
|
||||||
import util from "util";
|
import util from "util";
|
||||||
|
|
||||||
export class ErisError extends Error {
|
export class DiscordJSError extends Error {
|
||||||
code: number | string | undefined;
|
code: number | string | undefined;
|
||||||
shardId: number;
|
shardId: number;
|
||||||
|
|
||||||
|
@ -11,6 +11,6 @@ export class ErisError extends Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
[util.inspect.custom]() {
|
[util.inspect.custom]() {
|
||||||
return `[ERIS] [ERROR CODE ${this.code || "?"}] [SHARD ${this.shardId}] ${this.message}`;
|
return `[DISCORDJS] [ERROR CODE ${this.code ?? "?"}] [SHARD ${this.shardId}] ${this.message}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,4 @@
|
||||||
import { Client, Intents, TextChannel } from "discord.js";
|
import { Client, Intents, TextChannel } from "discord.js";
|
||||||
import fs from "fs";
|
|
||||||
import yaml from "js-yaml";
|
import yaml from "js-yaml";
|
||||||
import { Knub, PluginError } from "knub";
|
import { Knub, PluginError } from "knub";
|
||||||
import { PluginLoadError } from "knub/dist/plugins/PluginLoadError";
|
import { PluginLoadError } from "knub/dist/plugins/PluginLoadError";
|
||||||
|
@ -11,7 +10,7 @@ import { Configs } from "./data/Configs";
|
||||||
import { connect } from "./data/db";
|
import { connect } from "./data/db";
|
||||||
import { GuildLogs } from "./data/GuildLogs";
|
import { GuildLogs } from "./data/GuildLogs";
|
||||||
import { LogType } from "./data/LogType";
|
import { LogType } from "./data/LogType";
|
||||||
import { ErisError } from "./ErisError";
|
import { DiscordJSError } from "./DiscordJSError";
|
||||||
import "./loadEnv";
|
import "./loadEnv";
|
||||||
import { logger } from "./logger";
|
import { logger } from "./logger";
|
||||||
import { baseGuildPlugins, globalPlugins, guildPlugins } from "./plugins/availablePlugins";
|
import { baseGuildPlugins, globalPlugins, guildPlugins } from "./plugins/availablePlugins";
|
||||||
|
@ -21,8 +20,6 @@ import { ZeppelinGlobalConfig, ZeppelinGuildConfig } from "./types";
|
||||||
import { startUptimeCounter } from "./uptime";
|
import { startUptimeCounter } from "./uptime";
|
||||||
import { errorMessage, isDiscordAPIError, isDiscordHTTPError, successMessage } from "./utils";
|
import { errorMessage, isDiscordAPIError, isDiscordHTTPError, successMessage } from "./utils";
|
||||||
|
|
||||||
const fsp = fs.promises;
|
|
||||||
|
|
||||||
if (!process.env.KEY) {
|
if (!process.env.KEY) {
|
||||||
// tslint:disable-next-line:no-console
|
// tslint:disable-next-line:no-console
|
||||||
console.error("Project root .env with KEY is required!");
|
console.error("Project root .env with KEY is required!");
|
||||||
|
@ -81,7 +78,7 @@ function errorHandler(err) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err instanceof ErisError) {
|
if (err instanceof DiscordJSError) {
|
||||||
if (err.code && SAFE_TO_IGNORE_ERIS_ERROR_CODES.includes(err.code)) {
|
if (err.code && SAFE_TO_IGNORE_ERIS_ERROR_CODES.includes(err.code)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -176,14 +173,12 @@ connect().then(async () => {
|
||||||
});
|
});
|
||||||
client.setMaxListeners(200);
|
client.setMaxListeners(200);
|
||||||
|
|
||||||
client.on("debug", message => {
|
client.on("rateLimit", rateLimitData => {
|
||||||
if (message.includes(" 429 ")) {
|
logger.info(`[429] ${JSON.stringify(rateLimitData)}`);
|
||||||
logger.info(`[429] ${message}`);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on("error", err => {
|
client.on("error", err => {
|
||||||
errorHandler(new ErisError(err.message, (err as any).code, 0));
|
errorHandler(new DiscordJSError(err.message, (err as any).code, 0));
|
||||||
});
|
});
|
||||||
|
|
||||||
const allowedGuilds = new AllowedGuilds();
|
const allowedGuilds = new AllowedGuilds();
|
||||||
|
@ -266,5 +261,5 @@ connect().then(async () => {
|
||||||
bot.initialize();
|
bot.initialize();
|
||||||
logger.info("Bot Initialized");
|
logger.info("Bot Initialized");
|
||||||
logger.info("Logging in...");
|
logger.info("Logging in...");
|
||||||
await client.login(process.env.token);
|
await client.login(process.env.TOKEN);
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,7 +12,7 @@ export function runAutomodOnMessage(
|
||||||
message: SavedMessage,
|
message: SavedMessage,
|
||||||
isEdit: boolean,
|
isEdit: boolean,
|
||||||
) {
|
) {
|
||||||
const user = pluginData.client.users.cache!.get(message.user_id as Snowflake);
|
const user = pluginData.client.users.cache.get(message.user_id as Snowflake);
|
||||||
const member = pluginData.guild.members.cache.get(message.user_id as Snowflake);
|
const member = pluginData.guild.members.cache.get(message.user_id as Snowflake);
|
||||||
|
|
||||||
const context: AutomodContext = {
|
const context: AutomodContext = {
|
||||||
|
|
|
@ -37,7 +37,7 @@ export const RoleAddedTrigger = automodTrigger<RoleAddedMatchResult>()({
|
||||||
const role = pluginData.guild.roles.cache.get(matchResult.extra.matchedRoleId as Snowflake);
|
const role = pluginData.guild.roles.cache.get(matchResult.extra.matchedRoleId as Snowflake);
|
||||||
const roleName = role?.name || "Unknown";
|
const roleName = role?.name || "Unknown";
|
||||||
const member = contexts[0].member!;
|
const member = contexts[0].member!;
|
||||||
const memberName = `**${member.user.username}#${member.user.discriminator}** (\`${member.id}\`)`;
|
const memberName = `**${member.user.tag}** (\`${member.id}\`)`;
|
||||||
return `Role ${roleName} (\`${matchResult.extra.matchedRoleId}\`) was added to ${memberName}`;
|
return `Role ${roleName} (\`${matchResult.extra.matchedRoleId}\`) was added to ${memberName}`;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -37,7 +37,7 @@ export const RoleRemovedTrigger = automodTrigger<RoleAddedMatchResult>()({
|
||||||
const role = pluginData.guild.roles.cache.get(matchResult.extra.matchedRoleId as Snowflake);
|
const role = pluginData.guild.roles.cache.get(matchResult.extra.matchedRoleId as Snowflake);
|
||||||
const roleName = role?.name || "Unknown";
|
const roleName = role?.name || "Unknown";
|
||||||
const member = contexts[0].member!;
|
const member = contexts[0].member!;
|
||||||
const memberName = `**${member.user.username}#${member.user.discriminator}** (\`${member.id}\`)`;
|
const memberName = `**${member.user.tag}** (\`${member.id}\`)`;
|
||||||
return `Role ${roleName} (\`${matchResult.extra.matchedRoleId}\`) was removed from ${memberName}`;
|
return `Role ${roleName} (\`${matchResult.extra.matchedRoleId}\`) was removed from ${memberName}`;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -35,9 +35,7 @@ export const AddDashboardUserCmd = botControlCmd({
|
||||||
await pluginData.state.apiPermissionAssignments.addUser(args.guildId, user.id, [ApiPermissions.EditConfig]);
|
await pluginData.state.apiPermissionAssignments.addUser(args.guildId, user.id, [ApiPermissions.EditConfig]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const userNameList = args.users.map(
|
const userNameList = args.users.map(user => `<@!${user.id}> (**${user.tag}**, \`${user.id}\`)`);
|
||||||
user => `<@!${user.id}> (**${user.username}#${user.discriminator}**, \`${user.id}\`)`,
|
|
||||||
);
|
|
||||||
sendSuccessMessage(
|
sendSuccessMessage(
|
||||||
pluginData,
|
pluginData,
|
||||||
msg.channel as TextChannel,
|
msg.channel as TextChannel,
|
||||||
|
|
|
@ -46,7 +46,7 @@ export const ListDashboardPermsCmd = botControlCmd({
|
||||||
|
|
||||||
// If we have user, always display which guilds they have permissions in (or only specified guild permissions)
|
// If we have user, always display which guilds they have permissions in (or only specified guild permissions)
|
||||||
if (args.user) {
|
if (args.user) {
|
||||||
const userInfo = `**${args.user.username}#${args.user.discriminator}** (\`${args.user.id}\`)`;
|
const userInfo = `**${args.user.tag}** (\`${args.user.id}\`)`;
|
||||||
|
|
||||||
for (const assignment of existingUserAssignment!) {
|
for (const assignment of existingUserAssignment!) {
|
||||||
if (guild != null && assignment.guild_id !== args.guildId) continue;
|
if (guild != null && assignment.guild_id !== args.guildId) continue;
|
||||||
|
@ -82,9 +82,7 @@ export const ListDashboardPermsCmd = botControlCmd({
|
||||||
finalMessage += `The server ${guildInfo} has the following assigned permissions:\n`; // Double \n for consistency with AddDashboardUserCmd
|
finalMessage += `The server ${guildInfo} has the following assigned permissions:\n`; // Double \n for consistency with AddDashboardUserCmd
|
||||||
for (const assignment of existingGuildAssignment) {
|
for (const assignment of existingGuildAssignment) {
|
||||||
const user = await resolveUser(pluginData.client, assignment.target_id);
|
const user = await resolveUser(pluginData.client, assignment.target_id);
|
||||||
finalMessage += `\n**${user.username}#${user.discriminator}**, \`${
|
finalMessage += `\n**${user.tag}**, \`${assignment.target_id}\`: ${assignment.permissions.join(", ")}`;
|
||||||
assignment.target_id
|
|
||||||
}\`: ${assignment.permissions.join(", ")}`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,7 @@ export const ListDashboardUsersCmd = botControlCmd({
|
||||||
|
|
||||||
const dashboardUsers = await pluginData.state.apiPermissionAssignments.getByGuildId(guild.id);
|
const dashboardUsers = await pluginData.state.apiPermissionAssignments.getByGuildId(guild.id);
|
||||||
const users = await Promise.all(dashboardUsers.map(perm => resolveUser(pluginData.client, perm.target_id)));
|
const users = await Promise.all(dashboardUsers.map(perm => resolveUser(pluginData.client, perm.target_id)));
|
||||||
const userNameList = users.map(
|
const userNameList = users.map(user => `<@!${user.id}> (**${user.tag}**, \`${user.id}\`)`);
|
||||||
user => `<@!${user.id}> (**${user.username}#${user.discriminator}**, \`${user.id}\`)`,
|
|
||||||
);
|
|
||||||
|
|
||||||
sendSuccessMessage(
|
sendSuccessMessage(
|
||||||
pluginData,
|
pluginData,
|
||||||
|
|
|
@ -34,9 +34,7 @@ export const RemoveDashboardUserCmd = botControlCmd({
|
||||||
await pluginData.state.apiPermissionAssignments.removeUser(args.guildId, user.id);
|
await pluginData.state.apiPermissionAssignments.removeUser(args.guildId, user.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
const userNameList = args.users.map(
|
const userNameList = args.users.map(user => `<@!${user.id}> (**${user.tag}**, \`${user.id}\`)`);
|
||||||
user => `<@!${user.id}> (**${user.username}#${user.discriminator}**, \`${user.id}\`)`,
|
|
||||||
);
|
|
||||||
sendSuccessMessage(
|
sendSuccessMessage(
|
||||||
pluginData,
|
pluginData,
|
||||||
msg.channel as TextChannel,
|
msg.channel as TextChannel,
|
||||||
|
|
|
@ -49,7 +49,7 @@ export const ServersCmd = botControlCmd({
|
||||||
const lines = filteredGuilds.map(g => {
|
const lines = filteredGuilds.map(g => {
|
||||||
const paddedId = g.id.padEnd(longestId, " ");
|
const paddedId = g.id.padEnd(longestId, " ");
|
||||||
const owner = getUser(pluginData.client, g.ownerId);
|
const owner = getUser(pluginData.client, g.ownerId);
|
||||||
return `\`${paddedId}\` **${g.name}** (${g.memberCount} members) (owner **${owner.username}#${owner.discriminator}** \`${owner.id}\`)`;
|
return `\`${paddedId}\` **${g.name}** (${g.memberCount} members) (owner **${owner.tag}** \`${owner.id}\`)`;
|
||||||
});
|
});
|
||||||
createChunkedMessage(msg.channel as TextChannel, lines.join("\n"));
|
createChunkedMessage(msg.channel as TextChannel, lines.join("\n"));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -7,15 +7,15 @@ import { postCaseToCaseLogChannel } from "./postToCaseLogChannel";
|
||||||
|
|
||||||
export async function createCase(pluginData: GuildPluginData<CasesPluginType>, args: CaseArgs) {
|
export async function createCase(pluginData: GuildPluginData<CasesPluginType>, args: CaseArgs) {
|
||||||
const user = await resolveUser(pluginData.client, args.userId);
|
const user = await resolveUser(pluginData.client, args.userId);
|
||||||
const userName = `${user.username}#${user.discriminator}`;
|
const userName = `${user.tag}`;
|
||||||
|
|
||||||
const mod = await resolveUser(pluginData.client, args.modId);
|
const mod = await resolveUser(pluginData.client, args.modId);
|
||||||
const modName = `${mod.username}#${mod.discriminator}`;
|
const modName = `${mod.tag}`;
|
||||||
|
|
||||||
let ppName: string | null = null;
|
let ppName: string | null = null;
|
||||||
if (args.ppId) {
|
if (args.ppId) {
|
||||||
const pp = await resolveUser(pluginData.client, args.ppId);
|
const pp = await resolveUser(pluginData.client, args.ppId);
|
||||||
ppName = `${pp.username}#${pp.discriminator}`;
|
ppName = `${pp.tag}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.auditLogId) {
|
if (args.auditLogId) {
|
||||||
|
|
|
@ -16,7 +16,7 @@ export async function createCaseNote(pluginData: GuildPluginData<CasesPluginType
|
||||||
throw new RecoverablePluginError(ERRORS.INVALID_USER);
|
throw new RecoverablePluginError(ERRORS.INVALID_USER);
|
||||||
}
|
}
|
||||||
|
|
||||||
const modName = `${mod.username}#${mod.discriminator}`;
|
const modName = `${mod.tag}`;
|
||||||
|
|
||||||
let body = args.body;
|
let body = args.body;
|
||||||
|
|
||||||
|
|
|
@ -60,10 +60,10 @@ export const ArchiveChannelCmd = channelArchiverCmd({
|
||||||
|
|
||||||
while (archivedMessages < maxMessagesToArchive) {
|
while (archivedMessages < maxMessagesToArchive) {
|
||||||
const messagesToFetch = Math.min(MAX_MESSAGES_PER_FETCH, maxMessagesToArchive - archivedMessages);
|
const messagesToFetch = Math.min(MAX_MESSAGES_PER_FETCH, maxMessagesToArchive - archivedMessages);
|
||||||
const messages = (await args.channel.messages.fetch({
|
const messages = await args.channel.messages.fetch({
|
||||||
limit: messagesToFetch,
|
limit: messagesToFetch,
|
||||||
before: previousId as Snowflake,
|
before: previousId as Snowflake,
|
||||||
})) as Collection<Snowflake, Message>;
|
});
|
||||||
if (messages.size === 0) break;
|
if (messages.size === 0) break;
|
||||||
|
|
||||||
for (const message of messages.values()) {
|
for (const message of messages.values()) {
|
||||||
|
|
|
@ -16,7 +16,7 @@ export const LogsGuildBanAddEvt = logsEvt({
|
||||||
GuildAuditLogs.Actions.MEMBER_BAN_ADD as number,
|
GuildAuditLogs.Actions.MEMBER_BAN_ADD as number,
|
||||||
user.id,
|
user.id,
|
||||||
);
|
);
|
||||||
const mod = relevantAuditLogEntry ? relevantAuditLogEntry.executor : null;
|
const mod = relevantAuditLogEntry?.executor ?? null;
|
||||||
|
|
||||||
pluginData.state.guildLogs.log(
|
pluginData.state.guildLogs.log(
|
||||||
LogType.MEMBER_BAN,
|
LogType.MEMBER_BAN,
|
||||||
|
@ -41,7 +41,7 @@ export const LogsGuildBanRemoveEvt = logsEvt({
|
||||||
GuildAuditLogs.Actions.MEMBER_BAN_REMOVE as number,
|
GuildAuditLogs.Actions.MEMBER_BAN_REMOVE as number,
|
||||||
user.id,
|
user.id,
|
||||||
);
|
);
|
||||||
const mod = relevantAuditLogEntry ? relevantAuditLogEntry.executor : null;
|
const mod = relevantAuditLogEntry?.executor ?? null;
|
||||||
|
|
||||||
pluginData.state.guildLogs.log(
|
pluginData.state.guildLogs.log(
|
||||||
LogType.MEMBER_UNBAN,
|
LogType.MEMBER_UNBAN,
|
||||||
|
|
|
@ -52,7 +52,7 @@ export const LogsGuildMemberUpdateEvt = logsEvt({
|
||||||
GuildAuditLogs.Actions.MEMBER_ROLE_UPDATE as number,
|
GuildAuditLogs.Actions.MEMBER_ROLE_UPDATE as number,
|
||||||
member.id,
|
member.id,
|
||||||
);
|
);
|
||||||
const mod = relevantAuditLogEntry ? relevantAuditLogEntry.executor : null;
|
const mod = relevantAuditLogEntry?.executor ?? null;
|
||||||
|
|
||||||
if (addedRoles.length && removedRoles.length) {
|
if (addedRoles.length && removedRoles.length) {
|
||||||
// Roles added *and* removed
|
// Roles added *and* removed
|
||||||
|
@ -61,11 +61,11 @@ export const LogsGuildMemberUpdateEvt = logsEvt({
|
||||||
{
|
{
|
||||||
member: logMember,
|
member: logMember,
|
||||||
addedRoles: addedRoles
|
addedRoles: addedRoles
|
||||||
.map(roleId => pluginData.guild.roles.cache.get(roleId) || { id: roleId, name: `Unknown (${roleId})` })
|
.map(roleId => pluginData.guild.roles.cache.get(roleId) ?? { id: roleId, name: `Unknown (${roleId})` })
|
||||||
.map(r => r.name)
|
.map(r => r.name)
|
||||||
.join(", "),
|
.join(", "),
|
||||||
removedRoles: removedRoles
|
removedRoles: removedRoles
|
||||||
.map(roleId => pluginData.guild.roles.cache.get(roleId) || { id: roleId, name: `Unknown (${roleId})` })
|
.map(roleId => pluginData.guild.roles.cache.get(roleId) ?? { id: roleId, name: `Unknown (${roleId})` })
|
||||||
.map(r => r.name)
|
.map(r => r.name)
|
||||||
.join(", "),
|
.join(", "),
|
||||||
mod: mod ? userToConfigAccessibleUser(mod) : {},
|
mod: mod ? userToConfigAccessibleUser(mod) : {},
|
||||||
|
@ -79,7 +79,7 @@ export const LogsGuildMemberUpdateEvt = logsEvt({
|
||||||
{
|
{
|
||||||
member: logMember,
|
member: logMember,
|
||||||
roles: addedRoles
|
roles: addedRoles
|
||||||
.map(roleId => pluginData.guild.roles.cache.get(roleId) || { id: roleId, name: `Unknown (${roleId})` })
|
.map(roleId => pluginData.guild.roles.cache.get(roleId) ?? { id: roleId, name: `Unknown (${roleId})` })
|
||||||
.map(r => r.name)
|
.map(r => r.name)
|
||||||
.join(", "),
|
.join(", "),
|
||||||
mod: mod ? userToConfigAccessibleUser(mod) : {},
|
mod: mod ? userToConfigAccessibleUser(mod) : {},
|
||||||
|
@ -93,7 +93,7 @@ export const LogsGuildMemberUpdateEvt = logsEvt({
|
||||||
{
|
{
|
||||||
member: logMember,
|
member: logMember,
|
||||||
roles: removedRoles
|
roles: removedRoles
|
||||||
.map(roleId => pluginData.guild.roles.cache.get(roleId) || { id: roleId, name: `Unknown (${roleId})` })
|
.map(roleId => pluginData.guild.roles.cache.get(roleId) ?? { id: roleId, name: `Unknown (${roleId})` })
|
||||||
.map(r => r.name)
|
.map(r => r.name)
|
||||||
.join(", "),
|
.join(", "),
|
||||||
mod: mod ? userToConfigAccessibleUser(mod) : {},
|
mod: mod ? userToConfigAccessibleUser(mod) : {},
|
||||||
|
|
|
@ -73,11 +73,7 @@ export const AddCaseCmd = modActionsCmd({
|
||||||
});
|
});
|
||||||
|
|
||||||
if (user) {
|
if (user) {
|
||||||
sendSuccessMessage(
|
sendSuccessMessage(pluginData, msg.channel, `Case #${theCase.case_number} created for **${user.tag}**`);
|
||||||
pluginData,
|
|
||||||
msg.channel,
|
|
||||||
`Case #${theCase.case_number} created for **${user.username}#${user.discriminator}**`,
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
sendSuccessMessage(pluginData, msg.channel, `Case #${theCase.case_number} created`);
|
sendSuccessMessage(pluginData, msg.channel, `Case #${theCase.case_number} created`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,7 +196,7 @@ export const BanCmd = modActionsCmd({
|
||||||
// Confirm the action to the moderator
|
// Confirm the action to the moderator
|
||||||
let response = "";
|
let response = "";
|
||||||
if (!forceban) {
|
if (!forceban) {
|
||||||
response = `Banned **${user.username}#${user.discriminator}** ${forTime}(Case #${banResult.case.case_number})`;
|
response = `Banned **${user.tag}** ${forTime}(Case #${banResult.case.case_number})`;
|
||||||
if (banResult.notifyResult.text) response += ` (${banResult.notifyResult.text})`;
|
if (banResult.notifyResult.text) response += ` (${banResult.notifyResult.text})`;
|
||||||
} else {
|
} else {
|
||||||
response = `Member forcebanned ${forTime}(Case #${banResult.case.case_number})`;
|
response = `Member forcebanned ${forTime}(Case #${banResult.case.case_number})`;
|
||||||
|
|
|
@ -29,7 +29,7 @@ export const CasesModCmd = modActionsCmd({
|
||||||
async run({ pluginData, message: msg, args }) {
|
async run({ pluginData, message: msg, args }) {
|
||||||
const modId = args.mod || msg.author.id;
|
const modId = args.mod || msg.author.id;
|
||||||
const mod = await resolveUser(pluginData.client, modId);
|
const mod = await resolveUser(pluginData.client, modId);
|
||||||
const modName = mod instanceof User ? `${mod.username}#${mod.discriminator}` : modId;
|
const modName = mod instanceof User ? `${mod.tag}` : modId;
|
||||||
|
|
||||||
const casesPlugin = pluginData.getPlugin(CasesPlugin);
|
const casesPlugin = pluginData.getPlugin(CasesPlugin);
|
||||||
const totalCases = await casesPlugin.getTotalCasesByMod(modId);
|
const totalCases = await casesPlugin.getTotalCasesByMod(modId);
|
||||||
|
@ -57,7 +57,7 @@ export const CasesModCmd = modActionsCmd({
|
||||||
const embed: MessageEmbedOptions = {
|
const embed: MessageEmbedOptions = {
|
||||||
author: {
|
author: {
|
||||||
name: title,
|
name: title,
|
||||||
iconURL: mod instanceof User ? mod.avatarURL() || mod.defaultAvatarURL : undefined,
|
iconURL: mod instanceof User ? mod.displayAvatarURL() : undefined,
|
||||||
},
|
},
|
||||||
fields: [
|
fields: [
|
||||||
...getChunkedEmbedFields(emptyEmbedValue, lines.join("\n")),
|
...getChunkedEmbedFields(emptyEmbedValue, lines.join("\n")),
|
||||||
|
|
|
@ -61,10 +61,7 @@ export const CasesUserCmd = modActionsCmd({
|
||||||
const normalCases = cases.filter(c => !c.is_hidden);
|
const normalCases = cases.filter(c => !c.is_hidden);
|
||||||
const hiddenCases = cases.filter(c => c.is_hidden);
|
const hiddenCases = cases.filter(c => c.is_hidden);
|
||||||
|
|
||||||
const userName =
|
const userName = user instanceof UnknownUser && cases.length ? cases[cases.length - 1].user_name : `${user.tag}`;
|
||||||
user instanceof UnknownUser && cases.length
|
|
||||||
? cases[cases.length - 1].user_name
|
|
||||||
: `${user.username}#${user.discriminator}`;
|
|
||||||
|
|
||||||
if (cases.length === 0) {
|
if (cases.length === 0) {
|
||||||
msg.channel.send(`No cases found for **${userName}**`);
|
msg.channel.send(`No cases found for **${userName}**`);
|
||||||
|
@ -119,7 +116,7 @@ export const CasesUserCmd = modActionsCmd({
|
||||||
lineChunks.length === 1
|
lineChunks.length === 1
|
||||||
? `Cases for ${userName} (${lines.length} total)`
|
? `Cases for ${userName} (${lines.length} total)`
|
||||||
: `Cases ${chunkStart}–${chunkEnd} of ${lines.length} for ${userName}`,
|
: `Cases ${chunkStart}–${chunkEnd} of ${lines.length} for ${userName}`,
|
||||||
icon_url: user instanceof User ? user.avatarURL() || user.defaultAvatarURL : undefined,
|
icon_url: user instanceof User ? user.displayAvatarURL() : undefined,
|
||||||
},
|
},
|
||||||
fields: [
|
fields: [
|
||||||
...getChunkedEmbedFields(emptyEmbedValue, linesInChunk.join("\n")),
|
...getChunkedEmbedFields(emptyEmbedValue, linesInChunk.join("\n")),
|
||||||
|
|
|
@ -68,7 +68,7 @@ export const DeleteCaseCmd = modActionsCmd({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const deletedByName = `${message.author.username}#${message.author.discriminator}`;
|
const deletedByName = `${message.author.tag}`;
|
||||||
|
|
||||||
const timeAndDate = pluginData.getPlugin(TimeAndDatePlugin);
|
const timeAndDate = pluginData.getPlugin(TimeAndDatePlugin);
|
||||||
const deletedAt = timeAndDate.inGuildTz().format(timeAndDate.getDateFormat("pretty_datetime"));
|
const deletedAt = timeAndDate.inGuildTz().format(timeAndDate.getDateFormat("pretty_datetime"));
|
||||||
|
|
|
@ -70,7 +70,7 @@ export const ForcebanCmd = modActionsCmd({
|
||||||
// FIXME: Use banUserId()?
|
// FIXME: Use banUserId()?
|
||||||
await pluginData.guild.bans.create(user.id as Snowflake, {
|
await pluginData.guild.bans.create(user.id as Snowflake, {
|
||||||
days: 1,
|
days: 1,
|
||||||
reason: reason != null ? encodeURIComponent(reason) : undefined,
|
reason: reason ?? undefined,
|
||||||
});
|
});
|
||||||
} catch {
|
} catch {
|
||||||
sendErrorMessage(pluginData, msg.channel, "Failed to forceban member");
|
sendErrorMessage(pluginData, msg.channel, "Failed to forceban member");
|
||||||
|
|
|
@ -95,7 +95,7 @@ export const MassbanCmd = modActionsCmd({
|
||||||
|
|
||||||
await pluginData.guild.bans.create(userId as Snowflake, {
|
await pluginData.guild.bans.create(userId as Snowflake, {
|
||||||
days: deleteDays,
|
days: deleteDays,
|
||||||
reason: banReason != null ? encodeURIComponent(banReason) : undefined,
|
reason: banReason ?? undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
await casesPlugin.createCase({
|
await casesPlugin.createCase({
|
||||||
|
|
|
@ -60,10 +60,7 @@ export const MassunbanCmd = modActionsCmd({
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await pluginData.guild.bans.remove(
|
await pluginData.guild.bans.remove(userId as Snowflake, unbanReason ?? undefined);
|
||||||
userId as Snowflake,
|
|
||||||
unbanReason != null ? encodeURIComponent(unbanReason) : undefined,
|
|
||||||
);
|
|
||||||
|
|
||||||
await casesPlugin.createCase({
|
await casesPlugin.createCase({
|
||||||
userId,
|
userId,
|
||||||
|
|
|
@ -30,7 +30,7 @@ export const NoteCmd = modActionsCmd({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const userName = `${user.username}#${user.discriminator}`;
|
const userName = `${user.tag}`;
|
||||||
const reason = formatReasonWithAttachments(args.note, msg.attachments.array());
|
const reason = formatReasonWithAttachments(args.note, msg.attachments.array());
|
||||||
|
|
||||||
const casesPlugin = pluginData.getPlugin(CasesPlugin);
|
const casesPlugin = pluginData.getPlugin(CasesPlugin);
|
||||||
|
|
|
@ -51,7 +51,7 @@ export const UnbanCmd = modActionsCmd({
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ignoreEvent(pluginData, IgnoredEventType.Unban, user.id);
|
ignoreEvent(pluginData, IgnoredEventType.Unban, user.id);
|
||||||
await pluginData.guild.bans.remove(user.id as Snowflake, reason != null ? encodeURIComponent(reason) : undefined);
|
await pluginData.guild.bans.remove(user.id as Snowflake, reason ?? undefined);
|
||||||
} catch {
|
} catch {
|
||||||
sendErrorMessage(pluginData, msg.channel, "Failed to unban member; are you sure they're banned?");
|
sendErrorMessage(pluginData, msg.channel, "Failed to unban member; are you sure they're banned?");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -107,7 +107,7 @@ export const WarnCmd = modActionsCmd({
|
||||||
sendSuccessMessage(
|
sendSuccessMessage(
|
||||||
pluginData,
|
pluginData,
|
||||||
msg.channel,
|
msg.channel,
|
||||||
`Warned **${memberToWarn.user.username}#${memberToWarn.user.discriminator}** (Case #${warnResult.case.case_number})${messageResultText}`,
|
`Warned **${memberToWarn.user.tag}** (Case #${warnResult.case.case_number})${messageResultText}`,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -44,7 +44,7 @@ export const CreateBanCaseOnManualBanEvt = modActionsEvt({
|
||||||
const config = mod instanceof UnknownUser ? pluginData.config.get() : await pluginData.config.getForUser(mod);
|
const config = mod instanceof UnknownUser ? pluginData.config.get() : await pluginData.config.getForUser(mod);
|
||||||
|
|
||||||
if (config.create_cases_for_manual_actions) {
|
if (config.create_cases_for_manual_actions) {
|
||||||
reason = relevantAuditLogEntry.reason || "";
|
reason = relevantAuditLogEntry.reason ?? "";
|
||||||
createdCase = await casesPlugin.createCase({
|
createdCase = await casesPlugin.createCase({
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
modId,
|
modId,
|
||||||
|
|
|
@ -47,7 +47,7 @@ export const PostAlertOnMemberJoinEvt = modActionsEvt({
|
||||||
}
|
}
|
||||||
|
|
||||||
await alertChannel.send(
|
await alertChannel.send(
|
||||||
`<@!${member.id}> (${member.user.username}#${member.user.discriminator} \`${member.id}\`) joined with ${actions.length} prior record(s)`,
|
`<@!${member.id}> (${member.user.tag} \`${member.id}\`) joined with ${actions.length} prior record(s)`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -82,7 +82,7 @@ export async function actualKickMemberCmd(
|
||||||
ignoreEvent(pluginData, IgnoredEventType.Ban, memberToKick.id);
|
ignoreEvent(pluginData, IgnoredEventType.Ban, memberToKick.id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await memberToKick.ban({ days: 1, reason: encodeURIComponent("kick -clean") });
|
await memberToKick.ban({ days: 1, reason: "kick -clean" });
|
||||||
} catch {
|
} catch {
|
||||||
sendErrorMessage(pluginData, msg.channel, "Failed to ban the user to clean messages (-clean)");
|
sendErrorMessage(pluginData, msg.channel, "Failed to ban the user to clean messages (-clean)");
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ export async function actualKickMemberCmd(
|
||||||
ignoreEvent(pluginData, IgnoredEventType.Unban, memberToKick.id);
|
ignoreEvent(pluginData, IgnoredEventType.Unban, memberToKick.id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await pluginData.guild.bans.remove(memberToKick.id, encodeURIComponent("kick -clean"));
|
await pluginData.guild.bans.remove(memberToKick.id, "kick -clean");
|
||||||
} catch {
|
} catch {
|
||||||
sendErrorMessage(pluginData, msg.channel, "Failed to unban the user after banning them (-clean)");
|
sendErrorMessage(pluginData, msg.channel, "Failed to unban the user after banning them (-clean)");
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ export async function actualKickMemberCmd(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Confirm the action to the moderator
|
// Confirm the action to the moderator
|
||||||
let response = `Kicked **${memberToKick.user.username}#${memberToKick.user.discriminator}** (Case #${kickResult.case.case_number})`;
|
let response = `Kicked **${memberToKick.user.tag}** (Case #${kickResult.case.case_number})`;
|
||||||
|
|
||||||
if (kickResult.notifyResult.text) response += ` (${kickResult.notifyResult.text})`;
|
if (kickResult.notifyResult.text) response += ` (${kickResult.notifyResult.text})`;
|
||||||
sendSuccessMessage(pluginData, msg.channel, response);
|
sendSuccessMessage(pluginData, msg.channel, response);
|
||||||
|
|
|
@ -85,24 +85,24 @@ export async function actualMuteUserCmd(
|
||||||
if (args.time) {
|
if (args.time) {
|
||||||
if (muteResult.updatedExistingMute) {
|
if (muteResult.updatedExistingMute) {
|
||||||
response = asSingleLine(`
|
response = asSingleLine(`
|
||||||
Updated **${user.username}#${user.discriminator}**'s
|
Updated **${user.tag}**'s
|
||||||
mute to ${timeUntilUnmute} (Case #${muteResult.case.case_number})
|
mute to ${timeUntilUnmute} (Case #${muteResult.case.case_number})
|
||||||
`);
|
`);
|
||||||
} else {
|
} else {
|
||||||
response = asSingleLine(`
|
response = asSingleLine(`
|
||||||
Muted **${user.username}#${user.discriminator}**
|
Muted **${user.tag}**
|
||||||
for ${timeUntilUnmute} (Case #${muteResult.case.case_number})
|
for ${timeUntilUnmute} (Case #${muteResult.case.case_number})
|
||||||
`);
|
`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (muteResult.updatedExistingMute) {
|
if (muteResult.updatedExistingMute) {
|
||||||
response = asSingleLine(`
|
response = asSingleLine(`
|
||||||
Updated **${user.username}#${user.discriminator}**'s
|
Updated **${user.tag}**'s
|
||||||
mute to indefinite (Case #${muteResult.case.case_number})
|
mute to indefinite (Case #${muteResult.case.case_number})
|
||||||
`);
|
`);
|
||||||
} else {
|
} else {
|
||||||
response = asSingleLine(`
|
response = asSingleLine(`
|
||||||
Muted **${user.username}#${user.discriminator}**
|
Muted **${user.tag}**
|
||||||
indefinitely (Case #${muteResult.case.case_number})
|
indefinitely (Case #${muteResult.case.case_number})
|
||||||
`);
|
`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ export async function actualUnmuteCmd(
|
||||||
pluginData,
|
pluginData,
|
||||||
msg.channel as TextChannel,
|
msg.channel as TextChannel,
|
||||||
asSingleLine(`
|
asSingleLine(`
|
||||||
Unmuting **${user.username}#${user.discriminator}**
|
Unmuting **${user.tag}**
|
||||||
in ${timeUntilUnmute} (Case #${result.case.case_number})
|
in ${timeUntilUnmute} (Case #${result.case.case_number})
|
||||||
`),
|
`),
|
||||||
);
|
);
|
||||||
|
@ -57,7 +57,7 @@ export async function actualUnmuteCmd(
|
||||||
pluginData,
|
pluginData,
|
||||||
msg.channel as TextChannel,
|
msg.channel as TextChannel,
|
||||||
asSingleLine(`
|
asSingleLine(`
|
||||||
Unmuted **${user.username}#${user.discriminator}**
|
Unmuted **${user.tag}**
|
||||||
(Case #${result.case.case_number})
|
(Case #${result.case.case_number})
|
||||||
`),
|
`),
|
||||||
);
|
);
|
||||||
|
|
|
@ -80,7 +80,7 @@ export async function banUserId(
|
||||||
const deleteMessageDays = Math.min(30, Math.max(0, banOptions.deleteMessageDays ?? 1));
|
const deleteMessageDays = Math.min(30, Math.max(0, banOptions.deleteMessageDays ?? 1));
|
||||||
await pluginData.guild.bans.create(userId as Snowflake, {
|
await pluginData.guild.bans.create(userId as Snowflake, {
|
||||||
days: deleteMessageDays,
|
days: deleteMessageDays,
|
||||||
reason: reason != null ? encodeURIComponent(reason) : undefined,
|
reason: reason ?? undefined,
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
let errorMessage;
|
let errorMessage;
|
||||||
|
|
|
@ -49,7 +49,7 @@ export async function kickMember(
|
||||||
pluginData.state.serverLogs.ignoreLog(LogType.MEMBER_KICK, member.id);
|
pluginData.state.serverLogs.ignoreLog(LogType.MEMBER_KICK, member.id);
|
||||||
ignoreEvent(pluginData, IgnoredEventType.Kick, member.id);
|
ignoreEvent(pluginData, IgnoredEventType.Kick, member.id);
|
||||||
try {
|
try {
|
||||||
await member.kick(reason != null ? encodeURIComponent(reason) : undefined);
|
await member.kick(reason ?? undefined);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return {
|
return {
|
||||||
status: "failed",
|
status: "failed",
|
||||||
|
|
|
@ -32,10 +32,7 @@ export async function outdatedTempbansLoop(pluginData: GuildPluginData<ModAction
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
ignoreEvent(pluginData, IgnoredEventType.Unban, tempban.user_id);
|
ignoreEvent(pluginData, IgnoredEventType.Unban, tempban.user_id);
|
||||||
await pluginData.guild.bans.remove(
|
await pluginData.guild.bans.remove(tempban.user_id as Snowflake, reason ?? undefined);
|
||||||
tempban.user_id as Snowflake,
|
|
||||||
reason != null ? encodeURIComponent(reason) : undefined,
|
|
||||||
);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
pluginData.state.serverLogs.log(LogType.BOT_ALERT, {
|
pluginData.state.serverLogs.log(LogType.BOT_ALERT, {
|
||||||
body: `Encountered an error trying to automatically unban ${tempban.user_id} after tempban timeout`,
|
body: `Encountered an error trying to automatically unban ${tempban.user_id} after tempban timeout`,
|
||||||
|
|
|
@ -12,7 +12,7 @@ export const ClearBannedMutesCmd = mutesCmd({
|
||||||
|
|
||||||
const activeMutes = await pluginData.state.mutes.getActiveMutes();
|
const activeMutes = await pluginData.state.mutes.getActiveMutes();
|
||||||
|
|
||||||
const bans: Array<{ reason: string; user: User }> = (await pluginData.guild.bans.fetch({ cache: true })) as any;
|
const bans = await pluginData.guild.bans.fetch({ cache: true });
|
||||||
const bannedIds = bans.map(b => b.user.id);
|
const bannedIds = bans.map(b => b.user.id);
|
||||||
|
|
||||||
await msg.channel.send(`Found ${activeMutes.length} mutes and ${bannedIds.length} bans, cross-referencing...`);
|
await msg.channel.send(`Found ${activeMutes.length} mutes and ${bannedIds.length} bans, cross-referencing...`);
|
||||||
|
|
|
@ -67,7 +67,7 @@ export const MutesCmd = mutesCmd({
|
||||||
totalMutes = manuallyMutedMembers.length;
|
totalMutes = manuallyMutedMembers.length;
|
||||||
|
|
||||||
lines = manuallyMutedMembers.map(member => {
|
lines = manuallyMutedMembers.map(member => {
|
||||||
return `<@!${member.id}> (**${member.user.username}#${member.user.discriminator}**, \`${member.id}\`) 🔧 Manual mute`;
|
return `<@!${member.id}> (**${member.user.tag}**, \`${member.id}\`) 🔧 Manual mute`;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Show filtered active mutes (but not manual mutes)
|
// Show filtered active mutes (but not manual mutes)
|
||||||
|
@ -119,7 +119,7 @@ export const MutesCmd = mutesCmd({
|
||||||
|
|
||||||
lines = filteredMutes.map(mute => {
|
lines = filteredMutes.map(mute => {
|
||||||
const user = pluginData.client.users.resolve(mute.user_id as Snowflake);
|
const user = pluginData.client.users.resolve(mute.user_id as Snowflake);
|
||||||
const username = user ? `${user.username}#${user.discriminator}` : "Unknown#0000";
|
const username = user ? `${user.tag}` : "Unknown#0000";
|
||||||
const theCase = muteCasesById.get(mute.case_id);
|
const theCase = muteCasesById.get(mute.case_id);
|
||||||
const caseName = theCase ? `Case #${theCase.case_number}` : "No case";
|
const caseName = theCase ? `Case #${theCase.case_number}` : "No case";
|
||||||
|
|
||||||
|
@ -225,14 +225,11 @@ export const MutesCmd = mutesCmd({
|
||||||
interaction.reply({ content: `You are not permitted to use these buttons.`, ephemeral: true });
|
interaction.reply({ content: `You are not permitted to use these buttons.`, ephemeral: true });
|
||||||
} else {
|
} else {
|
||||||
collector.resetTimer();
|
collector.resetTimer();
|
||||||
|
await interaction.deferUpdate();
|
||||||
if (interaction.customId === `previousButton:${idMod}` && currentPage > 1) {
|
if (interaction.customId === `previousButton:${idMod}` && currentPage > 1) {
|
||||||
await interaction.deferUpdate();
|
|
||||||
await drawListPage(currentPage - 1);
|
await drawListPage(currentPage - 1);
|
||||||
} else if (interaction.customId === `nextButton:${idMod}` && currentPage < totalPages) {
|
} else if (interaction.customId === `nextButton:${idMod}` && currentPage < totalPages) {
|
||||||
await interaction.deferUpdate();
|
|
||||||
await drawListPage(currentPage + 1);
|
await drawListPage(currentPage + 1);
|
||||||
} else {
|
|
||||||
await interaction.deferUpdate();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -90,7 +90,7 @@ export async function muteUser(
|
||||||
try {
|
try {
|
||||||
await member.roles.add(muteRole as Snowflake);
|
await member.roles.add(muteRole as Snowflake);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const actualMuteRole = pluginData.guild.roles.cache.find(x => x.id === muteRole);
|
const actualMuteRole = pluginData.guild.roles.cache.get(muteRole as Snowflake);
|
||||||
if (!actualMuteRole) {
|
if (!actualMuteRole) {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
logs.log(LogType.BOT_ALERT, {
|
logs.log(LogType.BOT_ALERT, {
|
||||||
|
|
|
@ -31,7 +31,7 @@ export const NamesCmd = nameHistoryCmd({
|
||||||
const usernameRows = usernames.map(r => `\`[${r.timestamp}]\` **${disableCodeBlocks(r.username)}**`);
|
const usernameRows = usernames.map(r => `\`[${r.timestamp}]\` **${disableCodeBlocks(r.username)}**`);
|
||||||
|
|
||||||
const user = await pluginData.client.users.fetch(args.userId as Snowflake);
|
const user = await pluginData.client.users.fetch(args.userId as Snowflake);
|
||||||
const currentUsername = user ? `${user.username}#${user.discriminator}` : args.userId;
|
const currentUsername = user ? `${user.tag}` : args.userId;
|
||||||
|
|
||||||
const nicknameDays = Math.round(NICKNAME_RETENTION_PERIOD / DAYS);
|
const nicknameDays = Math.round(NICKNAME_RETENTION_PERIOD / DAYS);
|
||||||
const usernameDays = Math.round(NICKNAME_RETENTION_PERIOD / DAYS);
|
const usernameDays = Math.round(NICKNAME_RETENTION_PERIOD / DAYS);
|
||||||
|
|
|
@ -6,10 +6,7 @@ export const ChannelJoinEvt = nameHistoryEvt({
|
||||||
|
|
||||||
async listener(meta) {
|
async listener(meta) {
|
||||||
meta.pluginData.state.updateQueue.add(() =>
|
meta.pluginData.state.updateQueue.add(() =>
|
||||||
updateNickname(
|
updateNickname(meta.pluginData, meta.args.newState.member ?? meta.args.oldState.member!),
|
||||||
meta.pluginData,
|
|
||||||
meta.args.newState.member ? meta.args.newState.member : meta.args.oldState.member!,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -138,7 +138,7 @@ export async function actualPostCmd(
|
||||||
|
|
||||||
await pluginData.state.scheduledPosts.create({
|
await pluginData.state.scheduledPosts.create({
|
||||||
author_id: msg.author.id,
|
author_id: msg.author.id,
|
||||||
author_name: `${msg.author.username}#${msg.author.discriminator}`,
|
author_name: `${msg.author.tag}`,
|
||||||
channel_id: targetChannel.id,
|
channel_id: targetChannel.id,
|
||||||
content,
|
content,
|
||||||
attachments: msg.attachments.array(),
|
attachments: msg.attachments.array(),
|
||||||
|
|
|
@ -55,7 +55,7 @@ export const ButtonInteractionEvt = reactionRolesEvt({
|
||||||
.getPlugin(LogsPlugin)
|
.getPlugin(LogsPlugin)
|
||||||
.log(
|
.log(
|
||||||
LogType.BOT_ALERT,
|
LogType.BOT_ALERT,
|
||||||
`**A configuration error occured** on buttons for message ${int.message.id}, group **${context.groupName}** not found in config`,
|
`**A configuration error occurred** on buttons for message ${int.message.id}, group **${context.groupName}** not found in config`,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ export const ButtonInteractionEvt = reactionRolesEvt({
|
||||||
.getPlugin(LogsPlugin)
|
.getPlugin(LogsPlugin)
|
||||||
.log(
|
.log(
|
||||||
LogType.BOT_ALERT,
|
LogType.BOT_ALERT,
|
||||||
`**A internal error occured** on buttons for message ${int.message.id}, action **${context.action}** is not known`,
|
`**A internal error occurred** on buttons for message ${int.message.id}, action **${context.action}** is not known`,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,9 +38,7 @@ export async function addMemberPendingRoleChange(
|
||||||
"Reaction roles",
|
"Reaction roles",
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.warn(
|
logger.warn(`Failed to apply role changes to ${member.user.tag} (${member.id}): ${e.message}`);
|
||||||
`Failed to apply role changes to ${member.user.username}#${member.user.discriminator} (${member.id}): ${e.message}`,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|
|
@ -22,7 +22,7 @@ export async function handleOpenMenu(
|
||||||
.getPlugin(LogsPlugin)
|
.getPlugin(LogsPlugin)
|
||||||
.log(
|
.log(
|
||||||
LogType.BOT_ALERT,
|
LogType.BOT_ALERT,
|
||||||
`**A configuration error occured** on buttons for message ${int.message.id}, no menus found in config`,
|
`**A configuration error occurred** on buttons for message ${int.message.id}, no menus found in config`,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -52,14 +52,13 @@ export async function handleOpenMenu(
|
||||||
.getPlugin(LogsPlugin)
|
.getPlugin(LogsPlugin)
|
||||||
.log(
|
.log(
|
||||||
LogType.BOT_ALERT,
|
LogType.BOT_ALERT,
|
||||||
`**A configuration error occured** on buttons for message ${int.message.id}, menu **${context.roleOrMenu}** not found in config`,
|
`**A configuration error occurred** on buttons for message ${int.message.id}, menu **${context.roleOrMenu}** not found in config`,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const rows = splitButtonsIntoRows(menuButtons, Object.values(group.button_menus[context.roleOrMenu])); // new MessageActionRow().addComponents(menuButtons);
|
const rows = splitButtonsIntoRows(menuButtons, Object.values(group.button_menus[context.roleOrMenu])); // new MessageActionRow().addComponents(menuButtons);
|
||||||
|
|
||||||
int.reply({ content: `Click to add/remove a role`, components: rows, ephemeral: true });
|
int.reply({ content: `Click to add/remove a role`, components: rows, ephemeral: true });
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function handleModifyRole(
|
export async function handleModifyRole(
|
||||||
|
@ -78,7 +77,7 @@ export async function handleModifyRole(
|
||||||
.getPlugin(LogsPlugin)
|
.getPlugin(LogsPlugin)
|
||||||
.log(
|
.log(
|
||||||
LogType.BOT_ALERT,
|
LogType.BOT_ALERT,
|
||||||
`**A configuration error occured** on buttons for message ${int.message.id}, role **${context.roleOrMenu}** not found on server`,
|
`**A configuration error occurred** on buttons for message ${int.message.id}, role **${context.roleOrMenu}** not found on server`,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -101,10 +100,7 @@ export async function handleModifyRole(
|
||||||
.getPlugin(LogsPlugin)
|
.getPlugin(LogsPlugin)
|
||||||
.log(
|
.log(
|
||||||
LogType.BOT_ALERT,
|
LogType.BOT_ALERT,
|
||||||
`**A configuration error occured** on buttons for message ${int.message.id}, error: ${e}. We might be missing permissions!`,
|
`**A configuration error occurred** on buttons for message ${int.message.id}, error: ${e}. We might be missing permissions!`,
|
||||||
);
|
);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ export const SlowmodeClearCmd = slowmodeCmd({
|
||||||
pluginData,
|
pluginData,
|
||||||
msg.channel,
|
msg.channel,
|
||||||
asSingleLine(`
|
asSingleLine(`
|
||||||
Failed to clear slowmode from **${args.user.username}#${args.user.discriminator}** in <#${args.channel.id}>:
|
Failed to clear slowmode from **${args.user.tag}** in <#${args.channel.id}>:
|
||||||
Threads cannot have Bot Slowmode
|
Threads cannot have Bot Slowmode
|
||||||
`),
|
`),
|
||||||
);
|
);
|
||||||
|
@ -56,17 +56,13 @@ export const SlowmodeClearCmd = slowmodeCmd({
|
||||||
pluginData,
|
pluginData,
|
||||||
msg.channel,
|
msg.channel,
|
||||||
asSingleLine(`
|
asSingleLine(`
|
||||||
Failed to clear slowmode from **${args.user.username}#${args.user.discriminator}** in <#${args.channel.id}>:
|
Failed to clear slowmode from **${args.user.tag}** in <#${args.channel.id}>:
|
||||||
\`${disableInlineCode(e.message)}\`
|
\`${disableInlineCode(e.message)}\`
|
||||||
`),
|
`),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sendSuccessMessage(
|
sendSuccessMessage(pluginData, msg.channel, `Slowmode cleared from **${args.user.tag}** in <#${args.channel.id}>`);
|
||||||
pluginData,
|
|
||||||
msg.channel,
|
|
||||||
`Slowmode cleared from **${args.user.username}#${args.user.discriminator}** in <#${args.channel.id}>`,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -89,7 +89,7 @@ export const SlowmodeSetCmd = slowmodeCmd({
|
||||||
|
|
||||||
if (mode === "native") {
|
if (mode === "native") {
|
||||||
const missingPermissions = getMissingPermissions(
|
const missingPermissions = getMissingPermissions(
|
||||||
channelPermissions ? channelPermissions : new Permissions(),
|
channelPermissions ?? new Permissions(),
|
||||||
NATIVE_SLOWMODE_PERMISSIONS,
|
NATIVE_SLOWMODE_PERMISSIONS,
|
||||||
);
|
);
|
||||||
if (missingPermissions) {
|
if (missingPermissions) {
|
||||||
|
@ -104,7 +104,7 @@ export const SlowmodeSetCmd = slowmodeCmd({
|
||||||
|
|
||||||
if (mode === "bot") {
|
if (mode === "bot") {
|
||||||
const missingPermissions = getMissingPermissions(
|
const missingPermissions = getMissingPermissions(
|
||||||
channelPermissions ? channelPermissions : new Permissions(),
|
channelPermissions ?? new Permissions(),
|
||||||
BOT_SLOWMODE_PERMISSIONS,
|
BOT_SLOWMODE_PERMISSIONS,
|
||||||
);
|
);
|
||||||
if (missingPermissions) {
|
if (missingPermissions) {
|
||||||
|
|
|
@ -21,7 +21,7 @@ export async function applyBotSlowmodeToUserId(
|
||||||
await channel.permissionOverwrites.create(userId as Snowflake, { SEND_MESSAGES: false }, { type: 1 });
|
await channel.permissionOverwrites.create(userId as Snowflake, { SEND_MESSAGES: false }, { type: 1 });
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const user = (await pluginData.client.users.fetch(userId as Snowflake)) || new UnknownUser({ id: userId });
|
const user = await pluginData.client.users.fetch(userId as Snowflake).catch(() => new UnknownUser({ id: userId }));
|
||||||
|
|
||||||
if (isDiscordAPIError(e) && e.code === 50013) {
|
if (isDiscordAPIError(e) && e.code === 50013) {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
|
|
|
@ -21,8 +21,9 @@ export async function clearExpiredSlowmodes(pluginData: GuildPluginData<Slowmode
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error(e);
|
logger.error(e);
|
||||||
|
|
||||||
const realUser =
|
const realUser = await pluginData.client
|
||||||
pluginData.client.users!.fetch(user.user_id as Snowflake) || new UnknownUser({ id: user.user_id });
|
.users!.fetch(user.user_id as Snowflake)
|
||||||
|
.catch(() => new UnknownUser({ id: user.user_id }));
|
||||||
|
|
||||||
pluginData.state.logs.log(LogType.BOT_ALERT, {
|
pluginData.state.logs.log(LogType.BOT_ALERT, {
|
||||||
body: `Failed to clear slowmode permissions from {userMention(user)} in {channelMention(channel)}`,
|
body: `Failed to clear slowmode permissions from {userMention(user)} in {channelMention(channel)}`,
|
||||||
|
|
|
@ -120,8 +120,8 @@ export async function logAndDetectMessageSpam(
|
||||||
// Then, if enabled, remove the spam messages
|
// Then, if enabled, remove the spam messages
|
||||||
if (spamConfig.clean !== false) {
|
if (spamConfig.clean !== false) {
|
||||||
msgIds.forEach(id => pluginData.state.logs.ignoreLog(LogType.MESSAGE_DELETE, id));
|
msgIds.forEach(id => pluginData.state.logs.ignoreLog(LogType.MESSAGE_DELETE, id));
|
||||||
(pluginData.guild.channels.cache.get(savedMessage.channel_id as Snowflake)! as TextChannel)
|
(pluginData.guild.channels.cache.get(savedMessage.channel_id as Snowflake)! as TextChannel | undefined)
|
||||||
.bulkDelete(msgIds as Snowflake[])
|
?.bulkDelete(msgIds as Snowflake[])
|
||||||
.catch(noop);
|
.catch(noop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,19 +18,17 @@ export function createStarboardEmbedFromMessage(
|
||||||
text: `#${(msg.channel as GuildChannel).name}`,
|
text: `#${(msg.channel as GuildChannel).name}`,
|
||||||
},
|
},
|
||||||
author: {
|
author: {
|
||||||
name: `${msg.author.username}#${msg.author.discriminator}`,
|
name: `${msg.author.tag}`,
|
||||||
},
|
},
|
||||||
fields: [],
|
fields: [],
|
||||||
timestamp: msg.createdAt,
|
timestamp: msg.createdTimestamp,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (color != null) {
|
if (color != null) {
|
||||||
embed.color = color;
|
embed.color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg.author.avatarURL()) {
|
embed.author.icon_url = msg.author.displayAvatarURL({ dynamic: true });
|
||||||
embed.author.icon_url = msg.author.avatarURL()!;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The second condition here checks for messages with only an image link that is then embedded.
|
// The second condition here checks for messages with only an image link that is then embedded.
|
||||||
// The message content in that case is hidden by the Discord client, so we hide it here too.
|
// The message content in that case is hidden by the Discord client, so we hide it here too.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Message, MessageEmbed, Snowflake, TextChannel } from "discord.js";
|
import { Message, MessageEmbedOptions, Snowflake, TextChannel } from "discord.js";
|
||||||
import { GuildPluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { StarboardPluginType, TStarboardOpts } from "../types";
|
import { StarboardPluginType, TStarboardOpts } from "../types";
|
||||||
import { createStarboardEmbedFromMessage } from "./createStarboardEmbedFromMessage";
|
import { createStarboardEmbedFromMessage } from "./createStarboardEmbedFromMessage";
|
||||||
|
@ -16,6 +16,6 @@ export async function saveMessageToStarboard(
|
||||||
const embed = createStarboardEmbedFromMessage(msg, Boolean(starboard.copy_full_embed), starboard.color);
|
const embed = createStarboardEmbedFromMessage(msg, Boolean(starboard.copy_full_embed), starboard.color);
|
||||||
embed.fields!.push(createStarboardPseudoFooterForMessage(starboard, msg, starboard.star_emoji![0], starCount));
|
embed.fields!.push(createStarboardPseudoFooterForMessage(starboard, msg, starboard.star_emoji![0], starCount));
|
||||||
|
|
||||||
const starboardMessage = await (channel as TextChannel).send({ embeds: [embed as MessageEmbed] });
|
const starboardMessage = await (channel as TextChannel).send({ embeds: [embed as MessageEmbedOptions] });
|
||||||
await pluginData.state.starboardMessages.createStarboardMessage(channel.id, msg.id, starboardMessage.id);
|
await pluginData.state.starboardMessages.createStarboardMessage(channel.id, msg.id, starboardMessage.id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { UsernameSaverPluginType } from "./types";
|
||||||
|
|
||||||
export async function updateUsername(pluginData: GuildPluginData<UsernameSaverPluginType>, user: User) {
|
export async function updateUsername(pluginData: GuildPluginData<UsernameSaverPluginType>, user: User) {
|
||||||
if (!user) return;
|
if (!user) return;
|
||||||
const newUsername = `${user.username}#${user.discriminator}`;
|
const newUsername = `${user.tag}`;
|
||||||
const latestEntry = await pluginData.state.usernameHistory.getLastEntry(user.id);
|
const latestEntry = await pluginData.state.usernameHistory.getLastEntry(user.id);
|
||||||
if (!latestEntry || newUsername !== latestEntry.username) {
|
if (!latestEntry || newUsername !== latestEntry.username) {
|
||||||
await pluginData.state.usernameHistory.addEntry(user.id, newUsername);
|
await pluginData.state.usernameHistory.addEntry(user.id, newUsername);
|
||||||
|
|
|
@ -39,8 +39,6 @@ export const AboutCmd = utilityCmd({
|
||||||
version = "?";
|
version = "?";
|
||||||
}
|
}
|
||||||
|
|
||||||
// const shard = pluginData.client.shards.get(pluginData.client.guildShardMap[pluginData.guild.id])!; FIXME Sharding stuff
|
|
||||||
|
|
||||||
const lastReload = humanizeDuration(Date.now() - pluginData.state.lastReload, {
|
const lastReload = humanizeDuration(Date.now() - pluginData.state.lastReload, {
|
||||||
largest: 2,
|
largest: 2,
|
||||||
round: true,
|
round: true,
|
||||||
|
@ -51,7 +49,7 @@ export const AboutCmd = utilityCmd({
|
||||||
["Last reload", `${lastReload} ago`],
|
["Last reload", `${lastReload} ago`],
|
||||||
["Last update", lastUpdate],
|
["Last update", lastUpdate],
|
||||||
["Version", version],
|
["Version", version],
|
||||||
// ["API latency", `${shard.latency}ms`],
|
["API latency", `${pluginData.client.ws.ping}ms`],
|
||||||
["Server timezone", timeAndDate.getGuildTz()],
|
["Server timezone", timeAndDate.getGuildTz()],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -70,11 +68,7 @@ export const AboutCmd = utilityCmd({
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: "Status",
|
name: "Status",
|
||||||
value: basicInfoRows
|
value: basicInfoRows.map(([label, value]) => `${label}: **${value}**`).join("\n"),
|
||||||
.map(([label, value]) => {
|
|
||||||
return `${label}: **${value}**`;
|
|
||||||
})
|
|
||||||
.join("\n"),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: `Loaded plugins on this server (${loadedPlugins.length})`,
|
name: `Loaded plugins on this server (${loadedPlugins.length})`,
|
||||||
|
|
|
@ -16,15 +16,12 @@ export const AvatarCmd = utilityCmd({
|
||||||
async run({ message: msg, args, pluginData }) {
|
async run({ message: msg, args, pluginData }) {
|
||||||
const user = args.user || msg.author;
|
const user = args.user || msg.author;
|
||||||
if (!(user instanceof UnknownUser)) {
|
if (!(user instanceof UnknownUser)) {
|
||||||
const avatar = user.avatarURL() || user.defaultAvatarURL;
|
|
||||||
let extension = avatar.slice(avatar.lastIndexOf("."), avatar.lastIndexOf("?"));
|
|
||||||
// Some pngs can have the .jpg extention for some reason, so we always use .png for static images
|
|
||||||
extension = extension === ".gif" ? extension : ".png";
|
|
||||||
const avatarUrl = avatar.slice(0, avatar.lastIndexOf("."));
|
|
||||||
const embed: MessageEmbedOptions = {
|
const embed: MessageEmbedOptions = {
|
||||||
image: { url: avatarUrl + `${extension}?size=2048` },
|
image: {
|
||||||
|
url: user.displayAvatarURL({ dynamic: true, format: "png", size: 2048 }),
|
||||||
|
},
|
||||||
|
title: `Avatar of ${user.tag}:`,
|
||||||
};
|
};
|
||||||
embed.title = `Avatar of ${user.username}#${user.discriminator}:`;
|
|
||||||
msg.channel.send({ embeds: [embed] });
|
msg.channel.send({ embeds: [embed] });
|
||||||
} else {
|
} else {
|
||||||
sendErrorMessage(pluginData, msg.channel, "Invalid user ID");
|
sendErrorMessage(pluginData, msg.channel, "Invalid user ID");
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { MessageAttachment } from "discord.js";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import sharp from "sharp";
|
import sharp from "sharp";
|
||||||
import twemoji from "twemoji";
|
import twemoji from "twemoji";
|
||||||
|
@ -39,8 +40,8 @@ export const JumboCmd = utilityCmd({
|
||||||
const size = config.jumbo_size > 2048 ? 2048 : config.jumbo_size;
|
const size = config.jumbo_size > 2048 ? 2048 : config.jumbo_size;
|
||||||
const emojiRegex = new RegExp(`(<.*:).*:(\\d+)`);
|
const emojiRegex = new RegExp(`(<.*:).*:(\\d+)`);
|
||||||
const results = emojiRegex.exec(args.emoji);
|
const results = emojiRegex.exec(args.emoji);
|
||||||
let extention = ".png";
|
let extension = ".png";
|
||||||
let file;
|
let file: MessageAttachment | undefined;
|
||||||
|
|
||||||
if (!isEmoji(args.emoji)) {
|
if (!isEmoji(args.emoji)) {
|
||||||
sendErrorMessage(pluginData, msg.channel, "Invalid emoji");
|
sendErrorMessage(pluginData, msg.channel, "Invalid emoji");
|
||||||
|
@ -50,25 +51,19 @@ export const JumboCmd = utilityCmd({
|
||||||
if (results) {
|
if (results) {
|
||||||
let url = "https://cdn.discordapp.com/emojis/";
|
let url = "https://cdn.discordapp.com/emojis/";
|
||||||
if (results[1] === "<a:") {
|
if (results[1] === "<a:") {
|
||||||
extention = ".gif";
|
extension = ".gif";
|
||||||
}
|
}
|
||||||
url += `${results[2]}${extention}`;
|
url += `${results[2]}${extension}`;
|
||||||
if (extention === ".png") {
|
if (extension === ".png") {
|
||||||
const image = await resizeBuffer(await getBufferFromUrl(url), size, size);
|
const image = await resizeBuffer(await getBufferFromUrl(url), size, size);
|
||||||
file = {
|
file = new MessageAttachment(image, `emoji${extension}`);
|
||||||
name: `emoji${extention}`,
|
|
||||||
file: image,
|
|
||||||
};
|
|
||||||
} else {
|
} else {
|
||||||
const image = await getBufferFromUrl(url);
|
const image = await getBufferFromUrl(url);
|
||||||
file = {
|
file = new MessageAttachment(image, `emoji${extension}`);
|
||||||
name: `emoji${extention}`,
|
|
||||||
file: image,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let url = CDN_URL + `/${twemoji.convert.toCodePoint(args.emoji)}.svg`;
|
let url = CDN_URL + `/${twemoji.convert.toCodePoint(args.emoji)}.svg`;
|
||||||
let image;
|
let image: Buffer | undefined;
|
||||||
try {
|
try {
|
||||||
image = await resizeBuffer(await getBufferFromUrl(url), size, size);
|
image = await resizeBuffer(await getBufferFromUrl(url), size, size);
|
||||||
} catch {
|
} catch {
|
||||||
|
@ -77,12 +72,14 @@ export const JumboCmd = utilityCmd({
|
||||||
image = await resizeBuffer(await getBufferFromUrl(url), size, size);
|
image = await resizeBuffer(await getBufferFromUrl(url), size, size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file = {
|
if (!image) {
|
||||||
name: `emoji.png`,
|
sendErrorMessage(pluginData, msg.channel, "Invalid emoji");
|
||||||
file: image,
|
return;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
file = new MessageAttachment(image, "emoji.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.channel.send({ content: "", files: [file] });
|
msg.channel.send({ files: [file] });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -17,8 +17,6 @@ export const LevelCmd = utilityCmd({
|
||||||
run({ message, args, pluginData }) {
|
run({ message, args, pluginData }) {
|
||||||
const member = args.member || message.member;
|
const member = args.member || message.member;
|
||||||
const level = getMemberLevel(pluginData, member);
|
const level = getMemberLevel(pluginData, member);
|
||||||
message.channel.send(
|
message.channel.send(`The permission level of ${member.user.tag} is **${level}**`);
|
||||||
`The permission level of ${member.user.username}#${member.user.discriminator} is **${level}**`,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -29,8 +29,6 @@ export const PingCmd = utilityCmd({
|
||||||
const lowest = Math.round(Math.min(...times));
|
const lowest = Math.round(Math.min(...times));
|
||||||
const mean = Math.round(times.reduce((total, ms) => total + ms, 0) / times.length);
|
const mean = Math.round(times.reduce((total, ms) => total + ms, 0) / times.length);
|
||||||
|
|
||||||
// const shard = pluginData.client.shards.get(pluginData.client.guildShardMap[pluginData.guild.id])!; FIXME sharding stuff
|
|
||||||
|
|
||||||
msg.channel.send(
|
msg.channel.send(
|
||||||
trimLines(`
|
trimLines(`
|
||||||
**Ping:**
|
**Ping:**
|
||||||
|
@ -38,7 +36,8 @@ export const PingCmd = utilityCmd({
|
||||||
Highest: **${highest}ms**
|
Highest: **${highest}ms**
|
||||||
Mean: **${mean}ms**
|
Mean: **${mean}ms**
|
||||||
Time between ping command and first reply: **${msgToMsgDelay!}ms**
|
Time between ping command and first reply: **${msgToMsgDelay!}ms**
|
||||||
`), // Omitted line: Shard latency: **${shard.latency}ms**
|
Shard latency: **${pluginData.client.ws.ping}ms**
|
||||||
|
`),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Clean up test messages
|
// Clean up test messages
|
||||||
|
|
|
@ -25,7 +25,7 @@ export const VcdisconnectCmd = utilityCmd({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!args.member.voice || !args.member.voice.channelId) {
|
if (!args.member.voice?.channelId) {
|
||||||
sendErrorMessage(pluginData, msg.channel, "Member is not in a voice channel");
|
sendErrorMessage(pluginData, msg.channel, "Member is not in a voice channel");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -44,10 +44,6 @@ export const VcdisconnectCmd = utilityCmd({
|
||||||
oldChannel: channelToConfigAccessibleChannel(channel),
|
oldChannel: channelToConfigAccessibleChannel(channel),
|
||||||
});
|
});
|
||||||
|
|
||||||
sendSuccessMessage(
|
sendSuccessMessage(pluginData, msg.channel, `**${args.member.user.tag}** disconnected from **${channel.name}**`);
|
||||||
pluginData,
|
|
||||||
msg.channel,
|
|
||||||
`**${args.member.user.username}#${args.member.user.discriminator}** disconnected from **${channel.name}**`,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -57,7 +57,7 @@ export const VcmoveCmd = utilityCmd({
|
||||||
channel = closestMatch;
|
channel = closestMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!args.member.voice || !args.member.voice.channelId) {
|
if (!args.member.voice?.channelId) {
|
||||||
sendErrorMessage(pluginData, msg.channel, "Member is not in a voice channel");
|
sendErrorMessage(pluginData, msg.channel, "Member is not in a voice channel");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -85,11 +85,7 @@ export const VcmoveCmd = utilityCmd({
|
||||||
newChannel: channelToConfigAccessibleChannel(channel),
|
newChannel: channelToConfigAccessibleChannel(channel),
|
||||||
});
|
});
|
||||||
|
|
||||||
sendSuccessMessage(
|
sendSuccessMessage(pluginData, msg.channel, `**${args.member.user.tag}** moved to **${channel.name}**`);
|
||||||
pluginData,
|
|
||||||
msg.channel,
|
|
||||||
`**${args.member.user.username}#${args.member.user.discriminator}** moved to **${channel.name}**`,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -162,7 +158,7 @@ export const VcmoveAllCmd = utilityCmd({
|
||||||
sendErrorMessage(
|
sendErrorMessage(
|
||||||
pluginData,
|
pluginData,
|
||||||
msg.channel,
|
msg.channel,
|
||||||
`Failed to move ${currMember.user.username}#${currMember.user.discriminator} (${currMember.id}): You cannot act on this member`,
|
`Failed to move ${currMember.user.tag} (${currMember.id}): You cannot act on this member`,
|
||||||
);
|
);
|
||||||
errAmt++;
|
errAmt++;
|
||||||
continue;
|
continue;
|
||||||
|
@ -177,11 +173,7 @@ export const VcmoveAllCmd = utilityCmd({
|
||||||
sendErrorMessage(pluginData, msg.channel, "Unknown error when trying to move members");
|
sendErrorMessage(pluginData, msg.channel, "Unknown error when trying to move members");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sendErrorMessage(
|
sendErrorMessage(pluginData, msg.channel, `Failed to move ${currMember.user.tag} (${currMember.id})`);
|
||||||
pluginData,
|
|
||||||
msg.channel,
|
|
||||||
`Failed to move ${currMember.user.username}#${currMember.user.discriminator} (${currMember.id})`,
|
|
||||||
);
|
|
||||||
errAmt++;
|
errAmt++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ export const AutoJoinThreadEvt = utilityEvt({
|
||||||
|
|
||||||
async listener(meta) {
|
async listener(meta) {
|
||||||
const config = meta.pluginData.config.get();
|
const config = meta.pluginData.config.get();
|
||||||
if (config.autojoin_threads && meta.args.thread.joinable && !meta.args.thread.joined) {
|
if (config.autojoin_threads && meta.args.thread.joinable) {
|
||||||
await meta.args.thread.join();
|
await meta.args.thread.join();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -16,11 +16,10 @@ export const AutoJoinThreadSyncEvt = utilityEvt({
|
||||||
|
|
||||||
async listener(meta) {
|
async listener(meta) {
|
||||||
const config = meta.pluginData.config.get();
|
const config = meta.pluginData.config.get();
|
||||||
if (config.autojoin_threads) {
|
if (config.autojoin_threads) return;
|
||||||
for (const thread of meta.args.threads.values()) {
|
for (const thread of meta.args.threads.values()) {
|
||||||
if (!thread.joined && thread.joinable) {
|
if (!thread.joined && thread.joinable) {
|
||||||
await thread.join();
|
await thread.join();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -96,7 +96,7 @@ export async function getInviteInfoEmbed(
|
||||||
embed.fields.push({
|
embed.fields.push({
|
||||||
name: preEmbedPadding + "Invite creator",
|
name: preEmbedPadding + "Invite creator",
|
||||||
value: trimLines(`
|
value: trimLines(`
|
||||||
Name: **${invite.inviter.username}#${invite.inviter.discriminator}**
|
Name: **${invite.inviter.tag}**
|
||||||
ID: \`${invite.inviter.id}\`
|
ID: \`${invite.inviter.id}\`
|
||||||
Mention: <@!${invite.inviter.id}>
|
Mention: <@!${invite.inviter.id}>
|
||||||
`),
|
`),
|
||||||
|
@ -143,7 +143,7 @@ export async function getInviteInfoEmbed(
|
||||||
embed.fields.push({
|
embed.fields.push({
|
||||||
name: preEmbedPadding + "Invite creator",
|
name: preEmbedPadding + "Invite creator",
|
||||||
value: trimLines(`
|
value: trimLines(`
|
||||||
Name: **${invite.inviter.username}#${invite.inviter.discriminator}**
|
Name: **${invite.inviter.tag}**
|
||||||
ID: \`${invite.inviter.id}\`
|
ID: \`${invite.inviter.id}\`
|
||||||
Mention: <@!${invite.inviter.id}>
|
Mention: <@!${invite.inviter.id}>
|
||||||
`),
|
`),
|
||||||
|
|
|
@ -112,7 +112,7 @@ export async function getMessageInfoEmbed(
|
||||||
embed.fields.push({
|
embed.fields.push({
|
||||||
name: preEmbedPadding + "Author information",
|
name: preEmbedPadding + "Author information",
|
||||||
value: trimLines(`
|
value: trimLines(`
|
||||||
Name: **${message.author.username}#${message.author.discriminator}**
|
Name: **${message.author.tag}**
|
||||||
ID: \`${message.author.id}\`
|
ID: \`${message.author.id}\`
|
||||||
Created: **${authorAccountAge} ago** (\`${prettyAuthorCreatedAt}\`)
|
Created: **${authorAccountAge} ago** (\`${prettyAuthorCreatedAt}\`)
|
||||||
${authorJoinedAt ? `Joined: **${authorServerAge} ago** (\`${prettyAuthorJoinedAt}\`)` : ""}
|
${authorJoinedAt ? `Joined: **${authorServerAge} ago** (\`${prettyAuthorJoinedAt}\`)` : ""}
|
||||||
|
|
|
@ -65,7 +65,7 @@ export async function getServerInfoEmbed(
|
||||||
|
|
||||||
if (thisServer) {
|
if (thisServer) {
|
||||||
const owner = await resolveUser(pluginData.client, thisServer.ownerId);
|
const owner = await resolveUser(pluginData.client, thisServer.ownerId);
|
||||||
const ownerName = `${owner.username}#${owner.discriminator}`;
|
const ownerName = `${owner.tag}`;
|
||||||
|
|
||||||
basicInformation.push(`Owner: **${ownerName}** (\`${thisServer.ownerId}\`)`);
|
basicInformation.push(`Owner: **${ownerName}** (\`${thisServer.ownerId}\`)`);
|
||||||
// basicInformation.push(`Voice region: **${thisServer.region}**`); Outdated, as automatic voice regions are fully live
|
// basicInformation.push(`Voice region: **${thisServer.region}**`); Outdated, as automatic voice regions are fully live
|
||||||
|
|
|
@ -36,10 +36,10 @@ export async function getUserInfoEmbed(
|
||||||
const timeAndDate = pluginData.getPlugin(TimeAndDatePlugin);
|
const timeAndDate = pluginData.getPlugin(TimeAndDatePlugin);
|
||||||
|
|
||||||
embed.author = {
|
embed.author = {
|
||||||
name: `User: ${user.username}#${user.discriminator}`,
|
name: `User: ${user.tag}`,
|
||||||
};
|
};
|
||||||
|
|
||||||
const avatarURL = user.avatarURL() || user.defaultAvatarURL;
|
const avatarURL = user.displayAvatarURL();
|
||||||
embed.author.icon_url = avatarURL;
|
embed.author.icon_url = avatarURL;
|
||||||
|
|
||||||
const createdAt = moment.utc(user.createdAt, "x");
|
const createdAt = moment.utc(user.createdAt, "x");
|
||||||
|
@ -84,7 +84,7 @@ export async function getUserInfoEmbed(
|
||||||
embed.fields.push({
|
embed.fields.push({
|
||||||
name: preEmbedPadding + "User information",
|
name: preEmbedPadding + "User information",
|
||||||
value: trimLines(`
|
value: trimLines(`
|
||||||
Name: **${user.username}#${user.discriminator}**
|
Name: **${user.tag}**
|
||||||
ID: \`${user.id}\`
|
ID: \`${user.id}\`
|
||||||
Created: **${accountAge} ago** (\`${prettyCreatedAt}\`)
|
Created: **${accountAge} ago** (\`${prettyCreatedAt}\`)
|
||||||
Mention: <@!${user.id}>
|
Mention: <@!${user.id}>
|
||||||
|
|
|
@ -391,7 +391,7 @@ async function performMemberSearch(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fullUsername = `${member.user.username}#${member.user.discriminator}`;
|
const fullUsername = `${member.user.tag}`;
|
||||||
if (await execRegExp(queryRegex, fullUsername).catch(allowTimeout)) return true;
|
if (await execRegExp(queryRegex, fullUsername).catch(allowTimeout)) return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -458,7 +458,7 @@ async function performBanSearch(
|
||||||
|
|
||||||
const execRegExp = getOptimizedRegExpRunner(pluginData, isSafeRegex);
|
const execRegExp = getOptimizedRegExpRunner(pluginData, isSafeRegex);
|
||||||
matchingBans = await asyncFilter(matchingBans, async user => {
|
matchingBans = await asyncFilter(matchingBans, async user => {
|
||||||
const fullUsername = `${user.username}#${user.discriminator}`;
|
const fullUsername = `${user.tag}`;
|
||||||
if (await execRegExp(queryRegex, fullUsername).catch(allowTimeout)) return true;
|
if (await execRegExp(queryRegex, fullUsername).catch(allowTimeout)) return true;
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
@ -502,10 +502,10 @@ function formatSearchResultList(members: Array<GuildMember | User>): string {
|
||||||
const paddedId = member.id.padEnd(longestId, " ");
|
const paddedId = member.id.padEnd(longestId, " ");
|
||||||
let line;
|
let line;
|
||||||
if (member instanceof GuildMember) {
|
if (member instanceof GuildMember) {
|
||||||
line = `${paddedId} ${member.user.username}#${member.user.discriminator}`;
|
line = `${paddedId} ${member.user.tag}`;
|
||||||
if (member.nickname) line += ` (${member.nickname})`;
|
if (member.nickname) line += ` (${member.nickname})`;
|
||||||
} else {
|
} else {
|
||||||
line = `${paddedId} ${member.username}#${member.discriminator}`;
|
line = `${paddedId} ${member.tag}`;
|
||||||
}
|
}
|
||||||
return line;
|
return line;
|
||||||
});
|
});
|
||||||
|
|
|
@ -1099,6 +1099,7 @@ export class UnknownUser {
|
||||||
public id: string;
|
public id: string;
|
||||||
public username = "Unknown";
|
public username = "Unknown";
|
||||||
public discriminator = "0000";
|
public discriminator = "0000";
|
||||||
|
public tag = "Unknown#0000";
|
||||||
|
|
||||||
constructor(props = {}) {
|
constructor(props = {}) {
|
||||||
for (const key in props) {
|
for (const key in props) {
|
||||||
|
@ -1353,18 +1354,18 @@ export function messageSummary(msg: SavedMessage) {
|
||||||
|
|
||||||
export function verboseUserMention(user: User | UnknownUser): string {
|
export function verboseUserMention(user: User | UnknownUser): string {
|
||||||
if (user.id == null) {
|
if (user.id == null) {
|
||||||
return `**${user.username}#${user.discriminator}**`;
|
return `**${user.tag}**`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return `<@!${user.id}> (**${user.username}#${user.discriminator}**, \`${user.id}\`)`;
|
return `<@!${user.id}> (**${user.tag}**, \`${user.id}\`)`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function verboseUserName(user: User | UnknownUser): string {
|
export function verboseUserName(user: User | UnknownUser): string {
|
||||||
if (user.id == null) {
|
if (user.id == null) {
|
||||||
return `**${user.username}#${user.discriminator}**`;
|
return `**${user.tag}**`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return `**${user.username}#${user.discriminator}** (\`${user.id}\`)`;
|
return `**${user.tag}** (\`${user.id}\`)`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function verboseChannelMention(channel: GuildChannel): string {
|
export function verboseChannelMention(channel: GuildChannel): string {
|
||||||
|
|
|
@ -40,7 +40,7 @@ export interface IConfigAccessibleMember extends IConfigAccessibleUser {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function userToConfigAccessibleUser(user: User | UnknownUser): IConfigAccessibleUser {
|
export function userToConfigAccessibleUser(user: User | UnknownUser): IConfigAccessibleUser {
|
||||||
if (`${user.username}#${user.discriminator}` === "Unknown#0000") {
|
if (`${user.tag}` === "Unknown#0000") {
|
||||||
const toReturnPartial: IConfigAccessibleUser = {
|
const toReturnPartial: IConfigAccessibleUser = {
|
||||||
id: user.id,
|
id: user.id,
|
||||||
username: "Unknown",
|
username: "Unknown",
|
||||||
|
|
Loading…
Add table
Reference in a new issue