#development
1 messages ยท Page 926 of 1
@hardy vector in discord.js v12 avatarURL is a function
but say i have an embed
and I have two urls
that both show prettymuch the same json
oh
excpet with a few different values
how am I supposed to put it inside of the same embed?
const { algos } = await fetch('http://ric.pikapools.com/api/stats').then(response => response.json()); is what it does right now, but both of my jsons have the algos value
(node:5966) UnhandledPromiseRejectionWarning: TypeError: message.member.avatarURL is not a function
at Object.execute (/Users/sadashivappakenchannavar/Desktop/Frosty/commands/avatar.js:9:34)
at Client.<anonymous> (/Users/sadashivappakenchannavar/Desktop/Frosty/bot.js:57:31)
๐ฆ
dont destructure it
a = await fetch('http://ric.pikapools.com/api/stats1').then(response => response.json());
b = await fetch('http://ric.pikapools.com/api/stats2').then(response => response.json());
a.algos
b.algos
yes
doing { bla } = result is the same as doing bla = result.bla
@hardy vector member.user
avatar functions are on users, not on members
or use message.author
Question: What role permissions do you need to have to avoid a ban?
I know the admin permission avoids it
there is no role permission that guarantees you cant get banned
its not a permission, its the order of the roles
you can only get banned by a role that is above your highest role
So if role a has the administrator permission toggled on and role b is above role a, role b can ban role a?
administrator works for me
of both have admin, b should be able to ban a
ok cool, got my info now
if only a has admin, but b has ban members, im not sure tbh
but b should still be able to ban
I'll just make it so the bot can't ban admins or mods of a server
ban/warn/mute
Should mods be able to edit welcome/leave messages?
In what lib
d.js 11
So, the bot sends the message after you send the command and you want it deleted?
ty
wassup peoples! ^_^
so i put a website onto my contabo host. cant help but notice that its load time is a little slower now compared to when it was on heroku. wondering if maybe heroku has some kinda infrastructure to cache requests in the cloud for quicker loading or something, anyone any ideas?
I dont have any real latency issues with contabo?
my avg time is <5ms on the api and <100 on the page msot of the time
jesus
i can save 0.1second by testing the https route instead of http route which redirects
such performance enhancements ๐
its not even bad for me
clocking at 2.9 sconds load time
its a bit big tho, 2+mb
you could optimize your images
yea images are taking 4.5s apparently
google recommends me to change format to next-gen formats
Do you guys host your bots on Heroku or a VPS?
Just curious, I host my stuff on a VPS
GH student?
Oh, I see
unfortunately, im a grown ass man ๐
50 dollars credit renewable every year in gh student pack
oh nice
i think github used to do a student discount as well
idk since microsoft purchased it
So for a HS senior -> college freshman like myself, I get a free server for 10 months a year
Yeah, I guess the 50 dollar credit is the "discount" now
For sure dude
I was using vultr until my friend went on about gh student and the benefits it provides
theres an agar.io extension i use (delta) thats hosted on glitch!! ๐ฎ
was honestly surprised how well it performs
hosts custom game servers and such no issue
some twitch bots are hosted on glitch
tons disco bots too
yea all the nubs use it cuz its free lol
This pandemic made me make this bot in 3 weeks instead of 2 months
Yeah, I run a lot of stuff on my server other than bots
such as a full fledged VPN
lmao
I hate my ISP throttling me, so I decided to do something about it
i actually cut off heroku as a host provider the past few days, gonna be moving all my stuff to contabo i think
but they have no good system monitoring tools
so i need to add like 3-4 docker containers with things like cADVISOR and prometheus to diy it :/
idk much about it, I just host on there and that's about it
It's really easy actually
You can change the domain name, but the main index page is your github username
github username.github.io
ahh yea, i ca nt be dealing with that tbh
You can change it to something else
i need my url to be short and snappy ๐
Just need to pay for a domain
what mod admin thing
Have to differentiate commands between moderators and true admins
Just updated with that patch
admins have admin permission, mods dont
however, how would you qualify mods? if they have either of the manage_x permissions?
or only if they have ban/kick permission, and managing roles/emojis/channels is irrelevant?
let owo = qdb.fetch(`uwus_${message.guild.id}`)
if (message.content === "uwu" || message.content === "owo") {
owo.add(`uwus_${message.guild.id}`, 1)
}```
this is my code to track uwu and owo
but this is my code to see how mnay
```js
const Discord = require('discord.js')
const db = require('quick.db')
module.exports = {
name: 'uwu',
description: 'see how many uwus',
execute: async(client, message, args) => {
let owo = db.fetch(`uwus_${message.guild.id}`)
if (owo === null) owo = 0
message.channel.send(`There have been ${owo} uwus or owo in this server`)
},
};```
when i do uwu
and check
it says there have been 0 uwus or owo in this server and gives me this error
(node:6569) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'add' of null
at Client.<anonymous> (/Users/sadashivappakenchannavar/Desktop/Frosty/bot.js:162:7)
at Client.emit (events.js:323:22)
what database are you using? what is qdb?
is qdb.fetch() supposed to return a table?
i dont think so
you probably want to qdb.add() and not owo.add()
Put the text in embed description
i dont have a description
you're using py right? check the docs
@slender mountain I have an array of permissions for each command, one array for bot required permissions, and one for user permissions required to use the command. i find that works best for various 'admin' commands ๐
lol wrong person 
also how do i do author mention
such as
{member.mention}
but whats the author one
you get all mentions from message.mentions. not member?
language?
seems javascript from {}
what do you mean the author mention? cause as far as i know, thats not a thing.
what?
you look like a what
If you implement sharding at around 1k guilds, those 1k guilds won't be split into multiple shards will they? Those 1k guilds will be on 1 shard, correct?
no
i think you can define the number of shards
they get split evenly
@slender mountain I have an array of permissions for each command, one array for bot required permissions, and one for user permissions required to use the command. i find that works best for various 'admin' commands ๐
@neat ingot
May be a good idea
I'll put it in at v2.0
Ban user permission should be enough to consitute a mod for now
not all mod roles in servers get ban perm
how i can do {serverName} variable to my bot?;
m!setlwelcome Welcome to {serverName}!
String.Replace in CS
parse the text and replace it
you have to search and replace {serverName} in the string before sending it to discord
string.replace() in js
^
if u want a perm that mostly every staff role gets, manage messages is ur best option
ok thx
not all mod roles in servers get ban perm
@zenith terrace
So then what perks would constitute a mod
Perms
imo the permissions should be based on the command in question
if u want a perm that mostly every staff role gets, manage messages is ur best option
@fading laurel
like, kick/ban/manage guild are all different mod things
"mystring".replace('my', 'your');
Oh wait
"yourstring".replace('your', 'our');```
I'm dumb, I just figured it out
Instead of if x contains something from the list, I should check if the list contains x
@neat ingot the result is....
"replace all spaces".replace(' ', '_');```
no
"ABC".replace("A","Z") = "ZBC"
oh
^^
no
Mmm
you can chain replaces, or use a loop
although, strings are arrays iirc ๐
"ABC".replace("A","X").replace("B","Y") = "XYC"
In js, can you indent the replace statements to make them prettier?
ye python is weird
It's easy to learn tho
pi ugli
python dont have switch/case statements
"ABC".replace("A","X").replace("B","Y") = "XYC"
@quartz kindle ty
python dont have switch/case statements
What
small brain
What lang
discord.js
{}
there are multiple ways it can be done
I think
so just {} ?
an easy way it so check the message.content.length
That's how I did it back in the day
a better way is to check if the string contains valid characters using regexp
{} is the same thing as pass in python
well it works now
if (message.content == "something") return
includes?
oh
if (message.content.includes("something")) return
@quartz kindle wth is this Astrologico api actually for?
im guessing your main use case was the astrobot?
astrological and astronomical calculation
like lat lng for space?
ie: what is the position of an object at any given moment in time
yes
can be used for telescope tracking and such
but its main use case is astrology charts
oh nice! many folks use it? seems to have been up a few years now ๐
not really, i released it not long ago
the beta was made public on early january
no, 1999 is when my partner started working as a professional astrologer
ahhh ok, so just use that date cause why not? ๐
yeah because thats when it all started
partner = irl life partner? o0
business partner
lot to learn from an experienced lady ๐
anyhow, we're building a company centered around astrology, and techincally its since 1999 because thats when she started working with it and has been working ever since
just that the website and projects are starting to come now, because im doing them
Tim how old are you?
ahhh yea, i get that ๐
29
i think hes like 25
oh iw as close
tbh surprised you dont have more patreon backers
ยฏ_(ใ)_/ยฏ
my patreon is only about 1 month old anyway
my only backer is not even a bot user lmao
my bot users promised but didnt deliver
savages
i tried patreon a few years ago, but i never really posted there and it never went anywhere cause of it ๐
rip
Were you still making a lib?
my bot is finally on track
only got 170 lines tho
damn
thats it?
first bot i code bro
damn mines like 10k lines
man, i have single commands with more lines ๐
thats all the commands i have for now
horror
can i show you my bot?
sure
dms
when i try and run node index.js it runs the completely wrong bot
const Discord = require('discord.js');
const client = new Discord.Client();
client.once('ready', () => {
if (message.content === '!ping') {
// send back "Pong." to the channel the message was sent in
message.channel.send('Pong.');
}
});
client.login('seeewe');```
oy
alarms sound
^
๐
you should keep your tokens and important credentials ina config file, or .env file
Best would be to use a json file
module.exports = {
token: "aksjhdiuahsndas"
}
^ config file
const config = require('./config.js');
^in your code
how did u make it with that color text
with my mind
You could put it in json and require it too
put js next to your code blocks
Dont even need to parse it
yea, json is also valid option. i use js file so i can have functions that return config data
^example
Json is good for all languages, so I use it in C#
And then I interpret the json in a helper class
tries to show me his bot but its offline
f
fat L @earnest phoenix
offline bots pretty lit ngl
lmaoooo
Is there a NPM package or something that can recognize words through voices?
lmao
Maybe?
google has many api's for such things
๐ค
to determine things said, objects within pictures, etc
fancy
lol
RIPPP
f
Just posted my request today
it takes so long
speech recognition ๐ค
^
cause it takes too long
Mods are volunteers after all, so they have a day job I assume
Ohhhhh that makes more sense
mods refuse bots all day?
I've already got mine in 10 servers idk how
Website moderators
I found a speech recognition NPM module but I have no idea how to read the documentation.
awgh
not many bots have the same name as mine so
that's gonna be me when I learn rust and serenity
I find it, but I have no clue how to read the docs
is ur bot in py? @fading laurel
C#
gonna make another one in Rust
I got fed up with AIO bots with admin features
i find py easy
Same
i've been removing the admin commands from my bot
but I like C# more due to its wide variety of usage
they are pointless to have imo
Good.
literally every bot has the same generic commands, and a real mod bot could do everything much better than a generalized command
If you want administration, add an admin bot
yea exactly lol
Exactly, that's what I'm making. A real mod bot.
With all the good features from various AIO bots and without the fluff of a web dashboard etc
rekt from what?
nhl
mods dont check bots
@earnest phoenix no
Oh I'm actually stupid. I can just pass the permission through the function itself and check that way
therefore, it's a universal function
abstraction ๐ฏ
@summer torrent ?
sure hes saying mods do check bots
they dont
*admins don't check bots
they cant
const Discord = require('discord.js')
const client = new Discord.Client()
const fetch = require("node-fetch");
const stringify = (options, sep = "&", eq = "=") => {
return Object.keys(options)
.map(key => {
`${encodeURI(key)}${eq}${Array.isArray(options[key]) ? options[key].join(sep) : options[key]}`
}).join(sep)
}
module.exports = {
name: 'djs',
description: 'djs',
execute: async(client, message, args) => {
const versions = ["stable", "master", "rpc", "commando"];
const querystring = stringify({ src: versions.includes(args.slice(-1)[0]) ? args.pop() : "stable", q: args.join(" "), force: false });
const res = await fetch()
const json = await res.json(`https://djsdocs.sorta.moe/v2/embed?${querystring}`);
return json ? message.channel.send(json) : message.reply(`nothing was found for that.`);
},
};```(node:8302) UnhandledPromiseRejectionWarning: TypeError: Only absolute URLs are supported
at getNodeRequestOptions (/Users/sadashivappakenchannavar/Desktop/Frosty/node_modules/node-fetch/lib/index.js:1299:9)
at /Users/sadashivappakenchannavar/Desktop/Frosty/node_modules/node-fetch/lib/index.js:1404:19
website mods can check bots
please don't give false information @earnest phoenix
(your bot was declined by a mod)
What are you talking about? thats just oliy with his alt 
tbf hes also a web mod
im pointing out the fact that he says not to dm him, and dm the mod who declined it instead, but it was he himself who declined it :^)
Yo @quartz kindle
For my json
I want it to put in user input as the name of one of the objects
Like ricp.workers.(address) address is a variable from user input
workers[address]
without
And if Iโm pulling out another object under the addres
with
Workers[address].value?
yes
how do people do the welcome image?
like moo6
where it changes everytime
like the number and it displays your pfp and username
idk how 'moo' does it, but i use canvas.js to make images.
what
Lol
...
When Iโm using .message.content.slice I get the value in โโ how do I make it not do that
He means the mee6 profile picture on join lol
most generated graphics are done using canvas, although you can also do them with libraries such as jimp, sharp, or gm
i know what he means, i answered his question perfectly imo.
yes dekita's answer is accurate and valid
@quartz kindle is there a canvas for py?
He wants the function to get image url lol
no, he wants to create a unique image for the recently joined members.
^
In that case use canvas
for py there is tinker, idk what else

How do u make it so message.content doesnโt get thrown in with โ marks
(node:656) UnhandledPromiseRejectionWarning: TypeError: Cannot read property '
RSA3aZhFTKABYLGbQBcwcakQDrDtD125VB' of undefined
wdym
should be pools.workers[address]
why this dont work in messageDelete?
message.attachments.array()[0]
What doesn't work about it.
the bot say [object Object]
that means it works lol
an attachment is a class, check the docs to see what properties it has
hey guys, i'm curious to why my bot doesn't work properly. i'm coding my bot in python and it's mostly working.
@client.command(pass_contxt=True)
@has_permissions(manage_roles=True)
async def ps2register(ctx, member: discord.Member, *, cName):
rUser = ctx.message.author
message, serverID = ps2bot(rUser, member, cName)
print(message)
roleStranger = discord.utils.get(ctx.guild.roles, name="stranger")
roleps2USA = discord.utils.get(ctx.guild.roles, name="Planetside 2 Division NA")
roleps2EU = discord.utils.get(ctx.guild.roles, name="Planetside 2 Division EU")
role20r = discord.utils.get(ctx.guild.roles, name="20r")
roleRecruit = discord.utils.get(ctx.guild.roles, name="Recruit")
roleFriend = discord.utils.get(ctx.guild.roles, name="Friend")
roleUSA = discord.utils.get(ctx.guild.roles, name="NA")
roleEU = discord.utils.get(ctx.guild.roles, name="EU")
# roleps2 = discord.utils.get(ctx.guild.roles, name="Planetside 2 Division NA")
# roleps2d = discord.utils.get(ctx.guild.roles, name="Planetside 2 Division EU")
await ctx.send(message)
if serverID == "17":
print("Emerald server") # NA server
await member.add_roles(role20r, roleps2USA, roleRecruit, roleUSA)
await member.remove_roles(roleStranger, roleFriend)
if serverID == "13":
print("Cobalt server") # EU server
await member.add_roles(role20r, roleps2EU, roleRecruit, roleEU)
await member.remove_roles(roleStranger, roleFriend)```
add_roles seem to work but remove_roles do not work
please use sql
no, i'm not using sql
well what happens when you run it thats a problem?
and what is it meant to do "exactly"
@civic flower you talking to me?
well what it's supposed to do is grab the roles. from my script that detects what server they're on it assigns the role accordingly. the ps2bot function and assigning roles works fine
it's just removal of roles seems to be buggy. i have ensured it's using the correct names
i see so its a sort of "saved" role over servers that have your bot. well describe the bugginess.
it assigns the roles that i want it to but it doesn't remove the roles
if someone that knows anything about servers can explain to me - is public outbound bandwidth for 7.95 mbps a lot?
Yo is anyone having issues inviting bots right now?
I cannot invite anything
https://i.txj69.com/lISeiIMhb9.mp4
I've checked 3 browsers now too
if it doesn't work with other bots discord did a bad again
@pallid vector no, thats a bit under 1mb/s , its equivalent of most people's home internet
oh okay, I see, thank you
hmm
I was pinged by a discord dev mentioning discord bot inviting is down right now
I think its them
is there any way to increase speeds? @earnest phoenix like what would be the equivalent of increasing speeds for VPSes? (what factor am I looking for)
i dont know which provider you're using
most providers will have increasing bandwidth speeds with every increasing tier
okay so DO doesn't do that
DO has limits on how much bandwidth you can spend in each droplet tier
but the network going into the node is 1Gbps so you can expect a speed cap of 1Gbps and the normal speed of somewhere around 300Mbps
may be instead of remove role, to add role and then have the added role be stranger
@rotund prism
Can anyone help/link me to somewhere where I can make upvoter only commands
Just keep record of who/when voted, and check that when vote locked commands are used.
const Discord = require('discord.js')
const client = new Discord.Client()
const fetch = require("node-fetch");
const stringify = (options, sep = "&", eq = "=") => {
return Object.keys(options)
.map(key => {
`${encodeURI(key)}${eq}${Array.isArray(options[key]) ? options[key].join(sep) : options[key]}`
}).join(sep)
}
module.exports = {
name: 'djs',
description: 'djs',
execute: async(client, message, args) => {
const versions = ["stable", "master", "rpc", "commando"];
const querystring = stringify({ src: versions.includes(args.slice(-1)[0]) ? args.pop() : "stable", q: args.join(" "), force: false });
const res = await fetch()
const json = await res.json(`https://djsdocs.sorta.moe/v2/embed?${querystring}`);
console.log(json)
return json ? message.channel.send(json) : message.reply(`nothing was found for that.`);
},
};```(node:9597) UnhandledPromiseRejectionWarning: TypeError: Only absolute URLs are supported
why
fetch what?
djs docs
but what the hell are you fetching?
djs docs
wdym
Tim can you remember my proposed server setup, where theres multiple vps, some for bots (my statistics bot), some for the database (mysql), and one manager with info which guild data lies on which db server.
The bots cache this info and send the queries for the guilds to the respective database.
I was asking about the amount of connections that each db server would have, if every shard connected to each database. So lets say theres 1000 shards, then there would be 1000 connections per db server. You said and also my research found that that would be handable for a database server with moderate ram.
But better even would be to reduce the number of connections. This can be done, like you said a while ago, with opening/closing connections per transaction + proper query grouping. But i wonder how strongly does this strain on what resources?
I was wondering, would it make sense to instead do the following (assuming a vps with 100 shards):
- Use ipc to send all queries to the sharding manager/a separate process, who has a connection to all dbs (possibly multiple connections per db pooled) and return to the shard the values received via ipc again.
- You said something about internal sharding.. would this also reduce the connections drastically (as all shards in the same process would use the same db module with the connections)? How many shards per process can this handle?
kk
Any docs on how to get the user badges or status message ?
not possible about the custom status
for badges, I think you can't them too, but I'm not sure
I saw a bot that was showing status + badges
why don't you search the docs?
nothing on the discord.py docs
but on the discord api docs
you can get the status but i dont really understand their docs
I think it's just a get/post request?
i really dont know, im new in the discord developing universe
mhm
user badges is now public on API
๐
my question can sound like a bit stupid but how can i / how to use the discord api?
because i have discord.py
discord.py is python library for using discord api
^
so i can use discord api?
What does this mean?
(node:11189) UnhandledPromisRejectionWarning: RangeError: Invalid bitfield flag or number.
can you send me the link please?
@clear wraith show code
K
discord.py docs -_-
const Discord = require("discord.js");
const fs = require("fs");
module.exports.run = async (bot, message, args) => {
if(!message.member.hasPermission("MANAGE_SERVER")) return message.reply("You do not have perms to change the prefix for Me.");
if(!args[0] || args[0 == "help"]) return message.reply("Usage: !prefix <new prefix>");
let prefixes = JSON.parse(fs.readFileSync("./prefixes.json", "utf8"));
prefixes[message.guild.id] = {
prefixes: args[0]
};
fs.writeFile("./prefixes.json", JSON.stringify(prefixes), (err) => {
if (err) console.log(err)
});
let sEmbed = new Discord.RichEmbed()
.setColor("#FF9900")
.setTitle("Prefix Set!")
.setDescription(`The prefix has been set to ${args[0]}`);
message.channel.send(sEmbed);
}
module.exports.help = {
name: "prefix"
}```
https://discordpy.readthedocs.io/en/latest/api.html?highlight=activity#profile and these are the badges
it doesnt look like this for me ๐
What does this mean?
It means you passed a bitfield flag or number that was not valid.
MANAGE_SERVER is not a thing.
that's your flag.
no
@clear wraith that is MANAGE_GUILD
@graceful dock then you're on the wrong docs
What you need to do is check the available flags: https://discord.js.org/#/docs/main/stable/class/Permissions?scrollTo=s-FLAGS
Also using JSON as a database may lead to issues.
thank you tho
np
Hey
i need a bit of help
(node:13644) UnhandledPromiseRejectionWarning: TypeError: client.guilds.array is not a function
at ElusiveBotSettingsProvider.init (C:\Users\Jassm\Desktop\Elusive\utils\SettingsProvider.js:49:43)
at processTicksAndRejections (internal/process/task_queues.js:97:5)```
for (const guild in client.guilds.array()) {
try {
const result = await guildSettingsCollection.findOne({ guildId: client.guilds.array()[guild].id });
let settings;``` thats the code
what is your djs version
maybe toArray() ?
latest
client.guilds.cache.array()
How to make a bot can nofication when someone upload a video on youtube?
oh thx
How is this not defined?
@worn plaza check pubsubhubbub docs
https://developers.google.com/youtube/v3/guides/push_notifications
btw heres the error
Ill grab the code
let sChannel = channel.guild.channels.find(`name`, "logs");
sChannel.send(`The channel **${channel}** has been created.`);
});
the method you're using is deprecated
thanks
huh
pass a function instead to find
ok
that is example
same channel name lul
@summer torrent same thing with client.users.array()?
yes
k cool
i dont think we can get the user badges on dfiscord.py
howdy
if im making a owner only premium command where i can give a user premium in there server how would i do that with quick.db
you add a bool to the database
that shows wether or not the user is a premium user
that's literally basic
how @pale vessel ? do you have a link?
yes with the flags
yes
do you have any tutorial on how to use ? i sound stoopid lol but im new so
oke ty
hi, Error: val is not a non-empty string or a valid number. val=undefined i am getting this error, at ```js
let hi = ms(momentMilliseconds);
@pale vessel so it is like just doing a request with python?
i have ```js
if (hi === undefined || isNaN(hi) || hi === '') hi = 'Permanent';
what is the headers?
the error, both times, r happening let hi = ms(momentMilliseconds);
Integrate your service with Discord โ whether it's a bot or a game or whatever your wildest imagination can come up with.
this?
@digital ibex permanent is not a valid number
yes
go to reference and you'll see what you have to add
thank you
wait, then how can i say hi is permanent?
yo i have one more question
dont ask to ask, just ask
eventFunction.run(...args));```
that gives me a error
saying run is not a function
whats eventFunction?
const eventFunction = require(`./events/${file}`); if (eventFunction.disabled) return; const event = eventFunction.event || file.split('.')[0]; const emitter = (typeof eventFunction.emitter === 'string' ? client[eventFunction.emitter] : eventFunction.emitter) || client; const { once } = eventFunction; try { emitter[once ? 'once' : 'on'](event, (...args) => eventFunction.run(...args)); } thats the entire thing
p sure u won't use run to exec the file, u'd use once or on right?
so I use ytsearch and when I try to select a song from search, It doesn't get registers and tells me it timed out, code:
try {
response = await message.channel.awaitMessages(msg => 0 < msg.content && msg.content < videos.length + 1 && msg.author.id == message.author.id, {
maxMatches: 1,
time: 10000,
errors: ['time']
});```
waiit no
k lemme ry
emit is not a func
module.exports = {
how do I make "db!help" and "db! help' work
just the structure of it
its prolly mroe then 500 charc
module.exports = {
run: async (msg) => {
if (msg.author.bot) return;
if (msg.channel.type !== 'text') return;
if (!client.provider.isReady) return;
TypeError: eventFunction.emit is not a function
at CommandoClient.<anonymous> (C:\Users\Jassm\Desktop\Elusive\elusivebot.js:40:73)
at CommandoClient.emit (events.js:322:22)
at MessageCreateAction.handle (C:\Users\Jassm\Desktop\Elusive\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\Jassm\Desktop\Elusive\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\Jassm\Desktop\Elusive\node_modules\discord.js\src\client\websocket\WebSocketManager.js:386:31)
at WebSocketShard.onPacket (C:\Users\Jassm\Desktop\Elusive\node_modules\discord.js\src\client\websocket\WebSocketShard.js:436:22)
at WebSocketShard.onMessage (C:\Users\Jassm\Desktop\Elusive\node_modules\discord.js\src\client\websocket\WebSocketShard.js:293:10)
at WebSocket.onMessage (C:\Users\Jassm\Desktop\Elusive\node_modules\ws\lib\event-target.js:125:16)
at WebSocket.emit (events.js:310:20)
at Receiver.receiverOnMessage (C:\Users\Jassm\Desktop\Elusive\node_modules\ws\lib\websocket.js:800:20)
[nodemon] app crashed - waiting for file changes before starting...
i forgot to tell i have commando too
...
@fiery stream did you actually try to copy code without knowing that it's just pseudo code and hope it works?
i type node index and
I'm getting out of here
module.exports = async (params) => {
// whatever
}
``` wouldn't that be the structure of it tho?
internal/modules/cjs/loader.js:1213
throw err;
^
SyntaxError: D:\discord bot\config.json: Unexpected token t in JSON at position 5
at parse (<anonymous>)
[90m at Object.Module._extensions..json (internal/modules/cjs/loader.js:1210:22)[39m
[90m at Module.load (internal/modules/cjs/loader.js:1040:32)[39m
[90m at Function.Module._load (internal/modules/cjs/loader.js:929:14)[39m
[90m at Module.require (internal/modules/cjs/loader.js:1080:19)[39m
[90m at require (internal/modules/cjs/helpers.js:72:18)[39m
at Object.<anonymous> (D:\discord bot\index.js:1:55)
[90m at Module._compile (internal/modules/cjs/loader.js:1176:30)[39m
[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1196:10)[39m
[90m at Module.load (internal/modules/cjs/loader.js:1040:32)[39m
or am i ๐ฟ
what's inside the config.json file@worn plaza
wait
before you show
remove your token
so it doesn't get leaked
{
token:
}
that's the problem
it should be "token":
in json files every key must be a string
just assigning the name doesn't work, that only works in js
wdym zSnails?
valid json
Error: val is not a non-empty string or a valid number. val=undefined i am getting this error, at ```js
let hi = ms(momentMilliseconds);
wait are u talking about my error?
no
i have ```js
if (hi === undefined || isNaN(hi) || hi === '') hi = 'Permanent';
your error is that you literally copied and pasted code without knowing that it means jazz
uh not really im trying to rewrite
like, permanent isn't a number but what can i do to not make it error?
just do if (!hi)
'' = false 0 is false and undefined vara are also false
falsy and truthy shit in js
oh
(node:13776) UnhandledPromiseRejectionWarning: Error [TOKEN_INVALID]: An invalid token was provided.
at WebSocketManager.connect (D:\discord bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:135:26)
at Client.login (D:\discord bot\node_modules\discord.js\src\client\Client.js:221:21)
(Use node --trace-warnings ... to show where the warning was created)
(node:13776) 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:13776) [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.
what error?
token isnt correct
._.
wait, i'm confused @copper cradle
@Bรนi Xuรขn Huแบฅn#0222 did you add the token again?
I'm trying to use YTsearch to get results and add them to the queue but when I use the following code: let response; try { response = await message.channel.awaitMessages(msg => 0 < msg.content && msg.content < videos.length + 1 && msg.author.id == message.author.id, { maxMatches: 1, time: 10000, errors: ['time'] });
I get the following results
Trying to select #1
msg => 0 < msg.content && msg.content < videos.length + 1 && msg.author.id == message.author.id
whats this?
video = await ytdl.getBasicInfo(videos[videoIndex - 1].videoId)``` here's where the response variable is used
why are you checking msg content is lower than 0?
comparing strings to numbers?
then comparing message content with another number: videos.length
how much of this do I not need?
await message.channel.awaitMessages(reply => {
const valid_auth = reply.author === message.author;
const valid_reply = parseInt(reply.content) < videos.length+1;
return valid_auth && valid_reply;
});
``` seems like it should do what your trying
didn't work unfortunately
I really wanna have ytsearch but might have to remove it
library doesn't matter
you can't ping everyone
They are called webwooks
NOTE ABOUT STEP 5: Click "check now" to update the webhook immediately. If nothing happens, you've done something wrong
This is a quick, step-by-step tutorial on how to set up a YouTube to Discord webhook using the new version of IFTTT.
If you upload YouTube videos on a di...
@worn plaza
I think slice isn't defined for this
client.on("message", async message => {
if(message.author.bot || message.channel.type === "dm")return
let messageArray = messgae.content.split(" ")
let cmd = messageArray[0]
let args = messageArray.slice(1)
let commandFiles = client.commands.get(cmd.slice(length)) || client.commands.get(client.aliases.get(cmd.slice(length)))
if(commandFiles) commandFiles.run(client, message, args)
})
oh, oof
anyone here use prometheus+cadvisor+grafana per chance?
cause its not valid at all. you seem to be missing a few lines at the start
alright
but then your not calling any function within the client.on message event
bruh, now it says massage is undefined.
xd. . .
cant be checking if (message) when message isnt a thing yet
it should look something more like this:
client.on('message', function(message) {
if (message.content.startsWith("$kick")){
}
})```
but then, your still not defining client at all
as i said, you seem to be missing some code ffrom the start of your file.
also: you dont need to redefine the client.on('message') event
just handle that event one time, and do whatever you need to do or check in that one function
ok thanks
for example:
client.on('message', function(message) {
if (message.content.startsWith("$kick")){
// do a thing
}
if (message.content.startsWith("$ban")){
// do other thing
}
})```
ok so i put above each?
put what above each what?
is this good?
no, because your still checking if the message content starts with kick, when you have no access to the message, because you defined your if statement outside of your message event handler client.on('message')
i am getting frustrated
np ๐
btw u dont need to use function(args) {} on node.js => 10, you can use (args) => {}, this came w ecma 6 i think.
ok
This should be put in r/mildlyinfuriating
Why should developing a bot be that easy....
People litterally get verified bot developer from using this application
Ngl has pissed me off
ok
module.exports={
name: "ban",
description: "Ban a specified user from the server",
category:"moderation",
usage: "<user id> <reason> ```
will this work?
if i add above the ban
How to, in channelUpdate event, check if the oldChannel is not nsfw and newChannel is nsfw?
oh ok thx
if I want to switch to shoukaku, is "using https://github.com/Deivu/Kongou but modified to put my bot's comands in" a good idea?
coz I want to
yes
my brain is too small to do it
here is a shitty code I make, warning it burns eyes
SAMA
what
hastebin
i used the vanilla shoukaku and it works flawlessly and it was hosted on heroku
i'm sure you can do it too
im sure i'll explode
although i couldn't keep it 24/7 cause heroku web
*my brain will
hmm
ik I can use example from https://github.com/Deivu/Shoukaku, but idk then how to make other commands like skip & stop coz am stoopid
just trigger player#stopPlaying (or whatever it's called) and handle player on stop
worst command to make for me should be queue
like with a serverQueue and all the shit?
oh
it doesn't change anything lol
I'll try
why does this happen when i run my bot now?
I'll inform you if I succeed/fail
@indigo cloud make sure file exists
it does
@indigo cloud its just node index.js
and its just node index.js
true
^
when i run node index.js it dosent show anything
because your code is shit
ok then i will make another code to run the bot
@restive furnace yea i know you can do () to create a function; however, that function would have a 'lexical this scope' which isnt always ideal, i was just declaring the function to make it more obvious that it was a function ๐
does anyone use intellij idea
what is the command to show the total member count of all the servers that the bot is in
thats probably because you
wait no?
that is counting the guild size of the bot
not the user count?
the only way you can do to get non-cached users is fetch every guild's member list
which is gonna be pretty intense on the api
how does dbl handle that iin the dblapi?
do they just accept the cached guilds for guild counter i mean?
console.log(" - " + guild.name );
console.log();```
this only shows the log of it but it should be something similar to this right?
yeah ig
@modest maple was it you who has the contabo host and kept going on about the 'steal is high'?
i kinda fixed it
so it was you yea? ๐
yeah
Seems to only go into the high numbers when its under high load on a single core
this is just observing the charts on netdata
netdata? is that some kinda system monitoring thing?
yh
splitting the load into (litterally double the processes) basically reduced the steal to like 5% at most
lmao
nice
i've been looking into various monitoring tools, but cause i run all my things within docker containers it seems a little tricker to get the actual system resources
how?
docker creates an environment with limited resources
so if you check your cpu within a container
you get the restricted into
oh so netdata handles docker ok?
interesting. i've been researching for days now, and all i keep seeing is people talking about cadvisor and grafana
tbf, this setup allows me to customize graphcs for any data thing
but production gets 100% of the system
but i just want something to monitor load and cpu etc
this is spotify's charts atm
not the prettiest graphs in the world, but certainly gets the job done ๐
i do like the little 3 quarter pie charts at the top
idrc about looks just about system loads
yea tbh i dont care too much, but i'd like a reasonable interface to deal with if possible ๐
id defo say give net data a try tbf
added it to my trello todo ๐
ill have to check it out before invevsting more work into this other crap
cause tbqh, its insane
atm it uses 7 container
7
fucking 7!
I have 7 going atm lol
to monitor 1 bot, 1 db, and 1 site? overkill!
my db, and api is in a single service
as it keeps the db local host and secure
only port in and out is via the api through an express server now
yea its always good to keep things secure
so you just query the api internally ?
or is it still accessable from outsite?
the api handles all db interactions
and then the bots interact with the api from the ouside with docker's internal networking
yea i like docker for that ๐
very easy to give specific network access to the apps that actually need it
only thing i dis-like is the fact that unless u jump through alot of hoops docker dameon runs as root
so when you do top
every container process comes up as root
but i dont care too much considering most of the time ill use netdata
so how many containers does your setup use just for system monitoring?
what just to monitor everything?
yea
dude this netdata example page just keeps scrolling forever with more and more graphs ๐
PS C:\Users\xAutentiqz\Desktop\Discord Bot> node .
C:\Users\xAutentiqz\Desktop\Discord Bot\index.js:57
----- Command JS File -----
^^^^^^^^^
SyntaxError: Invalid left-hand side expression in prefix operation
at wrapSafe (internal/modules/cjs/loader.js:1047:16)
at Module._compile (internal/modules/cjs/loader.js:1097:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
how to fix this?
Don't provide an invalid left-hand side expression in the prefix operation
can i send u a pic and u tell me what to do
Hastebin/etc. the code snippet and send the link here
index.js:57
Line 57 in index.js
Node internals
ok
ive never seen that before lmao
so


