#development
1 messages · Page 1421 of 1
Nvm I'm not making embed, it just like a design anyways.
I wanna make it that the bot DM's a welcome message.
.createDM right?
its probably a good idea to get embeds down, they make your bot look alot nicer
Yeah, but I rather do the basics before doing it.
understandable
How do I use this thing
?
Do I just do .createDM before the code?
message.author.createDM()
<User>.createDM(...)
Oh, okay thank you.
Does this work:
client.on("message", message => { if (message.content === "~dm-me") { message.author.createDM() message.channel.send("🥛 | Hello!") } })
Lemme try
hang on
message.dm.send?
client.on("message", message => {
if (message.content === "~dm-me") {
message.author.createDM("🥛 | Hello!")
}
})
i think
idk cant test it rn to be sure its right
i thought to dm the author u do message.author.send()?
oh
Or is createDM outdated cause it does not work-
If you want to send a message, just use author.send
You create the DM, then you send a message in the returned DMChannel
then theres no need to createDm u can just send
So you must .createDM(), resolve the promise holding a DMChannel, and use that to .send("the message")
but yes, you can directly send to the user instead with <User>.send() I believe
note to self: "dont give advice before testing code"
Just use .send, if you have no purpose of resolving the DMChannel.
u realize that now

shut it
Doesn't work, thanks tho.
i main java, not js
What doesn't work about it.
No error, it just doesn't DM me.
in your console...
Yea
Send your full code, make sure it's message.author.send
client.on("message", message => {
if (message.content === "~command-name") {
message.author.send("Hello!")
}
})
could be fore py :shurg: (i think i had a stroke when i wrote that)
author
¯_(ツ)_/¯
np
It exists.
I can at least be friends with a bot now
lmao
that took far too long for a large group of devs to figure that out lol
ohk
Can a bot send you a fr lmao.
¯_(ツ)_/¯
I have had an issue with text not displaying as "No" when I reply with "n" and I found out after 3 days of looking for the answer (not priority but it bothered me) I put an extra equals sign ;-;
if x == "y" or x == "yes": finalresponses[i] = "Yes"
elif x == "n" or x == "no":
finalresponses[i] == "No"```
i think no
bloop is that py
oh I though you were boutta tell me to just use a dictionary
i was..
I was gonna punch someone
lol
alright we gonna punch someone
Equal operator also fucks me up sometimes, no worries 😂 @zenith gazelle
sure
it corrupted its own sd card thanks to pm2
Also, how do I make it that you can do a command with any capitalization?
.toLowerCase()
?
.toLowerCase()
See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase
you have to take the input through .toLowerCase()
exampledict = {"y" : "Yes", "yes" : "Yes", "n" : "No", "no" : "No"}
finalresponses[i] = exampledict[x]``` happy? @twilit geode
@queen hamlet .toLowerCase() is a function
How do I use it?
HAPPY?????
I like .lower() because it makes everything lowercase
wot
Python
oh
u can do message.content.toLowerCase()
you arent using python
why
so if the message was "Hi" it will become "hi"
they're like { key: value } but make sense
client.on("message", message => {
if (message.content.toLowerCase ("fuck")) {
message.author.send("Okay.")
}
})
Does that work?
Lemme try.
yep
Worked! Thank you!

np
Menin just so you know, that doesn't work correctly
isn't there a bot command for tryitoutandsee?
Now whenever I tell my bot to f it says okay.
wrong server nvm
I know there's a site for it
it does smh
like i use it alot
no it doesn't.
yeah, another server I am in has a command that sends the link
in js it does
no it doesn't
@queen hamlet did you go through the discord.js docs tutorial?
message.content.toLowerCase() does not take any arguments, so the "fuck" argument does nothing.
It also doesn't check if the content is equal to it
I tested the thing and people think I am mad at them
So in reality it's doing implicit condition checking to see if the string is really empty
type anything else and it triggers the command
That's going to DM you "Okay." on every message

