#development
1 messages ยท Page 566 of 1
you can do this: if the item is not assigned to a name in data
dont give it a dataName
so when the answer comes, you check if(items[answer].dataName) { do the data name } else { do a different thing, like adding it to an array }
hm
for now, both of your items can be deal with using the same function
Yea
but in the future, as you add different types of items, you might need to deal with each type differently
so you have to check what type of item it is, and use the correct function
checking if dataName exists or not, is one way of checking what type of item it is
you can give each item type a special property that only the same types have
yes
so I could do something like
actually
the roles would already have a special proprty
since I am doing
data[items[answer].dataName]
I could do
data[items[answer].name]
for the role stuff right?
if the name matches the value that is going to be worked on, yes
Wdym?
for example, if the name field contains the exact name of the role, so that you can use it in a role function
Yea
also
data.bal -= items[answer].price
data[items[answer].name] = 2;
if(!data[items[answer].dataName]){
}else{
message.author.send(`You have just bought ${items[answer].name}!`)
}
Would the check work like this?
you have to check before you do the operation
if you do that and data.datanamehere doesnt exist, it will create a new filed which will never be used
if (!data[items[answer].dataName]) {
} else {
data.bal -= items[answer].price
data[items[answer].name] = 2;
message.author.send(`You have just bought ${items[answer].name}!`)
}
yes
K
Ima add a new item
a role
would I add the role like this
let role = items[answer].name
message.author.addRole(role)
although
that may not be very efficient if the item isn't a role
and the item is also not in the Database
Hm
message.author.addRole(items[answer].name)
?/
adddRole requires the role id or a role object
discord roles are indexed by IDs
if you have the role name, you have to find the correct role from the list of roles
Hm
I see
Hm
how could I do that though?
I mean
I know how to find the role
that part is easy
but how could I implement it?
wait
could I do
let role = message.guild.roles.find(n => n.name === items[answer].name)
then do
message.author.addRole(role)
yup
.id*
Hm mk
that works better
Also
How does Math.floor(Math.random() * 10) + 5 work?
wouldn't it give me a number
between 0-15
umm
well
what ever number you got from Math.floor(Math.random() * 10), it will add 5
lmao
you should do 14 + 1 to avoid getting 0
ye
yes
ยฏ_(ใ)_/ยฏ
Whatever works
Lol
I think my shop cmd is done now
Time to test
Oh wait
I had one more question while I am here
If anyone is good with mongoDB
can someone please explain why this isn't giving them 1 level added every time they get double the required xp
let newLevel = data.xp / 50
let myquery = { levels: 0 }
let newvalues = { $set: { levels: newLevel } }
db.collection('users').createIndex({ "id": 1 })
db.collection('users').updateOne(myquery, newvalues)
if (data.level == newLevel) {
message.channel.send(`${mesage.author.id} Leveled up!`)
}
Oh wait
I am dumb
It is doing what it should
I just didn't use it properly
it is taking my current xp
and deviding it by 50
it isn't waiting to see if I have 50xp already
Hey quick question guys, how do I get my bot on DBL to show how many servers it's in? Do I just need to use client.guilds.size somewhere in my script and it'll work?
post to api
1 sec
you can look at the docs or #312614469819826177 but the last is kinda outdated
oh ok
this works for me
thanks guys, i appreciate it
(node:1368) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of null
does anyone know what the syntax error is here?

