I am trying to code a invite tracker this is the code :
let invites;
client.on('ready', async() => {
await wait(2000);
client.guilds.cache.get("926674245357039657").fetchInvites().then(inv => {
invites = inv;
})
});
client.on('guildMemberAdd', async(member) => {
if(member.guild.id !== "926674245357039657") return;
member.guild.fetchInvites().then(gInvites => {
const invite = gInvites.find((inv) => invites.get(inv.code).uses < inv.uses);
const channel = member.guild.channels.cache.get('940362032253923348');
channel.send(`${member} was invited by ${invite.inviter} and the code was ${invite.code}`);
});
});
when i run the bot i get this error
client.guilds.cache.get("926674245357039657").fetchInvites().then(inv => {
^
TypeError: client.guilds.cache.get(...).fetchInvites is not a function
can anyone help and thx
fetchInvites
does not work in Discord v13, use invites.fetch()
instead.