My friend and I have been brainstorming a business idea that involves using Discord as our platform. While I am somewhat new to coding, I do have some knowledge in Discord.js, Java, and HTML.
Here’s the plan:
- We will have a website where users can purchase a subscription.
- Upon purchasing the subscription, a unique code will be generated for verification purposes.
- This code will grant access to enter our server on Discord.
- The generated code will also trigger the Discord.js bot to assign a specific role to the user.
I could really use some advice on how to get started and what steps to take next. I'm willing to share some of my code and ideas if necessary. My main hurdle right now is figuring out how to generate a code and seamlessly integrate it with Discord.js and HTML.
(Updated content follows...)
I've embarked on this project and encountered two major issues.
bot.on('message', async message => {
if (message.author.bot) return;
if (message.channel.id === "*********************") {
if (message.content === "/clear") return;
let MessageContent = message.content;
client.query(`SELECT * FROM public."GeneratedCodes" WHERE generated_codes = '${MessageContent}'`)
.then(results => {
if (MessageContent === results.rows) {
let msg = message.reply(`***Code worked!*** ${results.rows}`)
msg.then(message => {
message.delete({
timeout: 3000
})
})
} else {
let msg = message.reply("Code ***DIDN'T*** work :(")
msg.then(message => {
message.delete({
timeout: 3000
})
})
}
})
.catch(e => console.log(e))
}
});
My current challenge is creating a query (using PostgreSQL) where the selected value matches message.content
. However, I'm struggling to compare message.content
to results.rows
. Is there a way for me to store
client.query(SELECT * FROM public."GeneratedCodes" WHERE generated_codes = '${MessageContent}')?
in a variable to properly compare it to another variable?