这其实是我的代码
const inviteLink = await message.content.match(/discord\.(gg|com)\/.+|discordapp\.(gg|com)\/.+|discordapp\.(gg|com)\/invite\/.+/)?.[0];
if (inviteLink) {
setTimeout(async () => {
try {
let inviteL
if (inviteLink.includes("discord.gg/") || inviteLink.includes("discord.com/")) {
inviteL = inviteLink.slice(11)
} else if (inviteLink.includes("discord.gg/invite") || inviteLink.includes("discord.com/invite")) { // && inviteLink.includes("discord.com/invite")) {
inviteL = inviteLink.slice(18)
} else if (inviteLink.includes("discordapp.gg/") || inviteLink.includes("discordapp.com/")) {
inviteL = inviteLink.slice(14)
} else if (inviteLink.includes("discordapp.gg/invite") || inviteLink.includes("discordapp.com/invite")) {
inviteL = inviteLink.slice(21)
} else {
console.log("invalid")
}
console.log(`inviteLink: ${inviteLink} | inviteL: ${inviteL} `)
const fetch = require('node-fetch');
const response = await fetch(`https://discordapp.com/api/invites/${inviteL}`,);
const dataLink = await response.json();
if (dataLink.message === 'Unknown Invite') {
return
}
await client.fetchInvite(dataLink.code)
.then(async (invite) => {
// Code to add 1 to the database (Ignore that)
const embed = new Discord.MessageEmbed()
.setAuthor({ name: `${message.author.tag} | ${message.author.id}`, iconURL: message.author.displayAvatarURL({ size: 512, dynamic: true, format: 'png' }) })
.setDescription(message.translate(`${data.config.cat.b5}/partnercount:SETDESCRIPTION`, {
guild: `${invite.guild.name} | ${invite.guild.id}`,
amount: user.partnerInfo.partnersCount
}))
return message.reply({ embeds: [embed] })
})
} catch (err) {
return
}
}, 500)
}
我希望它与Luminous bot中的一样
目前,bot处理以discord.gg/.com或discordapp.gg/.com等开头的所有内容。
我只想让它只接受代码,这样它就不会继续接受一行或多行代码
示例:discord.gg/codecode dasdsad(只进行编解码,不继续)
1条答案
按热度按时间xam8gpfp1#
答案是