#development
1 messages · Page 833 of 1
thanks :>
@digital ibexHow?
...
what is your djs version
latest
Thanks!
Uhh
It's been 2 minutes
Just 2
With presence
It works fine
But then it just turned my bot offline
And then back on
And the presence stopped working.
what
I have .catch and it didnt show any error
put your code to ready event
bot.on?#
yes
I did that
def count_chars(my_str):
my_dict = dict()
for x in my_str:
if my_str[x] not in my_dict:
my_dict[my_str[x]] = my_str.count(my_str[x])
return my_dict
``` File "main.py", line 4, in count_chars if my_str[x] in my_dict:TypeError: string indices must be integers
I worked for 2 minuyrs
im not sure why im getting an error?
And my bot went offline, presence stopped working
It only went offline with presence
It doesnt go offline when I don't have the presence on
bot.on("ready", () => {
bot.user.setActivity("activity text")
})```
Yeah but does that work
@narrow kettle Because you dont need to index that string
you've done sorta what i told u todo
x is going to be a character of a string
rather than a index (0, 1, 2, 3) etc...
thanks :>
How dare you forget....... I'm disappointed. You should just go and learn ASM instead.
great it works :>
@slender thistle Im sorry i disappointed you master
I'm trying to have fun with python newbies ok
Shiv dont make me thread you 👀
me.exe isnt working
when i start my bot with idle and playing activity, the activity shows up for like 1 second and it stops itself
idle as in setStatus
its one or the other
if i do ```py
for x in my_dict:
will it happen the 4 times if my_dict have 4 keys?
or does it happen by the stuff that my keys contain
depends
by defualt
that code would iterate over the keys
so x would be each key in the dictionary
but lets say we did my_dict.values() x would then become the values of each key
oh
nice to know, Thanks
can i access a dict with numbers
lets say access it like that my_dict[3] = "hello"
and simply change the name of the key?
If the key is 3 yes
You can't access indexes on dicts afaik
Because they're not exactly ordered
ok so if its in a for i simply access it by writing x
but how do i change the name of the key?
You create a new one and... delete the previous key? 
for some reason my music command isn't working, saying something about the fact ive hit my daily quota for queries yet I haven't even done 10k, I am using the youtube data api
anyone know how to work around this?
thank you master
why wouldnt this work?
def inverse_dict(my_dict):
my_dict = dict()
for x in my_dict:
my_dict[my_dict[x][0]] = my_dict.pop(x)
return my_dict
print(inverse_dict({'c': 'd', 'b': 'c', 'a': 'b'}))
its suppose to replace the name of the key with the first containment of the key and switch the first containment of the key to the key(hopefully if you understood what i just said)
its just returning []
because you're overriding the input
(i just remembered i forgot to replace the containment of the key but its still not working)
wym?
my_dict is immediately getting overridden into a dict object
you pass the dictionary
to the function
to the parameter called my_dict
then
my_dict = dict()
which completely overrides it
You're shadowing the parameter by creating another object under the same variable name
oh
hi guys can someone see my % command is it correct?
percentage = Math.floor(Math.random() * (103 - 1) + 1);
if (percentage < 45) rarity = "common";
else if (percentage > 44 && percentage < 79) rarity =
common 44.4% 0-400
thats the % i trying to code,please ping me if u can help me thanks
oh nvm
File "main.py", line 4, in inverse_dict my_dict[my_dict[x][0]] = my_dict.pop(x)KeyError: 'c'
im only getting that error
pretty sure if you want the value of that key popped out you need popitem()
wait
nvm
resend your code
def inverse_dict(my_dict):
for x in my_dict:
my_dict[my_dict[x][0]] = my_dict.pop(x)
return my_dict
print(inverse_dict({'c': 'd', 'b': 'c', 'a': 'b'}))
the error is in line 3*
my brain is so dead i just wrote arrow instead of error
its suppose to replace the name of the key with the first containment of the key and switch the first containment of the key to the key(hopefully if you understood what i just said)
so like swap the Values and keys around
so if i have
{'a': 'b', 'c': 4} would become {'b': 'a', 4: 'c'}
correct?
expected result?
also while doing this im suppose to sort the lists in the keys? can i just do my_dict["keyname"].sort()
oh thats noice
we can use <dict object>.keys() and list() it to get a list of keys
and then use <dict object>.values() and list() it to get a list of values
then just make values the keys and keys the values
but i need to make only the first value in the list into a key
so lets say the list is [1,3,4] then 1 will be the key now
Oh
I did it
actually
i didnt do it
its only working for one char
but if there is more then one it just YEETS it
this is what i did
def inverse_dict(my_dict):
new_dict = dict([(value, key) for key, value in my_dict.items()])
for x in new_dict:
new_dict[x] = list(new_dict[x])
return new_dict
but its only working if the list inside the keys contains only one char
what did you do?
def the_dictifer(my_dict):
new_dict = dict() # lets just make a blank dict object
for key, value in my_dict.items(): # lets iterate through the keys and values
new_dict[value[0]] = key # now we just assign the first index of value as the key and key become the value
return new_dict # return new dict
print(the_dictifer({'d': 'c', 'c': 'b', 'b': 'a'}))```
>>> {'c': 'd', 'b': 'c', 'a': 'b'}```
its working just like mine xD
you've just made it a lil more complicated than it needs to be
[ what the code returned ] - [ what is suppose to be ] - [ what command ran ]
its the same as mine :< both arent working completly fine
yeeee
just send me the bottom row
{'dd': ['c', 'c'], 'cd': ['b', 'b'], '5': ['$'], '4': ['%']} {'dd': ['cc'], 'cd': ['ab', 'bb'], '5': ['!', '$', 'dd'], '4': ['%']} inverse_dict({'cc': 'dd', 'dd': '5', 'ab': 'cd', '!': '5', '%': '4', 'bb': 'cd', '$': '5'})
i take it the first bit is the expected result?
no
the first is what we got
oh wait
its my code lemme show you what your code got
[ what the code returned ] - [ what is suppose to be ] - [ what command ran ] its like this btw
{'4': '%', 'd': 'cc', 'c': 'bb', '5': 'dd'} this is what your code returned
What Your Code Returned - {'4': '%', 'd': 'cc', 'c': 'bb', '5': 'dd'}, What Your Code Is Suppose To Return - {'dd': ['cc'], 'cd': ['ab', 'bb'], '5': ['!', '$', 'dd'], '4': ['%']}, The Command Ran - inverse_dict({'cc': 'dd', 'dd': '5', 'ab': 'cd', '!': '5', '%': '4', 'bb': 'cd', '$': '5'}).
here this is better
the only issue with that expected result
is that it depends on how you do it in order
because cd is gonna override the hashmap
that might take me some time to get my head around xD
its realy fine... you are helping me and i realy appreciate it!
I'm getting an error shortly after starting up my bot. I can read this but don't know how to repair it. Can someone help?
at Client.<anonymous> (C:\Users\Cools\dog1bot\src\index.js:16:13)
at Client.emit (events.js:219:5)
at Guild._addMember (C:\Users\Cools\dog1bot\node_modules\discord.js\src\structures\Guild.js:1542:19)
at GuildMemberAddHandler.handle (C:\Users\Cools\dog1bot\node_modules\discord.js\src\client\websocket\packets\handlers\GuildMemberAdd.js:12:13)
at WebSocketPacketManager.handle (C:\Users\Cools\dog1bot\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:108:65)
at WebSocketConnection.onPacket (C:\Users\Cools\dog1bot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:336:35)
at WebSocketConnection.onMessage (C:\Users\Cools\dog1bot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:299:17)
at WebSocket.onMessage (C:\Users\Cools\dog1bot\node_modules\ws\lib\event-target.js:120:16)
at WebSocket.emit (events.js:219:5)
at Receiver.receiverOnMessage (C:\Users\Cools\dog1bot\node_modules\ws\lib\websocket.js:789:20)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fyre@1.0.0 start: `node src/index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the fyre@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Cools\AppData\Roaming\npm-cache\_logs\2020-03-22T20_53_39_085Z-debug.log
C:\Users\Cools\dog1bot>```
show index.js 16th line
okay, so looking at it:
They want use to go through the dict
if there are multiple keys with the same values
we added them to one list with one inverted key (so we dont override it)
yep
This is 14-17.
const channel = member.guild.channels.find(channel => channel.name === "welcome-and-goodbye");
channel.send(`Welcome to the server! ${member}! Read the rules and have a good time!`)
});```
I have the same thing but instead it goodbyes users.
const channel = member.guild.channels.find(channel => channel.name === "welcome-and-goodbye");
channel.send(`Someone just left, it was ${member}.`)
});
make sure that there is channel named "welcome-and-goodbye" in your server
There is. But since it's a bot that is usable for all users, I believe that's why.
It trys to detect a channel in someone elses guild but dosen't and throws an error.
I'm just going to remove the whole idea.
how do i make my bot detect the lower or uppercase version of a command
like and
it also detects as And
I think you could just do ```js
if(channel) channel.send(Welcome to the server! ${member}! Read the rules and have a good time!)
so it only sends it if there is a channel found
Oh that's a good idea.
or js if (!channel) return;
^
np
const channel = member.guild.channels.find(channel => channel.name === "welcome-and-goodbye");
if(!channel) return;
channel.send(`Welcome to the server! ${member}! Read the rules and have a good time!`)
}); ```
for the 2 commands capitalizations I think you could just do
if(command == "help") {
// "help" stuff
}
if(command == "Help") {
// "Help" stuff
}
just make sure command is not set to always be lower cased
Can someone check out #topgg-api for what I'm asking?
it says dont ask to ask
@hollow granite why are u using them seperately
u can do if(command.toLowerCase === "help") {...
How would I put a certain command to a specific guild? I'm attempting to make the whole api vote thing, and I want it so that it goes into my server guild, finds the "vote" channel, then sends something like ${vote.user} has just voted! Woohoo! 🎉
@modest maple you good?
@astral yoke get the server by its id
i hope you didnt get your head around too much
ngl, i forgot when helping you i forgot i was supposed to be restarting the bots
xD
lol
@finite bough Already have it.
you got time to help me now tho? i just found out i got only 30 mins till i gotta go :<
i kinda could rlly do with sorting my current stuff out
ill still be thinking about it if you check in tomorrow?
ah nah its fine then if u got stuff to do
cuz i have only half hour to do it so tom wont realy help(even tho it wll help cuz then i will know how to do it) i will just try to do it myself :> You did help me ALOT today tho
thanks!
does anyone understand why this happens?
CPU usage suddenly spikes from time to time
just started happening recently and it causes bot to stop
which I need to restart
Discord.js version 12.0.2
let verifLevels = ["None", "Low", "Medium", "(╯°□°)╯︵ ┻━┻", "┻━┻ミヽ(ಠ益ಠ)ノ彡┻━┻"];
let FilterLevel = ["None", "With Out Roles", "All Members"];
embed.addField("Content Filter ", `\`${FilterLevel[message.guild.explicitContentFilter]}\``, true);
embed.addField("Verification Level", `\`${verifLevels[message.guild.verificationLevel]}\``, true);
I get it as undefined
well you dont index an array with string for one
you could convert it to a number by using a object to map the string to a number
i couldnt think of how to phrase that for some reason
@pallid vector u must be using something which takes a lot of cpu
like js let vericicationLevels = { NONE: "None", LOW: "Low", MEDIUM: "Medium", HIGH: "(╯°□°)╯︵ ┻━┻", VERY_HIGH: "┻━┻ミヽ(ಠ益ಠ)ノ彡┻━┻" }
and same with explicit content filter
it can be api requests, editing files, loading up a database
OOh I se
hm so what I think was the problem
hm actually.. idk how to explain, but basically I have a cached ver of prefixes that I load
but if bot down, it cant create a cached ver of prefixes on guild join
and some servers were added in while bot was down
u use customizable prefix?
yeah
db?
yeh but I create a cached ver of prefix
@royal portal any errors?
no
even with .catch
i have latest version of discord.js and node.js
running on raspberry pi 3
what db do u use
db?
@royal portal does ur bot still work?
can u show the code
not sure why it stops working randomly after 20 mins
ok
dms
@finite bough sent to you
Where can I find all the region options?
https://cdn.danbot.xyz/ik4Hc0hR
@heavy marsh d.js version
Yep
oofs
12.0.2
Cause I get it has for example europe I want it to be Europe
https://cdn.danbot.xyz/p9545Vbg
Lol
anyone know how to fix setActivity
@heavy marsh all you want is to make the first letter uppercase?
But incase if its US Central
else if (guild.region.toLowerCase === us central )
Ahh ok .. but where can I find the full list of server regions?
Discord Server Options?
Is there no special regions for verified & partnered servers?
const cregion = guild.region.charAt(0).toUpperCase() + guild.region.slice(1);
you can also do region[0].toUpperCase()
OOh ok thanks
now come to think of it
why tf do discord save names of the regions in small letter
data is usually stored as simply as possible
usually to avoid case issues when moving stuff around databases
true
can someone tell me what's wrong here
serverQueue.songs.map((song, index) => index + 1 + ". " + song.title).join("\n"); it says [object Object]
when i use an embedder
looks correct
ik but its say that
show where you put it in the embed
module.exports = {
name: "queue",
description: "Show the music queue",
execute(message) {
const serverQueue = message.client.queue.get(message.guild.id);
if (!serverQueue) return message.reply("There is nothing playing.").catch(console.error);
const queues = serverQueue.songs.map((song, index) => index + 1 + ". " + song.title).join("\n");
let embed = new discord.MessageEmbed()
.setColor('RANDOM')
.addField(queues)
return message.reply(embed)
.catch(console.error);
}
};```
What is the best way to check if a time has passed? For example a mute command. Just intervals and checks or is there a more efficient way
does it need to be remembered between bot restarts?
hey i have installed the jdk 1.8 and gradle 6.2.2 why doesn't appears java-application? Anynone can help me?
im following a guy tutorial..
btw
i dont use java sorry
@crimson vapor a timeout would be more effective, however if you're regularly tracking multiple timeouts (like hundreds of them), an interval would be better
Yeah
It would probably be an hourly check
you can do best of both worlds
Regardless of bot restarts though
an interval that fires timeouts
for regardless of bot restarts you need a database
If you check if a timestamp has passed then restarts aren't an issue, if you save the data correctly that is
I think I’ll check if the date now is greater than the data that it is supposed to expire and of it is, delete the data
how do i develop a fly swatter command
What does a fly swatter command do?
swat flies
First of all, you need a Pc
Does .bannerURL(options) = https://cdn.danbot.xyz/lsJR35V3
Or is this the splach banner
no it doesnt = that
the banner on the invite?
idk
https://cdn.danbot.xyz/UhH9L1Dz - How can the banner be a gif?
@quartz kindle thank you 
For discord.js v12, does ShardingManager.broadcastEval() only returns if something was found?
like if i try to get a user
@heavy marsh banner cannot be a gif
But why does have that option then lol
@earnest phoenix broadcastEval is like eval()
it returns whatever the code you sent evaluates to in an array, where each item of the array is the response from one shard
ie: if you have two shards, and you do broadcastEval("5+5") it should return [10,10]
But why does have that option then lol
@heavy marsh yes but it will be not animated
ok
yes
When I do ```js
<ShardingManager>.broadcastEval(client.users.cache.get("myidhereimtoolazytoputitin"))
It says that client is not defined. Any idea why is that a thing?
am using d.js v12
That is v12
so i have to remove the client?
ok now it says users is not defined
Can you show me the error?
did u try to do users.cache?
(node:21684) UnhandledPromiseRejectionWarning: ReferenceError: users is not defined
at eval (eval at _eval (/root/node_modules/discord.js/src/client/Client.js:376:12), <anonymous>:1:1)
at Client._eval (/root/node_modules/discord.js/src/client/Client.js:376:12)
at ShardClientUtil._handleMessage (/root/node_modules/discord.js/src/sharding/ShardClientUtil.js:184:82)
at process.emit (events.js:321:20)
at emit (internal/child_process.js:881:12)
at processTicksAndRejections (internal/process/task_queues.js:85:21)
(node:21684) 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)
what code did u run
don't you need a client instance for that?
manager is a ShardingManager
that's not what I meant
broadcastEval runs in the context of client
ah
shouldn't need client.
well
i didnt put it in
ok
yes
so instead of client use this
try that
I'm awaiting
kk
does the test webhook button on the website post to the webhook that tonkku voted?
no it uses your id
no
because i remember that when i was experimenting with webhooks
i remember that it always say tonkku voted
also will broadcastEval return anything if nothing was found on that shard?
I'm guessing it'll return null
btw how do I do typeof with custom classes
like if(typeof user === Discord.User)?
instanceof exists for a reason
wait it exists?
thanks
gtg
bye
dbl.webhook.on("vote", async vote => {
console.log("THE WEBHOOK RECEIVED SOMETHING!!!")
let db = mongo.db("main");
if(vote.type == "test") vote.user = "312559122144821248";
let user = await manager.broadcastEval(`this.users.cache.get(${vote.user})`);
let stats = await db.collection("users").findOne({_id: vote.user});
let player;
if(user[0] instanceof Discord.User) player = user[0];
if(user[1] instanceof Discord.User) player = user[1];
if(player && stats){
let embed = new Discord.MessageEmbed()
.setTitle(`Thanks for voting Beycord, ${player.username}!`)
.setDescription("Beycord would not be here without people like you who vote for Beycord every day.\n\nYou received :valtz:250 and 800 EXPs as a voting reward!")
.setAuthor(player.tag, player.displayAvatarURL())
.setColor("#7f7fff")
.setFooter("Make sure to turn on the voting reminder by doing ;reminder.")
.setTimestamp();
db.collection("users").updateOne({_id: user.vote}, {$set: {coins: stats.coins + 250, xp: player.xp + 800}});
player.send(embed);
if(stats.premium == true){
db.collection("users").updateOne({_id: user.vote}, {$set: {coins: stats.coins + 250, xp: player.xp + 800}});
player.send("You received a doubled reward because you have a Premium membership. Yay!:tada:");
}
if(stats.reminder == true){
setTimeout(() => {
let remind = new Discord.MessageEmbed()
.setTitle("24 hours had passed since your last vote which means... YOU CAN VOTE AGAIN NOW!")
.setURL("https://top.gg/bot/570115430786531340/vote")
.setColor("#7f7fff");
player.send(remind);
}, 86400000)
}
}
});
``` Can anyone tell me why doesn't it work? The console didn't output any errors about it so I have no idea where's wrong
manager is a ShardingManager, db is a MongoDB Client thing and I am using d.js v12
try {} catch {}
if(user[0] instanceof Discord.User) player = user[0];
if(user[1] instanceof Discord.User) player = user[1];``` is this code for your 2 shards?
yes @crimson vapor
you might want to change that because if you ever have more shards, it would need to be updated
could loop and a half over all results and the first one that is an instaceof Discord.User break
well a loop would be best probably
so if shards are down it doesnt matter
oh yeah I didnt think about that
you want to generalize your code as much as possible for things like that
It'd be an array index out of bounds most likely
oh yeah
so did you guys spotted any errors that caused it to not DM the voter?
I guess start console logging every other line and figure out how many lines down it stops
thats what I do
not very efficient but it works
im not sure that way will ever work
ok i will try that
what are you trying to do?
ok million's idea worked
the problem that caused it to not work is
if(player && stats)
but i dont get why it cant define them
i dont think you can send entire class instances over broadcastEval
messages are serialized/stringified when sent across processes
would someone mind checking out a site i'm working on and telling me what they think? i'm trying to work on making things slightly aesthetically pleasing since my past work has been gross
so what should i do?
also, you cant sent messages to people from your sharding manager, because there is no client instance there, so no access to any rest methods nor token
how do i fix it now then?
im stuck
also doesn't broadcastEval returns an array?
you need to run that function in your shards, not in the manager
yes
put that code inside a function in your shards, then call it from the shard manager via broadcastEval
like this
dbl.webhook.on("vote", user => {
manager.broadcastEval(`if(client.users.cache.has(${user}) { executeVote(${user}) }`)
})```
@earnest phoenix
thanks
you receive vote events in your manager, and then make the relevant shard run the rest of the function
so i just have to make a function in the client's file to handle votes?
thanks, i will try it now and tell you if it works
@zenith terrace blame discord
@crude magnet I want to see it
Duane the rock johnson
Duane the paper johnson
Duane the scissors johnson
anyone have any luck on fiverr?
i've been on the site for like a year and had no success whatsoever
ok
Well what you're doing with the api key is against their ToS
so, without spamming new ones, no
@crude magnet yo it looks promising
In this tutorial, I will show you guys how to host your Discord Bot/Web Application on a cloud 24/7. We will be using Heroku, which is free and requires no credit card information. You will need to make sure you know how to make a Bot, I recommend watching some of my earlier v...
@real summit I love that pfp
@earnest phoenix it doesn't matter
visual studio is just a text editor
the program you use (if you're a real programmer) doesn't matter
at the end of the day everything is just a text file
and in that video they're using atom
ffs
i don't think discord bot maker is a text editor
@real summit I love that pfp
@earnest phoenix thanks btw
Im rewatching dragon slayer lol
i still need to finish it
Who can tell me how can i make a status to count how many servers are my bot like Servers: NaN / n!help
shards or no?
it isn't really too much harder, this guy https://discord.js.org/#/docs/main/stable/class/ShardingManager?scrollTo=fetchClientValues makes it pretty much the same
Just need to reduce an array
which I guess if you dont know how to use reduce could be "hard"
how do i make an ON and OFF command for this script. https://pastebin.com/srf9qurD.
I want it so that admins can turn off or on the LEVEL UP( Line 19 ) message if they feel its annoying for their guild.
@calm shore use a database
You just need true and false
No
Oh.
I don't give lessons for free
tf
🤦♂️
guys i need help
then dont give a pointlessa ass answer in this channel
the discord installation it self
?
Listen. Even ik i need to use a database
Read channel topic you both
i tries for like 9 time to install it .... first a transparent box
and then
nothing
@calm shore if you're not dumb you never came here and asking for help
@stuck wedge you makes no sense
your basically calling all the people coming here dumb by saying that

go put ur toxic self somewhere else
Wow your attitude
@stuck wedge Please send me your error and code using pastebin.com
all in can see
For one
dont use discord on a website when ur trying to code a bot
download it
and please send me ur error on ur console
i can`t that white box is the discord updator
Just wait then
thanks
did you open task manager?
yup
click "More Details"
Yes
opened
Just end task discord
how do i make an ON and OFF command for this script. https://pastebin.com/srf9qurD.
I want it so that admins can turn off or on the LEVEL UP( Line 19 ) message if they feel its annoying for their guild.
totally done
Same
That's what i told him
is that all i have to do ?!
and then u said i dont give lessons for free
yes @stuck wedge
anyways @crimson vapor whats that
should i start it again
@calm shore you directly asking me to code it but i don't
No i didnt
You need to learn it
I never said. "Oh rlly. can you write me a whole code."
@crimson vapor he is using json
no, now please dont argue in here

