I want to know when a guild member logs in, not when the member joins, so guildMemberAdd
does not work in this case. Perhaps there is another way of going about what I want to do, so I will explain here.
When users of my website upgrade to a standard or pro membership they are able to join my discord server among other things. I still have to sort out how to determine that the discord user is a Standard/Pro subscribing member on my website, but I think I can send a one time invite link or a password which the member has to enter send the discord bot after the bot sends a welcome message asking for the password or something, but that should be relatively straightforward to do.
My concern is after a user has joined the discord server, what should I do if, for example, that user decides to unsubscribe from the standard/pro membership on my website? I want to kick that user now, so I was thinking that I could just detect when a guild member starts a session on my discord server with the bot and test to see if the user is still a standard/pro member from my website, but there doesn't appear to be any event for this.
Perhaps I should be thinking of this in another way. Is there a method for just kicking members from my discord server outside of the event callback context?? I just started with the API this morning, so forgive me if what I'm asking is simple. I literally and shamefully just copy/pasted the discord.js example in their docs to see if simple message detection works and it thankfully does (code below)
const Discord = require("discord.js")
const client = new Discord.Client()
client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}!`)
});
client.on("message", (msg) => {
if (msg.content === "ping") {
msg.reply("Pong!")
}
});
client.on("guildMemberAdd", (member) => {
member.send(
`Welcome on the server! Please be aware that we won't tolerate troll, spam or harassment.`
);
});
client.login(process.env.DISCORD_EVERBOT_TOKEN);
client
is ready I should be able to get a specific member on discord with the following approachmember = client.guilds.fetch('guild').guildmembers.fetch('member')
and kick them withkick(member)
or something similar.. I will test this later. I'm still open for other ideas though – KTobiasson