it does work
how do i explain
in fact it'll probably cause an infinite loop omegalul
no
howww
You can't explain it because it doesn't work.
IT WORKS
prove it!
@sudden geyser how high are YOU
i have been using it in 2 bots now
I am no js expert but looks like it would work to me
and have never found a single problem
Whenever I say somethign with "F, u, c, k" it DM's me.
const commandName = args.shift().toLowerCase();
``` is what i use @sudden geyser ...
any js bot dev can say that .toLowerCase() works
toLocaleLowerCase() 😎 /s
/s
Whenever I say something with f, u, c, k it DM's me someone help.
hmm
make sure its starts with only
Whatever I say warns me now.
@queen hamlet do if(message.content.toLowerCase() === "fuck")
Did you not listen
I'm on the third floor in my room if that's high for you 😎
As I said, if (message.content.toLowerCase("fuck")) {...} is wrong for several reasons:
.toLowerCasetakes no arguments.- You're not checking if the result of making it
.toLowerCaseis equal to the command you want to compare it with. - You're using implicit condition checking, where it'll try converting the value to its truthfully value.
It causes an infinite loop because it passes the if condition, and sends a message. Then, it triggers the message event, evaluates the if condition (which is always true because it's wrong), and does the same thing over and over.
that 3 equals will work
Thank you.
He knows better than you
who
Don't act ignorant
Then please educate me on how it works.
if that were true hughh would have inbox spam right about now
also
u only need to do let msg = message.content.toLowerCase() and then logging msg would show the message sent in lower case
I was surprised when I joined and the server wasn't like this, I thought it might be tolerable today, guess I was wrong. This is my queue to head out 
I'm spamming "fuck" in my test server rn.
fuck
Head out before you lose your sanity

of course, but what I said with the three points is still present. considering you said this was correct: #development message
oh
when it's simply not
alright
sry
🤦♂️
now last step to finish anti-swear.
How do I make it delete it?
Like when I say "fuck" it deletes my message and dm's me saying not to swear.
You can use <message>.delete();
I put message to delete <here> ?
you put your instance of <Message> here
the message event receives a parameter that is an instance of Message
You named it message, so instead of <Message>, you put message.
If you named it msg, you'd use msg instead.
client.on("message", message => {
if(message.content.toLowerCase() === "shit")
message.author.send("You have been warned. Do not swear.")
<shit>.delete();
}
)
There is an error.
Unexpected token
Christ
Read #development message
Hughh may I ask if you have a good understanding of JavaScript
@sudden geyser I think your way of explaining might confuse some beginners
client.on("message", message => {
if(message.content.toLowerCase() === "shit")
message.author.send("You have been warned. Do not swear.")
<message>.delete("shit");
}
)
?
yeah I know, but I think it's better to get the obstacle out of the way first
Understandable
Beginners do like to copy code without actually filtering what is being explained
This-
$help
Hughh you may want to spend some time learning JavaScript as a language.
Like Lite said, you need to replace that <message> with what parameter you defined for the message callback. You defined it as message so put message instead of <message>
Yes, also see #development message
That should be pinned if it isn't already.
Okay
shouldn't you always have a grasp on the basics of a language before you start a big project?
@earnest phoenix I forgot to say thank you to you, thank for helping me!
Yes, but you can learn a lot from working with a project.
Discord bots usually attract beginners because they're learning to code only because of it, so some want to get directly in action and skip the learning bits.
Hence, you get this channel's state.
how do i make it permant like doesn't crash during a restart?
@sudden geyser quick question, how do i get my topgg token for my bot lol
im reading the docs for the API and I don't know where to get mytoken
am I dumb?
tysm
- https://top.gg/api/docs#mybots
- Click on your bot
- See API key
Hello. Does anyone know any module that allows me to search for videos on Youtube and that has a safeSearch function?
Your alternatives are probably going to be using YouTube's API, which is going to have its limits as well. I don't see how that'll work unless you go for something like scraping.
I was using ytsr, but bugs often happen. I think the way will really be to use the YouTube API
Thank you!
is there any way to perform mute without a timeout?
because timeout's would go every restart
How do i check if a member can ban another member? So one cannot use the ban cmd to ban someone higher than the cmd sender
how to install ffmpeg on discord.js
is googletrans api drunk?
It works sometimes and other it doesn’t
I use a try catch in a while loop until there where no more error but somehow sometimes it still doesn’t work 
How to add 2 workers in Procfile?
@rugged terrace can you help me?
Sorry, I don't know anything about that
No, I don't think so. Anyone correct me if I'm wrong though.
I'm having trouble editing a message every 30 seconds or so
Doesn't seem to be updating
Shouldn't really be a problem, try logging it?
I've tried catching errors, how else would you log it?
ahh actually
i'll have a look
looking at the documentation is always a good idea tbh
Someone help me please
There is no limit but there are ratelimits
This is going every 30 seconds, might that be ratelimited?
It shouldn't
Strange
How to add 2 workers in Procfile?
@earnest phoenix have you tried searching it up
https://stackoverflow.com/questions/52919452/heroku-procfile-multiple-workers this looks like it could mean something
Will 1 minute intervals work? @rugged terrace
if (command === '~store') {
const testEmbed = new Discord.RichEmbed()
.setColor(0xed4a96)
.setTitle('Store')
.setDescription('Store')
.setAuthor(message.author.username)
.setFooter('Store')
Someone help me fix the error to this.
Making am embed.
click on packages on the left side and search for ffmpeg
if (command === '~store') {
const testEmbed = new Discord.RichEmbed()
.setColor(0xed4a96)
.setTitle('Store')
.setDescription('Store')
.setAuthor(message.author.username)
.setFooter('Store')
try {
message.author.sendEmbed(testEmbed);
} catch {
message.channel.send("Sorry <@{message.author.username}> I cannot message you, make sure your DMs are turned on.")
}
}
I need help with this.
There are errors.
Well, what is the error tho 
We can't read minds
command and message
Yeah but what is the error message
Did you copy pasted that from somewhere?
message is not defined, command is not defined
meaning you need to change both message.author.. and message.channel with the variables that are associated with your onMessage
I fixed it...
client.on(message === '~store') {
const testEmbed = new Discord.RichEmbed()
.setColor(0xed4a96)
.setTitle('Store')
.setDescription('Store')
.setAuthor(message.author.username)
.setFooter('Store')
try {
message.author.sendEmbed(testEmbed);
} catch {
message.channel.send("Sorry <@{message.author.username}> I cannot message you, make sure your DMs are turned on.")
}
}
)
This is what it looks like now ^^
That's...
There is a new error
what's the new error
you need to learn how to syntax correctly, get into how to use discord.js first
Huh?
@queen hamlet you are looking at code from old videos
go to https://discordjs.guide
go through that tutorial
it has all da shit
Invalid
also, you seem like you partially just jumped into it, i suggest reading documentations instead of youtube videos
Please. @queen hamlet https://anidiots.guide/first-bot/using-embeds-in-messages
youtube videos are a bad way to learn to make discord bots
just use something like https://discordjs.guide
yes
the discord.js guide above is already updated to the latest version of discord.js
also it has other stuff like an easy cooldown system and so on
very useful guide
client.on(message === '~store')is absolute nonsense.Discord.RichEmbed()is deprecated.sendEmbedis also deprecated.
Yep, thanks.
i just suggest not jumping right into it
i mean thats the only way some people learn
true, but not jump in with outdated things
don't use youtube tutorials for discord bots in the first place lol
You can ask all you want here, we'll greatly help but we can't spoonfeed you on basic stuff that you can easily find on docs
yes
It's just annoying to not be able to find things.
just use the discordjs.guide
Don't take that as a statement that'll bring you down alright, don't be shy to ask questions, but as I said again those can easily be found on djs docs.
Okay :)
if(!message.content.startsWith('m!'))return;
let user = message.author;
let timeout = 86400000;
let amount = 200;
let daily = await db.fetch(`daily_${message.guild.id}_${user.id}`);
if (daily !== null && timeout - (Date.now() - daily) > 0) {
let time = ms(timeout - (Date.now() - daily));
let timeEmbed = new Discord.RichEmbed()
.setColor("#FFFFFF")
.setDescription(`:Cross: You've already collected your daily reward\n\nCollect it again in ${time.hours}h ${time.minutes}m ${time.seconds}s `);
message.channel.send(timeEmbed)
} else {
let moneyEmbed = new Discord.RichEmbed()
.setColor("#FFFFFF")
.setDescription(`:Check: You've collected your daily reward of ${amount} coins`);
message.channel.send(moneyEmbed)
db.add(`money_${message.guild.id}_${user.id}`, amount)
db.set(`daily_${message.guild.id}_${user.id}`, Date.now())
}
};```
but when I do it, doesnt work
and my main - ``` bot.on("message", async message => {
if(message.author.bot) return;
if(message.channel.type === "dm") return;
let prefix = config.prefix
let messageArray = message.content.split(" ");
let args = message.content.slice(prefix.length).trim().split(/ +/g);
let cmd = args.shift().toLowerCase();
let commandfile;
if (bot.commands.has(cmd)) {
commandfile = bot.commands.get(cmd);
} else if (bot.aliases.has(cmd)) {
commandfile = bot.commands.get(bot.aliases.get(cmd));
}
if (!message.content.startsWith(prefix)) return;
try {
commandfile.run(bot, message, args);
} catch (e) {
}}
)})```
did you recently update it
can anyone help?
With what?
when i run the command, nothing happens
Hmmmm
there is an error
Can i see the code?
yes its above
add a debug line, something like console.log("command") on the beginning of the message
ok
thx
i will try
why that return after the startsWith?
if it doesnt start with the prefix
._.
then ignore
Oh i actually saw the !
?
Vut
But
o
nvm
ic ic
That line is not neccesary
o yeah i can put it in the main...
If the content of the message doesn't starts with the prefix and the command it will ignore without that line.
So that line is not neccesary.
And the embed builder
uh i have a quuestion
is there a way to have like the bot respond to both a @ mention and the regular prefix?
@solemn latch dev senpaii
I hope yes, bc my bot reponds to mentions
But with prefix idk
use a or (||) statement?
yo
thiss
Wut?
i have my prefix in a .env file H
for the mentions
message.members.mentions.first();
o rlly?
when
Ik that's for PM
i had no idea...
PM
yes
You create a variable with that value
ik
does it have to be const?
bc i did let
Like this: var user = message.members.mentions.first();
.setColor("#FFFFFF")
.setDescription(`**${user}'s Balance**\n\nPocket: ${bal}\nBank: ${bank}`);
message.channel.send(moneyEmbed)```
Let, var, const
i dont need mentions
my embed
To display a selected user you must use mentions
oooooo
ic ic ic
That's Python?
that won't work
oh
You need to define that in your code
but... isnt ${user} already a mention?
otherwise the prefix is literally that
my bot prefix?
Yes
No, you must define "user"
@pale vessel i also have a command to change the prefix to
so how would i structure it
like a normal prefix or
Do you have a database?
ooo
uh yes
@earnest phoenix use this let user = message.members.mentions.first();
Show the prefix from the database if exist. If not, show the default prefix
i did let user = message.author;
ok
sure
is a json db fine?
That's a member, not a user
Sure, I guess
oK
You should avoid it though since it could be corrupted easily
That probably returns undefined.
Why would it
he's trying to display a target user into an embed
Yeah and why would message.author be undefined?
then that's why
when you release updates for a package, a lot of scripts are usually installing it
actually, the code doesnt even do anything, no errors, no values returned, no messages
Package is not popular, I guess... 
so the number of installs you get don't truly represent the number of users who saw your package and decided to try it for themselves
I said probably, idk what's the all code, and he doesn't use user.tag so it wouldn't display something
something I think Xetera was telling you before
console.log(`Daily run successfully!`)
let user = message.members.mentions.first();
let timeout = 86400000;
let amount = 200;
let daily = await db.fetch(`daily_${message.guild.id}_${user.id}`);
if (daily !== null && timeout - (Date.now() - daily) > 0) {
let time = ms(timeout - (Date.now() - daily));
let timeEmbed = new Discord.MessageEmbed()
.setColor("#FFFFFF")
.setDescription(`:Cross: You've already collected your daily reward\n\nCollect it again in ${time.hours}h ${time.minutes}m ${time.seconds}s `);
message.channel.send(timeEmbed)
} else {
let moneyEmbed = new Discord.MessageEmbed()
.setColor("#FFFFFF")
.setDescription(`:Check: You've collected your daily reward of ${amount} coins`);
message.channel.send(moneyEmbed)
db.add(`money_${message.guild.id}_${user.id}`, amount)
db.set(`daily_${message.guild.id}_${user.id}`, Date.now())
}
};``` alright this is my entire daily code
it does nothing
You mean message.mentions.members.first()?
Also, you should fallback to message author if that doesn't exist
wdym
If anyone here is familiar to sql, will having a query inside a query causes any delays/problems?
sql.query(`SELECT xx1`), (err, result) => {
sql.query(`SELECT xx2`), (err, res) => {
sql.query(`SELECT xx3`), (err ress) => {
})
)}
)}
sql is a MySQL pool getconnection
?
So,are you using a json module and not DB?
uh ig
Alrigut
Alright
You must use a DB
With a DB you can log these prefixes and save that prefixes for each server
ye
quick.db is what i use
megadb is better, or mongoose.
You can use JSON to accomplish this task.
oh
It'll require each query to be evaluated one-by-one. I don't think the performance is going to be all that much, unless you're able to merge the queries into one single query.
json works but is bad practise
is this about custom prefixes?
i just want to know if they change the prefix will it change the other one
depends on how you save the prefix
https://www.npmjs.com/package/jsoning is better if you really want to use json
quick.db is bad because if one thing goes wronng you have to reset the entire DB
It can't be corrupted, I think since it uses atomic file writing
if you make a json array within the json and use the guildID as key it will work
JSON is looked down upon because of the use case in this situation. Think of CLI apps where you have a config.json file. It's completely normal, but as a Discord bot will have an arbitrary activity range, people prefer to use actual databases (SQLite, Postgres, etc.)
I can't merge them in a single query, and I've been getting performance issues. SQL included command won't run after a few minutes of uptime, the rest that doesn't contain any queries work just fine.
Same as JSON db 
Asked twice on SO, still no answers.
My goodness, callbacks
that moment you have the app and website open
ok
like the prefix and guild id?
but that would change all the prefixes
i want it to just change one
{
"Guild1.id":{
"prefix": "!"
},
"Guild2.id":{
"prefix":"?"
}
}
``` @young flame something like this
I don't see how running three queries would be giving you performance issues (especially for minutes). Then again, I don't know what database you're using, and the one you're using, I'm not familiar with (MySQL I assume).
this will if used right only change the prefix for one guild
i just want to know is there a way to change ONE prefix
Correct, MySQL.
And if anyone's wondering my sql pool handler :
let sql = {};
sql.query = function(query, params, callback) {
pool.getConnection(function(err, connection) {
if(err) {
if (callback) callback(err, null, null);
return;
}
connection.query(query, params, function(error, results, fields) {
connection.release();
if(error) {
if (callback) callback(error, null, null);
return;
}
if (callback) callback(false, results, fields);
});
});
};
the default prefixes is + and mention the bot
Please wrap it with promise
i want to know if someone doesn't like the + they can change that
but the mention stays
yes. but i would have to look it up first bcs i never used json as a storage bcs its slow, easy corrupted.
SQLite is what I use
any type of proper db is already better than json
json is fine for static configs but not for dynamic stuff or if it get written a lot on it
++
imo that's inconvenient in a way
ye
but its unique...
also letters
i feel like dank memer is the only one that actually uses letters
roses
like pls
use a insult as prefix. the bot will be non functional at some servers that use word filters.
??/??
maybe rs
oo
nope
they stopped adding bots bcs of a limitation
i nedeed ideaS
It never had any general impact on approval, it just got muted here in this discord
^
!r ?
nvm
@tardy hornet client.user.displayAvatarURL()
r.
r!
r/
yes
Basically whatever a numpad would have prepended with r
??
hey how do you convert from int to char in js
number to string?
never heard of it.
in java char is a primative data type that is a single ASCII character
how would i make a command
send a message then after it sent the message check if it did
@twilit geode you know there's a Java lib for discord right?
thats technically impossible
i spent 5 hours-
i saw a video over it the other day
so you want the bot to send a message after someone answered to a question from the bot?
and then send again a message?
there are 2 ways, use a message event that doesnt listen to your prefix or use message collectors
https://www.youtube.com/watch?v=IP-rGJKSZ3s why it is technically impossible
wtf i have 5k results and im now for almost a year here
Where can I get the DBL WEBHOOK password
it took 4 hours to fix one line of code with 3 people helping me
you generate one and set it on the website
client.on("message")(msg){
if(msg.toLowerCase().contains("hi")) return msg.channel.send("hi")
}
``` @young flame this does more or less what you want to do (but its not really good practise to use a 2nd listener to the message event)
You create it yourself
this maybe the most annoying question but does someone knows how can i get real time data from api?
To be more clear...
I'm trying to make an embed when a new transaction takes place in a specific wallet (BTC)
Easy solution is to keep looping on the api to find any new transactions. But that would be not good if i have a lot of address to look through....
I am trying to make an event that triggers when a new transaction takes place so i can notify the use....
use a timer to shedule a api call ever few minutes. unless the API you use got a client that can spawn events you can listen on
client.on("message")(msg)

im using this api
https://sochain.com/api#realtime-balance-updates
did you think i send complete valid code snippets?

they dont have a client so you are probably stuck to using a timer
aw ok
mm no
just change the css color inside dev console
?
like
once it sends hi set it like TRUE and the call a function to see if it was sent
but why?
I'm confused, what are you trying to do moon
you can use .catch() to catch an error if the message fails to be sended
You don't have to check it was sent
or a try/catch block
Because if it didn't get sent it would return a promise rejection
its not a error
if the message fails to be send you get an error
or did you want them in a certain order?
then use async code
then it will send one message and awaits until its done then it sends the next one
messages returns a collection of messages
const filter = m => m.content.includes('discord');
const collector = message.channel.createMessageCollector(filter, { time: 15000 });
collector.on('collect', m => {
console.log(`Collected ${m.content}`);
});
would that work
?
but i have it filter the word i want then after it collects it run the other functions
like
i have no idea what you want to do. the stuff you write here is quite random
What is she trying to do, [Confusion]
Are you trying to sent stuff in order but like, what else?
yes but i dont get it. you want the bot to react to hi, then you want to send messages in a certain order then you are again at message collectors that are somewhat connected to the bot reacting to hi
so it sends the warning message
yeah but, the one that tells you how to set the bot card
and stuff
but after that i want it to check to see if it sent the warning message and mute them
so you want to add a new bot?
[Visible Confusion]
"if it sent the warning message"
so you want to see if someone spams?
sigh
nvm bro
i already can
listen
once they spam
the bot
send a warning
after the warning
it should mute them
we have to make it step by step bcs your informations are a bit consufsing
so it fails to set the Mute Role
it fails to call the entire mute function
the mute function is only for voice
mute function?
if you want to mute text channels you need a role
yes. but discord doesnt offer any buildin function to mute users in Text Channels
Wtf is happening
its
did you got the role thing sorted out
this is what i wanted to know lol
if you look the mute function or part only runs if they are warned
its not running cause its not setting them as warned
i just want to know how to set them as warned
a quick reminder, dont use a timeout for temporary muting people
i can recomend using redis for it
Just set a boolean to a database sort of thing, if it's true then mute
im using maps
It should still work
but you still store it somewhere right?
i want to store it using maps
bcs maps and timeouts are not persistent over restarts
Something changed on me and I wasn’t ready for it, how do I define something when doing a randomNum sequence? Currently I’m getting an [object Promise] return when I should be getting an item. Here is the code:
it's temporary
yes but something has to trigger it
THATS WHAT I ASKED
You should better store those in an array and get a random one
i would define it as a function
how
like ```js
function isWarned(userid){
//your code checking if the provided userid is warned
}
hm
then just call somewhere isWarned(userid)
then set it true
like once it sends the warning message it is like IsWarned = true;
I DONT KNOW HOW TO SET IT TO TRUE

