mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-25 10:25:01 +00:00
Merge branch 'master' of https://github.com/Ibotmealot/ZeppelinBot into mod_actions-reason-aliases
This commit is contained in:
commit
882e79d171
13 changed files with 55 additions and 24 deletions
|
@ -75,7 +75,10 @@ export function initGuildsImportExportAPI(guildRouter: express.Router) {
|
||||||
try {
|
try {
|
||||||
data = importExportData.parse(req.body.data);
|
data = importExportData.parse(req.body.data);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return clientError(res, "Invalid import data format");
|
const prettyMessage = `${err.issues[0].code}: expected ${err.issues[0].expected}, received ${
|
||||||
|
err.issues[0].received
|
||||||
|
} at /${err.issues[0].path.join("/")}`;
|
||||||
|
return clientError(res, `Invalid import data format: ${prettyMessage}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,6 +90,14 @@ export function initGuildsImportExportAPI(guildRouter: express.Router) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const seenCaseNumbers = new Set();
|
||||||
|
for (const theCase of data.cases) {
|
||||||
|
if (seenCaseNumbers.has(theCase.case_number)) {
|
||||||
|
return clientError(res, `Duplicate case number: ${theCase.case_number}`);
|
||||||
|
}
|
||||||
|
seenCaseNumbers.add(theCase.case_number);
|
||||||
|
}
|
||||||
|
|
||||||
const guildCases = GuildCases.getGuildInstance(req.params.guildId);
|
const guildCases = GuildCases.getGuildInstance(req.params.guildId);
|
||||||
|
|
||||||
// Prepare cases
|
// Prepare cases
|
||||||
|
|
|
@ -17,7 +17,7 @@ if (!isAPI()) {
|
||||||
setTimeout(cleanup, 30 * SECONDS);
|
setTimeout(cleanup, 30 * SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const MAX_NICKNAME_ENTRIES_PER_USER = 10;
|
export const MAX_NICKNAME_ENTRIES_PER_USER = 20;
|
||||||
|
|
||||||
export class GuildNicknameHistory extends BaseGuildRepository {
|
export class GuildNicknameHistory extends BaseGuildRepository {
|
||||||
private nicknameHistory: Repository<NicknameHistoryEntry>;
|
private nicknameHistory: Repository<NicknameHistoryEntry>;
|
||||||
|
|
|
@ -17,7 +17,7 @@ if (!isAPI()) {
|
||||||
setTimeout(cleanup, 30 * SECONDS);
|
setTimeout(cleanup, 30 * SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const MAX_USERNAME_ENTRIES_PER_USER = 5;
|
export const MAX_USERNAME_ENTRIES_PER_USER = 20;
|
||||||
|
|
||||||
export class UsernameHistory extends BaseRepository {
|
export class UsernameHistory extends BaseRepository {
|
||||||
private usernameHistory: Repository<UsernameHistoryEntry>;
|
private usernameHistory: Repository<UsernameHistoryEntry>;
|
||||||
|
|
|
@ -25,7 +25,7 @@ export const BanAction = automodAction({
|
||||||
const reason = actionConfig.reason || "Kicked automatically";
|
const reason = actionConfig.reason || "Kicked automatically";
|
||||||
const duration = actionConfig.duration ? convertDelayStringToMS(actionConfig.duration)! : undefined;
|
const duration = actionConfig.duration ? convertDelayStringToMS(actionConfig.duration)! : undefined;
|
||||||
const contactMethods = actionConfig.notify ? resolveActionContactMethods(pluginData, actionConfig) : undefined;
|
const contactMethods = actionConfig.notify ? resolveActionContactMethods(pluginData, actionConfig) : undefined;
|
||||||
const deleteMessageDays = actionConfig.deleteMessageDays || undefined;
|
const deleteMessageDays = actionConfig.deleteMessageDays ?? undefined;
|
||||||
|
|
||||||
const caseArgs: Partial<CaseArgs> = {
|
const caseArgs: Partial<CaseArgs> = {
|
||||||
modId: pluginData.client.user!.id,
|
modId: pluginData.client.user!.id,
|
||||||
|
|
|
@ -4,6 +4,8 @@ import { LogType } from "../../../data/LogType";
|
||||||
import { noop } from "../../../utils";
|
import { noop } from "../../../utils";
|
||||||
import { automodAction } from "../helpers";
|
import { automodAction } from "../helpers";
|
||||||
|
|
||||||
|
const cleanDebugServer = process.env.TEMP_CLEAN_DEBUG_SERVER;
|
||||||
|
|
||||||
export const CleanAction = automodAction({
|
export const CleanAction = automodAction({
|
||||||
configType: t.boolean,
|
configType: t.boolean,
|
||||||
defaultConfig: false,
|
defaultConfig: false,
|
||||||
|
@ -27,13 +29,26 @@ export const CleanAction = automodAction({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pluginData.guild.id === cleanDebugServer) {
|
||||||
|
const toDeleteFormatted = Array.from(messageIdsToDeleteByChannelId.entries())
|
||||||
|
.map(([channelId, messageIds]) => `- ${channelId}: ${messageIds.join(", ")}`)
|
||||||
|
.join("\n");
|
||||||
|
// tslint:disable-next-line:no-console
|
||||||
|
console.log(`[DEBUG] Cleaning messages (${ruleName}):\n${toDeleteFormatted}`);
|
||||||
|
}
|
||||||
|
|
||||||
for (const [channelId, messageIds] of messageIdsToDeleteByChannelId.entries()) {
|
for (const [channelId, messageIds] of messageIdsToDeleteByChannelId.entries()) {
|
||||||
for (const id of messageIds) {
|
for (const id of messageIds) {
|
||||||
pluginData.state.logs.ignoreLog(LogType.MESSAGE_DELETE, id);
|
pluginData.state.logs.ignoreLog(LogType.MESSAGE_DELETE, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
const channel = pluginData.guild.channels.cache.get(channelId as Snowflake) as TextChannel;
|
const channel = pluginData.guild.channels.cache.get(channelId as Snowflake) as TextChannel;
|
||||||
await channel.bulkDelete(messageIds as Snowflake[]).catch(noop);
|
await channel.bulkDelete(messageIds as Snowflake[]).catch((err) => {
|
||||||
|
if (pluginData.guild.id === cleanDebugServer) {
|
||||||
|
// tslint:disable-next-line:no-console
|
||||||
|
console.error(`[DEBUG] Failed to bulk delete messages (${ruleName}): ${err}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -17,6 +17,7 @@ import { hasDiscordPermissions } from "../../../utils/hasDiscordPermissions";
|
||||||
import { automodAction } from "../helpers";
|
import { automodAction } from "../helpers";
|
||||||
import { AutomodContext } from "../types";
|
import { AutomodContext } from "../types";
|
||||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||||
|
import { messageIsEmpty } from "../../../utils/messageIsEmpty";
|
||||||
|
|
||||||
export const ReplyAction = automodAction({
|
export const ReplyAction = automodAction({
|
||||||
configType: t.union([
|
configType: t.union([
|
||||||
|
@ -109,6 +110,10 @@ export const ReplyAction = automodAction({
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (messageIsEmpty(messageOpts)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const replyMsg = await channel.send(messageOpts);
|
const replyMsg = await channel.send(messageOpts);
|
||||||
|
|
||||||
if (typeof actionConfig === "object" && actionConfig.auto_delete) {
|
if (typeof actionConfig === "object" && actionConfig.auto_delete) {
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { CaseTypes } from "../../data/CaseTypes";
|
import { CaseTypes } from "../../data/CaseTypes";
|
||||||
|
|
||||||
export const caseIcons: Record<CaseTypes, string> = {
|
export const caseIcons: Record<CaseTypes, string> = {
|
||||||
[CaseTypes.Ban]: "<:case_ban:742540201443721317>",
|
[CaseTypes.Ban]: "<:case_ban:906897178176393246>",
|
||||||
[CaseTypes.Unban]: "<:case_unban:742540201670475846>",
|
[CaseTypes.Unban]: "<:case_unban:906897177824067665>",
|
||||||
[CaseTypes.Note]: "<:case_note:742540201368485950>",
|
[CaseTypes.Note]: "<:case_note:906897177832476743>",
|
||||||
[CaseTypes.Warn]: "<:case_warn:742540201624338454>",
|
[CaseTypes.Warn]: "<:case_warn:906897177840844832>",
|
||||||
[CaseTypes.Kick]: "<:case_kick:742540201661825165>",
|
[CaseTypes.Kick]: "<:case_kick:906897178310639646>",
|
||||||
[CaseTypes.Mute]: "<:case_mute:742540201817145364>",
|
[CaseTypes.Mute]: "<:case_mute:906897178147057664>",
|
||||||
[CaseTypes.Unmute]: "<:case_unmute:742540201489858643>",
|
[CaseTypes.Unmute]: "<:case_unmute:906897177819881523>",
|
||||||
[CaseTypes.Deleted]: "<:case_deleted:742540201473343529>",
|
[CaseTypes.Deleted]: "<:case_deleted:906897178209968148>",
|
||||||
[CaseTypes.Softban]: "<:case_softban:742540201766813747>",
|
[CaseTypes.Softban]: "<:case_softban:906897177828278274>",
|
||||||
};
|
};
|
||||||
|
|
|
@ -87,7 +87,7 @@ export async function banUserId(
|
||||||
pluginData.state.serverLogs.ignoreLog(LogType.MEMBER_BAN, userId);
|
pluginData.state.serverLogs.ignoreLog(LogType.MEMBER_BAN, userId);
|
||||||
ignoreEvent(pluginData, IgnoredEventType.Ban, userId);
|
ignoreEvent(pluginData, IgnoredEventType.Ban, userId);
|
||||||
try {
|
try {
|
||||||
const deleteMessageDays = Math.min(30, Math.max(0, banOptions.deleteMessageDays ?? 1));
|
const deleteMessageDays = Math.min(7, 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 ?? undefined,
|
reason: reason ?? undefined,
|
||||||
|
|
|
@ -23,7 +23,7 @@ const defaultOptions: PluginOptions<NameHistoryPluginType> = {
|
||||||
|
|
||||||
export const NameHistoryPlugin = zeppelinGuildPlugin<NameHistoryPluginType>()({
|
export const NameHistoryPlugin = zeppelinGuildPlugin<NameHistoryPluginType>()({
|
||||||
name: "name_history",
|
name: "name_history",
|
||||||
showInDocs: false,
|
showInDocs: true,
|
||||||
|
|
||||||
configSchema: ConfigSchema,
|
configSchema: ConfigSchema,
|
||||||
defaultOptions,
|
defaultOptions,
|
||||||
|
@ -35,9 +35,8 @@ export const NameHistoryPlugin = zeppelinGuildPlugin<NameHistoryPluginType>()({
|
||||||
|
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
events: [
|
events: [
|
||||||
// FIXME: Temporary
|
ChannelJoinEvt,
|
||||||
// ChannelJoinEvt,
|
MessageCreateEvt,
|
||||||
// MessageCreateEvt,
|
|
||||||
],
|
],
|
||||||
|
|
||||||
beforeLoad(pluginData) {
|
beforeLoad(pluginData) {
|
||||||
|
|
|
@ -117,13 +117,13 @@ export const ReactionRolesPlugin = zeppelinGuildPlugin<ReactionRolesPluginType>(
|
||||||
RefreshReactionRolesCmd,
|
RefreshReactionRolesCmd,
|
||||||
ClearReactionRolesCmd,
|
ClearReactionRolesCmd,
|
||||||
InitReactionRolesCmd,
|
InitReactionRolesCmd,
|
||||||
// PostButtonRolesCmd,
|
PostButtonRolesCmd,
|
||||||
],
|
],
|
||||||
|
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
events: [
|
events: [
|
||||||
AddReactionRoleEvt,
|
AddReactionRoleEvt,
|
||||||
// ButtonInteractionEvt,
|
ButtonInteractionEvt,
|
||||||
MessageDeletedEvt,
|
MessageDeletedEvt,
|
||||||
],
|
],
|
||||||
configPreprocessor,
|
configPreprocessor,
|
||||||
|
|
|
@ -63,7 +63,7 @@ export const HelpCmd = utilityCmd({
|
||||||
let snippet = `**${prefix}${trigger}**`;
|
let snippet = `**${prefix}${trigger}**`;
|
||||||
if (description) snippet += `\n${description}`;
|
if (description) snippet += `\n${description}`;
|
||||||
if (usage) snippet += `\nBasic usage: \`${usage}\``;
|
if (usage) snippet += `\nBasic usage: \`${usage}\``;
|
||||||
snippet += `\n<https://zeppelin.gg/docs/plugins/${plugin.blueprint.name}/usage#command-${commandSlug}>`;
|
snippet += `\n<https://zeppelin-dashboard.up.railway.app/docs/plugins/${plugin.blueprint.name}/usage#command-${commandSlug}>`;
|
||||||
|
|
||||||
return snippet;
|
return snippet;
|
||||||
});
|
});
|
||||||
|
|
|
@ -130,9 +130,10 @@ export async function getMessageInfoEmbed(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.attachments.size) {
|
if (message.attachments.size) {
|
||||||
|
const attachmentUrls = message.attachments.map((att) => att.url);
|
||||||
embed.fields.push({
|
embed.fields.push({
|
||||||
name: preEmbedPadding + "Attachments",
|
name: preEmbedPadding + "Attachments",
|
||||||
value: message.attachments[0].url,
|
value: attachmentUrls.join("\n"),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -571,7 +571,7 @@ export function convertMSToDelayString(ms: number): string {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function successMessage(str, emoji = "<:zep_check:650361014180904971>") {
|
export function successMessage(str, emoji = "<:zep_check:906897402101891093>") {
|
||||||
return emoji ? `${emoji} ${str}` : str;
|
return emoji ? `${emoji} ${str}` : str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue