#development
1 messages ยท Page 669 of 1
@abstract crow for future reference tho, you can check the version of an npm package by doing npm list <package>
@winged thorn box-shadow: none !important
in .columns .bot-img { ... }
to get rid of the white border
So I have a public github project going up soon. Should I just link the documentation in a readme or put in in both the website and the read me? It will include the setup and all of the commands so idk
Hi! I run a discord.js bot and was wondering if anyone knows how to set up a system where when a member joins a server, it checks for them in a JSON file, and if it finds them, kick them from the server and send a message to a channel called logs. Thanks in advance.
Use a database instead of a JSON file.
Boom, the whole problem became so much easier.
Okay
database will make the process much easier if youโre scaling up
i've got a free sql database with my vps hoster
if you want to go the JSON route you could just list user IDs line by line and parse that on startup
ah super cool
well, 25
which library?
javascript
cool
split on new line chars and record in a set-like structure probably
uh
Donโt use JSON for it
and i have no idea what a server join event is. never used it.
ah
probably check the docs for it then
the djs api should generate events somewhere and youโll attach functions to those
@stable hatch i can help, but you don't need to ping the whole moderation team
ok sorry
]]supportserver
This server is NOT the support server for ANY bot. You need to click on the "Support Server" button on the bot's page, NOT the "Join Discord" button at the top of DBL.
ok thanks
oh, i thought you meant yours
Lol
Have a good day 
yeah, you'll need to go to theirs lol
ya thanks
Mute
We don't mute if they genuinely have a question and don't seem to have meant to hurt anyone, and/or trolling
Please do not mention (ping) more than one or two moderators for help, unless there is an emergency.
Here are some examples of emergencies:
- Raids / Multiple members mass spamming.
- Severe disruption of Discord's ToS (NSFW content, etc)
- Anything that requires more than 2 moderators to handle.
Mentioning an entire moderator role without a justifiable reason is a punishable offence.
@wooden lance https://discord.js.org/#/docs/main/stable/class/Client?scrollTo=e-guildMemberAdd this looks like the right event. unfortunately the documentation has a bit of a threshold, and it could probably be organized better, but this is the event you are looking for
https://nodejs.org/dist/latest/docs/api/events.html#events_class_eventemitter the client extends* the event emitter which allows it to broadcast events (at the top of that page). just replace the event name with what you need
thank you so much! this is starting to make sense! ๐
Imagine tagging 15 people
oof
I've got a question. I'm new to Javascript and am wanting to understand how to use the new method of finding a specific role (Don't know how new it is, just that I'm using a deprecated method).
Currently in my script I have
var role = member.guild.roles.find('name', 'Member');
I have seen examples that don't really give specifics or explain how the new method works, and as such, I don't know how to use it. Any answers would be appreciated
I think it's more in regards to any .find thing
thats the new method or the old one?
use a function
(role) => role.name === 'Member' is the basic replacement for 'name', 'Member'
Will be deprecated soon anyways
oh what's the alternative
the function won't be deprecated but the 'name', 'Member' will be on d.js v12
Oh okay, thanks @sick cloud, helpful. I can understand how that works. Every other example I saw (that I can't remember off the top of my head) had no clarity or explanation to it, but I can read your example perfectly fine, so thank you ๐
yep it's fine
Wonderful! It works, and I no longer am receiving deprecation warnings. Much appreciated! โค

Hello everyone!
I have been trying to submit my bot here for a month now, and every time it was being reviewed a Missing Access error turned up and I don't know why. When someone called my help command on the Testing server the command returned with the mentioned error.
Anyone knows why?
also how do you people store stats for a user or anything of that sort without it being written into the class? as of now, im trying to go kinda with a minecraft approach, where stats are stored externally from the user, and it stores a list of stat names with an int value. all i know is that i've been overthinking this for awhile, and i need to see from a different perspective lmao
Oof python can't help ya there bud @ionic kiln
What do you mean by that?
oh i see ๐
Sorry
You're making global checks for perms. Make the checks per command
Because it makes no sense for a help command to need elevated permissions
Also you should consider that your bot can be invited without permissions to any server. Put that in mind
When that happens make sure you output a message asking the user to grant the bot the required permission, and it has to make sense and be in the context of the command
Oh ok. Thanks for helping ๐
No problem
Hello i have a question.
I use discordjs.
Lets say i get a message event and with it the msg object.
In that object i can access the guild members by msg.guild.members.
Will it contain truely all users of that guild, or might not all be cached?
Execute me, here ask for any advice.
I would like to implement bot to read image from some hosting which free and friendly for non-dev users
The image will host for a period of time (weekly)
And bot will fetch that image to show when it got command
Any suggestion for the service that approach what I said? any suggestion will be appreciate
Define KUser...
Idk, what is KUser supposed to be
Wait i see
You have KUser but you use kUser everywhere
Note the capital k at the first
.-.
Change it everywhere
Or u can simply change let KUser to kUser
Is it spamming if I send a message through my bot to 21 servers?
if its "out of nowhere" yes
Put the message as a footer in some of your embeds or something
Or any commonly used commands

w
u need help? @sweet niche
Does anyone know an npm package I could use to get info from discord servers like channel IDs that i can use on a website or could I use d.js
you'd have to fetch that data on the backend
since it needs a bot token
and sending that to everyone who opens your site is an easy way to get banned
It's for a report function
But I see what you're getting at
Any other way I could get a guild ID without getting banned?
if you arent in it, no
I'm in the server
You don't have access to channels or guilds your application isn't it
OAuth2 has guilds scope
Yea
That's why I was gonna add a login button
But idk how to use the OAuth shit
I've tried
Never succeeded
You can check what guilds someone is in, but you cannot gain specific information about channels and users within the guilds.
Then it would be possible
And connect the bot with the website
That's possible
Hey
Whereโs the support channel ?
You're in it
Uhm idk
I don't use DBL server listing
Only bot listing
And I don't think this is the right channel for that topic
I thought you were talking about coding wise
how to get usertag of serverowner
im using d.js
guild.owner.id iirc
did they change the stutus shit in discord.py?
because i cant get the watching status
it was type=3 for watching before? what happend?
Docs?
@stray garnet Guild#owner should be a GuildMember
so you could do something like guild.owner.user.tag
or, if it isn't
client.users.fetch(guild.ownerID).then(r => r.tag)
make a website where users can set those options
Any API?
and when they do it, update ur database
you make the api
^
Lol
why lol? im trying to help ya here 
Ik
I was laughing on me
When someone summit any info the info should be send to my Gmail
And I have to edit
??
to send email, it's probably easiest to use postfix or postal
or a hosted service like sendgrid
Can I save info in db
lol i think he wants to make a contact form with the custom prefix and custom commands stuff
Then my bot can read it
and then he will manually change the DB
alternative use sentry and throw an error so you get an alert report
^
@opaque eagle lmaoof
no but honestly
google mongodb guide or some shit
would be very cool if you used Google before asking here yk
lol
@tight heath Is it worth to pay for Sentry?
@abstract crow are you a student?
Wdym by student
You get it for free with github premium
Either
HS
Yeah,youcan sign up for free github pro
Ooo
And get free sentry
Yes GItHub Student Pack is good
Does my school need to approve it
Well yeah
like a report card or student id card
what about school email
Not yet
ok
So I am going next week
Does this last only until I am in HS?
And if so, after HS ends, does my stuff save to go back and pay for it later
Does anyone know how to reload a js file ?
In College
@eager wasp delete the cache of that file
Damn you get a lot
You can also do stuff for your school. 
ok
https://vinniehat.is-inside.me/HcLCydvd.png If I would have known I wouldn't be paying for Vultr
DO and Azure
A free .me domain 
lol
how to mention an role? im using currently ${roles.name}
Paris #BringLucaBackToday at 5:47 PM
how to mention an role? im using currently ${roles.name}
you can either use the appropriately named property on the Role object or construct it yourself;<@&id>
even the free 10k plan is a lot
Helo, I'm having a bit of a problem here with .forEach
lets say user has mentioned members and i wanna list each in embed
problem is: using .forEach will send message for each mentioned member and i want to somehow add them to variable
and send single embed with members in a variable rather than multiple embeds
(discordjs)
You could use something like <Array>.map() to map each user to an array
Create a variable and append to it the member's tags in the forEach loop then send it after
map/join seems to be what you want
o shid, it was way too simple
eg [1, 2, 3].map(x => x + " is even: " + (x % 2 == 0)).join("\n")
x & 1
much more efficient ๐
@inner jewel [11425, 12532, 119783].map(x => x + " is even: " + Boolean(x & 1) ).join("\n")
as if that matters
you save a few clock cycles you'll instantly lose with the main memory accesses it needs to do
๐
I guess it's only a viable solution for huge numbers where division would actually create processing
I just like the "1 condition" aspect of it
division isn't slower for larger numbers
it's a constant time
unless you're using BigInt
It's actually been awhile since I looked at a division math library
We made one for practice back in the day as a subtraction loop
which a series of conditionals
0|clap | at Function.keys (<anonymous>)```
I keep getting that error
But I thought you could convert null values to a new value or smth
undefined and null are different types
I don't know the exact correct description
but its basically "lack of a definition" vs "lack of a calculatable value"
The thing I'm checking is null
I don't know how to do that
It's for a database
I'm checking if res is null and if so then it would create a DB entry for that guild
so your checking to add a new entry to DB?
Ye
if !( db.find(res) )
Do you even know what db I'm using
pseudocode
but the lack of a found entry in db/array
creates a boolean
rather than iterating your db checking for a null value
I read that wrong
const doc = model.findOne({snowflake: message.author.id});
if(!doc) { ... } // no "snowflake" was found in database matching the message author
normally if you query your db for an entry and it doesnt find anything it gives you null
that's mongoose syntax
yeah like that
checking for null just tends to lead down a weird path
using a potential null variable to check a boolean is preferable
I just use mongoose because the syntax was alittle quicker to pick up on
Also the schema validation has been useful in my project
Is anyone here a god or just good with SQL / storing data? I need someone's opinion on implementation of storing ping logs
if (cmd.startsWith('$buy-dlc')) {
if (!fs.existsSync('data//' + message.author.id + '.txt')) {
oldpoints = 0
} else {
oldpointsstring = fs.readFileSync('data//' + message.author.id + '.txt').toString().split('\n');
oldpoints = parseFloat(oldpointsstring, 10)
}
if (oldpoints < 150) {
pointsneeded = 150 - oldpoints
message.channel.send('You cannot buy this item. You need **' + pointsneeded + "** more points to buy this item.")
return
}
stockmaxstring = fs.readFileSync('keydata//dlcmax.txt').toString().split('\n');
stockmax = parseFloat(stockmaxstring, 10)
stockcurrentstring = fs.readFileSync('keydata//dlccurrent.txt').toString().split('\n');
stockcurrent = parseFloat(stockcurrentstring, 10)
if (stockmax == stockcurrent) {
message.channel.send('There is no more DLC keys in stock.')
return
}
stockcurrent = stockcurrent + 1
reward = fs.readFileSync('dlckeys//' + stockcurrent + '.txt').toString().split('\n');
try {
const embed = new Discord.RichEmbed()
.setAuthor('DLC Steam Key')
.setColor(0xFF0000)
.setDescription('Key: `' + reward + '`')
message.author.send({embed});
} catch(temp) {
message.channel.send(message.author + ", it seems like your DMs are disabled or you blocked me. Please enable them to claim prizes.")
return
}
message.channel.send(message.author + " check your DMs! :mailbox_with_mail:")
fs.writeFile('keydata//dlccurrent.txt', stockcurrent, function(err) {
if (err) throw err;
});
newpoints = oldpoints - 150
fs.writeFile('data//' + message.author.id + '.txt', newpoints, function(err) {
if (err) throw err;
});
return
}
I'm trying to make a little steam claimer bot
but after the command ends, the points become NaN
Why dont you add a bunch of logging in there, logging the points at key intervals
yah im trying that rn
oldpointsstring:
oldpoints: NaN
stockmaxstring: 7
stockmax: 7
stockcurrentstring: 6
stockcurrent: 7
newpoints: NaN
file not read?
sometimes works sometimes not
oldpoints: 151
stockmaxstring: 7
stockmax: 7
stockcurrentstring: 6
stockcurrent: 7
newpoints: 1
oldpointsstring:
oldpoints: NaN
stockmaxstring: 7
stockmax: 7
stockcurrentstring: 6
stockcurrent: 7
newpoints: NaN
it loads when they have less than 150 points
for some reason
Seems like 2 file actions were kinda running at the same time. I fixed the bug
bruh, how do i .push json file ;
w h a t
what
oof
read it, parse it, push it, parse it, write it. Incase what you're doing doesnt work
generate an ssh key and add it to your github account
Already done and connected and everything
But my bot fails at updating
I can't even clone things
My bot has an auto update feature
are you using the ssh links instead of https
No
Got it installed
Not because I need it, but because I'm interested on how it would work:
Let's say you have a really big bot and have to cluster it over multiple servers.
How would you do that?
A master that locks the shards (the other servers) to specific guilds/shards over a websocket?
@hushed berry hey nik you might be able to answer here ^
Feel free to ping be if you answer, I will have to sleep
@onyx summit youre pretty much on the right path
some manually assign ranges for each server
ie, server 1 logs into shards 0 - 4 and server 2 logs into shards 5 - 9
but a dynamic solution is definitely possible
the main issue is that its really easy for a shard to get lost
a few bots have had issues where shards get logged into twice, which also probably means a different shard has been logged into 0 times
groovy actually had that issue for quite awhile
On nodejs, what's the most efficient and quick way of looping through an array of around 400 elements and running some code for each on an interval?
You could use the setInterval method for doing an action every X miliseconds and iterate through the array with a for of loop or forEach loop.
"most efficient" can go a lot of ways
thats a lot of intervals
a nicer way would be to have a master setInterval that loops through the array then runs the code for each using a for loop
^
I am using for each but bench marks proved to be to be one of the slowest
for 400 elements it doesn't matter
unless you're in a hot loop
aka thousands of times per second
and to specify node.js is an env, not a lang
I'm using glitch... I've had this happen before, but I don't know/remember how to fix it.
1st and only step: don't use glitch
buy a vps
or just delete the package.json and try installing all the node modules with npm i
ยฏ_(ใ)_/ยฏ
glitch doesn't support npm
you need to use it's own special installer
Hmm
Or copy paste node_modules into glitch?
But most of my other bots work and I do the same thing
idk never used glitch
:/
No
@floral bloom tbh try heroku
Heroku's console is better and uptime is better
ยฏ_(ใ)_/ยฏ
Yes heroku is free
Hmm
That's more than enough compared to glitch's 12 hour hard uptime
and besides you're having problems with glitch
or how about vps like Tonybo suggested from the beginning. I don't know what else to suggest. Sorry.
Delete the line "discord.js":"version" from package.json
then re-add it with the "glitch package installer"
It's highly recommended to get a vps though. Glitch is shit.
I can't buy a VPS though
Uhm, excuse me?! Where is discord.js?!
๐คฆ
Why does it need a capital D?
Oooook
I found the problem
It wasn't able to install the Discord.js package because the version I had for canvas wasn't a proper version
Welp, thanks for the help all
Wait, canvas is a seperate npm package how does it have any relation with discord.js ? And no it doesn't require a capital D
You just had to write discord.js, remove s and add it again in order to reload the search
@earnest phoenix It seems like it caught the error of the incorrect version of canvas before it loaded Discord.js.
_ _
Anybody know what would cause this?
- UnhandledPromiseRejectionWarning: DiscordAPIError: 401: Unauthorized
Ping with response please!
I'm trying to teach my bot how to have a conversation with people, but at the moment the bot simply finds the first trigger word and then posts that response ordered in the JSON file. How do I get the bot to look at the entire context of a message and make a somewhat intelligent response and not just respond to the first matching word typed on the list?
got it ty
Np
const mReason = args[1] || 'N/A';
if(!mReason){
message.reply('Please supply a reason: -mute @user reason time')
}
For some reason the if statement isn't working
Wait
I'm trying to check if they don't supply a reason
yeah
const mReason = args[1] || 'N/A';
|| 'N/A' will make it so there is always something
Ah true
const mutetime = args[2];
if (!mutetime) {
const mutetime = 5;
return message.channel.send('โYou did not provide a time so as default they have been muted for 5min!');
}
``` now this is firing if they don't provide a time
is args[0] the command itself?
Hm?
args[2] will get the second thing in the command
oh is ee above
-mute @user args[1] (reason) args[2] (mutetime)
Or how they would use it -mute @user test 5m
so args[1] is user tag?
oh you just said that
lol
hm
so mReason is either the existence of a string, or 'N/A'
is 'N/A' some defaulted value? I've never seen that
can some one help me get started i have visual studios?
ah
I removed it though
well for sure i would log exactly what the variables are
anytime your dealing with strings and conditionals
js works
your structure doesn't
๐
i have they nevver work for some reason tho
they always work, you just haven't learned yet
@earnest phoenix maybe we can help you with a few things to get started
Learn a language before coding a discord bot
That always helps
@maiden mauve thnx
You have visual studios, but that doesn't mean you have a starting point
You need to decide what language you want to code in
alright for javascript you don't need an IDE like visual studios
Then make a bot application at https://discordapp.com/developers
Integrate your service with Discord โ whether it's a bot or a game or whatever your wildest imagination can come up with.
you can use any text editor
It is recommended, however
ok
try youtubing "create a discord bot in js tutorial"
Vsc is good
you will learn how to:
install npm
install nodejs
Yeah Vsc is pretty lit
from there you can copy pasta some starter code
and be on your way
ok thnx
bot.on('message', async message => { console.log("I'm a bot"); });
figure out whats happening after seeing that
async not required
๐
Ez you calling the message even though you don't need the msg event to console log that
Event*
Lol
tbh I kinda learned backwards
I'm no pro just waaaay out of currency with hobby coding
I like to take simple copy pasta and break it down back to how i understand the syntax
looking at the ES6 shortcuts were super confusing at first
as was the concept of "promises"
it's almost like calculus definition of a derivative
you learn the long algebra
then you use the shortcuts
when the answer is the same, you figured it out
I like to think of promises like
This code might be done correctly, or it might fail, and we can wait for this to happen

I like of promises as "hey, we're about to do this. Hold on"
nodejs "cannot convert type promise to string"
await

When using the default http module for Node.js, how can I get bar in a route such as /foo/:bar
http://owo.sh/9JKsFxM.png my bot doesn't listen to reactions
any idea why?
nevermind
my bot is so slow
idk why
Could be internet, discord, or if ur bot is large then just the fact that ur using discord.js
d.js master works like a charm for me
Yeah I kinda like d.js master cuz of partials
Partials are neat af
It makes d.js a tad bit better to use
i think it's because uws?
k
npm i discordjs/uws
yup
idk why it's still listed as a peer dependency then lol
like how I said, it's an issue with it
cuz d.js devs r on crack
by uninstalling it, you fix the high latency
@opaque eagle isnt a peer dependency on master
idk
exactly
idek if they update that version
I'd just update to master
much better
but it will refactor a lot of code, especially if you use embeds and moderation
On the contrary, eris got rid of it already
https://github.com/abalabahaha/eris/blob/master/package.json
Plus Eris gets updated according to changes in the Discord API far more frequently
Also on the master branch tho
All eris users use the master branch, there's no stable
Well that's probably why they get updates more frequently
Exactly, the eris community is actually smart about things
Last commit to eris was 23 days ago.
Last commit to d.js master was 5 days ago
however it was most likely a pull request
if you use d.js stable, it's just asking for problems when you update and master becomes stable
And having a stable branch and a master branch is a good idea because master might contain bugs
Like an alpha version of an app
or discord canary for example
Anyways, Imma head to bed, it's 3:14 AM LOL
Lol go to sleep
can somebody tell me, how to make convert link to text like that? highlighted texts
Language/lib?
wat
discord.js ?
anyone can help :-; ?
Read the docs
ai ai captain
I have this problem on my website, and it only happens when I try to enter from chrome, it works on opera, firefox, chrome incognito and chrome on other computers
Maybe chrome on the PC you are using needs to be updated
but it works on incognito mode
Huh hm
Odd
Well assuming that's the error
Your website is being blocked
Is it SSL certified?
If it's not then it won't be an https it'd be http
Any good bot names Iโm making a new one
@upper ember tried clearing your cache?
https://paste.nomsy.net/unayiqaval.rb
I don't understand what made it fail at fetching whatever it was trying to fetch
what does the headers tab say? in the dev tools network tab
I'd say it's your ad blocker (don't ask me how i know) try disabling it
^ also possible yes
@lusty dew regular error you get while doing anything with the dbl api, you have to catch em
Okay thanks @onyx summit
How long is the time limit for hasVoted like so you don't get rate limited
dblapi btw
Hey, I want to use Discord.ReactionCollector() but it doesn't work ! I think i miss the filter but I don't know what to put because the filter that I saw on Google is already used in the collector.on("collect"). Here is my code : ```js
let pollCollector = new Discord.ReactionCollector(message, {
time: 15000
}) // 604800
let emojiUP = 0
let emojiDOWN = 0
pollCollector.on("collect", function (reaction) {
if(reaction.emoji.name === "โ
") {
emojiUP = emojiUP + 1
}
if(reaction.emoji.name === "โ") {
emojiDOWN = emojiDOWN + 1
}
})```and here is my error : ```TypeError: Function.prototype.apply was called on #<Object>, which is a object and not a function
at ReactionCollector._handle (c:\Users\Megaport\Desktop\TimeBot\node_modules\discord.js\src\structures\interfaces\Collector.js:82:48)
at emitTwo (events.js:126:13)
at Client.emit (events.js:214:7)
at MessageReactionAdd.handle (c:\Users\Megaport\Desktop\TimeBot\node_modules\discord.js\src\client\actions\MessageReactionAdd.js:24:31)
at MessageReactionAddHandler.handle (c:\Users\Megaport\Desktop\TimeBot\node_modules\discord.js\src\client\websocket\packets\handlers\MessageReactionAdd.js:7:39)
at WebSocketPacketManager.handle (c:\Users\Megaport\Desktop\TimeBot\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:105:65)
at WebSocketConnection.onPacket (c:\Users\Megaport\Desktop\TimeBot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (c:\Users\Megaport\Desktop\TimeBot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:296:17)
at WebSocket.onMessage (c:\Users\Megaport\Desktop\TimeBot\node_modules\ws\lib\event-target.js:120:16)
at emitOne (events.js:116:13)```
It works now ! For people like me, I used new Discord.ReactionCollector(message, () => true, {}). Thank you @oak ore ๐
Np x)
how to let my bot send a custom server emoji in a message?
:emoji_name: does not work
the custom emoji format is actually <:emojiname:emoji_id>
your client does the magic of making it look like it's just :emoji:
e.g
under the hood is actually !pepowot
you can get the emoji in that format by putting a backslash before sending :emoji:
depends where in the embed
in a field
field name or value
value
it should work yeah
alright, thx
psa your bot needs to be in the guild where the emoji's in to use it
aha got it
Anybody here have experience with writing JSDoc templates?
Just ask the question and someone will help
Ok
How do I get the actual JSDoc data of all the classes and stuff in my publish?
Nevermind I got it
Is there a way to allow the user to vote from your bot directly or do you have to go to the DBL website
The latter
Dang
Okay next question
What is dblapi has voted time limit before it becomes a rate limit problem
Like .hasVoted() method
Check DBL docs
CLOSE ATTENTION COMRADE 
Lol
has hasvoted is a http GET so there may be a ratelimit
Not for me
Won't let you navigate to it
Desktop mode wins
that's 1/s
They're not the same
exPLAIn
Any way I can prevent rate limit exceeding
ok fine
60 requests per minute that's 1 request every 60 seconds right?
But you wouldn't be able to not get ratelimited if you sent 2 requests per second with 1/1s
My math is horrible so don't mind me lol
Wait you can send 60 requests per minute?
Yes but I don't see a reason why you would want that
Oh I thought it was 1 request every minute lol

For the api, will it be checking for 60 requests every minute then clear it all when the minute passes, or hold a collection of your requests and clear it for the minute of each request.
For example: I send 30 requests every 2 seconds so it's been a minute. WIll my requests limit go back to 60 immediately, or would it slowly increase when the minute passes for each request. Confusing question I'm asking
That makes things a lot easier
I thought I'd run into rate limiting problems
Actually I still could
Most likely you would get the ratelimit reset immediately but then again, it's just my guess
I'm adding vote check to commands that get used all the time
And 2500 people have access to those vote locked commands wouldn't that cause problems if a bunch of people use it at once?
Unless I add a cooldown of 1m
Or 30s
Cause then it'd have time to reset before it's get rate limited
You're better off using s webhook
Idk how to use webhooks lol
What's your library
dblapi.js has built-in webhook feature
Oh?
webhook auth is the auth phrase you put in in the website
port is the port to listen on for posts
the discordbots.org website
go to your bot's edit page
Oh
and scroll to the bottom
have you opened a port and forwarded it
and do you know your public ip
actually first where are you hosting your bot
that colour scheme should be illegal
@winged thorn on a friend's hosting service
They need to open and forward a port
Any port above 1024 will do
and the url takes the form
http://ip-address:port/optional-path
The bots ip address or the service?
Are you trying to have a vote webhook?
Yes lol
the host's public ip
its optional
Ah okay
What port
Doesn't matter tbh
Dude I'm asking him
but it doesn't really matter
Mk port 1025
Nah
Then what port should I say
Gonna give you 30001
3001? Or 30001
30,001
what os is the machine running
Mr*
ubuntu
webhooks.chilo.space/clap/
last slash is important afaik
paste that into the dbl thing
Okay
And in your application you listen on port 30 001
Okayy
don't you need an http:// at the start
Thank youuu
Is it supposed to give me an authorization thing or so I put one?
Do*
I'm assuming I have to put one so I did
yeah you have to define that
Okay
It's to compare if the votes are really coming from dbl or not just some random trying to trick you
gay
yes everyone has a little happiness within us......somewhere
look at the second example
it wants you to do that
Instead of passing 'name'
- It's a deprecation warning, nothing that serious
- See Turtles link
- Nothing that serious until v12 comes around
Pretty sure you have to change a bit more when switching to v12
Collection.find() is really similar to Array.prototype.find()
a little help please
One message removed from a suspended account.
@has_permissions(manage_roles=True, ban_members=True)
async def _kick(ctx, member: Member):
await client.kick(member)```
this is not working for some reason
how to do prefixes like that? exapmle ki help
Anyone using discord.py here?
connor that isn't how has_permissions works
then?
also are you using async instead of rewrite
i know
async doesn't works anymore?
can you open up the python shell for me
yes?
and type these lines
import discord
print(discord.__version__)
One message removed from a suspended account.
version 1.2.3
ok so your syntax is just incorrect then
I get deprecation warnings all the time, they're a big deal believe me
has permissions is like this:
@commands.has_permissions()
not
@has_permissions()```
Discord.js v12 is not a joke
my kick used to work before i added has_permissions
whats the correct syntax
not @has_permissions
@commands.has_permissions(manage_roles=True, ban_members=True)
async def kick(ctx, member: Member, reason=None):
await member.kick(reason=reason)```
this doesnt works aswell
Is there an error
from discord import Member
from discord.ext import commands
from discord.ext.commands import has_permissions, MissingPermissions
import random```
remove these lines:
from discord.ext.commands import has_permissions, MissingPermissions
from discord import Member```
they are unnecesary
and change the
member: Member
to
member: discord.Member```
good ๐
Thnx man
nws
How did you initialize it (without token and secret kthx)
const DBL = require('dblapi.js')
const dbl = new DBL('Nahhhboi', { webhookPort: 30001, webhookAuth: 'ye no'})
Then I did
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at https://${hook.hostname}:${hook.port}${hook.path}`)
})
dbl.webhook.on('vote', vote => {
console.log(vote)
})
This stuff
Inside the command file as well
What does it log in the ready event?
Hm, dunno
Nor do I
But you will need to edit the URL where you did earlier
to https://webhooks.chilo.space/clap/dblwebhook
(Not my fault, it's because the dbl package handles it like this)
do webhooks support passwords with spaces?
a lot of internet things dont like spaces in names/urls/fields/etc
But its in the auth header so i'd expect it to be ok
why would one of my shards shut down and make pm2 restart it?
I also noticed my shards become unpredictable after being online around a day
have you checked for errors/memory leaks?
which means completely random and weird issues sometimes occur
my memory rises to around 1.1gb for each shard after being online for around a day, its usually at around 600mb
how many guilds?
so you're running 2 shards of 1.6k? or more?
4
sometimes changing the shard count causes different behaviours
and yes, all shards are around the same usage
limit the cache of messages or your ram goes rip after a few days
Hmph webhook still not working tf
do you have zucc installed?
me?
yes
then you should limit/clear caches, your ram usage is way too high
a peer dependencie of d.js
I need help
my bot is using ~300mb at 1.5k guilds
also, are you on stable or master?
Me?
https://github.com/Clemens-E/better-airhorn/blob/master/src/index.js#L18
That fixed most of my ram problems btw
Master of you're talking to me
talking to speedy lul
But the ready event never fires? dafuq
I dunno because I have my own server receiving votes
Hmph
is port 30001 available?
Everything seems to hate me ๐
Yes, I'm pretty sure it is
@quartz kindle stable, will switch to master soon because it allows objects being returned through broadcast eval
Should be is it CHY4E
Lol
Shard count has an auto thing?
Someone told me it didn't dafuq
@split hazel when you switch to master, be sure to install zlib-sync, and optionally also erlpack and bufferutil
but zlib-sync alone cuts your cpu usage by more than half
The only process listening to port 30 001 is your bot xD
I switched from stable to master and didn't install those packages
Yo yeah, it's free
@lusty dew can you show your full code?
May I ask what those packages do?
He didn't mean everything
@split hazel some people are talking of 10x less CPU usage with zlib
But it's probably not that much
@lusty dew only show the part where you are starting the dbl server
everything that has to do with dbl
Gonna just look at the files myself 
@split hazel zlib-sync is a compression package to uncompress the packets discord sends. d.js master has pako built in, which is a pure javascript uncompressor, which works everywhere but uses a lot of cpu because of it. zlib-sync is a native C package which must be compiled, but since its native low-level, its dozens of times more efficient than pako
and yeah, the cpu reduction is not 10x, but realistically 2-3x
alright, thanks alot for the help
I'm just repeating other people, I don't have it in prod yet
const Discord = require('discord.js');
const DBL = require('dblapi.js')
const dbl = new DBL('ha nope', { webhookPort: 30001, webhookAuth: 'ye no'})
module.exports.load = (client) => {
client.commands['ncos'] = {
async run(message) {
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at https://${hook.hostname}:${hook.port}${hook.path}`)
})
dbl.webhook.on('vote', vote => {
console.log(vote)
})
},
};
};
Okay you attach those listeners too late
webhook are supposed to be silently listening at all times, and updating your database. they are not supposed to be run with a command
you have to do it in the main file, it's not supposed to be in a command
it's not different from a welcome message, it's active and listening at all times, has to be in your index.js or it won't work




d.js isn't really slow