The code is for a discord bot, what I want to do is when the message '!setup' is sent into the discord chat it sends the code from '2ndQ.js' (The second section of code)
client.on('message', msg => {
if (msg.content === ping_char+'setup') {
msg.channel.send(install 2ndQ);
}
What it should run is this, after '!setup' is entered into the discord message it should print menu and then the user enters '1, 2 or 3' depending on what they want to do!
Printing isn't an issue the issue is how I can get this code to run when imported from another file.
I am using repl.it to code the bot of which I am using node.js
var menu = new Discord.MessageEmbed()
.setTitle("Options: ")
.setDescription("Here are the different options for this bot!")
.addField("--> 1 = Casino", "Change prices of items and payout amount!")
.addField("--> 2 = Quotes", "Change around the quotes eg add a quote to the quote list")
.addField("--> 3 = Moderation", "Kick, Ban members and much more")
.addField("--> More to come in the future", "Leave some suggestions!")
.setImage("https://www.bolero.net/wp-content/uploads/2020/11/inr-banner-sercure.jpg")
var casino = new Discord.MessageEmbed()
.setTitle("--> Casino:")
.setDescription("Here are the different options under the Casino section!")
.addField("----> Change payout range on **slot machine**", "Type [SLR = Min(number), Max(number)]")
.addField("----> Change payout range on **blackjack**", "Type [BJR = Min(number), Max(number)]")
.addField("----> Change payout range on **cock fight**", "Type [CFR = Min(number), Max(number)]")
.addField("----> Change price of **chicken** for **cock fight**", "Type [CFP = Price]")
.addField("----> Change price of **lottery tickets**", "Type [LTP = x1(number), x5(number), x10(number), x100(number)]")
.setImage("https://www.startus.cc/sites/default/files/styles/company_profile_cover_crop/public/img-casino.jpg?itok=E1XXjp5b&sc=775a4769d2582602853a3c7b3efeed6f")
var casino = new Discord.MessageEmbed()
.setTitle("--> Casino:")
.setDescription("Here are the different options under the Casino section!")
.addField("----> Change payout range on **slot machine**", "Type [SLR = Min(number), Max(number)]")
.addField("----> Change payout range on **blackjack**", "Type [BJR = Min(number), Max(number)]")
.addField("----> Change payout range on **cock fight**", "Type [CFR = Min(number), Max(number)]")
.addField("----> Change price of **chicken** for **cock fight**", "Type [CFP = Price]")
.addField("----> Change price of **lottery tickets**", "Type [LTP = x1(number), x5(number), x10(number), x100(number)]")
.setImage("https://www.startus.cc/sites/default/files/styles/company_profile_cover_crop/public/img-casino.jpg?itok=E1XXjp5b&sc=775a4769d2582602853a3c7b3efeed6f")
var quote = new Discord.MessageEmbed()
.setTitle("--> Quotes:")
.setDescription("Here are the different options under the Casino section!")
.addField("----> Clear **quotes**", "Type [Clear quotes]")
.addField("----> Add to quotes", "Type [Add (quote....- first name, last name)]")
.addField("----> Remove a quote", "Type [Remove (quote...)]")
.setImage("https://www.startus.cc/sites/default/files/styles/company_profile_cover_crop/public/img-casino.jpg?itok=E1XXjp5b&sc=775a4769d2582602853a3c7b3efeed6f")
var mod = new Discord.MessageEmbed()
.setTitle("--> Casino:")
.setDescription("Here are the different options under the Casino section!")
.addField("----> **Ban** a member", "Type [Ban @member]")
.addField("----> **Warn** a member", "Type [Warn @member]")
.addField("----> Create a **self role* message", "Type [Create ]")
.setImage("https://www.startus.cc/sites/default/files/styles/company_profile_cover_crop/public/img-casino.jpg?itok=E1XXjp5b&sc=775a4769d2582602853a3c7b3efeed6f")
client.on("guildMemberAdd", (member) => {
const channel = member.guild.channels.cache.find(
(ch) => ch.name === "general"
);
if (!channel) return;
channel.send(
"Welcome to the server, I'm the resident bot."
);
});
channel.send(menu)
ping_char = '!'
client.on('message', msg => {
if (msg.content === ping_char+'1') {
msg.channel.send(casino);
}
if (msg.content === ping_char+'2') {
msg.channel.send(quote);
}
if (msg.content === ping_char+'3') {
msg.channel.send(mod);
}
});
