mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-16 22:21:51 +00:00
Merge pull request #212 from almeidx/feat/emojiinfo-snowflakes
Added support for snowflakes on EmojiInfoCmd
This commit is contained in:
commit
501820b805
3 changed files with 18 additions and 18 deletions
|
@ -1,7 +1,7 @@
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||||
import { sendErrorMessage } from "../../../pluginUtils";
|
import { sendErrorMessage } from "../../../pluginUtils";
|
||||||
import { customEmojiRegex } from "../../../utils";
|
|
||||||
import { getEmojiInfoEmbed } from "../functions/getEmojiInfoEmbed";
|
import { getEmojiInfoEmbed } from "../functions/getEmojiInfoEmbed";
|
||||||
|
import { getCustomEmojiId } from "../functions/getCustomEmojiId";
|
||||||
import { utilityCmd } from "../types";
|
import { utilityCmd } from "../types";
|
||||||
|
|
||||||
export const EmojiInfoCmd = utilityCmd({
|
export const EmojiInfoCmd = utilityCmd({
|
||||||
|
@ -15,13 +15,13 @@ export const EmojiInfoCmd = utilityCmd({
|
||||||
},
|
},
|
||||||
|
|
||||||
async run({ message, args, pluginData }) {
|
async run({ message, args, pluginData }) {
|
||||||
const emojiIdMatch = args.emoji.match(customEmojiRegex);
|
const emojiId = getCustomEmojiId(args.emoji);
|
||||||
if (!emojiIdMatch?.[2]) {
|
if (!emojiId) {
|
||||||
sendErrorMessage(pluginData, message.channel, "Emoji not found");
|
sendErrorMessage(pluginData, message.channel, "Emoji not found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const embed = await getEmojiInfoEmbed(pluginData, emojiIdMatch[2]);
|
const embed = await getEmojiInfoEmbed(pluginData, emojiId);
|
||||||
if (!embed) {
|
if (!embed) {
|
||||||
sendErrorMessage(pluginData, message.channel, "Emoji not found");
|
sendErrorMessage(pluginData, message.channel, "Emoji not found");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -2,26 +2,20 @@ import { Snowflake } from "discord.js";
|
||||||
import { getChannelId, getRoleId } from "knub/dist/utils";
|
import { getChannelId, getRoleId } from "knub/dist/utils";
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||||
import { sendErrorMessage } from "../../../pluginUtils";
|
import { sendErrorMessage } from "../../../pluginUtils";
|
||||||
import {
|
import { isValidSnowflake, noop, parseInviteCodeInput, resolveInvite, resolveUser } from "../../../utils";
|
||||||
customEmojiRegex,
|
import { getUserInfoEmbed } from "../functions/getUserInfoEmbed";
|
||||||
isValidSnowflake,
|
|
||||||
noop,
|
|
||||||
parseInviteCodeInput,
|
|
||||||
resolveInvite,
|
|
||||||
resolveUser,
|
|
||||||
} from "../../../utils";
|
|
||||||
import { canReadChannel } from "../../../utils/canReadChannel";
|
import { canReadChannel } from "../../../utils/canReadChannel";
|
||||||
import { resolveMessageTarget } from "../../../utils/resolveMessageTarget";
|
import { resolveMessageTarget } from "../../../utils/resolveMessageTarget";
|
||||||
import { getChannelInfoEmbed } from "../functions/getChannelInfoEmbed";
|
import { getChannelInfoEmbed } from "../functions/getChannelInfoEmbed";
|
||||||
import { getEmojiInfoEmbed } from "../functions/getEmojiInfoEmbed";
|
|
||||||
import { getGuildPreview } from "../functions/getGuildPreview";
|
import { getGuildPreview } from "../functions/getGuildPreview";
|
||||||
import { getInviteInfoEmbed } from "../functions/getInviteInfoEmbed";
|
import { getInviteInfoEmbed } from "../functions/getInviteInfoEmbed";
|
||||||
import { getMessageInfoEmbed } from "../functions/getMessageInfoEmbed";
|
import { getMessageInfoEmbed } from "../functions/getMessageInfoEmbed";
|
||||||
import { getRoleInfoEmbed } from "../functions/getRoleInfoEmbed";
|
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 { getServerInfoEmbed } from "../functions/getServerInfoEmbed";
|
||||||
import { getSnowflakeInfoEmbed } from "../functions/getSnowflakeInfoEmbed";
|
import { getSnowflakeInfoEmbed } from "../functions/getSnowflakeInfoEmbed";
|
||||||
import { getUserInfoEmbed } from "../functions/getUserInfoEmbed";
|
|
||||||
import { utilityCmd } from "../types";
|
|
||||||
|
|
||||||
export const InfoCmd = utilityCmd({
|
export const InfoCmd = utilityCmd({
|
||||||
trigger: "info",
|
trigger: "info",
|
||||||
|
@ -139,9 +133,9 @@ export const InfoCmd = utilityCmd({
|
||||||
|
|
||||||
// 8. Emoji
|
// 8. Emoji
|
||||||
if (userCfg.can_emojiinfo) {
|
if (userCfg.can_emojiinfo) {
|
||||||
const emojiIdMatch = value.match(customEmojiRegex);
|
const emojiId = getCustomEmojiId(value);
|
||||||
if (emojiIdMatch?.[2]) {
|
if (emojiId) {
|
||||||
const embed = await getEmojiInfoEmbed(pluginData, emojiIdMatch[2]);
|
const embed = await getEmojiInfoEmbed(pluginData, emojiId);
|
||||||
if (embed) {
|
if (embed) {
|
||||||
message.channel.send({ embeds: [embed] });
|
message.channel.send({ embeds: [embed] });
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue