how to make a discord invitation bot,

Hello, I would have a question about how to make a discord invitation bot, I tried to do it like in the example but it doesn't work properly, is there a sample project? InviteCreate event
class Events {
constructor() {
this.name = Event.InviteCreate
}
async execute(invite) {
const newInvite = new Invite({
CreateInv: invite.inviter.id,
GuildID: invite.guild.id,
InviteCode: invite.code
});
await newInvite.save();
}
}
module.exports = Events
class Events {
constructor() {
this.name = Event.InviteCreate
}
async execute(invite) {
const newInvite = new Invite({
CreateInv: invite.inviter.id,
GuildID: invite.guild.id,
InviteCode: invite.code
});
await newInvite.save();
}
}
module.exports = Events
GuildMemberAdd event
const client = Underline.Thealoq
const { Events: Event, EmbedBuilder } = require("discord.js")
const Discord = require("discord.js")
const Invite = Underline.Model.Invite
const Modal = Underline.Model.GuildSettings
const Message = require("../../../Variables/variables")
class Events {
constructor() {
this.name = Event.GuildMemberAdd
}
async execute(member) {

let Settings = await Modal.findOne({ GuildID: member.guild.id })
if(!Settings) return
if(!Settings.Status) return
let channel = client.channels.cache.get(Settings.InvCh)
if (!channel) return

const invites = await Invite.find({ GuildID: member.guild.id });
if (!invites) return;

const usedInvite = invites.find(invite => invite.Point < invite.Point + 1);
if (!usedInvite) return;

const InvMember = await member.guild.members.fetch(usedInvite.CreateInv);
usedInvite.UseMember.push(member.id);
usedInvite.Point++;
await usedInvite.save();
const content = Message.InvAdd(member,InvMember,usedInvite)
const embed = new EmbedBuilder()
.setColor(Discord.Colors.Green)
await channel.send({ embeds :[embed.setDescription(content)]});


}

}
module.exports = Events
const client = Underline.Thealoq
const { Events: Event, EmbedBuilder } = require("discord.js")
const Discord = require("discord.js")
const Invite = Underline.Model.Invite
const Modal = Underline.Model.GuildSettings
const Message = require("../../../Variables/variables")
class Events {
constructor() {
this.name = Event.GuildMemberAdd
}
async execute(member) {

let Settings = await Modal.findOne({ GuildID: member.guild.id })
if(!Settings) return
if(!Settings.Status) return
let channel = client.channels.cache.get(Settings.InvCh)
if (!channel) return

const invites = await Invite.find({ GuildID: member.guild.id });
if (!invites) return;

const usedInvite = invites.find(invite => invite.Point < invite.Point + 1);
if (!usedInvite) return;

const InvMember = await member.guild.members.fetch(usedInvite.CreateInv);
usedInvite.UseMember.push(member.id);
usedInvite.Point++;
await usedInvite.save();
const content = Message.InvAdd(member,InvMember,usedInvite)
const embed = new EmbedBuilder()
.setColor(Discord.Colors.Green)
await channel.send({ embeds :[embed.setDescription(content)]});


}

}
module.exports = Events
`
2 Replies
d.js toolkit
d.js toolkit2mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Thealoq
Thealoq2mo ago
could not find the invited code correctly