Thealoq
DIAdiscord.js - Imagine an app
•Created by Thealoq on 4/24/2024 in #djs-questions
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
GuildMemberAdd 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
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
3 replies