2020-10-01 01:43:38 +03:00
|
|
|
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
2020-07-05 05:00:54 +03:00
|
|
|
import { ConfigSchema, UtilityPluginType } from "./types";
|
|
|
|
import { GuildLogs } from "../../data/GuildLogs";
|
|
|
|
import { GuildCases } from "../../data/GuildCases";
|
|
|
|
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
|
|
|
|
import { GuildArchives } from "../../data/GuildArchives";
|
|
|
|
import { Supporters } from "../../data/Supporters";
|
2021-02-13 19:02:43 +01:00
|
|
|
import { ServerInfoCmd } from "./commands/ServerInfoCmd";
|
2020-07-05 05:00:54 +03:00
|
|
|
import { RolesCmd } from "./commands/RolesCmd";
|
|
|
|
import { LevelCmd } from "./commands/LevelCmd";
|
2020-07-06 00:53:28 +03:00
|
|
|
import { SearchCmd } from "./commands/SearchCmd";
|
|
|
|
import { BanSearchCmd } from "./commands/BanSearchCmd";
|
2020-08-06 00:48:29 +03:00
|
|
|
import { UserInfoCmd } from "./commands/UserInfoCmd";
|
2020-07-06 01:51:48 +03:00
|
|
|
import { NicknameResetCmd } from "./commands/NicknameResetCmd";
|
|
|
|
import { NicknameCmd } from "./commands/NicknameCmd";
|
|
|
|
import { PingCmd } from "./commands/PingCmd";
|
|
|
|
import { SourceCmd } from "./commands/SourceCmd";
|
|
|
|
import { ContextCmd } from "./commands/ContextCmd";
|
2020-12-12 21:15:15 +01:00
|
|
|
import { VcmoveAllCmd, VcmoveCmd } from "./commands/VcmoveCmd";
|
2020-07-06 01:51:48 +03:00
|
|
|
import { HelpCmd } from "./commands/HelpCmd";
|
|
|
|
import { AboutCmd } from "./commands/AboutCmd";
|
2020-07-06 02:10:22 +03:00
|
|
|
import { PluginOptions } from "knub";
|
2020-07-06 02:47:39 +03:00
|
|
|
import { activeReloads } from "./guildReloads";
|
|
|
|
import { sendSuccessMessage } from "../../pluginUtils";
|
|
|
|
import { ReloadGuildCmd } from "./commands/ReloadGuildCmd";
|
|
|
|
import { JumboCmd } from "./commands/JumboCmd";
|
|
|
|
import { AvatarCmd } from "./commands/AvatarCmd";
|
2020-07-06 02:56:54 +03:00
|
|
|
import { CleanCmd } from "./commands/CleanCmd";
|
2020-07-29 02:21:22 +02:00
|
|
|
import { Message } from "eris";
|
2020-08-05 18:52:15 +03:00
|
|
|
import { InviteInfoCmd } from "./commands/InviteInfoCmd";
|
2020-08-05 22:54:14 +03:00
|
|
|
import { ChannelInfoCmd } from "./commands/ChannelInfoCmd";
|
2020-08-06 00:46:47 +03:00
|
|
|
import { MessageInfoCmd } from "./commands/MessageInfoCmd";
|
2020-08-06 01:10:40 +03:00
|
|
|
import { InfoCmd } from "./commands/InfoCmd";
|
2020-08-09 17:28:21 +03:00
|
|
|
import { SnowflakeInfoCmd } from "./commands/SnowflakeInfoCmd";
|
2020-08-10 00:39:07 +03:00
|
|
|
import { discardRegExpRunner, getRegExpRunner } from "../../regExpRunners";
|
2020-08-19 00:19:12 +03:00
|
|
|
import { TimeAndDatePlugin } from "../TimeAndDate/TimeAndDatePlugin";
|
2021-01-28 00:28:26 +01:00
|
|
|
import { VcdisconnectCmd } from "./commands/VcdisconnectCmd";
|
2021-04-02 21:31:05 +03:00
|
|
|
import { refreshMembersIfNeeded } from "./refreshMembers";
|
2020-07-06 02:10:22 +03:00
|
|
|
|
|
|
|
const defaultOptions: PluginOptions<UtilityPluginType> = {
|
|
|
|
config: {
|
|
|
|
can_roles: false,
|
|
|
|
can_level: false,
|
|
|
|
can_search: false,
|
|
|
|
can_clean: false,
|
|
|
|
can_info: false,
|
|
|
|
can_server: false,
|
2020-08-06 01:10:40 +03:00
|
|
|
can_inviteinfo: false,
|
|
|
|
can_channelinfo: false,
|
|
|
|
can_messageinfo: false,
|
2020-08-06 00:48:29 +03:00
|
|
|
can_userinfo: false,
|
2020-08-09 17:28:21 +03:00
|
|
|
can_snowflake: false,
|
2020-07-06 02:10:22 +03:00
|
|
|
can_reload_guild: false,
|
|
|
|
can_nickname: false,
|
|
|
|
can_ping: false,
|
|
|
|
can_source: false,
|
|
|
|
can_vcmove: false,
|
2021-01-28 00:28:26 +01:00
|
|
|
can_vckick: false,
|
2020-07-06 02:10:22 +03:00
|
|
|
can_help: false,
|
|
|
|
can_about: false,
|
|
|
|
can_context: false,
|
|
|
|
can_jumbo: false,
|
|
|
|
jumbo_size: 128,
|
|
|
|
can_avatar: false,
|
2020-07-29 02:21:22 +02:00
|
|
|
info_on_single_result: true,
|
2020-07-06 02:10:22 +03:00
|
|
|
},
|
|
|
|
overrides: [
|
|
|
|
{
|
|
|
|
level: ">=50",
|
|
|
|
config: {
|
|
|
|
can_roles: true,
|
|
|
|
can_level: true,
|
|
|
|
can_search: true,
|
|
|
|
can_clean: true,
|
|
|
|
can_info: true,
|
|
|
|
can_server: true,
|
2020-08-06 01:10:40 +03:00
|
|
|
can_inviteinfo: true,
|
|
|
|
can_channelinfo: true,
|
|
|
|
can_messageinfo: true,
|
2020-08-06 00:48:29 +03:00
|
|
|
can_userinfo: true,
|
2020-08-09 17:28:21 +03:00
|
|
|
can_snowflake: true,
|
2020-07-06 02:10:22 +03:00
|
|
|
can_nickname: true,
|
|
|
|
can_vcmove: true,
|
2021-01-28 00:28:26 +01:00
|
|
|
can_vckick: true,
|
2020-07-06 02:10:22 +03:00
|
|
|
can_help: true,
|
|
|
|
can_context: true,
|
|
|
|
can_jumbo: true,
|
|
|
|
can_avatar: true,
|
2020-08-05 23:57:09 +03:00
|
|
|
can_source: true,
|
2020-07-06 02:10:22 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
level: ">=100",
|
|
|
|
config: {
|
|
|
|
can_reload_guild: true,
|
|
|
|
can_ping: true,
|
|
|
|
can_about: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
2020-07-05 05:00:54 +03:00
|
|
|
|
2020-10-01 01:43:38 +03:00
|
|
|
export const UtilityPlugin = zeppelinGuildPlugin<UtilityPluginType>()("utility", {
|
2020-07-30 13:08:06 +03:00
|
|
|
showInDocs: true,
|
|
|
|
info: {
|
|
|
|
prettyName: "Utility",
|
|
|
|
},
|
|
|
|
|
2020-08-19 00:19:12 +03:00
|
|
|
dependencies: [TimeAndDatePlugin],
|
2020-07-05 05:00:54 +03:00
|
|
|
configSchema: ConfigSchema,
|
2020-07-06 02:10:22 +03:00
|
|
|
defaultOptions,
|
2020-07-05 05:00:54 +03:00
|
|
|
|
2020-07-06 01:02:55 +03:00
|
|
|
// prettier-ignore
|
|
|
|
commands: [
|
2020-07-06 01:51:48 +03:00
|
|
|
SearchCmd,
|
2020-07-06 01:02:55 +03:00
|
|
|
BanSearchCmd,
|
2020-08-06 00:48:29 +03:00
|
|
|
UserInfoCmd,
|
2020-07-06 01:02:55 +03:00
|
|
|
LevelCmd,
|
|
|
|
RolesCmd,
|
2021-02-13 19:02:43 +01:00
|
|
|
ServerInfoCmd,
|
2020-07-06 01:51:48 +03:00
|
|
|
NicknameResetCmd,
|
|
|
|
NicknameCmd,
|
|
|
|
PingCmd,
|
|
|
|
SourceCmd,
|
|
|
|
ContextCmd,
|
|
|
|
VcmoveCmd,
|
2021-01-28 00:28:26 +01:00
|
|
|
VcdisconnectCmd,
|
2020-12-12 21:15:15 +01:00
|
|
|
VcmoveAllCmd,
|
2020-07-06 01:51:48 +03:00
|
|
|
HelpCmd,
|
|
|
|
AboutCmd,
|
2020-07-06 02:47:39 +03:00
|
|
|
ReloadGuildCmd,
|
|
|
|
JumboCmd,
|
|
|
|
AvatarCmd,
|
2020-07-06 02:56:54 +03:00
|
|
|
CleanCmd,
|
2020-08-05 18:52:15 +03:00
|
|
|
InviteInfoCmd,
|
2020-08-05 22:54:14 +03:00
|
|
|
ChannelInfoCmd,
|
2020-08-06 00:46:47 +03:00
|
|
|
MessageInfoCmd,
|
2020-08-06 01:10:40 +03:00
|
|
|
InfoCmd,
|
2020-08-09 17:28:21 +03:00
|
|
|
SnowflakeInfoCmd,
|
2020-07-06 01:02:55 +03:00
|
|
|
],
|
2020-07-05 05:00:54 +03:00
|
|
|
|
2020-07-06 02:47:39 +03:00
|
|
|
onLoad(pluginData) {
|
|
|
|
const { state, guild } = pluginData;
|
|
|
|
|
2020-07-05 05:00:54 +03:00
|
|
|
state.logs = new GuildLogs(guild.id);
|
|
|
|
state.cases = GuildCases.getGuildInstance(guild.id);
|
|
|
|
state.savedMessages = GuildSavedMessages.getGuildInstance(guild.id);
|
|
|
|
state.archives = GuildArchives.getGuildInstance(guild.id);
|
|
|
|
state.supporters = new Supporters();
|
|
|
|
|
2020-08-10 00:39:07 +03:00
|
|
|
state.regexRunner = getRegExpRunner(`guild-${pluginData.guild.id}`);
|
|
|
|
|
2020-07-05 05:00:54 +03:00
|
|
|
state.lastReload = Date.now();
|
2020-07-06 02:47:39 +03:00
|
|
|
|
|
|
|
if (activeReloads.has(guild.id)) {
|
2021-01-17 21:05:11 +02:00
|
|
|
sendSuccessMessage(pluginData, activeReloads.get(guild.id)!, "Reloaded!");
|
2020-07-06 02:47:39 +03:00
|
|
|
activeReloads.delete(guild.id);
|
|
|
|
}
|
2021-04-02 21:31:05 +03:00
|
|
|
|
|
|
|
// FIXME: Temp fix for role change detection for specific servers, load all guild members in the background on bot start
|
|
|
|
const roleChangeDetectionFixServers = [
|
|
|
|
"786212572285763605",
|
|
|
|
"653681924384096287",
|
|
|
|
"493351982887862283",
|
|
|
|
"513338222810497041",
|
|
|
|
"523043978178723840",
|
|
|
|
"718076393295970376",
|
|
|
|
"803251072877199400",
|
|
|
|
"750492934343753798",
|
|
|
|
];
|
|
|
|
if (roleChangeDetectionFixServers.includes(pluginData.guild.id)) {
|
|
|
|
refreshMembersIfNeeded(pluginData.guild);
|
|
|
|
}
|
2020-07-06 00:53:28 +03:00
|
|
|
},
|
2020-08-10 00:39:07 +03:00
|
|
|
|
|
|
|
onUnload(pluginData) {
|
|
|
|
discardRegExpRunner(`guild-${pluginData.guild.id}`);
|
|
|
|
},
|
2020-07-05 05:00:54 +03:00
|
|
|
});
|