Spaces:
Runtime error
Runtime error
Update index.js
Browse files
index.js
CHANGED
|
@@ -70,7 +70,8 @@ const client = new Client({
|
|
| 70 |
GatewayIntentBits.GuildMessages,
|
| 71 |
GatewayIntentBits.MessageContent,
|
| 72 |
GatewayIntentBits.GuildMessageReactions,
|
| 73 |
-
GatewayIntentBits.GuildMembers
|
|
|
|
| 74 |
],
|
| 75 |
partials: [Partials.Message, Partials.Channel, Partials.Reaction],
|
| 76 |
rest: {
|
|
@@ -3008,10 +3009,16 @@ function getGuildLineupB(guildId) {
|
|
| 3008 |
function resolveEmojis(text, guildId) {
|
| 3009 |
if (!text || typeof text !== 'string') return text;
|
| 3010 |
const guild = client.guilds.cache.get(guildId);
|
| 3011 |
-
if (!guild) return text;
|
| 3012 |
|
| 3013 |
return text.replace(/:([a-zA-Z0-9_]+):/g, (match, name) => {
|
| 3014 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3015 |
return emoji ? emoji.toString() : match;
|
| 3016 |
});
|
| 3017 |
}
|
|
|
|
| 70 |
GatewayIntentBits.GuildMessages,
|
| 71 |
GatewayIntentBits.MessageContent,
|
| 72 |
GatewayIntentBits.GuildMessageReactions,
|
| 73 |
+
GatewayIntentBits.GuildMembers,
|
| 74 |
+
GatewayIntentBits.GuildEmojisAndStickers
|
| 75 |
],
|
| 76 |
partials: [Partials.Message, Partials.Channel, Partials.Reaction],
|
| 77 |
rest: {
|
|
|
|
| 3009 |
function resolveEmojis(text, guildId) {
|
| 3010 |
if (!text || typeof text !== 'string') return text;
|
| 3011 |
const guild = client.guilds.cache.get(guildId);
|
|
|
|
| 3012 |
|
| 3013 |
return text.replace(/:([a-zA-Z0-9_]+):/g, (match, name) => {
|
| 3014 |
+
// 1. Try finding in current guild (case-insensitive)
|
| 3015 |
+
let emoji = guild?.emojis.cache.find(e => e.name.toLowerCase() === name.toLowerCase());
|
| 3016 |
+
|
| 3017 |
+
// 2. Try finding globally if not found in guild
|
| 3018 |
+
if (!emoji && client) {
|
| 3019 |
+
emoji = client.emojis.cache.find(e => e.name.toLowerCase() === name.toLowerCase());
|
| 3020 |
+
}
|
| 3021 |
+
|
| 3022 |
return emoji ? emoji.toString() : match;
|
| 3023 |
});
|
| 3024 |
}
|