json isnt too bad for guild data if you only have a few guilds
btw...... thanks for the help
yw
@stuck wedge you need to end em all
he did\
Ok
yup
Start it again
@crimson vapor so would this be correct
xpNotifications = message.channel.send(`Congratulations ${authorId}! You leveled up to level ${curlvl + 1}`); ?????
@calm shore no
you need to have an if check for whether or not that server's xp notifications are on
if(xp = true) {your message} else return;
Where xp is a stored object in your database
if (xpNotifications) //if true, this block will proc
{
//xp stuff here
}```
but thats saying if the xp is active. I want it so if i type a command, it will turn off the whole levelup message
No
yay
You need to set guild id with it
If(guild.id = xp.guild&& xp.msg = true) @calm shore where xp.guild and xp.msg have guild id and boolean respectively
@stuck wedge uh oh
Restart it again
Or reinstall or download latest version from website
i reinstalled before like 9 times ..... sign
Or you can use specific statement and string
yes
Yes
i thought so
Try it @calm shore
that if (xpNotifications) might need to be if (xpNotifications == "on")
I thought you were gonna use a boolean
He didn't?
although I'm not sure "on" and "off" count as type boolean in javascript
if (xpNotifications == "on") //if true, this block will proc
^
ReferenceError: xpNotifications is not defined
You need to get it from json file
what should i define it as
xpNotifications = message.channel.send(Congratulations ${authorId}! You leveled up to level ${curlvl + 1});
?
I'm assuming you could define it by default as "on" if you want them to be on by default, or "off" if you want them off by default
but you'll want to define that out-of-scope, so that it's not reset on every command trigger
if(message.content.startsWith("-leveling on")) {
xpNotifications: "on",
} else if(message.content.startsWith("-leveling off")) {
xpNotifications: "off",
}```
xp[message.author.id] = {
xp: 0,
level: 1
};
}
You never defined xpNotifications
Ik
🤦♂️
what would i define it as
True or false
You know how to use json database?
nope
so instead of
if(message.content.startsWith("-leveling on")) {
xpNotifications: "on",
} else if(message.content.startsWith("-leveling off")) {
xpNotifications: "off",
}```
if(message.content.startsWith("-leveling on")) {
let xpNotifications = true,
} else if(message.content.startsWith("-leveling off")) {
let xpNotifications = false,
}```
You need to use fs.writeFile
Yea i have no clue how to use that
it did start ....i guess
I just looked piece by piece on google trying to connect it like a puzzle
LoL
That's not how programming works
You won’t be able to figure out the puzzle if there are no colors
Lol
Yeah so learn js
Otherwise you'll keep causing bugs
got any idea ??
You need to use it after xpNotifications
i did
Really?
What you're changing is xp
#memes-and-media ....here
You never did anything with xpNotifications
//off
if (xpNotifications == "off") //if true, this block will proc
{
let xpAdd = Math.floor(Math.random() * 7) + 8;
console.log(xpAdd);
if(!xp[message.author.id]) {
xp[message.author.id] = {
xp: 0,
level: 1
};
}
let authorId = message.author;
let curxp = xp[message.author.id].xp;
let curlvl = xp[message.author.id].level;
let nxtLvl = xp[message.author.id].level * 400;
xp[message.author.id].xp = curxp+ xpAdd;
if(nxtLvl <= xp[message.author.id].xp){
xp[message.author.id].level = curlvl + 1;
}
}```
?
I made it so if it == "off" then it will still level people up but not send the messager
for example
No u didn't
Tell me where you saved the xpNotifications
line 27 has the message sent if the leveling is on
and line 50 where its off completely ignores it
uhhh
xp[message.author.id] = {
xp: 0,
level: 1
};
}
Learn from this
And check how you defined xp
there's 2 things here - whenever I close it, it always gives me an error saying that unclosed client session, how do I fix that
also, does the attempting to bind address mean
that port is taken?
and I should use something else
Hello, I try to get role by id using eval, but I get only error
UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body
content: Must be 2000 or fewer in length.
//eval message.guild.roles.get(roleid);
(Discord.js v11.6.1)
thats because the bot after you tried to use eval sent a message which was too long
@proper inlet
because once you got the role it sent the entire role object
Thx
Devs that have web interface for your bot: What tools did you use and what are you running it on? I've never done an 'actual' website so it's gonna be a long journey for me. I just have no idea where to start from except learning more html and css.
Some use frontend frameworks, I go with WYSIWYG
Sounds interesting, what framework would you suggest?
ive personally worked with react a lot but there's angular which is a really good competitor
you'll have to do a bit of research to see which one really suits you, that is if you want to go for a SPA on frontend
IMO React is definitely easier to learn than angular
I usually go with node.js and express + nginx on the server side, React for UI
Ive never used any frontend framework lul, maybe thats why i hate frontend deving
But i always felt that websites that use react and stuff are slow and bloated af
what's problem??
Discord.js - v12.0.2
bot.guilds.get('611881570202025986').members.cache.filter(m => m.presence.status === 'online').size
ERROR:
bot.guilds.get is not a function
what
@heavy marsh It's bot.guilds.cache.get(...)
for me?
members.cache.filter
bot.guilds.cache.get('611881570202025986').members.cache.filter(m => m.presence.status === 'online').size```
I did that ...
The code is correct, maybe you have provided the wrong ID to get
who can help me to fix that?
@pallid vector
?
Sorry, was trying to get anothers attention.
@glad charm
Are you using JS/py? or
Js
12.0.2
Right, this.guilds.size
const roles = member.roles.cache.sort((a, b) => b.position - a.position).array();
const userRoles = roles.cache.filter(r => r.id !== message.guild.id);
error:
TypeError: Cannot read property 'filter' of undefined
discord.js version 12.0.2
I've never sorted roles before, but you can guess that roles doesn't get a result.
const member = message.mentions.members.first() || message.guild.members.cache.get(args[0]) || message.member;
member is defined
Let's say the member has no roles.
Doesnt it give the roles https://cdn.danbot.xyz/l2BpyQmc
Shouldn't have to do cache for client guilds.
embed.addField("Roles", `${userRoles.slice(0, 8).join(' ')}${userRoles.length > 8 ? ` **+${userRoles.length - 8} role(s)**` : ''}` || "No Roles");
@heavy marsh you're assuming the member has roles, what if the member doesn't?
const roles = member.roles.cache.sort((a, b) => b.position - a.position).array();
// roles is alreadu taken out of the cache here, doing roles.cache here is like going member.roles.cache.cache
const userRoles = roles.filter(r => r.id !== message.guild.id);```
ooh
Tim got ur back
Ah good point.
🙂
@zenith terrace let me see
who can just give me a exemple
undefined nickname lol
i know
client.on("guildCreate", guild => {
// This event triggers when the bot joins a guild.
console.log(New guild joined: ${guild.name} (id: ${guild.id}). This guild has ${guild.memberCount} members!);
client.user.setActivity(Serving ${this.guilds.size} servers);
});
@final creek
is it muted?
n!help
yep
lol
or maybe
Common prefix
ok this is the code for that
so its muted
**client.on("ready", () => {
// This event will run if the bot starts, and logs in, successfully.
console.log(Bot has started, with ${client.users.size} users, in ${client.channels.size} channels of ${this.guilds.size} guilds.);
// Example of changing the bot's playing game to something useful. client.user is what the
// docs refer to as the "ClientUser".
client.user.setActivity(Serving ${this.guilds.size} servers);
});
**
Dear lord.
I would recommend to use code blocks
`${client.guilds.size}````
afaik setActivity takes an object, not a string, whats your discord.js version?
what's the port # range that it has to be in between again?
port range for what?
there is no port range for that, you chose whatever port is available in your host
They're probably referring to this https://github.com/DiscordBotList/DBL-Python-Library#additional-information
what was the range of numbers it had to be in?
client.on("ready", () => {
// This event will run if the bot starts, and logs in, successfully.
console.log(Bot has started, with ${client.users.cache.size} users, in ${client.channels.cache.size} channels of ${client.guilds.cache.size} guilds.);
// Example of changing the bot's playing game to something useful. client.user is what the
// docs refer to as the "ClientUser".
client.user.setActivity(Serving ${client.guilds.cache.size} servers);
});```
@soft flare Gotta have .cache in v12
o I remember seeing something about that
Quoting from there:
webhook_port must be between 1024 and 49151.
whats your discord.js version?
that error is not coming from that code. but that code has other issues
in v12 you have to put .cache before all collections
users.cache.size, channels.cache.size, guilds.cache.size
Version 12 has many changes compared to the previous version, I would recommend to follow their guide: https://discordjs.guide/creating-your-bot/#getting-your-bot-up-running
hello
It's worth upgrading, newer version mostly cover more of the API, older issues should also be fixed
yeah
v12 is like
UNDEFINED
I just told you to put .cache before everything...
Not everything
Before collections
and where i suppose to put .cache in glitch com
yea
client.on("ready", () => {
// This event will run if the bot starts, and logs in, successfully.
console.log(Bot has started, with ${client.users.cache.size} users, in ${client.channels.cache.size} channels of ${client.guilds.cache.size} guilds.);
// Example of changing the bot's playing game to something useful. client.user is what the
// docs refer to as the "ClientUser".
client.user.setActivity(Serving ${client.guilds.cache.size} servers);
});```
@soft flare Gotta have .cache in v12
@zenith terrace

