© 2026 Hedgehog Software, LLC
public async messageRun(message: CardinalCommand.Message, args: CardinalCommand.Args) { await args.repeat('url', { times: 50 }).catch(() => null); // remove urls from the message const isAfk = await this.container.db.afk.count({ where: { memberId: message.member.id, guildId: message.guildId } }); if (isAfk !== 0) { return sendTemporaryMessage(message, { embeds: [new CardinalEmbedBuilder().setStyle('fail').setDescription('You are already AFK')] }); } let afkMessage = (await args.rest('string').catch(() => 'AFK')).slice(0, 250); return await this.goAfk(message, afkMessage); }
const urlRegex = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g; afkMessage.replaceAll(urlRegex, '').replaceAll(/\s{2,}/g, ' ').trim();
Join the Discord to ask follow-up questions and connect with the community
Sapphire is a next-gen object-oriented Discord.js bot framework.
2,286 Members