Skip to content

Commit

Permalink
feat(cleanContent): add missing emojis & slash mentions
Browse files Browse the repository at this point in the history
  • Loading branch information
DraftProducts committed Mar 26, 2023
1 parent b8b852e commit a7aec46
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/discord.js/src/util/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ function basename(path, ext) {
* @returns {string}
*/
function cleanContent(str, channel) {
return str.replaceAll(/<(@[!&]?|#)(\d{17,19})>/g, (match, type, id) => {
switch (type) {
return str.replaceAll(/<(?:(@[!&]?|#)|([/:])([\w ]+):)(\d{17,19})>/g, (match, type, prefix, name, id) => {
switch (type ?? prefix) {
case '@':
case '@!': {
const member = channel.guild?.members.cache.get(id);
Expand All @@ -336,6 +336,10 @@ function cleanContent(str, channel) {
const mentionedChannel = channel.client.channels.cache.get(id);
return mentionedChannel ? `#${mentionedChannel.name}` : match;
}
case '/':
return `/${name}`;
case ':':
return `:${name}:`;
default: {
return match;
}
Expand Down

0 comments on commit a7aec46

Please sign in to comment.