Merge branch 'master' of github.com:Dragory/ZeppelinBot
This commit is contained in:
commit
3ddfb3b65a
19 changed files with 72 additions and 35 deletions
|
@ -65,6 +65,8 @@ These instructions are intended for bot development only.
|
|||
Configuration is stored in the database in the `configs` table
|
||||
|
||||
```yml
|
||||
prefix: '!'
|
||||
|
||||
# role id: level
|
||||
levels:
|
||||
"12345678": 100 # Example admin
|
||||
|
|
|
@ -37,7 +37,7 @@ export function initDocs(app: express.Express) {
|
|||
app.get("/docs/plugins", (req: express.Request, res: express.Response) => {
|
||||
res.json(
|
||||
docsPlugins.map(plugin => {
|
||||
const thinInfo = plugin.info ? { prettyName: plugin.info.prettyName } : {};
|
||||
const thinInfo = plugin.info ? { prettyName: plugin.info.prettyName, legacy: plugin.info.legacy ?? false } : {};
|
||||
return {
|
||||
name: plugin.name,
|
||||
info: thinInfo,
|
||||
|
|
|
@ -73,6 +73,10 @@ const configPreprocessor: ConfigPreprocessorFn<AutomodPluginType> = options => {
|
|||
rule["enabled"] = true;
|
||||
}
|
||||
|
||||
if (rule["allow_further_rules"] == null) {
|
||||
rule["allow_further_rules"] = false;
|
||||
}
|
||||
|
||||
if (rule["affects_bots"] == null) {
|
||||
rule["affects_bots"] = false;
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ export async function runAutomod(pluginData: GuildPluginData<AutomodPluginType>,
|
|||
|
||||
matchResult.fullSummary = `Triggered automod rule **${ruleName}**\n${matchResult.summary}`.trim();
|
||||
|
||||
break triggerLoop;
|
||||
if (!rule.allow_further_rules) break triggerLoop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ export async function runAutomod(pluginData: GuildPluginData<AutomodPluginType>,
|
|||
});
|
||||
}
|
||||
|
||||
break;
|
||||
if (!rule.allow_further_rules) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ export const Rule = t.type({
|
|||
triggers: t.array(t.partial(AvailableTriggers.props)),
|
||||
actions: t.partial(AvailableActions.props),
|
||||
cooldown: tNullable(t.string),
|
||||
allow_further_rules: t.boolean,
|
||||
});
|
||||
export type TRule = t.TypeOf<typeof Rule>;
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ export const CensorPlugin = zeppelinGuildPlugin<CensorPluginType>()({
|
|||
Censor words, tokens, links, regex, etc.
|
||||
For more advanced filtering, check out the Automod plugin!
|
||||
`),
|
||||
legacy: true,
|
||||
},
|
||||
|
||||
dependencies: [LogsPlugin],
|
||||
|
|
|
@ -43,6 +43,7 @@ export const RoleAddCmd = selfGrantableRolesCmd({
|
|||
pluginData,
|
||||
msg.channel,
|
||||
`<@!${msg.author.id}> Unknown ${args.roleNames.length === 1 ? "role" : "roles"}`,
|
||||
{ users: [msg.author.id] },
|
||||
);
|
||||
lock.unlock();
|
||||
return;
|
||||
|
@ -87,6 +88,7 @@ export const RoleAddCmd = selfGrantableRolesCmd({
|
|||
pluginData,
|
||||
msg.channel,
|
||||
`<@!${msg.author.id}> Got an error while trying to grant you the roles`,
|
||||
{ users: [msg.author.id] },
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
@ -118,7 +120,9 @@ export const RoleAddCmd = selfGrantableRolesCmd({
|
|||
messageParts.push("couldn't recognize some of the roles");
|
||||
}
|
||||
|
||||
sendSuccessMessage(pluginData, msg.channel, `<@!${msg.author.id}> ${messageParts.join("; ")}`);
|
||||
sendSuccessMessage(pluginData, msg.channel, `<@!${msg.author.id}> ${messageParts.join("; ")}`, {
|
||||
users: [msg.author.id],
|
||||
});
|
||||
|
||||
lock.unlock();
|
||||
},
|
||||
|
|
|
@ -51,12 +51,14 @@ export const RoleRemoveCmd = selfGrantableRolesCmd({
|
|||
msg.channel,
|
||||
`<@!${msg.author.id}> Removed ${removedRolesStr.join(", ")} ${removedRolesWord};` +
|
||||
` couldn't recognize the other roles you mentioned`,
|
||||
{ users: [msg.author.id] },
|
||||
);
|
||||
} else {
|
||||
sendSuccessMessage(
|
||||
pluginData,
|
||||
msg.channel,
|
||||
`<@!${msg.author.id}> Removed ${removedRolesStr.join(", ")} ${removedRolesWord}`,
|
||||
{ users: [msg.author.id] },
|
||||
);
|
||||
}
|
||||
} catch {
|
||||
|
@ -64,6 +66,7 @@ export const RoleRemoveCmd = selfGrantableRolesCmd({
|
|||
pluginData,
|
||||
msg.channel,
|
||||
`<@!${msg.author.id}> Got an error while trying to remove the roles`,
|
||||
{ users: [msg.author.id] },
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
@ -71,6 +74,7 @@ export const RoleRemoveCmd = selfGrantableRolesCmd({
|
|||
pluginData,
|
||||
msg.channel,
|
||||
`<@!${msg.author.id}> Unknown ${args.roleNames.length === 1 ? "role" : "roles"}`,
|
||||
{ users: [msg.author.id] },
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ export const SpamPlugin = zeppelinGuildPlugin<SpamPluginType>()({
|
|||
Basic spam detection and auto-muting.
|
||||
For more advanced spam filtering, check out the Automod plugin!
|
||||
`),
|
||||
legacy: true,
|
||||
},
|
||||
|
||||
dependencies: [LogsPlugin],
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage } from "../../../pluginUtils";
|
||||
import { customEmojiRegex } from "../../../utils";
|
||||
import { getEmojiInfoEmbed } from "../functions/getEmojiInfoEmbed";
|
||||
import { getCustomEmojiId } from "../functions/getCustomEmojiId";
|
||||
import { utilityCmd } from "../types";
|
||||
|
||||
export const EmojiInfoCmd = utilityCmd({
|
||||
|
@ -11,17 +11,17 @@ export const EmojiInfoCmd = utilityCmd({
|
|||
permission: "can_emojiinfo",
|
||||
|
||||
signature: {
|
||||
emoji: ct.string({ required: false }),
|
||||
emoji: ct.string({ required: true }),
|
||||
},
|
||||
|
||||
async run({ message, args, pluginData }) {
|
||||
const emojiIdMatch = args.emoji.match(customEmojiRegex);
|
||||
if (!emojiIdMatch?.[2]) {
|
||||
const emojiId = getCustomEmojiId(args.emoji);
|
||||
if (!emojiId) {
|
||||
sendErrorMessage(pluginData, message.channel, "Emoji not found");
|
||||
return;
|
||||
}
|
||||
|
||||
const embed = await getEmojiInfoEmbed(pluginData, emojiIdMatch[2]);
|
||||
const embed = await getEmojiInfoEmbed(pluginData, emojiId);
|
||||
if (!embed) {
|
||||
sendErrorMessage(pluginData, message.channel, "Emoji not found");
|
||||
return;
|
||||
|
|
|
@ -2,26 +2,20 @@ import { Snowflake } from "discord.js";
|
|||
import { getChannelId, getRoleId } from "knub/dist/utils";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage } from "../../../pluginUtils";
|
||||
import {
|
||||
customEmojiRegex,
|
||||
isValidSnowflake,
|
||||
noop,
|
||||
parseInviteCodeInput,
|
||||
resolveInvite,
|
||||
resolveUser,
|
||||
} from "../../../utils";
|
||||
import { isValidSnowflake, noop, parseInviteCodeInput, resolveInvite, resolveUser } from "../../../utils";
|
||||
import { getUserInfoEmbed } from "../functions/getUserInfoEmbed";
|
||||
import { canReadChannel } from "../../../utils/canReadChannel";
|
||||
import { resolveMessageTarget } from "../../../utils/resolveMessageTarget";
|
||||
import { getChannelInfoEmbed } from "../functions/getChannelInfoEmbed";
|
||||
import { getEmojiInfoEmbed } from "../functions/getEmojiInfoEmbed";
|
||||
import { getGuildPreview } from "../functions/getGuildPreview";
|
||||
import { getInviteInfoEmbed } from "../functions/getInviteInfoEmbed";
|
||||
import { getMessageInfoEmbed } from "../functions/getMessageInfoEmbed";
|
||||
import { getRoleInfoEmbed } from "../functions/getRoleInfoEmbed";
|
||||
import { getEmojiInfoEmbed } from "../functions/getEmojiInfoEmbed";
|
||||
import { getCustomEmojiId } from "../functions/getCustomEmojiId";
|
||||
import { utilityCmd } from "../types";
|
||||
import { getServerInfoEmbed } from "../functions/getServerInfoEmbed";
|
||||
import { getSnowflakeInfoEmbed } from "../functions/getSnowflakeInfoEmbed";
|
||||
import { getUserInfoEmbed } from "../functions/getUserInfoEmbed";
|
||||
import { utilityCmd } from "../types";
|
||||
|
||||
export const InfoCmd = utilityCmd({
|
||||
trigger: "info",
|
||||
|
@ -139,9 +133,9 @@ export const InfoCmd = utilityCmd({
|
|||
|
||||
// 8. Emoji
|
||||
if (userCfg.can_emojiinfo) {
|
||||
const emojiIdMatch = value.match(customEmojiRegex);
|
||||
if (emojiIdMatch?.[2]) {
|
||||
const embed = await getEmojiInfoEmbed(pluginData, emojiIdMatch[2]);
|
||||
const emojiId = getCustomEmojiId(value);
|
||||
if (emojiId) {
|
||||
const embed = await getEmojiInfoEmbed(pluginData, emojiId);
|
||||
if (embed) {
|
||||
message.channel.send({ embeds: [embed] });
|
||||
return;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { Util } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { canActOn, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { errorMessage } from "../../../utils";
|
||||
import { canActOn, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { utilityCmd } from "../types";
|
||||
|
||||
export const NicknameCmd = utilityCmd({
|
||||
|
@ -11,10 +12,19 @@ export const NicknameCmd = utilityCmd({
|
|||
|
||||
signature: {
|
||||
member: ct.resolvedMember(),
|
||||
nickname: ct.string({ catchAll: true }),
|
||||
nickname: ct.string({ catchAll: true, required: false }),
|
||||
},
|
||||
|
||||
async run({ message: msg, args, pluginData }) {
|
||||
if (!args.nickname) {
|
||||
if (!args.member.nickname) {
|
||||
msg.channel.send(`<@!${args.member.id}> does not have a nickname`);
|
||||
} else {
|
||||
msg.channel.send(`The nickname of <@!${args.member.id}> is **${Util.escapeBold(args.nickname)}**`);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.member.id !== args.member.id && !canActOn(pluginData, msg.member, args.member)) {
|
||||
msg.channel.send(errorMessage("Cannot change nickname: insufficient permissions"));
|
||||
return;
|
||||
|
@ -29,9 +39,7 @@ export const NicknameCmd = utilityCmd({
|
|||
const oldNickname = args.member.nickname || "<none>";
|
||||
|
||||
try {
|
||||
await args.member.edit({
|
||||
nick: args.nickname,
|
||||
});
|
||||
await args.member.setNickname(args.nickname ?? null);
|
||||
} catch {
|
||||
msg.channel.send(errorMessage("Failed to change nickname"));
|
||||
return;
|
||||
|
|
|
@ -19,10 +19,13 @@ export const NicknameResetCmd = utilityCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
if (!args.member.nickname) {
|
||||
msg.channel.send(errorMessage("User does not have a nickname"));
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await args.member.edit({
|
||||
nick: "",
|
||||
});
|
||||
await args.member.setNickname(null);
|
||||
} catch {
|
||||
msg.channel.send(errorMessage("Failed to reset nickname"));
|
||||
return;
|
||||
|
|
|
@ -5,7 +5,7 @@ import { utilityCmd } from "../types";
|
|||
const { performance } = require("perf_hooks");
|
||||
|
||||
export const PingCmd = utilityCmd({
|
||||
trigger: "ping",
|
||||
trigger: ["ping", "pong"],
|
||||
description: "Test the bot's ping to the Discord API",
|
||||
permission: "can_ping",
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
const customEmojiRegex = /(?:<a?:[a-z0-9_]{2,32}:)?([1-9]\d+)>?/i;
|
||||
|
||||
export function getCustomEmojiId(str: string): string | null {
|
||||
const emojiIdMatch = str.match(customEmojiRegex);
|
||||
return emojiIdMatch?.[1] ?? null;
|
||||
}
|
|
@ -27,6 +27,7 @@ export interface ZeppelinGuildPluginBlueprint<TPluginData extends GuildPluginDat
|
|||
description?: TMarkdown;
|
||||
usageGuide?: TMarkdown;
|
||||
configurationGuide?: TMarkdown;
|
||||
legacy?: boolean;
|
||||
};
|
||||
|
||||
configPreprocessor?: (
|
||||
|
|
|
@ -49,6 +49,7 @@ export interface ZeppelinPluginInfo {
|
|||
description?: TMarkdown;
|
||||
usageGuide?: TMarkdown;
|
||||
configurationGuide?: TMarkdown;
|
||||
legacy?: boolean;
|
||||
}
|
||||
|
||||
export interface CommandInfo {
|
||||
|
|
|
@ -321,7 +321,7 @@
|
|||
actions:
|
||||
set_counter:
|
||||
counter: "antiraid_decay"
|
||||
amount: 10 # "Disable after 10min"
|
||||
value: 10 # "Disable after 10min"
|
||||
|
||||
start_antiraid_timer_high:
|
||||
triggers:
|
||||
|
@ -330,7 +330,7 @@
|
|||
actions:
|
||||
set_counter:
|
||||
counter: "antiraid_decay"
|
||||
amount: 20 # "Disable after 20min"
|
||||
value: 20 # "Disable after 20min"
|
||||
|
||||
disable_antiraid_after_timer:
|
||||
triggers:
|
||||
|
|
|
@ -155,7 +155,14 @@
|
|||
...menu,
|
||||
{
|
||||
label: 'Plugins',
|
||||
items: this.plugins.map(plugin => ({
|
||||
items: this.plugins.filter(plugin => !plugin.info.legacy).map(plugin => ({
|
||||
label: plugin.info.prettyName || plugin.name,
|
||||
to: `/docs/plugins/${plugin.name}`,
|
||||
})),
|
||||
},
|
||||
{
|
||||
label: "Legacy Plugins",
|
||||
items: this.plugins.filter(plugin => plugin.info.legacy).map(plugin => ({
|
||||
label: plugin.info.prettyName || plugin.name,
|
||||
to: `/docs/plugins/${plugin.name}`,
|
||||
})),
|
||||
|
|
Loading…
Add table
Reference in a new issue