#development
1 messages · Page 1121 of 1
How could I make a function that repeats itself 10 times after another function is made.
First run -> Run the Function -> wait for user input -> Second run
use a for loop over a while
Hi
Im Wondering on how to make logging stuff
so mod commands get logged in (channel)
store the channelid somewhere (json file works too) then just make sure on bot Startup the channel is cached. Then just add in your Moderator Commands a function that sends a message into the stored channel
Im Wondering on how to make logging stuff
@austere robin use events provided by your library
and send it to some channel you preferred (or store it on database)
what language do you use?
discord.js
its simple
did you have a json file where you store your configuration?
like config.json
did you use a Database?
oh.
wtf man. did you Hardcoded everything in to your bot (prefix as example)
lol wdym? hardcode?
its nothing bad the json file makes it just easy to change the channel if it changes
try learning editing json files in javascript, there are a lot of tutorials out there
you dont need it its just a qol feature
wait, im using a json file.....
then just make a new key where you store your ChannelID
you have something like this : ```json
{
prefix: "!"
}
ehhh
{
// other stuff here
"channel":"channelid"
}```
no....
{
"serverid": "channelid"
}```
did you got a config.json?
no
or is it a package.json?
i got a package.json
where did you code your bot? @austere robin
ok dont touch this file
@radiant kraken server.js
Dont mind the warns and servers and economy and ranks stuff
nothing in there -_-
you're using json as a db?
yikes
everything
yikeeess
that's ok if your bot is small though
everything literally everything
Which type is better for a db?
mongo or sql
SQLite
Sql better
k
see <#development message> on why json bad
lol
my friend had a bot with 500+ servers and still uses json as a db
yikes 
Mega yikes
-_-
500+ server and json as db?
Wait, so sql?
Yeah
config.sql
First try learn xampp will be usefull
try learn using mongoose/mongodb
bruh, alright
MongoDB 100% better
it's beginner friendly imo
for a config json is fine, for ephemeral storage with data that changes often look into using a proper database
Just make sure you secured the dB instance
545 means nothing since
lines do not matter in the slightest
If u use separate files for each guild will it be fine?
You can make it smaller
you fucking donkey full of yanky danky doodle shite
And better
lmfao @golden condor
Mongodb is user friendly especially with mongoose
i suggest you do research on what a database is, what sql is and what sql databases are
you need to grasp a better understanding of this
lmfao
Lol, so Databases are stuff in which data is held
database is where you store data so that if your bot goes offline all of the data doesn't disappear
i can easily explain everything to you right now but you won't understand it, i cant understand it for you ergo you have to do your own research on this
do the research, im on phone it hurts to type
Should i...
yes
but anyways, there are many layers to a database - from encryption to storage to what type it even is, sql is a querying language meant to work with sql based databases
they're built to sustain huge amounts of requests
@golden condor -_-
¯_(ツ)_/¯
Yes fine
and once again...
lol how long would that take
try watching yt tutorials
no
How could I make a function that repeats itself 10 times after another function is made.
First run -> Run the Function -> wait for user input -> Second run
stop suggesting youtube tutorials because you damn well know they'll end up on a how to and end up copypasting
Callum I am.
@austere robin there is no set "how long will that take", once you get it you'll get it
alr
It's just causing my bot to crash.
for (let i = 0; 10 > i; i++){
//do something
}```
@golden condor will that allow a function to be fully run
yes
That will run whatever code you put in there 10 times
just a question, how long have u all been coding
then run it again
if you use await then yes
ok
hmm?
just a question, how long have u all been coding
@austere robin 2 months now
for ( 10 > qNumber; qNumber++){
//do something
}```
time wise im a senior full stack dev by this point but still in high school lol
i mean longer but 2 month bot dev
ok.
@earnest phoenix haha, what grade?
I have been coding properly for 6 months
for ( 10 > qNumber; qNumber++) {
i've worked on some backend before
is an error
backend is fun
yes
Yes
better than frontend
frontend = annoying
junior @austere robin
Not if you use vue
my frontend looks shite
Vue is good
@earnest phoenix bruh, ur fking smart then
i suck at UI design
lol
lmao same @radiant kraken
American grades are confusing
I'm in Year 8
aus is australia right
yeah
Callum, only?
@golden condor ur in AUS??
i have an aunt in australia
alr
how old would I be lol
I'm in year 10 but leant coding myself because teachers are pointless.
lmao
I know more JavaScript then them.
lol
I sometimes have to teach the class.
I am in year 9 same
don't make a bot just for the badge
@misty sigil Lmfao, i'll continue it
you need to work hard to get the badge
@radiant kraken ik
Eris
Oi.
Respect
Alright.
I've never worked with something like this become.
It has become a challenge.
Nw
Yes
any suggestions how to get the userid of every user that reacted with x emote?
Yes.
Emoji Reactor.
js
Djs?
@pine aspen doesnt work
Probs discord.js
yes
lies
I think uh
I'll send code.
im already in a event
hold on
messageReactionAdd event. i want to prevent users from adding mutiple reactions to a message
You could loop through all reactions
that too.
yea just got a idea
👍
I am tryna use web
Ngl I thought this was the website's tagline
Please, help
Trying to get a full thing done with the user input. Doesn't work and just skips.
I'll check and compare my code.
Ok.
0|index | SyntaxError: Unexpected token ';'
0|index | at wrapSafe (internal/modules/cjs/loader.js:1054:16)
0|index | at Module._compile (internal/modules/cjs/loader.js:1102:27)
0|index | at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
0|index | at Module.load (internal/modules/cjs/loader.js:986:32)
0|index | at Function.Module._load (internal/modules/cjs/loader.js:879:14)
0|index | at Module.require (internal/modules/cjs/loader.js:1026:19)
0|index | at Module.Hook._require.Module.require (/root/.nvm/versions/node/v12.18.1/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:80:39)
0|index | at require (internal/modules/cjs/helpers.js:72:18)
0|index | at Object.module.exports.run (/root/ModCord/commands/developer/reload.js:16:22)
0|index | at runMicrotasks (<anonymous>)
0|index | at processTicksAndRejections (internal/process/task_queues.js:97:5)
btw
...as soon as Firefox loads
ok
Oof, assignment rather than comparison
Yep
Hi
@earnest phoenix https://www.nohello.com/
Do you have a question?
Don't Just Say "Hello" in Chat.
I'm from Brazil
@earnest phoenix https://www.nohello.com/
Do you have a question?
@faint prism I think not
Don't Just Say "Hello" in Chat.
Not sure if this is the correct channel, but, where do you recommend me to host a music bot?
and what specs would you recommend? and internet speed maybe?
Depends on your program's cpu load when in use really. Which is pretty specific to your bot
These are good. You can get one for $3/mo
https://galaxygate.net/hosting/vps/
https://www.digitalocean.com/
@remote silo
Let's say a 1000 servers
How can I add a bot to my server?
what specs would you recommend
Invite one via a link @earnest phoenix
Depends on the calculations a command performs @remote silo
Bot's are typically pretty lightweight
Mine is running on a rasp pi 4's specs if that gives you an idea
Invite one via a link @earnest phoenix
@faint prism Thank you
Really depends on the data you hold in memory, man. I can't do a profiling of your bot's overhead. Open TaskManager and see how expensive it is to run
Besides me, are there other Brazilians around here?
I typically do a profiling in VS, but I wasn't sure how JS devs do it
i dont even use vs for memory profiling
its good for cpu profiling, but i use chrome for memory
https://sourceb.in/e743696a54 | https://gyazo.com/c250eba24ed0cf0d3b0c123fa23d0cbb
I'm supposed to have one message then a user responds. Then the next question comes.
await message with a filter
Check the code.
assuming its d.jsd
it seems rather bad to be doing those regexes like you are tbh
do i put the entire emoji name (including ID) in reaction.emoji.name?
like <:name:id> or just ID?
emoji name is just the name iirc
its either name or id
since i dont know eris, no, but regexing the mesages doesnt seem like a very good idea
Ok.
specially cuz you arent lowercasing them
i wouldnt use collectors for that
it makes everything needlesly complicated
are you using eris additions or whatever that package name is?
do you have access to a helper function like awaitMessages?
you could make your own too, its a wrapper around the collector
that returns a promise that resolves once its conditions are met
Slc maluco é bilíngue
makes it much easier to use in this specific scenario
let responses = await message.channel.awaitMessages(m => m.content === "yes", { time: 10000, maxMatches: 1 });
oh
ok
I can do that
👍
@earnest phoenix english only here, no hue hue hue
Slc maluco é bilíngue
Rule 6 #rules-and-info
I'll be back to Brazil's servers, bye
whats not working?
i've not been coding or anything dev related for the past few days soooo might not be much help
It's the fucking poo mug peerjs server
Of course you don't understand you easy bake oven
Doesn't it have sample get/post requests?
Nope
<reaction>.emoji should return emoji stuff right
have u tried it?
yes
what is <reaction> ?
its the reaction object from messageReactionAdd
weird
?
its returning undefined for me
how are u doing it?
just reaction.emoji
send ur code the client.on('messageReactionAdd.... bit
Would it return a reaction obj or a reaction obj and a message obj?
client.on('messageReactionAdd', (messageReaction, user) => {
console.log(messageReaction, user);
});```
i've logged the reaction.emoji bit too
so messageReaction logs, but has no .emoji?
console.log(messageReaction.emoji.name)
yea
Can i ask what channel i should use if i want to report something
emoji is undefined
what discord.js version are you on?
latest
not you
Ohm mb
lmao
lol
are u using discord.js-light?
nope
cuz i believe it recently got updated
oh
what does messageReaction respond with?
like if u just log it
doesn't say it would be undefined in any case so
how to create a channel in specific category using dpy
ye fixed it
ook
if(msg.auhtor == member) return msg.reply("Boomer, You wanna ban yourself?")```
this does not work
person can still ban himself
auhtor - typo
;-;
idk if msg.author == member works tho, just try 😄
oo
auhtor lmao
Is member a user object or a member?
User == Member would never be true right?
depends on what kind of type coercion it does
but the correct thing would be to compare ids directly
^^
who is member here
is it?
member means bot??
bot means bot
Author means User
var means bad
You have to check if there is the member variable first and if there is an object inside of it or if it's just undefined
he using javascript
or use conditional chaining
Also what is wrong with var
Global
And... Is that an issue? What if you want global
no reason to use var over let/const, just causes hard to catch bugs down the line
if you DO want, use it
Then var is usable for that
but most of the times there isnt reason for it
If you can use let, use let
it does have its uses for sure, but mostly can be replaced by let
I just switch between the two all the time tbh
what is difference between a category and categoryChannel
Thats generally a bad idea
yay. cant check something i have coded already in a other bot bcs my NAS is having a stroke again
Oh feels bad man
Sometimes I just instinctively do it
i have a brainfart rn. want to remove only 1 reaction from a message not all reactions by this one user
somebody answer my question
what is difference between a category and categoryChannel
@wanton anvil
Don't know if there is one
i think categoryChannel is the channels in the category, and category is a category object or something idk
i literally said "i think" and "idk" "or something"
@digital ibex I appericiate it thanks anyways
Category Channel is a category
no difference?? @golden condor
hEY
how can I build a Category class without bot
A category is an instance of CategoryChannel basically
RangeError: Source is too large
at Uint16Array.set (<anonymous>)
at OpusScript.encode (/root/bot/node_modules/opusscript/index.js:67:16);
Keep getting this when the bot is hosted on a vps but never when i host it on my own pcs
haha
Didn't we help you with this issue already
tim already said that the file, or something, ur trying to play is too large
something like that idk
but it only happens on my vps
maybe ur vps cant handle it
it has 80gb ssd space
Ssd space? Your source is from your ssd?
Hey
I wanna make my bot see
If the person he is trying to van
Ban
Has higher role then him
Like I do s!ban @mod
compare highest role
members have a role property if im not mistaking
O
Docs explain how quite well
:o
im having a small issueee if anyone knows
So
So
Is this form data?
yeah
if (msg.author.highestrole < member.user.highestrole) return
Then just a post request with all the form data
i've got that bit
if (msg.author.highestrole < member.user.highestrole) return
It this how u do it
but i dont know how to send "oof" to it
like, for each server, its going to be different
if (msg.author.highestrole < member.user.highestrole) return
@delicate shore
a user doesnt have a role
users dont have-
He
Ok
You know the docs literally explain this if you follow the role chain
Theres already a method that tells you the order of two roles.
Reading the docs is an amazing thing
@digital ibex
hi
Are you setting the value to oof?
i know dis bit
Den just post the value
i have a blockade rn. I want to remove a reactions of a User if there is already one reaction from him on the message. any suggestions?
Set the value to oof and post unless that's what you're doing already
Formdata
https://javascript.info/formdata
wdym set the value?
<input value="oof">
lemme show u what im doing 1 sec
Alright
<form action="/guilds/<%- id %>/moderation" method="post">
<div class="select">
<select>
<option>Select the muted role</option>
<% roles.forEach((role) => { %>
<option><%- role.name %></option> <!-- trying to send the value of "option" which the user clicked -->
<% }) %>
</select>
</div>
<%- include('../imports/save') %>
</form>```
<option value="titties"> will post titties when submitted
Whatever you wanna post
That makes the most sense tho
Yeah that makes sense if you're setting a muted role
Oh
Iirc, they need to be in a form
i've got this as my middleware app.use(express.urlencoded({ extended: true })); so no idea why its not working
You gotta set the name
its in the form
Weh
name?
Yeah
<option name="Donald trump">
Oh nice
I'm retar btw
Wait I gotta go to my site a sec
It was all woo
lmfao
lol
Hi
Some one can help with website
I need js script what redirect from domain.com to www.domain.com
Thx
js has a redirect
if !url.startswith("www.") redirect
But why do that at all?
I don't think you need www. for a url lol
you need to contact ur website hosting serverice thingy for www as a subdomain for website.com to redirect u to www.domain.com
www is ugly tho, i dont have it as any of my subdomains because yuck
It's actually not necessary to use WWW in URLs. It exists for just one purpose – to identify the address as a website.
So unless you're using the url for another service than website hosting
you need to contact ur website hosting serverice thingy for www as a subdomain for website.com to redirect u to www.domain.com
@digital ibex I Aleready have www subdomain
then make it when u go to website.com to www.website.com
what domain provider thingy u using?
@grave jay do you use cloudflare?
I'm having trouble configuring postgres on my VPS
I installed it, added a user, added a database with that new user as the owner, edited pg_hba.conf, and allowed ufw firewall on port 5432
but when I try to connect, my connection times out
@opaque eagle make sure the service your running it listening on 0.0.0.0 and not 127.0.0.1
last line
how can I send timed messages using dpy
127.0. 0.1 is the loopback address (also known as localhost). 0.0. 0.0 is a non-routable meta-address used to designate an invalid, unknown, or non-applicable target (a 'no particular address' place holder)
@opaque eagle change this line iirc https://img.ichigo.uk/mSbEUdsc4GTQ.png
to 0.0.0.0
if that doesnt help idk
ohh
Careful changing localhost to non-specific ip addrs, could break a connection between services
Okay but how made redirect from example.com to www.example.com?
what is /64 ipv6 network
A range basically
how can I send timed messages using dpy
@wanton anvil help please
IP addresses are assigned to networks in different sized 'blocks'. The size of the 'block' assigned is written after an oblique (/), which shows the number of IP addresses contained in that block. For example, if an Internet Service Provider (ISP) is assigned a “/16”, they receive around 64,000 IPv4 addresses
@misty sigil
show the panel where u add the subdomain @earnest phoenix
u can send it here
still nothing
woah so 64000 different ipv6 ip addresses for /16 network
funny enought if it wont work the normal way try it with Docker. had some issues getting MongoDB working in a Replicaset with the Normal Installation. with docker it took 5 minutes
yeah I'm used to using docker
but I don't want to spin up entirely new instances of postgres for each new project
@lusty quest
you dont need to?
wdym
you can just run a Container with Postgres and connect with mutiple projects to it
if i include a postgres db in my docker-compose file then it can only be used by other containers in that project right
Should I actually make this to a good command?
Current things I may add:
Embed Messages.
Templates for diffirent desings.
lol thats overkill
yea
ok ok lemme try that
yeah
If I'm posting data for stats should I put that in the ready?
wouldn't it bad for my VPS's memory tho
why?
it would be more efficient to just run postgres natively
because it's inside a docker container
Is discord bot delaying send message every sending 5 message?
i was running MongoDB on 3 VPS (each 1GB Ram) and each used maybe 12% Ram (together with OS, Docker)
Docker has a small overhead
Digital Ocean doesnt offer VPS with lower Specs
but i switched to a paid Plan from MongoDB Atlas. Gives me some nice stuff and i need to care less about it
eh
Try Azure, Vultr, Linode, Conoha, etc..
i see no reason to use atlas unless you're working with other developers on ur project
what i have RN is pretty decent
get a Replicaset at Atlas for a decent price
since i dont need to pay for 3 Individual Instances im fine with it
how can I add timeouts in python which library is best??????
Anyone good in API's?
what do u need?
thats not you ACTUALLY interacting with the api itself, u are, but its an api wrapper
I putted new Discord.Collection() in my code but it's said Discord is not defined but I'm putting const Discord at the start of the code.
show ur code
where is it erroring?
it's said Discord not defined
why the space
Just wanted to make sure since the syntax highlight color is diff
Oh guess not
where can I promote my bot
here but not here
whats the full error?
which channel
discord not define.
not a channel but https://top.gg/bot/new
No channel for that, bud
Look up another server for adverting
Ask in #support for any more questions not development related please
@earnest phoenix
whats the full error?
mmmm let me try something.
thats not the full error
Sorry for that, it's fixed.
?
no ignore me
I did all my bot and the economy is working but how can I add a command to control the credits etc.
do you know what youre even doing
@earnest phoenix not here
did you write that code
coz its a very bad code
and it doesnt work
i would make it completely different
you cant fix it if you dont know what each line of your code exactly does
Bruh
Where is this "code" being referenced
It's deleted
Can't help someone who does that
there are mutiple mistakes
why is the captcha the same text and not random?
- Never Nest Events into each other
- The entire architecture of that costs a lot of technical debt
and why always the same text? then the verification is defeated by the first smart person who knows how to make selfbots
?
- Pretty much 90% of the syntax is embeds
I am, fairly new tbh lol
just use a Random String Generator and send it to the user. its already better than sending the same image to everyone
Especially if the bot is public
if you need a idea for a Random string i can recommend looking into the crypto package (makes it easy to get a random string) otherwise you can easy make one in plain js
My approach for that was get some random int within ascii's letter range, cast to a char, then add append to a string
string randomStr = string.Empty;
Random rng = new Random();
for (int i = 0; i <= 15; i++)
{
randomStr += (char)rng.Next(65, 123);
}```
``zg^McmLGPD_eRGx`
Quick and dirty example
huh
tbh in js you don't need that at the declaration, you can use let/const
does (char)rng.Next return a character under returned code?
I can give a simple example for it
i find a command handler, this may work https://medium.com/discordbot/create-a-basic-command-handler-for-your-discord-js-bot-4e24e17cb594 ?
But I cba to type it on mobile
Every char has an int for it's ascii (or whatever encoding) position. This allows the cast
yeah, that just didn't look very intuitive to me as a Python dev
What, what I sent?
yeah, the (char)rng.Next(65, 123); part
Filthy Python dev @slender thistle
In Python you'd do chr(random.randint(65, 124)) 
In Python you'd do
chr(random.randint(65, 124)):catshrug:
@slender thistleIn C# that's equivalent to this, assuming char cast works the same
Actually, I don't know why I expected that to return a character when the returned random integer is at least two numbers long
What do you mean? I am having a bit of trouble reading that message, lol.
It should return a char as long as the int is within the encoding's char value range
assuming char cast works the same
(char)65 wouldn't make sense to return 65 as char type
and that's essentially what I expected it to do, for some reason
65 as a char is 'A' in ASCII
yeah, makes sense
I think you can also do byte conversions in a similar way. Characters have hex values as well
0x41 for example is 'A'
So like (char)0x41?
while we're talking about this, could i do (int)('A') and get 65
👌
Huh, that's neat
Console.WriteLine('\x41');
returns A
Since the hexcode/byte representation is essentially the char itself
What Lang is that
Ah ok
you can do that in js as well
ha lol
I'm looking to get into better web development, I have started learning vue, is that a good choice or is there better things?
-ask2ask
Vue.JS is known for implementing the best of aspects of Angular and React
@golden condor
Well it'd just be
\x41I think .Let me check
@faint prism how to write that
vue is simple, you dont really learn much if u understand the basics of es6 and just js in general, its really lightweight too with its cool features
Black background
I like vue
` ` The grave character @barren sand
Ok
its source code is in ts so its better for ts if ur using it
ok
wdym?
Vue.js lets you add it on top of an existing html page by just referencing it's script. Pretty neat imo
It's components are a bit confusing and it's tutorial on their docs is weird because it's a game
Vue.js lets you add it on top of an existing html page by just referencing it's script. Pretty neat imo
@faint prism yeah I like it because of that, I made a basic cookie clicker with it
traversy media uploaded a crash course on it around a year ago, he explains vue in detail
I mean react
Vue is quite simple and the docs are well presented too
So that's why I like it
But if any of you could link a good website and/or video for react I'd appreciate it :+1:
I'm not a webdev sorry. More of a backend C# dev
Alr
i've not watched it, but traversy media uploaded a react crash course too
In this crash course you will learn what React JS is and the fundamentals such as components, state, props, JSX, events, etc.
Modern React Front To Back - 13.5 Hour Course
https://www.udemy.com/modern-react-front-to-back/?couponCode=TRAVERSYMEDIA
Code For Tutorial:
https://...
vue.js has video tutorials on their website
Moving from ejs to Vue has been easy tbh, can you use it with express's render function if you set the view engine?
er
possibly if u use the cdn (not sure)
but u cant if u install the cli then defo no
-faq 3
@digital ibex I think there is a Vue npm pkg
Also can you link the Vue crash course?
yeah
Thanks :+1:
@vue/cli
https://youtu.be/Wy9q22isx3U found iy
In this crash course you will learn all about Vue.js including what it is, Vue-CLI, components, data, events, directives, etc
Sponsor:
http://www.netlify.com
Code For Turorial:
https://github.com/bradtraversy/vue_crash_todolist
Deploy Sites With Netlify (Video):
https://www...
yeah
Nothing is coming in #502193464054644737
traversy media is really good
it's last message in #502193464054644737
rp creator ^^
Its had some issues with some shards
For like the past few weeks
Invite manager has a support server, should ask there for more info
Where please ?
🤷 this isnt the invite manager server, so idk what their link is.
You can find it on their top.gg page
Restart your client
...
I am new
ah
Oh god I introduced a breaking bug to prod
Good thing it was just dotnet publish not overwriting the config file. EZ fix
<None Update="config.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</None>```
Which is weird because it always should..
real programmers test in prod
lol
why when i try to make commands in the commands folder they never work
It worked in Test. I just forgot to update the config.json in prod
@jolly wave did you got a command handler?
Command handlers also expect a format. If you dont follow that format it won't load the command properly
I really need to finish my bot's devops pipeline...
Doing a manual update is tedious:
alias update-discordbot='sudo echo Starting as admin && cd /home/ubuntu/{BOTNAME}; git pull && sudo systemctl stop discordbot.service && dotnet publish -c Release -o release; sudo systemctl restart discordbot.service'
are you handling them properly
let me rewatch teh guide xd
like storing them in a collection/map and using them in the message create event
watch?
discordjs.guide isn't a video guide
oh you said discord.js guide
others suck
you don’t watch website pages?
e ok
I like watching Google.com
I like watching discord
You can watch discord
Two people arguing is a great thing to watch
I still haven't fixed my postgres error
but I've gotten better
I went from a "connection timeout" to a "connection refused"
can i post my wall of screenshots
ping.js don't work when i try it
Id go back and make sure you did everything outlined in the guide properly
did you run it now in docker?
No
refused is good, this means something wont let it connect
firewall is allowed? or is it local?
- my firewall looks good
did you allow connections?
pg_hba.conf?
yes
time to retry ping.js
i can't save index.js anymore why
i think you have there an error.
where
not sure if you are allowed to have localhost and any host at the same time
You can't save a file?
yes
🤔
idk
where did you want to save your file? if it is a NAS or external Drive is it still reachable?