what file and what line?
I don't see any has in the code you send
you dont have `
`Bot has started...`
you're not using strings
where `
console.log(`Bot has started, with ${client.users.cache.size} users, in ${client.channels.cache.size} channels of ${client.guilds.cache.size} guilds.`);
^^
meh ... you fooled me
I forgot to add them in
done
no more i think
Bot Power Up
yep
Bot has started, with 23524 users, in 308 channels of 10 guilds.
hooooly
works
WORKS
10 servres
user count is false uwu
wow
Lol
i know
ez to fix
let usercount = 0;
client.guilds.cache.forEach(g => {usercount += g.memberCount})```
Thank you
i will leave it
Bot has started, with 23524 users, in 308 channels of 10 guilds. its showing only on console
or use a for loop which should be more performant 
not on stattus
you only show this on status: Serving ${client.guilds.cache.size} servers
^
let me think my bot is on this server and mine
hmm
can someone tell me how can i make bot to show servers?
to show servers?
like a serverlist?
2 sec
cuz im curious
i know my bot is on this server and my server
and other 8 i dont know
aww its command handler
let string = '';
client.guilds.cache.forEach(guild => {
string += guild.name + '\n';})
message.author.send(string)
message.channel.send('Server list sent in dm!');```
code looks like this
basic but works
im bad at it because i dont know how to run it
lol
jk
let usercount = 0;
client.guilds.cache.forEach(g => {usercount += g.memberCount})```
@tight plinth so would the bottom part go into the .setActivity
usercount replaces client.users.cache.size
how about this
are you aware of what that does
that will send a separate message for each guild
and each message will show one guild plus all previous guilds
lmao
oh nvm i was looking at the wrong brackets
@final creek
is getting the default everyone role using js message.guild.roles.everyone.id
a good idea?
yes
the default role has the same id as the guild
a
so you can simply use the guild id
ok i didnt know that
${member.nickname !== null ? `${member.nickname}` : "None"}
Why is it undefined
just put member.nickname ?
If no nickname?
you're checking if member.nickname is not EXACTLY null
|| "Non"
${member.nickname !== 0 ? `${member.nickname}` : "None"}
if you do member.nickname ? something : something else it will check for all falsey values instead of strictly checking for null
I mean, I have !== null ? for mine and it works fine 👀
but why null?
I am in v12.0.2
its the same as doing if(!member.nickname) {}
use an easier method when there's one
another way would be to do member.nickname || "None"
Anyway back to college work. Cya
the OR there makes it resolve to "None" if member.nickname is any falsey value
How would I be able to make a web hook that outputs discord’s status? Like, if there’s outages or lags on the website it states it sends to the web hook.
For discord.js.
Hello
I am very confused
when I type message.guild.id
It comes out with (node:4366) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of null
d.js = v11.6
How would I be able to make a web hook that outputs discord’s status? Like, if there’s outages or lags on the website it states it sends to the web hook.
@astral yoke
https://discord.js.org/#/docs/main/stable/class/WebhookClient
wrong thing
that
It comes out with (node:4366) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of null
@golden condor
what do you not understand about it? guild is null - which is an indicator that the message was in a dm
I told it not to do anything if it is a dm
luffy, recheck your syntax, it tells you where the mistake is
cxllm, you obviously didn't if it hit the error
if (message.channel.type == "dm") return message.channel.send(Sorry, you can't use commands here, please go to a server to use Corynth commands.);