if i did i wold not be here rn
return true 
Set it to true

lowercase
that's not related to maps
Warns.get(<ID>).isWarned = true```
Yes, and to check if the user is warned

it took me 7 hours just to figure this out lool

Yes
wtf is that
dont ask you wont get it
but its for Machine Learning with C#
i know c#
Machine learning on crack
why did you then write a bot in js?
i know alot of programming languages just retarted with functions
C# is more efficent in my opinion
it is
Something like this?
this bot is more of a fun build
Yes
i have a bot made in elixir that took 1 month to make
is it fun to figure out how to make a single function for 7 Hours?
thats me being sireous
ig
then i can clown myself
Okay. I’ll get to work, thank you Voltrex
Yes
once it took me 4 hours with 5 people helping me to fix one line of code
well sometimes you just cant see the issue, if im at this point i take a break and maybe get an idea later
yeah
The thing is, you shouldn't push yourself too hard while coding
If you can't get an idea of why your stuff doesn't work just take a break
had this the last time when ive made the multi language support for my bot. i use a Github repo for having the Translations open source and easy to merge if someone makes corrections or want to add a new translation.
it turned red
i just need to restart the bot to get the latest language file loaded
idk
Arrow
why a lambda function?
oh isnt that how you call it?
you can use it but you need to tell what you want to get
They can be called an arrow function or lambda function
if((a) => {
});
idk
this is not how they work in js
so remove the arrow function?
Just remove =>
everything before = is to fetch the user
Maybe you wouldn't have 30k messages in this channel if you actually took your time to learn the language you're using? Just a thought
It should be
usersMap.set(<ID>, {
isWarned: true
})``` if they're not in the map
ok
Using the <style> tag within your long description. Below is just example
<style>
body {
background-color: black;
}
</style>
you spammed on a server and the bot sends a DM?
my bot does
and it muted me but i set the timeout for 10 seconds to test it

