mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-21 00:35:02 +00:00
added emojiinfo command
This commit is contained in:
parent
89a4b4a153
commit
5d52f88c56
5 changed files with 82 additions and 3 deletions
|
@ -26,7 +26,6 @@ import { ReloadGuildCmd } from "./commands/ReloadGuildCmd";
|
||||||
import { JumboCmd } from "./commands/JumboCmd";
|
import { JumboCmd } from "./commands/JumboCmd";
|
||||||
import { AvatarCmd } from "./commands/AvatarCmd";
|
import { AvatarCmd } from "./commands/AvatarCmd";
|
||||||
import { CleanCmd } from "./commands/CleanCmd";
|
import { CleanCmd } from "./commands/CleanCmd";
|
||||||
import { Message } from "eris";
|
|
||||||
import { InviteInfoCmd } from "./commands/InviteInfoCmd";
|
import { InviteInfoCmd } from "./commands/InviteInfoCmd";
|
||||||
import { ChannelInfoCmd } from "./commands/ChannelInfoCmd";
|
import { ChannelInfoCmd } from "./commands/ChannelInfoCmd";
|
||||||
import { MessageInfoCmd } from "./commands/MessageInfoCmd";
|
import { MessageInfoCmd } from "./commands/MessageInfoCmd";
|
||||||
|
@ -38,6 +37,7 @@ import { VcdisconnectCmd } from "./commands/VcdisconnectCmd";
|
||||||
import { ModActionsPlugin } from "../ModActions/ModActionsPlugin";
|
import { ModActionsPlugin } from "../ModActions/ModActionsPlugin";
|
||||||
import { refreshMembersIfNeeded } from "./refreshMembers";
|
import { refreshMembersIfNeeded } from "./refreshMembers";
|
||||||
import { RoleInfoCmd } from "./commands/RoleInfoCmd";
|
import { RoleInfoCmd } from "./commands/RoleInfoCmd";
|
||||||
|
import { EmojiInfoCmd } from "./commands/EmojiInfoCmd";
|
||||||
|
|
||||||
const defaultOptions: PluginOptions<UtilityPluginType> = {
|
const defaultOptions: PluginOptions<UtilityPluginType> = {
|
||||||
config: {
|
config: {
|
||||||
|
@ -52,6 +52,7 @@ const defaultOptions: PluginOptions<UtilityPluginType> = {
|
||||||
can_messageinfo: false,
|
can_messageinfo: false,
|
||||||
can_userinfo: false,
|
can_userinfo: false,
|
||||||
can_roleinfo: false,
|
can_roleinfo: false,
|
||||||
|
can_emojiinfo: false,
|
||||||
can_snowflake: false,
|
can_snowflake: false,
|
||||||
can_reload_guild: false,
|
can_reload_guild: false,
|
||||||
can_nickname: false,
|
can_nickname: false,
|
||||||
|
@ -82,6 +83,7 @@ const defaultOptions: PluginOptions<UtilityPluginType> = {
|
||||||
can_messageinfo: true,
|
can_messageinfo: true,
|
||||||
can_userinfo: true,
|
can_userinfo: true,
|
||||||
can_roleinfo: true,
|
can_roleinfo: true,
|
||||||
|
can_emojiinfo: true,
|
||||||
can_snowflake: true,
|
can_snowflake: true,
|
||||||
can_nickname: true,
|
can_nickname: true,
|
||||||
can_vcmove: true,
|
can_vcmove: true,
|
||||||
|
@ -142,6 +144,7 @@ export const UtilityPlugin = zeppelinGuildPlugin<UtilityPluginType>()("utility",
|
||||||
InfoCmd,
|
InfoCmd,
|
||||||
SnowflakeInfoCmd,
|
SnowflakeInfoCmd,
|
||||||
RoleInfoCmd,
|
RoleInfoCmd,
|
||||||
|
EmojiInfoCmd,
|
||||||
],
|
],
|
||||||
|
|
||||||
onLoad(pluginData) {
|
onLoad(pluginData) {
|
||||||
|
|
32
backend/src/plugins/Utility/commands/EmojiInfoCmd.ts
Normal file
32
backend/src/plugins/Utility/commands/EmojiInfoCmd.ts
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
import { utilityCmd } from "../types";
|
||||||
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||||
|
import { sendErrorMessage } from "../../../pluginUtils";
|
||||||
|
import { customEmojiRegex } from "../../../utils";
|
||||||
|
import { getEmojiInfoEmbed } from "../functions/getEmojiInfoEmbed";
|
||||||
|
|
||||||
|
export const EmojiInfoCmd = utilityCmd({
|
||||||
|
trigger: ["emoji", "emojiinfo"],
|
||||||
|
description: "Show information about an emoji",
|
||||||
|
usage: "!emoji 106391128718245888",
|
||||||
|
permission: "can_emojiinfo",
|
||||||
|
|
||||||
|
signature: {
|
||||||
|
emoji: ct.string({ required: false }),
|
||||||
|
},
|
||||||
|
|
||||||
|
async run({ message, args, pluginData }) {
|
||||||
|
const emojiIdMatch = args.emoji.match(customEmojiRegex);
|
||||||
|
if (!emojiIdMatch?.[2]) {
|
||||||
|
sendErrorMessage(pluginData, message.channel, "Emoji not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const embed = await getEmojiInfoEmbed(pluginData, emojiIdMatch[2]);
|
||||||
|
if (!embed) {
|
||||||
|
sendErrorMessage(pluginData, message.channel, "Emoji not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
message.channel.createMessage({ embed });
|
||||||
|
},
|
||||||
|
});
|
|
@ -2,7 +2,7 @@ import { utilityCmd } from "../types";
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||||
import { sendErrorMessage } from "../../../pluginUtils";
|
import { sendErrorMessage } from "../../../pluginUtils";
|
||||||
import { getInviteInfoEmbed } from "../functions/getInviteInfoEmbed";
|
import { getInviteInfoEmbed } from "../functions/getInviteInfoEmbed";
|
||||||
import { isValidSnowflake, parseInviteCodeInput, resolveInvite, resolveUser } from "../../../utils";
|
import { customEmojiRegex, isValidSnowflake, parseInviteCodeInput, resolveInvite, resolveUser } from "../../../utils";
|
||||||
import { getUserInfoEmbed } from "../functions/getUserInfoEmbed";
|
import { getUserInfoEmbed } from "../functions/getUserInfoEmbed";
|
||||||
import { resolveMessageTarget } from "../../../utils/resolveMessageTarget";
|
import { resolveMessageTarget } from "../../../utils/resolveMessageTarget";
|
||||||
import { canReadChannel } from "../../../utils/canReadChannel";
|
import { canReadChannel } from "../../../utils/canReadChannel";
|
||||||
|
@ -13,6 +13,7 @@ import { getChannelId, getRoleId } from "knub/dist/utils";
|
||||||
import { getGuildPreview } from "../functions/getGuildPreview";
|
import { getGuildPreview } from "../functions/getGuildPreview";
|
||||||
import { getSnowflakeInfoEmbed } from "../functions/getSnowflakeInfoEmbed";
|
import { getSnowflakeInfoEmbed } from "../functions/getSnowflakeInfoEmbed";
|
||||||
import { getRoleInfoEmbed } from "../functions/getRoleInfoEmbed";
|
import { getRoleInfoEmbed } from "../functions/getRoleInfoEmbed";
|
||||||
|
import { getEmojiInfoEmbed } from "../functions/getEmojiInfoEmbed";
|
||||||
|
|
||||||
export const InfoCmd = utilityCmd({
|
export const InfoCmd = utilityCmd({
|
||||||
trigger: "info",
|
trigger: "info",
|
||||||
|
@ -114,7 +115,15 @@ export const InfoCmd = utilityCmd({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: 8. Emoji ID
|
// 8. Emoji
|
||||||
|
const emojiIdMatch = value.match(customEmojiRegex);
|
||||||
|
if (emojiIdMatch?.[2] && userCfg.can_emojiinfo) {
|
||||||
|
const embed = await getEmojiInfoEmbed(pluginData, emojiIdMatch[2]);
|
||||||
|
if (embed) {
|
||||||
|
message.channel.createMessage({ embed });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 9. Arbitrary ID
|
// 9. Arbitrary ID
|
||||||
if (isValidSnowflake(value) && userCfg.can_snowflake) {
|
if (isValidSnowflake(value) && userCfg.can_snowflake) {
|
||||||
|
|
34
backend/src/plugins/Utility/functions/getEmojiInfoEmbed.ts
Normal file
34
backend/src/plugins/Utility/functions/getEmojiInfoEmbed.ts
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
import { EmbedOptions } from "eris";
|
||||||
|
import { GuildPluginData } from "knub";
|
||||||
|
import { UtilityPluginType } from "../types";
|
||||||
|
import { trimLines, preEmbedPadding, EmbedWith } from "../../../utils";
|
||||||
|
|
||||||
|
export async function getEmojiInfoEmbed(
|
||||||
|
pluginData: GuildPluginData<UtilityPluginType>,
|
||||||
|
emojiId: string,
|
||||||
|
): Promise<EmbedOptions | null> {
|
||||||
|
const emoji = pluginData.guild.emojis.find(e => e.id === emojiId);
|
||||||
|
if (!emoji) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const embed: EmbedWith<"fields"> = {
|
||||||
|
fields: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
embed.author = {
|
||||||
|
name: `Emoji: ${emoji.name}`,
|
||||||
|
icon_url: `https://cdn.discordapp.com/emojis/${emoji.id}.${emoji.animated ? "gif" : "png"}?v=1`,
|
||||||
|
};
|
||||||
|
|
||||||
|
embed.fields.push({
|
||||||
|
name: preEmbedPadding + "Emoji information",
|
||||||
|
value: trimLines(`
|
||||||
|
Name: **${emoji.name}**
|
||||||
|
ID: \`${emoji.id}\`
|
||||||
|
Animated: **${emoji.animated ? "Yes" : "No"}**
|
||||||
|
`),
|
||||||
|
});
|
||||||
|
|
||||||
|
return embed;
|
||||||
|
}
|
|
@ -19,6 +19,7 @@ export const ConfigSchema = t.type({
|
||||||
can_messageinfo: t.boolean,
|
can_messageinfo: t.boolean,
|
||||||
can_userinfo: t.boolean,
|
can_userinfo: t.boolean,
|
||||||
can_roleinfo: t.boolean,
|
can_roleinfo: t.boolean,
|
||||||
|
can_emojiinfo: t.boolean,
|
||||||
can_snowflake: t.boolean,
|
can_snowflake: t.boolean,
|
||||||
can_reload_guild: t.boolean,
|
can_reload_guild: t.boolean,
|
||||||
can_nickname: t.boolean,
|
can_nickname: t.boolean,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue