How to make a settings command [discord.js]












-3















I am using discord.js to make a settings command for a bot: I need help to make it to where it let you choose if you want it to have a specific event on or off.

I’ve been trying to look for tutorials for the past week and had no luck. it should look like this:





Example of the command: !settings blacklist on/off



Here’s the code I’m trying to make as a settings command:



bot.on('message', async message => {

//1 blacklisted words
let blacklisted = ['fuck', 'shit,', 'bullshit', 'bitch', 'asshole', 'cunt', 'virgin', 'discord.gg'] //words

//2 looking for words
let foundInText = false;
for (var i in blacklisted) { // loops through the blacklisted list
if (message.content.toLowerCase().includes(blacklisted[i].toLowerCase())) // checks casesensitive words
foundInText = true;
}

//3 deletes and send message
if (foundInText) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:').then(msg => msg.delete(5000));
}
});


I dont expect a spoon feed or something, maybe a little example for me to tinker with or a link to do this. Thank you if your here to help me. Id appricate that.










share|improve this question




















  • 1





    What are you asking here? Do you want the whole command to be able to be toggled on/off or do you want some of the words to be flagged/unflagged?

    – T. Dirks
    Nov 21 '18 at 14:46











  • @T.Dirks to become toggled on/off. Heres an example: !settings blacklist on/off

    – Apollyon365
    Nov 21 '18 at 22:40













  • Why don't you create a command that interacts with the database where you can create a table with the settings and GuildName?

    – Koen Hollander
    Nov 21 '18 at 22:43











  • @KoenHollander I am new to discord.js and i need a little asistance. Either spoonfeed, guide me, or give me a link.

    – Apollyon365
    Nov 22 '18 at 4:35











  • Maybe w3schools.com/nodejs/nodejs_mysql.asp will help, otherwist I advise you to learn a little bit more about NodeJS/MySQL/Javascript

    – Koen Hollander
    Nov 22 '18 at 7:23
















-3















I am using discord.js to make a settings command for a bot: I need help to make it to where it let you choose if you want it to have a specific event on or off.

I’ve been trying to look for tutorials for the past week and had no luck. it should look like this:





Example of the command: !settings blacklist on/off



Here’s the code I’m trying to make as a settings command:



bot.on('message', async message => {

//1 blacklisted words
let blacklisted = ['fuck', 'shit,', 'bullshit', 'bitch', 'asshole', 'cunt', 'virgin', 'discord.gg'] //words

//2 looking for words
let foundInText = false;
for (var i in blacklisted) { // loops through the blacklisted list
if (message.content.toLowerCase().includes(blacklisted[i].toLowerCase())) // checks casesensitive words
foundInText = true;
}

//3 deletes and send message
if (foundInText) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:').then(msg => msg.delete(5000));
}
});


I dont expect a spoon feed or something, maybe a little example for me to tinker with or a link to do this. Thank you if your here to help me. Id appricate that.










share|improve this question




















  • 1





    What are you asking here? Do you want the whole command to be able to be toggled on/off or do you want some of the words to be flagged/unflagged?

    – T. Dirks
    Nov 21 '18 at 14:46











  • @T.Dirks to become toggled on/off. Heres an example: !settings blacklist on/off

    – Apollyon365
    Nov 21 '18 at 22:40













  • Why don't you create a command that interacts with the database where you can create a table with the settings and GuildName?

    – Koen Hollander
    Nov 21 '18 at 22:43











  • @KoenHollander I am new to discord.js and i need a little asistance. Either spoonfeed, guide me, or give me a link.

    – Apollyon365
    Nov 22 '18 at 4:35











  • Maybe w3schools.com/nodejs/nodejs_mysql.asp will help, otherwist I advise you to learn a little bit more about NodeJS/MySQL/Javascript

    – Koen Hollander
    Nov 22 '18 at 7:23














-3












-3








-3


1






I am using discord.js to make a settings command for a bot: I need help to make it to where it let you choose if you want it to have a specific event on or off.

I’ve been trying to look for tutorials for the past week and had no luck. it should look like this:





Example of the command: !settings blacklist on/off



Here’s the code I’m trying to make as a settings command:



bot.on('message', async message => {

//1 blacklisted words
let blacklisted = ['fuck', 'shit,', 'bullshit', 'bitch', 'asshole', 'cunt', 'virgin', 'discord.gg'] //words

//2 looking for words
let foundInText = false;
for (var i in blacklisted) { // loops through the blacklisted list
if (message.content.toLowerCase().includes(blacklisted[i].toLowerCase())) // checks casesensitive words
foundInText = true;
}

//3 deletes and send message
if (foundInText) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:').then(msg => msg.delete(5000));
}
});


I dont expect a spoon feed or something, maybe a little example for me to tinker with or a link to do this. Thank you if your here to help me. Id appricate that.










share|improve this question
















I am using discord.js to make a settings command for a bot: I need help to make it to where it let you choose if you want it to have a specific event on or off.

I’ve been trying to look for tutorials for the past week and had no luck. it should look like this:





Example of the command: !settings blacklist on/off



Here’s the code I’m trying to make as a settings command:



bot.on('message', async message => {

//1 blacklisted words
let blacklisted = ['fuck', 'shit,', 'bullshit', 'bitch', 'asshole', 'cunt', 'virgin', 'discord.gg'] //words

//2 looking for words
let foundInText = false;
for (var i in blacklisted) { // loops through the blacklisted list
if (message.content.toLowerCase().includes(blacklisted[i].toLowerCase())) // checks casesensitive words
foundInText = true;
}

//3 deletes and send message
if (foundInText) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:').then(msg => msg.delete(5000));
}
});


I dont expect a spoon feed or something, maybe a little example for me to tinker with or a link to do this. Thank you if your here to help me. Id appricate that.







discord.js






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '18 at 22:39







Apollyon365

















asked Nov 20 '18 at 4:19









Apollyon365Apollyon365

102




102








  • 1





    What are you asking here? Do you want the whole command to be able to be toggled on/off or do you want some of the words to be flagged/unflagged?

    – T. Dirks
    Nov 21 '18 at 14:46











  • @T.Dirks to become toggled on/off. Heres an example: !settings blacklist on/off

    – Apollyon365
    Nov 21 '18 at 22:40













  • Why don't you create a command that interacts with the database where you can create a table with the settings and GuildName?

    – Koen Hollander
    Nov 21 '18 at 22:43











  • @KoenHollander I am new to discord.js and i need a little asistance. Either spoonfeed, guide me, or give me a link.

    – Apollyon365
    Nov 22 '18 at 4:35











  • Maybe w3schools.com/nodejs/nodejs_mysql.asp will help, otherwist I advise you to learn a little bit more about NodeJS/MySQL/Javascript

    – Koen Hollander
    Nov 22 '18 at 7:23














  • 1





    What are you asking here? Do you want the whole command to be able to be toggled on/off or do you want some of the words to be flagged/unflagged?

    – T. Dirks
    Nov 21 '18 at 14:46











  • @T.Dirks to become toggled on/off. Heres an example: !settings blacklist on/off

    – Apollyon365
    Nov 21 '18 at 22:40













  • Why don't you create a command that interacts with the database where you can create a table with the settings and GuildName?

    – Koen Hollander
    Nov 21 '18 at 22:43











  • @KoenHollander I am new to discord.js and i need a little asistance. Either spoonfeed, guide me, or give me a link.

    – Apollyon365
    Nov 22 '18 at 4:35











  • Maybe w3schools.com/nodejs/nodejs_mysql.asp will help, otherwist I advise you to learn a little bit more about NodeJS/MySQL/Javascript

    – Koen Hollander
    Nov 22 '18 at 7:23








1




1





What are you asking here? Do you want the whole command to be able to be toggled on/off or do you want some of the words to be flagged/unflagged?

– T. Dirks
Nov 21 '18 at 14:46





What are you asking here? Do you want the whole command to be able to be toggled on/off or do you want some of the words to be flagged/unflagged?

– T. Dirks
Nov 21 '18 at 14:46













@T.Dirks to become toggled on/off. Heres an example: !settings blacklist on/off

– Apollyon365
Nov 21 '18 at 22:40







@T.Dirks to become toggled on/off. Heres an example: !settings blacklist on/off

– Apollyon365
Nov 21 '18 at 22:40















Why don't you create a command that interacts with the database where you can create a table with the settings and GuildName?

– Koen Hollander
Nov 21 '18 at 22:43





Why don't you create a command that interacts with the database where you can create a table with the settings and GuildName?

– Koen Hollander
Nov 21 '18 at 22:43













@KoenHollander I am new to discord.js and i need a little asistance. Either spoonfeed, guide me, or give me a link.

– Apollyon365
Nov 22 '18 at 4:35





@KoenHollander I am new to discord.js and i need a little asistance. Either spoonfeed, guide me, or give me a link.

– Apollyon365
Nov 22 '18 at 4:35













Maybe w3schools.com/nodejs/nodejs_mysql.asp will help, otherwist I advise you to learn a little bit more about NodeJS/MySQL/Javascript

– Koen Hollander
Nov 22 '18 at 7:23





Maybe w3schools.com/nodejs/nodejs_mysql.asp will help, otherwist I advise you to learn a little bit more about NodeJS/MySQL/Javascript

– Koen Hollander
Nov 22 '18 at 7:23












1 Answer
1






active

oldest

votes


















0














Fixed code (sorry for that last one):



bot.on("message", async message => {
var message1 = message.content.toLowerCase();

if (message1.includes('offensiveword1')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword2')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword3')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword4')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword5')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword6')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword7')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword8')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}





share|improve this answer


























  • I fail to see how this solves any of OP's questions. To me it just looks like a way to complicated way of checking if certain word from a list is in the message. How I see it, OP's code is much more efficient than this (although even that code can be optimized)

    – T. Dirks
    Nov 21 '18 at 14:49











  • true this is a more complexed version of the blacklisted words, sorry for wasting ur time but i want to make it to where people can say !settings blacklist on/off

    – Apollyon365
    Nov 21 '18 at 22:35













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53386154%2fhow-to-make-a-settings-command-discord-js%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Fixed code (sorry for that last one):



bot.on("message", async message => {
var message1 = message.content.toLowerCase();

if (message1.includes('offensiveword1')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword2')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword3')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword4')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword5')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword6')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword7')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword8')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}





share|improve this answer


























  • I fail to see how this solves any of OP's questions. To me it just looks like a way to complicated way of checking if certain word from a list is in the message. How I see it, OP's code is much more efficient than this (although even that code can be optimized)

    – T. Dirks
    Nov 21 '18 at 14:49











  • true this is a more complexed version of the blacklisted words, sorry for wasting ur time but i want to make it to where people can say !settings blacklist on/off

    – Apollyon365
    Nov 21 '18 at 22:35


















0














Fixed code (sorry for that last one):



bot.on("message", async message => {
var message1 = message.content.toLowerCase();

if (message1.includes('offensiveword1')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword2')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword3')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword4')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword5')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword6')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword7')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword8')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}





share|improve this answer


























  • I fail to see how this solves any of OP's questions. To me it just looks like a way to complicated way of checking if certain word from a list is in the message. How I see it, OP's code is much more efficient than this (although even that code can be optimized)

    – T. Dirks
    Nov 21 '18 at 14:49











  • true this is a more complexed version of the blacklisted words, sorry for wasting ur time but i want to make it to where people can say !settings blacklist on/off

    – Apollyon365
    Nov 21 '18 at 22:35
















0












0








0







Fixed code (sorry for that last one):



bot.on("message", async message => {
var message1 = message.content.toLowerCase();

if (message1.includes('offensiveword1')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword2')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword3')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword4')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword5')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword6')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword7')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword8')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}





share|improve this answer















Fixed code (sorry for that last one):



bot.on("message", async message => {
var message1 = message.content.toLowerCase();

if (message1.includes('offensiveword1')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword2')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword3')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword4')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword5')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword6')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword7')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}
if (message1.includes('offensiveword8')) {
message.delete();
message.channel.send('Hey! That word is not allowed!! :rage:')
.then(message => message.delete(5000));
}






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 21 '18 at 15:07









Federico Grandi

2,81321127




2,81321127










answered Nov 21 '18 at 14:43









CristCrist

236




236













  • I fail to see how this solves any of OP's questions. To me it just looks like a way to complicated way of checking if certain word from a list is in the message. How I see it, OP's code is much more efficient than this (although even that code can be optimized)

    – T. Dirks
    Nov 21 '18 at 14:49











  • true this is a more complexed version of the blacklisted words, sorry for wasting ur time but i want to make it to where people can say !settings blacklist on/off

    – Apollyon365
    Nov 21 '18 at 22:35





















  • I fail to see how this solves any of OP's questions. To me it just looks like a way to complicated way of checking if certain word from a list is in the message. How I see it, OP's code is much more efficient than this (although even that code can be optimized)

    – T. Dirks
    Nov 21 '18 at 14:49











  • true this is a more complexed version of the blacklisted words, sorry for wasting ur time but i want to make it to where people can say !settings blacklist on/off

    – Apollyon365
    Nov 21 '18 at 22:35



















I fail to see how this solves any of OP's questions. To me it just looks like a way to complicated way of checking if certain word from a list is in the message. How I see it, OP's code is much more efficient than this (although even that code can be optimized)

– T. Dirks
Nov 21 '18 at 14:49





I fail to see how this solves any of OP's questions. To me it just looks like a way to complicated way of checking if certain word from a list is in the message. How I see it, OP's code is much more efficient than this (although even that code can be optimized)

– T. Dirks
Nov 21 '18 at 14:49













true this is a more complexed version of the blacklisted words, sorry for wasting ur time but i want to make it to where people can say !settings blacklist on/off

– Apollyon365
Nov 21 '18 at 22:35







true this is a more complexed version of the blacklisted words, sorry for wasting ur time but i want to make it to where people can say !settings blacklist on/off

– Apollyon365
Nov 21 '18 at 22:35




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53386154%2fhow-to-make-a-settings-command-discord-js%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

How to fix TextFormField cause rebuild widget in Flutter