i still would recomend using something like Redis to temporary store the muted users. if your bot mute someone and a few seconds after it restarts the user will stay perma muted
it only resets when the bot is turned off and on right
but if the bot is always on it wont reset

(you can get a free redis server and it emits a event if a entrys ttl runs out) if your bot restarts for some reason its broken
like even apply an update to break it
mhm
is possible to .hasVoted() return also the left time to vote again?
just get the current timestamp + 12 hours iirc
pog bro
making a bot called roses
https://open.spotify.com/playlist/2jMfIjuRsFjCEeuSrqVhgu listening to my playlist called roses
@lusty quest oh and
is there a way to make a filter for mentions and invites?
like if there not spamming messages but invites or spamming a role or user mention
you can use regex to match all urls or certain urls
and mentions is also relatively easy
i assume the library you are using automatically stores mention data
im using maps to store each message
i want to make a filter so i can use my regex for mentions to filter the messages out
so it isnt just like oh there spamming instead of oh there spamming mentions
for example for discord.js you can do ```js
const users = msgObject.mentions.users;
const guildMembers = msgObject.mentions.members;
const allMentionsInGeneral = msgObject.mentions;
I am currently doing something like that, I will set a conf that a limit of mentions then use message.mentions.members.size also you can include the roles or channels mentions
wut
in maps?
please help i can't get my bot to work without admin perm
@sour oxide what stuff did you added?
if you're storing the messages in a map, the mentions will be stored with it..
i dont see why they wouldnt be
oh
so no filter neeed?
i have a anti message spam command and a anti mention spam one
what did they add in new version of discord.js?
you can check to see if there are any mentions
how would you do that?
it adds channels and stuff and without admin perm i couldn't find how to send messages; without admin perm it throws forbidden access error
hi
manage channels permission
yes i tried that but it didn't work
and probably send messages possible manage messages
heres the documention
ok
also the role of the bot has to allow the creation of Channels
where is that?
@sour oxide you should be checking to see if the bot has permissions for whatever actions you're trying to do before you try to do them
so like message.mentions.has ect
and it will filter automatically
yeah that's what i've been doig
make sure to use some detailed informations for errors if your bot doesnt got the Permission. like just writing no permission wont help you. if you check for certain permissions make sure to add the same permission to the error or you wont be able to find the issue
like if ur on discord.js
It's not a permission error, it's an access error
permissions grants your access
if (!message.member.hasPermissions("ADMINISTRATOR"))
{
// stuff here
}
i had the manage channels/messages and stuff
so simple
TERI its not really helping. his bot works with Admin permissions but not with lower ones
and this is bad
wait who are you talking to?
since it can get you denied here
oh
loooooool
bruh
i also need help but ill ask later
oh thanks but that's not my issue
ok
ok
So my bot makes private channels so that only specific members may see them (it disables the @everyone role from seeing it), and when I don't have administrator.
Wait that may be my issue, I probably have to enable myself before removing @everyone...
message.mentions.ROLES_PATTERN
message.mentions.USERS_PATTERN
message.mentions.EVERYONE_PATTERN
that would filter it right @steel drum
Yeah i got a Missing Access error or something when the bot tried to say something in the channel
dmChannel is not a thing
so its a permission error. give the bot permissions for the channel or handle such errors
uh
createDM
im pretty sure
or member.send
should dm the user your message
or in you message event you have run commands in dms off
so you can like have a message content thing
basically the same
I'll try changing channel perms
ok dmChannel is a thing but for some reason your context is not defined
@lusty quest that would filter it right
i dont think so
or should i just use a regex and try to find a way to implement it
well i have a regex for mentions
idk how to put it in my maps
never used regex on maps so idk its probably possible but i would have to search it first too
how do I do debug?
read the error and understand what causes the error
client or bot.on(debug)
k
if you want to debug your code but still have it run just do
client.on("debug", console.log)
i was being difficult
i ca just use this
if (message.content.includes('discord.gg/'||'discordapp.com/invite/')) { //if it contains an invite link
message.delete() //delete the message
.then(message.channel.send('Link Deleted:\n**Invite links are not permitted on this server**'))
case "lite":
if(!msg.member.hasPermission("ADMINISTRATOR")) {
return msg.channel.send("You do not have enough permission to use the command");
}```
error :-```js
if(!msg.member.hasPermission("ADMINISTRATOR")) {
^
TypeError: Cannot read property 'hasPermission' of null```
i always make things more complicated then they are
this is more or less how regex work lol
^^^
and for mentions you can just check if your spam messages contain mentions and check on the first one already how many mentions are present
try msg.member.permission.has()
message.content.includes('discord.gg/'||'discordapp.com/invite/') that's not how the OR operator works
ok
still ```js
if(!msg.member.permission.has("ADMINISTRATOR")) {
^
TypeError: Cannot read property 'permission' of null```
client.on('message', msg => {
if (msg.content.charAt(0) === botChar) {
const request = msg.content.substr(1);
let command, parameters = [];
if (request.indexOf(" ") !== -1) {
command = request.substr(0, request.indexOf(" "));
parameters = request.split(" ");
parameters.shift();
} else {
command = request;
}```
its in the same file as your switchcase?
yup
client.on('message', msg => {
if (msg.content.charAt(0) === botChar) {
const request = msg.content.substr(1);
let command, parameters = [];
if (request.indexOf(" ") !== -1) {
command = request.substr(0, request.indexOf(" "));
parameters = request.split(" ");
parameters.shift();
} else {
command = request;
}
switch (command.toLowerCase()) {
case "mem":
sendUserApplyForm(msg);
break;
case "help":
msg.reply(`Available commands: \`\`\`${botChar}apply, ${botChar}addrole, ${botChar}setup, ${botChar}endsetup, ${botChar}setsubmissions, ${botChar}help\`\`\``);
break;
case "lite":
if(!msg.member.permission.has("ADMINISTRATOR")) {
return msg.channel.send("You do not have enough permission to use the command");
}
if(msg.member.permission.has("ADMINISTRATOR")) {
let target = msg.mentions.members.first();
if(!target) {
return msg.channel.send("cannot found the member, try again");
}
const acceptchnl = client.channels.get("781500691117506561")
acceptchnl.send(`${target} , your **LITE MEMBERSHIP** has been confirmed, kindly check [#752137420522389544](/guild/264445053596991498/channel/752137420522389544/) & [#746497133678559242](/guild/264445053596991498/channel/746497133678559242/)`)
//target.send(`Your **LITE MEMBERSHIP** has been confirmed, kindly check [#752137420522389544](/guild/264445053596991498/channel/752137420522389544/) & [#746497133678559242](/guild/264445053596991498/channel/746497133678559242/)`)
let role = msg.guild.roles.find(role => role.id === "749348685074137098")
target.addRole(role.id)
}
break; ```
did you use normal Discord.js or some other libary?
whole code
it is a parameter which you give during
clint.on('message', msg)
next time pls a hastebin
i can read code, thanks.
how to use guildMemberAdd
in node js
its an event that is called if someone joins the guild your bot is in
i know but when i tyr like this
client.on('guildMemberAdd', member => {
console.log(member.user.username)
})
for testing it dont show anything in console when a user is added
@lusty quest do you have a regex i can use for the mentions thingy
/<@.*?>/g will match every mention
tyy
your help case works fine?
?
yup
why again user from the member object?
your not listening