elsif ?
should it be elsif?
elif is correct
no it shouldnt
oh
thats python
ahh and ruby
wat
elsif in ruby as well
idk python, just ruby
discord itself uses Ajax, so it can be a bit confusing sometimes as discord.py has to convert functions to and from JSON
oof
Code: https://hastebin.com/jedusodeqa.js
Error: (node:1368) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of null
so fix it
What's up?
let role = message.guild.roles.find(r => r.name === items[answer].name)
that looks correct to me
cause it is getting the name
from the item
So what's your error?
it looks like the role may not exist
no
Its offline rip
cuz no one is spoonfeeding you
my bot ded
newer
Then code it
Kawaii, it looks like you need to have your bot to create the role if it doesn't exist
i cant code to save my life
Overdone#2166
Bot Prefix: -
To run a command, use -command.
Use -help <command> for a more detailed description about a certain command, or use -help on its own for a list of all commands.
-ban ~ -ban <member> - Ban a member from your server.
-bans ~ -bans - Check the bans for this guild.
-eval ~ -eval [Code] - Eval Javascript code.
-help ~ -help [command] - Display all available commands, or detailed information about the specified command. Text enclosed in <> Indicates optional parameters.
-invite ~ -invite - Invite the bot to your server
-kick ~ -kick [@User] - Kick someone.
-kill ~ -kill - Kill the bot.
-mute ~ -mute [@User] [Time] - Mute the mentioned user.
-purge ~ -purge <@User> [Messages] - Deletes a user's or messages in a channel
-ticket ~ -ticket <Message> - Create a support ticket.
-ticketlogs ~ -ticketlogs [Channel] - Get the chatlog of the given ticket channel.
-tickets ~ -tickets - Check outstanding tickets.
-warn ~ -warn [@User] <Reason> - undefined
thats it so far
Then look up how to make it
pretty sure i'll be returning a NoneType object instead of a role, so the role probably doesn't exist
no one cares
-kill
Check d.js
I am still getting the id error
(node:1368) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of null at dmchannel.awaitMessages.then (C:\Users\Aj\Desktop\The Clinic\commands\shop.js:57:65)
Your id is returning null
If the role is returning as null, it's because it doesn't exist
^^^
Oh but it does
check you are retrieving it correctly
Yes, lol
discord will return it null as undefined would cause a bigger error
I only know python but it should be similar t this
user = client.get_user(message.author.id)
if user is not None:
except its not python
where discord returns None where the object does not exist
yes...
What is line 57?
but the discord API is cross-platform
What he means is their lib are different
Good thing he said which panda ๐
That is a snippet of the code boi
Honestly felux if you don't know JS don't answer JS questions
oh lol
Try doing let sUser = message.author.id; then change line 57 to sUser.addRole(role.id);
message.author.id?
(node:9308) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'price' of undefined
I think I know the error with that
actually
no
what I did should have worked
data.bal >= items[answer].price errored line
https://hastebin.com/bitepixana.js
^full code
Why are you checking to see if data.bal is greater or equal to items.price?
I mean you can
I kinda have too
What line is the error occurring on?
(node:9308) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'price' of undefined at dmchannel.awaitMessages.then (C:\Users\Aj\Desktop\The Clinic\commands\shop.js:52:59)
items[answer] is not defined
ahem
I could be wrong but it could be what answer is equal to
Hm?
You could do is let answer = args[1];
does anyone know why this is happening?
Nah try what I told you to do before jumping to solutions
I am wanting to do
tc!shop it dms embed
then they can just send the [itemID] of the item they want
(node:5700) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'price' of undefined at dmchannel.awaitMessages.then (C:\Users\Aj\Desktop\The Clinic\commands\shop.js:52:59)
@vernal rivet Didn't work
The key doesnt exist
I just tried SQl, I feel fresh
Could it be bc
I have the item set to 0
or is that not the problem?
but .price
does exist
Ok
Discord.js error
const Discord = require('discord.js');
>const< client = new Discord.client()```
const< is the issue
but would that change the const?
it should be
Or is it just because it's the first line
client = new Discord.Client()
Word in the line*
iirc
Ok, thanks
https://hastebin.com/avaxosufay.js
It gave me the role even though I requested Coin Multiplier
and I got 0 errrors
anyone online?
Huh?
Mk
but I need a way to not ping every bot that has 2 letters in their prefix
let cmdFile = bot.cmds.get(cmd.slice(prefix.length));```
1 > const admins = ['438733159748599813'/*pineapple*/]
2 > const bl = [];
3 > const Discord = require('discord.js');```
i also get const : The term 'const' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 every const
Hey tim
Tim do you know why this happened
https://hastebin.com/avaxosufay.js
It gave me the role even though I requested Coin Multiplier
and I got 0 errrors
Anyone able to host my bot untill it gets verified.?
@wide ruin what do you mean? it has to run in node.js
how are you trying to run it?
Tim is God here OwO
I'm just clicking run active file
Yee
https://hastebin.com/avaxosufay.js
It gave me the role even though I requested Coin Multiplier
and I got 0 errrors
(node:6060) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'price' of undefined at dmchannel.awaitMessages.then (C:\Users\Aj\Desktop\The Clinic\commands\shop.js:52:59)
if (data.bal >= items[answer].price)
Is answer a number
it should be converted to a number
because u will be getting a string
from discord message
yes
Also wondering if there's a reason why you added an id to the items
If the id is just the same as the index in the array
Bc
I wanted to
lol
I have a reason
Anyway
I am trying to parseInt it
but I can't figure out how to
so when sharding is the best way of just replacing
client.channels.get(id).send(msg)```
with
```js
client.broadcastEval(`if(client.channels.has(${id})) client.channels.get(${id}).send(${msg})`) ```
no
you need to make it a string
because js has no integer types
so you'd get the ids corrupted
wdym
client.channels.has(${id})
yea
oh didnt know that, so do i have to do id.toString()
no
whatdo
also instead of has/get you can just do a single lookup and store to a variable
If you do that, its backticks not single quotes
const channel = client.channels.get(...); if(channel) channel.send(...)
oh ye
so wait yas am i write
its bc(`client.channels.get('${id}')`)
etc.
and how would i return the message object after the fact just curious?
how could I parseInt answer.content
parseInt(answer.content)
I tried that
I don't thinnk I used it properly
if (isNaN(answer.content)) return dmchannel.send("Not valid id number!")
parseInt(answer.content)
if (!data[items[answer].dataName]) {
data.bal -= items[answer].price
let role = message.guild.roles.find(r => r.name === items[2].name)
if (message.member.roles.has(role.id)) return message.reply("โ You already bought that role.");
await (message.member.addRole(role.id))
message.author.send(`You have just bought ${items[2].name}`)
} else {
data.bal -= items[answer].price
data[items[answer].name] = 2;
message.author.send(`You have just bought ${items[answer].name}!`)
}
Oh wait
It should just be that right?
you're not using it properly
parseInt does not modify it's input
it returns the result
IDblSelfBot me = await DblApi.GetMeAsync();
await me.UpdateStatsAsync(_client.Guilds.Count, 1);```
@astral quail
alrighty
AuthDiscordBotListApi DblApi = new AuthDiscordBotListApi(506258153545924618, "token");```
How to make a rich presence for the discord bot?
have you required the dblapi.js packaged?
bots cant have RP
moreso you don't HAVE to
oh fuck, I though you did because everyone does
You do use semicolons in js tho
but you dont have to
python api is slow af
why would I
@spring wharf this page lol
doesnt explain how you send a message without typing
alright so you have imported dbl right?
rich presence belongs to an application
using DiscordBotsList.Api;```
Put that number before "token" in a string?
which is where you'd store the assets/etc
I'd like to do that, but for the discord bot
:/
it would error if it needed a string
Okay
says it takes a ulong
rp depends on the client, which bots do not have
rp is sent over the ws
the client just re-sends it
but discord blocks rp data sent from bots
what is the problem starman
the official .net library for dbl api is full of deadlocks so i wouldn't be surprised if the entire library is the problem
the API is not working and crashes my bot
again I dont get why it would just stop though
consistencyโข
it can vary to your cpu performance up to the library updates
e.g if your cpu is fast enough to process a racing condition it won't deadlock, in other cases it will
Huh
but this is the exact CPU I used originally when it worked
I've done nothing to my PC
but you aren't dedicating your entire cpu to the app, are you
meaning the cpu has to work with the app alongside other applications and programs open
it's not your fault though
the official library is badly written
make your own
For sites, how to make one with the API to use the bot?
wat
For example, there are sites like mee6's that use the API
No?
which api
discord's?
To manage the bot from a site
Yes
it varies from dev to dev
there's no template for it
I am dumb
Okay
Thx
Rich presences are allowed on an account with this if I understand correctly
it's an example
on how it would look on a user account
Yes, but is this allowed?
...
you don't understand rich presence really do you?
: dude
its so people who make their programs can do stuff like this
Make it whatever you want.
I've almost been banned for a rich presence before.
your discord app is the one maintaining the rich presence, not your bot, your discord app is not your discord bot
no you haven't
lol
Okay
if you have, you probably put something either offensive or inappropriate in your presence
probably :x
Yeah.
Where do I sell my bot?
I don't know
Show me your bot
when i send an emoji retrieved from broadcastEval it just shows [object Object]
let answer = coll.first()
if (isNaN(answer.content)) return dmchannel.send("Not valid id number!")
let a = parseInt(answer.content)
if (data.bal >= items[a].price) {
if (!data[items[a].dataName]) {
data.bal -= items[a].price
let role = message.guild.roles.find(r => r.name === items[2].name)
if (message.member.roles.has(role.id)) return message.reply("โ You already bought that role.");
await (message.member.addRole(role.id))
message.author.send(`You have just bought ${items[2].name}`)
} else {
data.bal -= items[a].price
data[items[a].name] = 2;
message.author.send(`You have just bought ${items[a].name}!`)
}
(node:8000) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'content' of undefined at dmchannel.awaitMessages.then (C:\Users\Aj\Desktop\The Clinic\commands\shop.js:52:46)
The emoji is an object thats why... JPBBerry
.toString() will automatically convert it into the emoji tho
How to make a black list of users?
@earnest phoenix
if (message.author.id === "id of blacklist") return message.channel.send('Blacklisted')
I want to make a blacklist with a json file
I already know the id technique but I want it in file
I'd suggest a db not a json file
DB's are better then json files when storing stuff like that
I have an sql db
I'd suggest using it
I don't know how to do it.....
ยฏ_(ใ)_/ยฏ
I use json for my blacklists and have a db
I dont see them as that important
Just make an array of ids and check if the array includes their id
And i dont see blacklisted people as a high priority to care enough if the file corrupts
https://hastebin.com/eleyesimoj.js
It keeps giving me the role even though I type 0 for the coinMultiplier
I get no more errors
how do i return the message object after using broadcastEval, i console logged the response after it and the shard with the channel's response was {}
{} or [object Object]
{}
(also ik im supposed to do it one variable i have it like that everywhere else but i had a brain fart randomly and did it like that)
return await <channel>.send()?
I got part of my problem fixed
but it isn't taking the coins away
nor is it adding the item it should
@inner jewel the thing is i cant seem to get a real async function working in eval like i tried this js client.shard.broadcastEval(` async function oof() { if(!this.channels.has('528367776419676180')) return null return await this.channels.get('528367776419676180').send('test') } oof() `).then(console.log)
but then it just gives me [{},{}]
await oof()
is there anyone with sharding experience that can help me
@keen drift idk ive been through a whole rollercoaster
i just want the damn message id of the message sent
its so needlessly difficult
then let it call a reply func when it completes
wym
yea i wanna .then( and get the message object
which should work
but i get a promise instead i think
yea
that's why I said have it call a return result fn
client.shard.broadcastEval(this.channels.has('528367776419676180') ? this.channels.get('528367776419676180').send('test').then(m=>m.id) : null;).then(console.log) i've gotten to this
and its still doing [null, {}]
yeah, again, it doesn't await for async result
yea
๐คฆ๐พ
am i missing something 
ijdqwij whatever im just gonna make it push to the db in the broadcast eval idc anymore
i dont get it so :/
Excerpt taken from Commando
const doReply = val => {
if(val instanceof Error) {
msg.reply(`Callback error: \`${val}\``);
} else {
const result = this.makeResultMessages(val, process.hrtime(this.hrStart));
if(Array.isArray(result)) {
for(const item of result) msg.reply(item);
} else {
msg.reply(result);
}
}
};
eval(anSyncFn().then(result => doReply(result.whatever))
How you implement that similar behavior is up to your discretion
client.shard.broadcastEval(`
let tic = this.channels.get('509886529729200128')
if(tic) {
tic.send('TICKETID = ${ticid} : Word ticket > ${message.author} via ${sent}: ${message.content} || Match site: ${iscensor[1]}').then(msg=>{
client.db.table('tickets').insert({
id: '${ticid}',
author: '${message.author.id}',
ticmsg: msg.id,
word: '${word}'
}).run()
})
}
`)
its saying missing ) after argument list but i cant seem to find it idk
also fishy im just gonna keep it simple so i actually understand what im doing oof
https://hastebin.com/qagekojoqo.js
My daily command won't work now and I have no errors
Could it be my checks?
@granite yoke are you running Windows?
Yes
If so, make sure node.js and npm are installed on your system and in the PATH
https://goo.gl/vJx9AT
Node.js
I have node.js
Just I have to write cmd.exe in terminal to do it, right?
Press the Windows key and search cmd
Ok
Ok i have cmd
Type in node
And tells me what happens
fun*
Nothing happened
Alright
Where is it
are you in your bots directory in the terminal?
Yes
Do you have a screenshot program?
If so please post a screenshot of the command prompt window
Yes
So we know what's going on
Hit prntscr on your keyboard and then control v in discord
Okay what is the file that you wrote your bot in called
You mean folder?
node file.js
Ok
Ok
Lmfao
"Alright rename that to file.js"
omfg
Their name file is actually called node file.js
You are contributing nothing please talk in #memes-and-media @lusty dew
Sure sure
https://hastebin.com/qagekojoqo.js
My daily command won't work now and I have no errors
Could it be my checks?
Bot is still offline : (
Do basic debugging @lusty dew
- Check variables near conditional statements for expected results
- Add console.logs to checkpoints to see where it gets
@granite yoke please send another screenshot
K t hanks
Remove lines 2 5 6 7 8 9
Ok
Then run it again
still offline : (
Screenshot
Ok
What can I use?
discord.js
Ok
if you need to
Discord.js is the easiest
https://youtu.be/Z-tc91hArlM
๐ฅ Discord.js Bot Development - Project Setup - Episode 1
Tune in every Wednesday & Friday for Discord.js Videos! Go easy on Ned as it's his first coding tutorial in a while! :D SourceCode: https://github.com/The-So...
videos are out of date too
I recommend starting from scratch and watching this or another discord.js tutorial
just follow https://discordjs.guide
A guide made by the community of discord.js for its users.
made by the devs
Since many of your issues are handled in the videos
The guide is another option but videos may be easier in your case
https://hastebin.com/abilesagow.js
Didn't even reach the first console.log
I wasn't reposting to get attention
@lusty dew So I have to copy and paste it to my file.js?
What?
Aaa
that I am having problems with
what
Is it a good idea?
I don't see anything related to cpp
I will write it again but related to cpp
what
I'll try ;;
@earnest phoenix come translate this
I just wanna make my bot online and responding : (
yeah, but would you?
YES I WILL DO ANYTHING TO MAKE MY BOT ONLINE
learn some language and make a bot then
;;;;;;;;;;;;;
i don't know how to work a high abstraction language
let me try a lower abstraction language

I just wanted someone to help me
With my problem
Beucause I'm now tired and didn't sleep by whole night
because of this
not trying hard enough as you wanted to switch to cpp saying it'd be easier 
you dont learn a programming language by making a bot
Why won't you help me but have fun of my lack of knowledge
i didnt know much python but making my bot helped a ton
It's almost 6 am in my country
ok
But I undestand pieces of python
@granite yoke pick a language then look up tutorials for learning it
If you know python then make ur bot in python
;;
I wanna my bot online today pls
This week is the only week i have free time
So I wanted to spend it for things I wanted to do
I wanted to create a maybe good server in this week
cool
mei no one is going to help you if you don't have basic knowledge of the language you are doing
it's like jumping into Calculus without even knowing Algebra
using*
10/10
np
Rip
Does anyone know any decent databases other than mongodb and mysql
mysql is not decent kek
Also #topgg-api exists, DBL API questions go there
how to give the role on discord by role ID in discordjs
for example as if they did !verify gives the role but i dont know if theres way do by role id
so like this? js if (message.content.startsWith(prefix + 'verify')) { message.member.addRole('542291593709879327') .then(message.member.removeRole('542292515642933258')) .catch(console.error); }
Can somebody help
how to make typing t!eq m1 do this
const test = args[0]
eq.selected.level = eq. (here test) .level
xoz i have like m1/m2 etc etc and want to make current level same as level from one of these
Anyone now how to make poll, voting bot
@timber cloud eq[test].level
Is anyone here familiar with hosting on glitch
Anyone familiar with youtube api if we can check if someone is subscribed to someone?
show code?
const t = .credits
message.channel.send(eq[t])```
t = .credits is not valid javascript
there are '' just forgot to write them here
show the contents of eq
if you have a property called credits, then you access it by using eq.credits or eq[credits]
not eq[.credits]
so the dot there is wrong
eq is a shema from mongodb
And i acces it by eq.credits
I know i can just type eq.otherstuff but im oversimplyfing it here
I just need to be able to change this .credits so it works
yes but if you use [] then you dont need the dot
but it will be just eqcredits
so it should be const t = "credits"
thats not how it works but lets try
thats what im telling you
the dot means its a property of
eq.credits is the same as eq[credits]
the brackets replace the dot
ok it worked
and i cust continue with readind propeties
eq[test].user.level etc etc
yes
ok thx
anyone good with github pages? im trying to add css rules to a jekyll remote theme. i tried creating an assets folder as recommended, but it doesnt work
@earnest phoenix it's decent for php but that was not what I was looking for
@sick cloud thanks for the suggestions btw
heihei iam back with a new issue :))
i think that the problem iis the line let jsfiles = files.filter(f => f.split(".").pop === "js");
when i console.log(files) i get
.pop() ?
so you check if a function is equalt to "js"
instead of the result of the function call
ok yea thx it works with .pop()
Does anyone know what's wrong with my bot and why it won't go online?
Ping me when you reply
@earnest phoenix it needs some time to go offline, the bot doesnt show offline when you close it directly
None
Then no one can help ya
ignore my msg thx
ยฏ_(ใ)_/ยฏ
We won'
Shhhh
If your not gonna help leave this channel till you help
xD
xd
give code = get help
๐ค
ok
Am I wrong?
Shhhh
still triggered that iam not green xd
Am I supposed to just know how to fix it without seeing the code or the erorrs?
errors*
If you aren't going to provide what we need to help you then don't ask for help
MoBiLe
๐คฆ
show code or no help
Hm
full code
I know what it is meant to do
I just don't understand what a big chunk it means oof
Anyway
yall think its better to split setting related stuff into multiple commands or keep it rather simple for the enduser to just have one command with a param designated to deciding which setting is being changed?
guess im going for the single command then, less documentation and command spam 
i just make subcommands for each setting

kong left Discord Bot List which has 36079 members. The bot now serves 40646 users.
rip
eris doesnt automatically deal with guildspecific prefixes does it
no
๐
players:
[ { name: '1', score: 24, time: 4283.09130859375 },
{ name: '2', score: 12, time: 2838.73486328125 },
{ name: '3', score: 43, time: 2583.64208984375 },
{ name: '4', score: 3, time: 2537.353515625 },
{ name: '5', score: 8, time: 2210.147216796875 },
{ name: '6', score: 15, time: 1887.413818359375 } ]```
How I can get a 3 best values in score and then sort them by scores?
```{ name: '3', score: 43, time: 2583.64208984375 }
{ name: '1', score: 24, time: 4283.09130859375 }
{ name: '6', score: 15, time: 1887.413818359375 }```

im not sure thats how you would want to run a js file anyways
well thats the only error i get
terminal > run active file
and occasionally
Cannot read property 'indexOf' of undefined
the latter is a problem with your code
try running node server.js in your bots directory
cmd.exe?
do you know how to use the cmd
yes
then whats the problem
