#development
1 messages ยท Page 858 of 1
but in this server. i want cor! prefix to work
he's not ready for it yet
oh thanls
i dont know why
quick.db seems to be faster than better-sqlite3 with no wrapper
@Icero this is nicer
let prefix = ".";
if (message.guild.id === "DBLID") prefix = "cor!";
postgres is better overall if you can set it up
Use a non file based db 
quick.db is not faster than sqlite
quick db uses better sqlite 3 no
So technically it should be the same
Or a bit slower
it might be the settings
anything that is built of another thing will not be faster than the thing its built off
Yeah
unless u do some crazy mumbo jumbo and commit tax faud
yup
I think its because I didn't optimize bettersqlite3 for the fastest use
fastest
@pale vessel is this fine now? sorry for ping
Better sqlite 3 has different use optimisation?
idek
Never seen it
i would put my own code
right now its making 3 files
farrrrrrrrr slower before blaming the DB
like my sqlite db atm thats what 1.4 Million rows on one table rn ignoring the other, takes a fraction of a ms
@edgy heron http://tryitands.ee
sqlite3 has extensive customization and options for various use cases, for example if you prioritize write-intensive usage or read-intensive usage, large data or small data, redundancy/atomicity or performance
I have been trying to set my bot to dnd for ages and it won't work
on discord.js
how can i try though
No
Just doesn't work
client.user.setPresence({ activity: { name: c!help | ${client.guilds.cache.size} servers | ${value.toLocaleString()} users }, status: 'dnd' })
discord status is wonky, sometimes it simply doesnt work and then it randomly works again
idk
@pale vessel sad
I have tried many times before
Odd
did you try it on a dm?
wdym
actually i cant try it
coz i cant try the commands in this server
the bot has common prefix role
๐
both prefix are working
but we need only cor! working here
var prefix ="cor!";
}else{
var prefix ="c!"```
what should i do xD
let
You could make it way simpler with let
let prefix = ".";
if(guild.id === "26435355"){
prefix= "cor!"
}
Shorter code
"it works" != "It's good"

let is better Imo
var is bad practive
guild isnt defined
let and var have their differences
i am new
@edgy heron It's cuz you're getting DMs.
I-
Ig they didn't put a guild object in
try ```js
let prefix = ".";
if (message.guild && message.guild.id == "264445053596991498") prefix = "cor!";

also, you probably want to store your prefixes in a variable outside the message event lol
pretty sure shitposting belongs in #memes-and-media :)
defining it in every command
i think i am adding the code in wrong place
is a very bad practice
bot.on("message", async message => {
const prefixes = JSON.parse(process.env.PREFIXES);
let chosenPrefix;
let prefix = ".";
if (message.guild && message.guild.id == "697473598033756241") prefix = "cor!";
for (const prefix of prefixes) {
if (message.content.startsWith(prefix)) {
chosenPrefix = prefix;
break;
}```
smh im not minimodding nerd
@edgy heron youre overcomplicating something very simple
๐
Ugh
message.channel.send({embed: {description: "Fetching statistics...", color: "#36393F"}}).then(msg => {
invalid form body
Uhh idk whatyoire doing
@woven sundial don't take rules/guidelines out of context
@edgy heron how many prefixes do you have?
2
that has nothing to do with starting actual bot development, the rule is defined so people dont think adding a bot to DBL is how you create a bot
and you use both prefixes for all servers?
@woven sundial. Some people create a bot on top.gg and input their code in the description
xD
and markdown examples
And think it'll host
Spoiler: it won't host. :')
also note that line you screenshotted relates to the note right above it, which essentially provides the original context for the statement as a whole
is this true?
btw is luca using d.js or custom?
well it's not, don't discourage new people asking for development help by spreading misinformation on the guidelines in #502193464054644737
iirc djs :') but ion remember
stimky, me?
not you
oh
const prefixes = JSON.parse(...) // parse your prefixes once and save them, instead of parsing them on every single message
bot.on("message", async message => {
let px = message.guild && message.guild.id === "id" ? ["cor!"] : prefixes;
let currentPrefix = px.find(t => message.content.startsWith(t));
if(currentPrefix) {
// do your code
}
})```
or module.exports
So i have a purge command but how can i make it delete my message first then delete the amount of messages that was mentioned in front of it?
Like: _purge 1
Output: My message gets deleted and a message above that
i'm trying to work with json web tokens to authenticate requests on my api, and i'm thinking about how to handle passwords. so basically i have a jwt with a payload with the user's username, and i'm thinking about adding a the user's password hash to the payload so if their password changes, the server can also check the hash and compare to see if they are the same or not and determine the validity of the token
basically is it a good idea to do this? storing a password hash in plaintext theoretically
but on the client side
@earnest phoenix delete the message first, then use purge
Lmao
or do purge +1 lol
Like seriously how is it possible?
When i even try to like do
{args[0] + 1} it doesn't return as a number...
It's just isNaN
because args is a string
"1" + 1 = "11"
and args[0] is possibly not the correct arg
Hmm what's the correct one then?
idk whats your code?
@valid frigate not familiar with jwts but passwords, hashed or not, shouldnt be stored on the client side, instead you should probably exchange the password for a token, and store that on client side. if im understanding the question correctly
yes thats what i mean
Idk
function cooldown(message, client) {
const time = 5000
function delay() {
setTimeout(() => {
commandCooldown.delete(message.author.id);
message.author.send(`You can now use daily again! `+client.emoji.ring)
}, time);
}
if(commandCooldown.has(message.author.id)) {
const minute = 60000
const hour = minute * 24
message.channel.send(`you need to wait **${Math.round((commandCooldown.get(message.author.id) - Date.now)/minute)} minutes** and **${Math.round((commandCooldown.get(message.author.id) - Date.now)/hour)} hours** untill you can use daily again`)
}
else {
// other stuff happening which I did not show and is not relevant
commandCooldown.set(message.author.id, new Date())
delay()
}
}
My problem is that when I am trying to get the minutes and hours which are left for the cooldown to expire I get NaN
or u can do message.deleate() then or await prune
its just the concern over invalidating tokens because when a user changes their password, the token is still valid since it only carries a username
Hmm lemme try deleting the message with that then doing it...
i was thinking like maybe adding the token to a redis db and blacklisting it until the token expires
yes, a password change doesnt necessarily mean the token is reset, i've seen a few services that dont bother invalidating the token when you change your password
but if you want to, you can always manually invalidate the token on password change
i was reading about how others went about invalidating tokens
anyway thanks for the clarification mate, i think i know where to go from here
@marble juniper new Date() creates a date object, which when stringified, returns a date string
you want Date.now() instead, which creates a timestamp
oh ok
@crimson vapor is this the way you talking about?
Hmm
thats not gonna work and you are abusing api
message.delete()
then
message.channel.bulkDelete()
Wait... Do i have to put a .then after the message.delete()? @crimson vapor
no
yes
or await it
you dont need to fetch the messages before bulkDeleting
bulkDelete also takes a number
Wait when i try to put a .then() function after message.delete() it says message.delete().then()
Is not a function..
Full code of purge command? @quartz kindle
yes
It's literally up there... Scroll up
if(isNaN(args[0])) return; //check if its a number
if(args > 100 || args < 2) return; //make sure its correct value, no point going lower than 2 and higher than 100 will not work
await message.delete(); //delete the message
await message.channel.bulkDelete(args[0]); //clear the amount you want
return; //end the command```
Hmm lemme try that real quick...
await message.delete()
await message.channel.bulkDelete()
inside an async function
yes
Thx it worked as
await message.channel.bulkDelete(args[0]);```
@finite bough also ik that lmao
^
ow to edit a picture via node js script?
verified where?
on dbl or on discord?
having a genuine bot I guess
there're lots of data they request u in the certification form
like what data you collect, why you collect, where you store, is your server safe, etc
they'll PM you when the time comes
read the above comment
yep
not the, but an
you can use any card that can be used to identify yourself
hi
I know it varies based on your bot, but does anyone else rely very heavily on databases to make their bots work?
define "very heavily"
Say you want to add a new feature, you immediately need to create a new table because you don't really have any other suitable way to make the feature work
if you need to persist something you gotta make a new table
best practice is to have one table for each subject
avoiding to make a misc table
disgostang
Yeah I do have a misc table but I don't think it's used anymore
disSgOSTANG
No u
With this discord verification thing, if a user wanted me to clear their data but they were in my blacklist table does that that mean I'd have to subsequently unblacklist them or would I be allowed to leave their id in that table
hi, how would i create a prefix command with mongoose?
you probably have the incorrect infrastructue for your database - the most reliable way is to have a table of guilds and then adding columns to that table based on what you need
if one shard goes down (can a shard go down?) in discord.js v12's internal sharding, what happens?
it goes down
no
only one shard goes down
/opt/watcher/app-types/node/start.sh: line 9: wait_for: No record of process 24395
now it wont reload
shards always try to reconnect automatically
oh right reconnect
is there ever a scenario where it can't reconnect and just permanently dies while the process is running
yeah, but you'll have to find out why
isnt this a contradiction? i don't get how i am getting this error
i believe so
its not a contradiction
no its because there are no attachments
because trying to get a property of undefined will error out before it ever attempts to do the comparison
how else do i check if a message contains an attachment in discord.js?
is heap size the amount of ram i am able to use?
because my host said i have 2gb of ram lol
which would explain why my bot was logging due to heap used
@earnest phoenix first check if an attachment exists, then get its url
you can use a little trick for that
i dont understand but i know its an image that says i am wrong 
(message.attachments.first() || {}).url
@grizzled raven heap is a section of ram dedicated to storing objects
it will be dynamically resized based on its needs
huh
resident set (rss) is the total ram used by the process
how do you get the total ram available
process.memoryUsage().rss
star eval silent message.author.send(process.memoryUsage().rss / (1024**3))
that was ~1.3
so 1.3 gb?
seems a bit hacky but none of the methods i found intuitive has worked so far
oh
oh okay its 2gb
but
uh
if rss passes
nah im confused i cant phrase this question

just tried message.attachments.size !== 0 that seems to work, not sure if your way checks for more @quartz kindle
maybe i was calculating my ram wrong

zerp thats fine
tims way just makes it return undefined if there are no attachements, or the url if there are
if rss gets to 2gb it will crash the process due to out of memory
hm
well i've been measuring heapused, which isnt rss obv
, and it hasnt ever really gotten above 1.3gb
"6123459" here how can i make it 6,123,459 ?
in what lang
Js
new Intl.NumberFormat('en').format(num) should work
or this ^ if your region is different
Ok..lemme try in testing
or if you need to format multiple times const formatter = new Intl.NumberFormat('en') then using formatter.format(num) should do the trick
Ohk
if you really wanted to be uncool like me, you could do ```js
let num = 2038 // whatever number
let s = num.toString().substring(0, 2) + "k"

lmao
lmao
lmao
or if you wanted to be extra uncool this might not work for some regions lol you could do this
let num = 728290
num.toLocaleString().split(/\.|,/)[0] + "k"
``` 
collection('users').find({ skillsQueue: { $exists: true, $ne: [] } })
``` for anyone good with mongodb my logic is this would pull all mongo entries with non empty skillsQueue arrays right?
what
nvm thats probably how it works
Eval
Executed in 12.910363ms.
Input
let num = 728290
num.toLocaleString().split(/.|,/)[0] + "k"
Output
'728k'
whats your just "toLocaleString()" output?
toLocaleString for me outputs 000,000,000,000...
uuh
nnn,nnn
num.toLocateString does that??
well i see yours is spaces
oh yeah its in spaces
is this possible to convert 2000 to 2K trough toLocaleString tho?
forgot some countries output spaces
why do you need to substring that message flavex?
Math.floor(2038/1000) + "k"
uuh and btw, toLocaleString seems so stupid to use
seems like some counties could be using , instead of .
and exchange between them so it looks like . is ,
so like if you dont floor your number, you would get like 10.412,12 and it would be 10k or something
or im dumb
nvm, if you were using [0] then it would work
and if it only used . and ,
memory exception?
the heap size will be increased
oh right this isnt java
huh
wait this deosnt make sense
my process is using 1.2gb of ram but thw bot is offline lol
and why is the bot offline

Did anyone here used Discord.js ans sharding yet?
many people
So I created a simple event handler but for some reason the command is unresponsive,
index.js
client.commands = new Discord.Collection();
client.aliases = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
for(const file of commandFiles){
const command = require(`./commands/${file}`);
client.commands.set(command.name, command)
}
client.on("message", message => {
let args = message.content.substring(prefix.length).split(" ")
switch (args[0]) {
case 'adora':
client.commands.get('adora')
break;
};
});
adora.js
module.exports = {
name: 'adora',
description: 'says Catra!',
execute(message, args){
message.channel.send("Catra!");
}
}
``` is there something wrong, because i don't know because nothing shows on the console logs.
yeah i dont see any console.log either
no I mean like no errors show
Hab someone help me?
I get this Error:
Launched shard 0
(node:32187) UnhandledPromiseRejectionWarning: TypeError: process.send is not a function
at Client.<anonymous> (/root/Wumpy/node_modules/discord.js/src/sharding/ShardClientUtil.js:37:17)
at Client.emit (events.js:323:22)
at WebSocketManager.triggerClientReady (/root/Wumpy/node_modules/discord.js/src/client/websocket/WebSocketManager.js:433:17)
at WebSocketManager.checkShardsReady (/root/Wumpy/node_modules/discord.js/src/client/websocket/WebSocketManager.js:417:10)
at WebSocketShard.<anonymous> (/root/Wumpy/node_modules/discord.js/src/client/websocket/WebSocketManager.js:199:14)
at WebSocketShard.emit (events.js:311:20)
at /root/Wumpy/node_modules/discord.js/src/client/websocket/WebSocketShard.js:478:12
at Timeout._onTimeout (/root/Wumpy/node_modules/discord.js/src/client/BaseClient.js:83:7)
at listOnTimeout (internal/timers.js:549:17)
at processTimers (internal/timers.js:492:7)
(node:32187) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:32187) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:32187) UnhandledPromiseRejectionWarning: Error [SHARDING_READY_TIMEOUT]: Shard 0's Client took too long to become ready.
at Timeout.onTimeout (/root/Wumpy/node_modules/discord.js/src/sharding/Shard.js:160:16)
at listOnTimeout (internal/timers.js:549:17)
at processTimers (internal/timers.js:492:7)
(node:32187)
at Timeout.onTimeout (/root/Wumpy/node_modules/discord.js/src/sharding/Shard.js:160:16)
at listOnTimeout (internal/timers.js:549:17)
at processTimers (internal/timers.js:492:7)
(node:32187) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
Using this code:
process.send is not a function
Yes but I dont use process.send ...
dunno then
ive never used it, is your Main.js file really named Main.js?
just making sure
@pine bear two things
- putting a function in an object should be done like this:
execute: (args) => {}orexecute: function(args) {}and notexecute(args) {}as this one is for class methods
- you get the command but never execute it. should be
commands.get(name).execute(args)
oh ok.
and 3. you dont need a switch case
because you dont need to check for the name of every single command
you can simply check if the command exists in client.commands: if(client.commands.has(args[0])) { client.commands.get(args[0]).execute() }
@lime jewel which discord.js version?
Outdated NodeJS version maybe 
your Main.js might have a problem thats preventing it to load
and yeah, whats your node.js version?
show your main.js code
- putting a function in an object should be done like this: execute: (args) => {} or execute: function(args) {} and not execute(args) {} as this one is for class methods
execute(args) {}is actually fine according to JS.
Too long For Discord
Upload it somewhere
๐คทโโ๏ธ
Oh ok.
found something in Main? @quartz kindle
you are not using express.js anywhere, so you should remove it
you have an interval without a timer
you have duplicated double loops
I used Express before I startet Coding in sharding
Ok but anything Throwing the Error?
uhh, like 2 things,
@lime jewel a lot of bad ideas but nothing causing the error specifically, might be another file. try disabling some stuff like chatbot api and see if it works
Ok i'll try it
what the fuck
i cant even

(and dont you dare remove client)
I ain't that dumb!
good
ok maybe, sometimes.
lmao
I disabled ChatBot API but there is the Error against
Ok
wth
ok anyways, I want to use embeds for information that's obtained from the message but the issue is like.. it can be like 100 in one messages if someone wanted to abuse it, ie: omg im cringe weeb bro fuckin watch {sowrd atr oline} it amazing!! and make sure to read <deomn slyer> it so good bro
and of course memes aside it would gather info on the shit inbetween {} and <> and that can be up to how much discord messages can handle. So the issue is I would use multiple embeds in one message but that's not possible for bots, sending them individually would be troubelsome. Not really sure what to do in this case
plain message is hard as fuck to format
@pine bear are you even trying?
yes.
get doesnt exist
i told you to remove switch, not replace it
remove the block completely
and get the command directly from client.commands by using args[0]
client.commands.get(args[0])
then just call execute on it
and give the execute whatever arguments your execute needs
your execute needs message and args, so your command should call .execute(message,args)
but first you need to check if the commands exist
so you can put the command in a variable
let command = client.commands.get(args[0])
then check if(command)
and if there is a command, do command.execute(message.args)
@quartz kindle calm down a little...
Don't get angry...
You're literally Overloading your brain...
Lmao
when i go into teacher mode i cant stop lmao
lmao
oof
I still don't, bruh.
what now...
I don't think I followed it correctly,
if we are talking about changing channel names how often can they be changes without abusing discord api
*why this?*
message.args = get args from inside message
message, args = get message and then get args
faceplalms, why am I like this, I literally feel that much os a dummy.
tim can u answer that^
you feel dumb because you dont know the language, you should learn the language first
for example, dots . are always used to get stuff from inside other stuff
and commas , are always used to separate things
I kinda know that, it's just that I never got back into JavaScript in over 2 weeks.
yes and that, and I've been at this for over 2 says, no cap.
but repeating mistakes is the path to learning, the more mistakes you repeat, the less often you will repeat them again because the harder they will get stuck in your brain
yes,
just a lot of those mistakes can be easily fixed by going through the basics of the language again
that and continuously misspelling length as lenth
i misspell it as lenght
has anyone here dealt with appveyor and visual studio building?
@quartz kindle, ok so this is not that much, but I think there is some problems with it.
@quartz kindle Tim sorry if i annoyed you about the broadcastEval()
let embed = new discord.MessageEmbed();
if (color) embed.setColor(color.hexColor);
embed.addField("Premium Added", `${UserID.tag} \`${UserID.id}\``);
let premiumadd = new discord.MessageEmbed();
premiumadd.setTitle('Premium Added');
premiumadd.setDescription(
`**User ID:** ${UserID.id}\n**User Name:** ${UserID.tag}\n**User Created:** \`${bot.users.cache.get(UserID.id).createdAt.toUTCString().substr(0, 16)}\``
);
premiumadd.setThumbnail(UserID.displayAvatarURL({dynamic:true}));
premiumadd.setTimestamp();
premiumadd.setColor('#2ACC76');
premiumadd.setFooter(`Command Run By: ${message.author.tag}`);
bot.shard.broadcastEval(`
const channel = this.channels.cache.get('679079839466127390');
if (channel) {
channel.send('${JSON.stringify(premiumadd)}');
true;
} else {
false;
} `) .then(sentArray => {
if (!sentArray.includes(true)) {
return message.reply('I could not find such a channel!');
}
return message.channel.send(embed);
});
This worked successfully
It it possible to get it as an embed?
.send({embed:${JSON.stringify(...)}})
No
@pine bear i told you to remove that extra client.commands.get(args[0]) since you already have it. no need for duplicate code
other than that it should work
@royal portal return from where?
message
if the user is banned from the same guild where the message is coming from, the user cant be banned, else he wouldnt be able to send the message there
Is it possible to store data in discord.js without a database
well
is your code still the same as yesterday?
i know you can use json files but is that better then trying to set up the database
i have an unban command and if you unban someone then it sends a thing to a logs channel saying who unbanned the user and the reason but you can unban the user multiple times and it sends the embed even though the user is already unbanned
e I was editing my main script and it refused to save the file (i host it on a vps), i checked the file on the vps and it was blank
not sure how to make it so if the user is already unbanned then dont send embed and dont try to unban user
is your code still the same as yesterday?
How does it still not work? that is so strange.
yes
does your console log any error when you unban someone who is not banned?
oh, that was about the command handler.
@queen needle without any external saving form, any data saved inside the process, in variables objects arrays etc.. will be lost when the process restarts/crashes
@royal portal then you need to handle the error correctly
i believe i told you yesterday that you cant use try/catch like that
so if i do json files i lose the data when i restart my bot
try {
await ....members.unban()
....send("done")
} catch(e) {
....send("not banned")
}
or
....members.unban().then(() => {
....send("done")
}).catch(() => {
....send("not banned")
})```
@royal portal
@queen needle no, json files are stored in files, not in the process, so they are not lost
if we are talking about changing channel names how often can they be changes without abusing discord api
idk the exact limit, but i wouldnt change them more than once a minute
ok so im so bad in math so im asking
how can i get % in js?
like what % is 1 of 10 to get output 10%
n * 100 / %
ty
actually better to do % = % * N / 100
actually thats for getting the % value, not the % %
now im confused lmao
i need sleep
this would be right?
client.on("message", message => {
let args = message.content.substring(prefix.length).split(" ");
let command = client.commands.get(args[0])
if(command)command.execute(message, args)
/* get(args[0]) => {
client.commands.get(adora).execute(args);
}; */
});
should work
with this?
client.commands = new Discord.Collection();
client.aliases = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
for(const file of commandFiles){
const command = require(`./commands/${file}`);
client.commands.set(command.name, command)
}
put console.log(client.commands) somewhere in your code (after the command loader)
and show what comes up in your console
@quartz kindle and if I put it inside a member add thingy and suppose 5 people joined in 1 min surprisingly so its api abuse?
also, that code allows all prefixes if they have the same length
c!, but it's a "ping" command
so your command should work if you do c!adora
but it will also work if you do 12adora or abadora or $%adora
your code is checking for any 2-letter prefix
add this if(!message.content.startsWith(prefix)) return
before the let args = line
that will make it only work with !c prefix instead of any 2-letter prefix
@finite bough i suppose thats fine
oki
how to make it work without the prefix?
remove the line i told you to add, and remove the .substring() part from args
ok now it works.
My bot just went offline randomly and I have no output on my console that indicates why it went down. I just recently started using shardingManager, could it be that my shards somehow went down and didn't re-spawn? I have 2 shards atm.
I got my bot back online by simply restarting, but I would like to know if there's any ways to prevent this from happening?
toMute.addRole(role); says its not an function
@earnest phoenix what's toMute as defined as?
let toMute = msg.mentions.members.cache.first() || msg.guild.members.cache.get(args[0]);
try logging shard events ie manager.on("shardCreate", shard => { shard.on("disconnect",console.log) }) (v12)
@wide ridge
@earnest phoenix
toMute.roles.add(role)
ohhhh
oof
i forgot about that
thx
Lol np
there is no cache in mentions
@earnest phoenix also if it doesn't work...
Try changing the:
let toMute = message.mentions.users.first() || message.guild.members.cache.get(args[0]);
To
let toMute = message.guild.member(message.mentions.users.first()) || message.guild.member(message.guild.members.cache.get(args[0]);
i am running 12
Hmm did it work? @earnest phoenix
yeh
Nice
@earnest phoenix half of that is redundant lol
yes i am a sad creature
you are simultaniously like the most active person on this discord but the least ha
someone here have the bot developer badge?
what badge?
@quartz kindle the badge you get after you get Verified on the discord developer verification program...
lol
Yea if your bot is in 75 or more guilds then it's necessary...
is there a way to fetch messages in v12?
How do I check for the API ping of Discord? I am on djs v12
Docs?
I canโt find it
thanks
found it, channel.messages.fetch
๐
I want my bot to send multiple responses to a "ping" command, how do I do that?
I forgot about sqlite
sql.run(DELETE FROM giveawaymess WHERE points > 0;).run()
would this be right
for the comparison
can i ask here for ejs ?
if ejs is eris then yes
EJS -- Embedded JavaScript templates
how would I be able to test this?
client.on('guildMemberAdd', member => {
const guild = config.guild;
const welcomeChannel = member.guild.channels.get('660593478807322634');
welcomeChannel.send(`<@${member.user.id}>`);
const embed = new Discord.RichEmbed()
.setColor(0x00A2E8)
.setTitle("Welcome, " + `${member.user.tag}`)
.setDescription("Feel free the stay for awhile! We are honored to have you here. We offer many things here")
.addField("**NOTE:** you have to verify yourself in [#657412989011492915](/guild/264445053596991498/channel/657412989011492915/)")
.addField("come here [#660717524639547413](/guild/264445053596991498/channel/660717524639547413/) to tell us your love about She-ra!")
welcomeChannel.send({embed});
});
It would be as explained in the node docs: https://nodejs.org/api/events.html#events_emitter_emit_eventname_args
client.emit('guildMemberAdd', ... args);
it's saying guild is not defined.
this ain't a bot support server.
@mortal lynx this server is not meant for a specific bot support...
@earnest phoenix then this server which for support
const welcomeChannel = member.guild.channels.get('660593478807322634');
^
``` it's saying that the guild is not defined.
bot dev
@mortal lynx for bot building... Testing and getting approved and declined...
@pine bear how did you emit the event
ofc you gotta pass in everything that djs passes by default duhh
if you only passed a string or an object with random props then that's what you'll get
To hamara bot kyu nahi Kam kr raha hai kab online aayega
client.on("message", message => {
if (message.author.bot) return;
if (message.content.indexOf(config.prefix) !== 0) return;
const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
if(command === 'add') {
client.emit('guildMemberAdd', ... args);
}
});
@mortal lynx wrong server, and wrong channel
@pine bear ...
learn the basics of js
what I said was an example
Please help me
if you pass in args it'll pass an array
Guys
and that array doesn't have any property that you need duh
@mortal lynx this is the wrong server
this isn't a support server
@copper cradle Hello ham Apne server pr member count bot add kiye the pr Kam hi Nahi kr raha
are you blind? I don't speak that language, and this ISN'T (IS NOT) [NOT === NEGATION === NO] a support server
@copper cradle do you know what he is saying?
Kinda looks like enchantment table...
Me either
looks like an english creole of some sort
Aur m!setup bhi likhe pr hamre server ka member count hi Nahi kr raha hai Kya kru
@copper cradle it's hindi lmao
@copper cradle this is Hindi language
@copper cradle please help me
this server isn't a support server, we don't provide help for any bot
I can't help you
Please
rule 6: speak english, #memes-and-media is the only exception
this is the WRONG server @mortal lynx
I know but help me guys
we can't help you holy cow
-wrongserver
Hey! We think you have our server mistaken. We do not provide support, help, or advice for any bot. You need to click on the "Support Server" button on the bot's page, not the "Join Discord" button at the top of our website. If there isn't a button that says Join Support Server, then we can't help you. Sorry :(
Hello, I don't understand how to calculate user flags https://discordapp.com/developers/docs/resources/user#user-object-user-flags
Integrate your service with Discord โ whether it's a bot or a game or whatever your wildest imagination can come up with.
my bot didnt respond on everything -.-
@hexed moat with bitwise operations
check out permissions on the docs
they work on the same principle
ok thanks
So I wanna make the .setTitle a Hyperlink but how can I make it work properly?
with ''
Alright
I kinda wanted like where it'll show the hyperlink as the title
allowed[randomnumber].data.title
Am I dumb or something?
https://mineko.is-inside.me/77jIeQdH.png
OWH, right...
Also
${clientname} is unnecessary if your variable is already a string, just use clientname
help plz it say value not specified https://hastebin.com/afevilakul.js
where
typeof Infinity returns number
What
infinity is in js yes
typeof <x> returns whatever <x> is

is it bc of discord js 12
idk
i have been breaking my head on that for days now
ok but i have no idea no how to use it
cache
its discord 12
ye
I Made my Bot researching YouTube for an Video URL. Now my code wont store the URL ans the title of the Video into ly variables...
Code and Console are screenshottet here:
@lime jewel wdym
What?
what?

Ok I'll try
-bots
read docs smh
it's been 2 weeks i wait 
ah sorry xd
const Discord = require('discord.js');
const bot = new Discord.Client();
client.on("message", message => {
if(message.content.startsWith("*hi")){
message.channel.send("hey");
}
})```
when i run it it says client isn't defined
cause isnt
u never defined it
^
^
but I suggest you using client instead of bot
yeah its more instinctive
coz every docs uses client
it's normal for beginner
._.
what
video tutorial = never
what'
thankfully
thankfully????????
I have some error with heroku
my bot keep crashing
the error is this one
heroku[web.1]: State changed from starting to crashed
so far so good i can log stuff into my json files
Hi, can someone help me with discord.py, I don't know this language very well, I'm at the beginning
How can I change a user's nickname by adding something else (eg "Test") to his current nickname?
For example in my case: Simo >> Simo Test
@slender thistle is there no .displayName ?
member.display_name
That would work no?
Would but it might not be what they need
So it's their nick / their name
Seems like it could work but idk
His status says js dev
member.edit :p
What is the string to insert that allows me to change his nickname
member being ctx.author I would assume
I'll never understand discord.py
In this case, I want to add after his nick content
User:
!powerlevel 5
Bot:
changes nickname from User to User 5
Is that what you want?
Yes
It is the one in summary with a bit of formatting or
User:
!powerlevel 5
Bot:
changes nickname from User to User [โก 5]
Thanks shivaco for your help
I'd suggest creating a dict somewhere where key is the level and value is the string you want to add to their nick
I repeat is my first code that I make in discord.py, I don't know how
dictionaries are basic Python 
levels = {'1': '[:hammer: 1]',
'2': '[:hammer: 2]'}
async def powerlevel:
await ctx.author.edit(nick=ctx.author.display_name + levels[content])``` a bit of pseudocode for you
I try
Our bot doesn't want to make an embed. It says TypeError: Discord.RichEmbed is not a constructor. We already changed the discord.js version in package.json. What to do?
@nocturne grove Replace RichEmbed with MessageEmbed
@nocturne grove npm i
@small plume oh thank you!
@golden condor what do you mean?
If you want to change the package version
Is .RichEmbed old code?
ohh okay thx
RichEmbed renamed to MessageEmbed on v12
and changing in package doesn't do anything?
Unless you use glitch no
okay thanks!
We just installed discord.js so I guess that was the newest. But we're used to use RichEmbed
Do you know in HTML for help me ?
if you prefer discord.js v11, you can install it like this npm install discord.js@11.6.4
What do you need help with @earnest phoenix ?
My board don't show
See this ```<!DOCTYPE html>
<html lang="en">
<head>
<link rel="icon"
type="image/png"
href="https://cdn.glitch.com/98ebb41d-db5d-4d3a-ab38-83a53f1e0b58%2FCapture.PNG?v=1586428175937https://cdn.glitch.com/98ebb41d-db5d-4d3a-ab38-83a53f1e0b58%2FCapture.PNG?v=1586428443956">
<title>SoundBoard - TapsHTS</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- import the webpage's stylesheet -->
<link rel="stylesheet" href="/style.css">
<!-- import the webpage's javascript file -->
<script src="/script.js" defer></script>
</head>
<body>
<font size="5"><font face="Poppins">Si toi aussi tu veux utiliser mon soundboard avec les mรชmes bruit voici les sons au dessus</font></font>
<div class="divTable steelBlueCols"></div>
<div class="divTableBody">
<div class="divTableRow">
<div class="divTableCell"><iframe width="110" height="200" src="https://www.myinstants.com/instant/popopoooooo-7896/embed/" frameborder="0" scrolling="no"></iframe></div>
<div class="divTableCell"><iframe width="110" height="200" src="https://www.myinstants.com/instant/cheh-23601/embed/" frameborder="0" scrolling="no"></iframe></div>
<div class="divTableCell">cell3_1</div>
<div class="divTableCell">cell4_1</div>
<div class="divTableCell">cell5_1</div>
<div class="divTableCell">cell6_1</div>
<div class="divTableCell">cell7_1</div>
<div class="divTableCell">cell8_1</div>
<div class="divTableCell">cell9_1</div>
<div class="divTableCell">cell10_1</div>
<div class="divTableCell">cell11_1</div>
<div class="divTableCell">cell12_1</div>
</div>
</div>
<!-- include the Glitch button to show what the webpage is about and
to make it easier for folks to view source and remix -->
</body>
</html>
Web: https://soundboard-hts.glitch.me/
@elder vine
Why use div for tables
But i don't understand tables
this:
Borders?
Border would be css
yes i have
body {
font-family: helvetica, arial, sans-serif;
margin: 2em;
}
h1 {
font-style: italic;
color: #373fff;
}
div.steelBlueCols {
border: 4px solid #555555;
width: 400px;
text-align: center;
border-collapse: collapse;
}
.divTable.steelBlueCols .divTableCell, .divTable.steelBlueCols .divTableHead {
border: 5px solid #000000;
padding: 5px 10px;
}
.divTable.steelBlueCols .divTableBody .divTableCell {
font-size: 12px;
font-weight: bold;
color: #000000;
}
.steelBlueCols .tableFootStyle {
font-size: 13px;
}
/* DivTable.com */
.divTable{ display: table; }
.divTableRow { display: table-row; }
.divTableHeading { display: table-header-group;}
.divTableCell, .divTableHead { display: table-cell;}
.divTableHeading { display: table-header-group;}
.divTableFoot { display: table-footer-group;}
.divTableBody { display: table-row-group;}
@elder vine
const msg = await member.send(solvecaptchaembed, {
files: [{```
tried to send an embed but it sent [object object]
the send function actually looks like this: .send(message) or .send(options) or .send(message,options)
embed is part of options
so if you put .send(a,b) embed should go in b, and a will become ONLY for text messages
if you do .send(options) embed should go inside options, together with all other options
so your send should look like this .send({embed:captchaembed,files:[...]})
i used it but the embed is being sent after the file
theres nothing you can do about that, discord decides the order
if you want the embed first, you needs to send 2 messages
can i use .then or somthing
I tried and it worked
const msg = await member.send(solvecaptchaembed).then (await member.send({
files: [{
attachment: `${__dirname}/captchas/${captcha}.png`,
name: `${captcha}.png`
}]
}));```
First the captchaembed, then the captcha itself
Thanks Tim!
like i said
await send(embed)
await send(files)
the await does the same thing as the .then() at the end
its redundant
its like doing Number(1) when 1 is already a number
or "abc".toString()
await member.send(solvecaptchaembed)
await member.send({
files: [{
attachment: `${__dirname}/captchas/${captcha}.png`,
name: `${captcha}.png`
}]
}));
``` lol
oh ok
thanks
const msg = await member.send(solvecaptchaembed)
await member.send({
files: [{
attachment: `${__dirname}/captchas/${captcha}.png`,
name: `${captcha}.png`
}]
});```
msg.mentions.members.cache.first() it says cant not read first
there is no cache in mentions
^
k
My bot has a training programme for recruiting staff so I have to send text one paragraph after another (await reactions inbetween) although for some users it doesn't send them all the text and for some it does
Any ideas what could be causing that?
I assume those are dm messages? @true ravine
Yeah they are
maybe the users have dms disabled
But it will send maybe the first three and then not the rest
Only for some users
Other users get everything fine
then idk
show code?
I've even put it in a try catch and even when it doesn't show all the text the catch is never fired
(it's in a while loop to try and force it to work)
(and I know the code is weird)
is it possible to put serprate the data in my json file by lines
{"id":{"coins":"10"}
thats how the data works it writes next to each other is there a way i can make them on a new line
coins: coins[message.author.id].coins + coinAmt
and thats what enters it
@true ravine what is steps? i assume i is 0 and the rest are empty arrays?
you should check for the existance of a step before attempting to send them
The steps are defined right above that so they should always exist Tim ^
@queen needle you can pretty print an object in js using JSON.stringify
Why did I assume you were using Python...
client.on("message", (message) => {
if (!coins[message.author.id]) {
coins[message.author.id] = {
coins: 0,
};
}
let coinAmt = Math.floor(Math.random() * 15) + 1;
let baseAmt = Math.floor(Math.random() * 15) + 1;
if (coinAmt === baseAmt) {
coins[message.author.id] = {
coins: coins[message.author.id].coins + coinAmt
};
fs.appendFile("./coins.json", JSON.stringify(coins), (err) => {
if (err) console.error(err);
});
}
});```
thats my code i tried like + \n but it didnt work
my data doesnt enter in between the {}
if you want to add c it will look like this js { "a":10, "b":20, "c":30 }
however, if you use append file
it ends like this js { "a":10, "b":20 } { "c":30 }
which is invalid json
and will destroy your data
i can check this error code to see if it is true then what would happen? UnhandledPromiseRejectionWarning: Error: Not found
{
{
}```
if i do that my data enters after the bracket
{
}(then my data shows uo here)```
but my data shows up like that normally
because the file becomes invalid and will give you an error whenever you try to read it
you cannot use appendfile and json files, it simply doesnt work
yeah
they are not compatible
How do i get client.guilds.size on discord.js v12?
client.guilds.cache.size
but is it possible to get my data to show up in the right place and be on different lines
{
}{"id1":{"coins":"10"},{"id2":{"coins":"18"}```
thars what it looks like in my json file rn
not with appendfile
yeah would i use write
the json structure is very strict, the only way to update a json file is like this
- read the ENTIRE file
- make the changes in memory
- save the ENTIRE file
which is why json is very bad for saving dynamic data, or things that get updated often
I can check this error code? if tag error code which I want to check UnhandledPromiseRejectionWarning: Error: Not found
what code?
osuApi.getUser({ u: args[0] }).then(user => {
let play_time = `${Math.round(Number(user.secondsPlayed) / 3600)}h`;
play_time += ` ${Math.round(Number(user.secondsPlayed) % 3600 / 60)}m`;
let grades = "";
grades += `XH ${Number(user.counts.SSH).toLocaleString()}โ`;
grades += `X ${Number(user.counts.SS).toLocaleString()}โ`;
grades += `SH ${Number(user.counts.SH).toLocaleString()}โ`;
grades += `S ${Number(user.counts.S).toLocaleString()}โ`;
grades += `A ${Number(user.counts.A).toLocaleString()}`;
let osu = new Discord.MessageEmbed()
.setColor('#30acff')
.setAuthor(`${user.name} - ${+Number(user.pp.raw).toFixed(2)}pp (#${Number(user.pp.rank).toLocaleString()}) (${user.country}#${Number(user.pp.countryRank).toLocaleString()})`, `http://s.ppy.sh/a/${user.id}`)
.setThumbnail(`http://s.ppy.sh/a/${user.id}`)
.setDescription(`**[Profile](http://osu.ppy.sh/u/${user.id})**`)
.addField(`Ranked Score`, `${Number(user.scores.ranked).toLocaleString()}`, true)
.addField(`Total Score`, `${Number(user.scores.total).toLocaleString()}`, true)
.addField(`Play Count`, `${Number(user.counts.plays).toLocaleString()}`, true)
.addField(`Play Time`, `${play_time}`, true)
.addField(`Level`, `${+Number(user.level).toFixed(2).toString()}`, true)
.addField(`Hit Accuracy`, `${Number(user.accuracy).toFixed(2)}%`, true)
.addField(`Grades`, `${grades}`, true)
.setFooter(`Playing for ${moment(user.raw_joinDate).fromNow(true)} | Joined on ${moment(user.raw_joinDate).format('D MMMM YYYY')}`)
message.channel.send({embed: osu})
});```
so how would i be able to save it so it works
how?
is there a difference?
I have a daily command and a working cooldown but I want to be able to tell the user the remaining time in minutes seconds and hours
and idk how to do that
const time = 60000
function delay() {
setTimeout(() => {
commandCooldown.delete(message.author.id);
message.author.send(`You can now use daily again! `+client.emoji.ring)
}, time);
}
if(commandCooldown.has(message.author.id)) {
const minute = 60000 * 8
const hour = minute * 24
message.channel.send(`you need to wait **${Math.round((commandCooldown.get(message.author.id) - Date.now())/minute)} minutes** and **${Math.round((commandCooldown.get(message.author.id) - Date.now())/hour)} hours** untill you can use daily again`)
}
this is what I have rn
but it doesn't work
i would suggest looking into ms
so for my mute command i have this javascript `@${person.user.tag} has now been muted for ${ms(ms(time))}
and it tells them how long they are muted for using ms
@marble juniper any reason for 60000 * 8?
does commandCooldown.get() return the time remaining in milliseconds?
when I set the cooldown for the user I do this
commandCooldown.set(message.author.id, Date.now())
ah ok
but rn I just get 0
0 minutes
even though the cooldown is at 2 minutes
so technically it should show me 1
how big is the cooldown?
let remaining = commandCooldown.get(id) + time - Date.now();
let seconds = remaining / 1000;
let minutes = seconds / 60;
yeah oke


