diff --git a/backend/src/plugins/Utility/UtilityPlugin.ts b/backend/src/plugins/Utility/UtilityPlugin.ts index 56a00b4d..0ae876ec 100644 --- a/backend/src/plugins/Utility/UtilityPlugin.ts +++ b/backend/src/plugins/Utility/UtilityPlugin.ts @@ -5,7 +5,7 @@ import { GuildCases } from "../../data/GuildCases"; import { GuildSavedMessages } from "../../data/GuildSavedMessages"; import { GuildArchives } from "../../data/GuildArchives"; import { Supporters } from "../../data/Supporters"; -import { ServerCmd } from "./commands/ServerCmd"; +import { ServerInfoCmd } from "./commands/ServerInfoCmd"; import { RolesCmd } from "./commands/RolesCmd"; import { LevelCmd } from "./commands/LevelCmd"; import { SearchCmd } from "./commands/SearchCmd"; @@ -116,7 +116,7 @@ export const UtilityPlugin = zeppelinGuildPlugin()("utility", UserInfoCmd, LevelCmd, RolesCmd, - ServerCmd, + ServerInfoCmd, NicknameResetCmd, NicknameCmd, PingCmd, diff --git a/backend/src/plugins/Utility/commands/ChannelInfoCmd.ts b/backend/src/plugins/Utility/commands/ChannelInfoCmd.ts index c65ab41d..044ba63d 100644 --- a/backend/src/plugins/Utility/commands/ChannelInfoCmd.ts +++ b/backend/src/plugins/Utility/commands/ChannelInfoCmd.ts @@ -7,7 +7,7 @@ export const ChannelInfoCmd = utilityCmd({ trigger: ["channel", "channelinfo"], description: "Show information about a channel", usage: "!channel 534722016549404673", - permission: "can_channel", + permission: "can_channelinfo", signature: { channel: ct.channelId({ required: false }), diff --git a/backend/src/plugins/Utility/commands/InfoCmd.ts b/backend/src/plugins/Utility/commands/InfoCmd.ts index 12af56e3..f47fa139 100644 --- a/backend/src/plugins/Utility/commands/InfoCmd.ts +++ b/backend/src/plugins/Utility/commands/InfoCmd.ts @@ -27,11 +27,16 @@ export const InfoCmd = utilityCmd({ async run({ message, args, pluginData }) { const value = args.value || message.author.id; + const userCfg = pluginData.config.getMatchingConfig({ + member: message.member, + channelId: message.channel.id, + message, + }); // 1. Channel const channelId = getChannelId(value); const channel = channelId && pluginData.guild.channels.get(channelId); - if (channel) { + if (channel && userCfg.can_channelinfo) { const embed = await getChannelInfoEmbed(pluginData, channelId!, message.author.id); if (embed) { message.channel.createMessage({ embed }); @@ -41,7 +46,7 @@ export const InfoCmd = utilityCmd({ // 2. Server const guild = pluginData.client.guilds.get(value); - if (guild) { + if (guild && userCfg.can_server) { const embed = await getServerInfoEmbed(pluginData, value, message.author.id); if (embed) { message.channel.createMessage({ embed }); @@ -51,7 +56,7 @@ export const InfoCmd = utilityCmd({ // 3. User const user = await resolveUser(pluginData.client, value); - if (user) { + if (user && userCfg.can_userinfo) { const embed = await getUserInfoEmbed(pluginData, user.id, Boolean(args.compact), message.author.id); if (embed) { message.channel.createMessage({ embed }); @@ -61,7 +66,7 @@ export const InfoCmd = utilityCmd({ // 4. Message const messageTarget = await resolveMessageTarget(pluginData, value); - if (messageTarget) { + if (messageTarget && userCfg.can_messageinfo) { if (canReadChannel(messageTarget.channel, message.member)) { const embed = await getMessageInfoEmbed( pluginData, @@ -80,7 +85,7 @@ export const InfoCmd = utilityCmd({ const inviteCode = await parseInviteCodeInput(value); if (inviteCode) { const invite = await resolveInvite(pluginData.client, inviteCode, true); - if (invite) { + if (invite && userCfg.can_inviteinfo) { const embed = await getInviteInfoEmbed(pluginData, inviteCode); if (embed) { message.channel.createMessage({ embed }); @@ -91,7 +96,7 @@ export const InfoCmd = utilityCmd({ // 6. Server again (fallback for discovery servers) const serverPreview = getGuildPreview(pluginData.client, value).catch(() => null); - if (serverPreview) { + if (serverPreview && userCfg.can_server) { const embed = await getServerInfoEmbed(pluginData, value, message.author.id); if (embed) { message.channel.createMessage({ embed }); @@ -100,13 +105,17 @@ export const InfoCmd = utilityCmd({ } // 7. Arbitrary ID - if (isValidSnowflake(value)) { + if (isValidSnowflake(value) && userCfg.can_snowflake) { const embed = await getSnowflakeInfoEmbed(pluginData, value, true, message.author.id); message.channel.createMessage({ embed }); return; } // 7. No can do - sendErrorMessage(pluginData, message.channel, "Could not find anything with that value"); + sendErrorMessage( + pluginData, + message.channel, + "Could not find anything with that value or you are lacking permission for the snowflake type", + ); }, }); diff --git a/backend/src/plugins/Utility/commands/InviteInfoCmd.ts b/backend/src/plugins/Utility/commands/InviteInfoCmd.ts index 4121bfc0..0406ff84 100644 --- a/backend/src/plugins/Utility/commands/InviteInfoCmd.ts +++ b/backend/src/plugins/Utility/commands/InviteInfoCmd.ts @@ -8,7 +8,7 @@ export const InviteInfoCmd = utilityCmd({ trigger: ["invite", "inviteinfo"], description: "Show information about an invite", usage: "!invite overwatch", - permission: "can_invite", + permission: "can_inviteinfo", signature: { inviteCode: ct.string({ required: false }), diff --git a/backend/src/plugins/Utility/commands/MessageInfoCmd.ts b/backend/src/plugins/Utility/commands/MessageInfoCmd.ts index 2d694d24..4681fd2e 100644 --- a/backend/src/plugins/Utility/commands/MessageInfoCmd.ts +++ b/backend/src/plugins/Utility/commands/MessageInfoCmd.ts @@ -8,7 +8,7 @@ export const MessageInfoCmd = utilityCmd({ trigger: ["message", "messageinfo"], description: "Show information about a message", usage: "!message 534722016549404673-534722219696455701", - permission: "can_message", + permission: "can_messageinfo", signature: { message: ct.messageTarget(), diff --git a/backend/src/plugins/Utility/commands/ServerCmd.ts b/backend/src/plugins/Utility/commands/ServerInfoCmd.ts similarity index 95% rename from backend/src/plugins/Utility/commands/ServerCmd.ts rename to backend/src/plugins/Utility/commands/ServerInfoCmd.ts index 2792b821..97a5d06a 100644 --- a/backend/src/plugins/Utility/commands/ServerCmd.ts +++ b/backend/src/plugins/Utility/commands/ServerInfoCmd.ts @@ -3,7 +3,7 @@ import { commandTypeHelpers as ct } from "../../../commandTypes"; import { sendErrorMessage } from "../../../pluginUtils"; import { getServerInfoEmbed } from "../functions/getServerInfoEmbed"; -export const ServerCmd = utilityCmd({ +export const ServerInfoCmd = utilityCmd({ trigger: ["server", "serverinfo"], description: "Show server information", usage: "!server",