#development
1 messages · Page 1693 of 1
the last thing to do ispkill the process but i won't recommend that
well nvm install script also uses curl
might break something
yeah
just saw it in the code
cargo install deno
if you already have rust installed
okie
WHY DO ALL INSTALL SCRIPTS USE CURL
install scripts need internet to download things and install them.
because lots of pcs have curl
Why is repl.it saying that staying_alive is undefined?
from threading import Thread
app = Flask('')
@app.route('/')
def home():
return "Webserver OK, Discord Bot OK"
def run():
app.run(host="0.0.0.0",port=8080)
def staying_alive():
t = Thread(target=run)
t.start()```
unless the script have its own install data(probably folder) to get contents from.
import it?
in my case is in the samefile as my bot
?
app=Flask("")
@app.route("/")
def index():
return "<h1>Bot is running</h1>"
Thread(target=app.run,args=("0.0.0.0",8080)).start()
in my case i use like this
What file is that in?
main
Im confused what would I do?
why the fuck wont it work
I haven’t coded in long time
replace it
what process is using the shit
¯_(ツ)_/¯
restart
or install from source
cargo install deno
Can you show me bigger example or something
yeah imma do that
except i dont know how to do that
¯_(ツ)_/¯
What do you put at the end of your code?
thing that i just send
this
Is that’s all you put in your entire bot for it?
for keeping it alive yes

it worked
oh cool
but i have to type the path to deno everytime i need to use it
lol
add to bashrc
didnt you noticed something that the code that you send haves flask?
i got a nice lil gimmick for bashrc @earnest phoenix
ok
function extract {
if [ -z "$1" ]; then
# display usage if no parameters given
echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"
echo " extract <path/file_name_1.ext> [path/file_name_2.ext] [path/file_name_3.ext]"
return 1
else
for n in $@
do
if [ -f "$n" ] ; then
case "${n%,}" in
*.tar.bz2|*.tar.gz|*.tar.xz|*.tbz2|*.tgz|*.txz|*.tar)
tar xvf "$n" ;;
*.lzma) unlzma ./"$n" ;;
*.bz2) bunzip2 ./"$n" ;;
*.rar) unrar x -ad ./"$n" ;;
*.gz) gunzip ./"$n" ;;
*.zip) unzip ./"$n" ;;
*.z) uncompress ./"$n" ;;
*.7z|*.arj|*.cab|*.chm|*.deb|*.dmg|*.iso|*.lzh|*.msi|*.rpm|*.udf|*.wim|*.xar)
7z x ./"$n" ;;
*.xz) unxz ./"$n" ;;
*.exe) cabextract ./"$n" ;;
*)
echo "extract: '$n' - unknown archive method"
return 1
;;
esac
else
echo "'$n' - file does not exist"
return 1
fi
done
fi
}
multi unzipper
ok
i love it 😛 saves some time
i have no idea what flask is 😛
what the absolute fuck is this
if [ -z "$1" ]; then
this is the most black magic shit i've ever seen being done in Lua before
oh
😉
I haven’t coded in like a year and now I’m confused with some basic importing shit
Wtf
Not actually a year but damn
goes quick 😛
oh i want to bring up my problem with using bash scripts in my node project
i also want it to work on windows
?
bash can run in windows, ported
scoop install bash
but ur better off with powershell i rekon
#!/usr/bin/env node
require("../build/run");
i know this wont work in windows
i disagree
ok how so
i know u have ported shells from linux to windows (forgot the name of it)
but why ?
the package is called cygwin
looked it up
A singular cluster worker shouldn't consist of too many shards where it would get to that point. Processing incoming socket messages doesn't take that much processing power. The master thread wouldn't even be doing anything else computationally expensive if a thread pool is used to delegate command processing which could consist of 2D canvas rendering which is a good example of potentially heavy processing. Another would be audio encode/decode.
If a thread isn't being utilized, then that's wasted resources.

i need to optimize it, but it takes too long for my liking
[Processor][4/7/2021 9:59:51 AM] -> Task Command from 'Barret'
[Command][4/7/2021 9:59:51 AM] Running '!top10'
[Command][4/7/2021 9:59:52 AM] <- Task Command finished in 963ms
Is that actually time spent from processing or from network I/O as well
i might need to reduce the image size
thats time spend on executing a command (that contains 4 charts and linq query's)
thats the result of that command
ah. Lovely
demn you talk about advanced stuff
My highest res image is 800x500, but I'd say this still looks pretty clean
it does look nice indeed
how do you guys make threads talk to each other? do you guys use worker_threads?
talk to each other?
Why This Is Invalid?
You haven't saved your file
in worker_threads, there is a parent port and the parent port can post messages to workers and workers can send stuff back to the parent. The workers extend EventEmitters, so communication between 2 threads feels native
You should read the node.js docs on worker threads though
IPC
very helpful
or callback's
keep_alive.py:```from flask import Flask
from threading import Thread
app = Flask('')
@app.route('/')
def home():
return "Webserver OK, Discord Bot OK"
def run():
app.run(host="0.0.0.0",port=8080)
def keep_alive():
t = Thread(target=run)
t.start()```
File "main.py", line 3388, in <module>
keep_alive.keep_alive()
AttributeError: module 'keep_alive' has no attribute 'keep_alive'``` somebody plz
you don't really need threads in the first place
but if a thread sent 2 messages at the same time and the main thread responds, how do you know which is response to which
i mean.. i'm just curious
Pretty sure you can listen to individual workers and provide callbacks for each message receive
you can't process 2 things at the same time so there is no race condition when receiving messages
even if you can't do what I mentioned (unlikely), then you can make a system where threads identify themselves
i meant if the same worker thread sent 2 messages to main thread at the same time.
Can somebody plz help me xd
unless u can do it by chunks 😛
like torrent clients do
wha
chunk as in, partial piece of work, over several threads
you cant just make a function in function
If you're talking about trying to resolve a Promise to somewhere else other than the direct callback, you'd have to set up an outgoing Map with keys the threads would bounce back and forth to identify what it's linked to and relate that key with a Promise's resolve function.
woot... my bot just exceeded the 300 users mark
I mean you can receive messages in multiple threads simultaneously but not on one. I've never had to use threads in node tho so they're not even a particularly useful concept unless you're dealing with cpu intensive work
Where did I do this?
ive seen nodej's threads, i find them confusing
main => create task with resolve => store in Map. key 123 (example) => send key 123 and task to worker => worker does task => worker sends back 123 and result of work => main thread can get the key and resolve the Promise
Cause I’m watching video and it does the exact same thing
if you're doing something that requires threading I'd argue you're using the wrong language
You just have to fix the identation
my bot has between 5 and 10 threads, more then half is from the discord Library,
I meant in javascript obviously
my bad 😉
Ah. Alright. I mean, the alternative is making separate processes which is more of a chore to setup ipc than it is to just have a parent port visible to worker threads. I've definitely come into issues with audio encode when applying ffmpeg filters since exec sucks.
look into fluent-ffmpeg 
will check out
i wish u could make high prio threads 😛
isn't that up for user task delegation though
dunnow, dotnet has the 'background' flag on them
out of function
Can't you select which threads get used in a pool?
Actually, it wouldn't really make sense to include a high priority task in a pool
?
was a joke
I made keep_alive.py
I imported it
I ran keep_alive.keep_alive()
And it say that keep_alive has no attribute called keep_alive
Wyf
Guys, who can help me to make bot with Leveling, Music, YT and Twitch announcements, level rewards and website for it please dm me i am new in this and I really need help
ok
what's the pay
Really? Can you send me it?
Idk
its vb but the math is the same logarithm
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
What does VB mean?
Hi
Hi
You don't know?
ehh ..
No
I forgot what it means lmao
Lol
Visual Basic
visual basic... iguessss?
Yeah I think so
well i dont think the logarithm level code wont do any good 😛

Ok
Is it for GitHub?
this is a source yes
u can extract the formula and use it else where
in another language
Can I check my level by !rank with it?
well you need a way to add experience (a number) that comes from some mechanic
in my case, i have a chat stats bot that multiplies 0.5 * TotalWords
How do I add xp?
you have a user class, for instance with 3 fields. Experience, Level and Required
the experience is where you add the input points , then computeRequired(current) calculates the required experience to level up
if that condition is met, you can level up
And where do I place it?
Public Shared Sub LevelUp(p As Profile)
If (p.Level < Constants.LevelMax) Then
p.Exp = 0
p.Level += 1
p.Required = Words.Calculate(p.Level)
End If
End Sub
``` this would be the level up code
in my code that is
Cool
ehm if u dont know what to do with it ...
i think you need to do some more tutorials 😛
Maybe u can just tell me where to place it?
i gave you my codes, u cant just expect me to do all of it?
You don't just place it somewhere and expect it to work
Oh so that’s another code for lvl up?
I never did coding-
Oh ok
How do you make typescript ignore imports that contain .ts at the end? VSC is yelling at me for putting .ts at the end and Deno is yelling at me for NOT putting .ts at the end
i did and i got no proper results but ok
and also i already have deno extension installed but it doesnt work
sigh is it time to do @obtuse osprey-ignore on all my files
thanks discord for the ping
anyone mind reading over my libraries FAQ page? i would like the eyes of someone whos never really looked much into the project, if you can point out anything you'd ask that should be there please?
https://github.com/brainboxdotcc/DPP/wiki/Frequently-Asked-Questions
looks good
thanks, did I miss any important question?
I don't think so
Everything is fine except for some grammar mistakes
please let me know them and I'll fix 👍
np
hi weeb
go watch it
im in class
even better, tell your teacher you're learning japanese culture
does sqlite support aarch64
sqlite is a self-contained database
if your system support files then i guess it does support sqlite
nah bro, I don't think my science teacher will care that im watching anime
nobody ever said you should mention the word anime
just say you're also learning in a culture exchange program
cuz you plan to travel abroad in the future

exemplary student, working 2x as hard as the rest

why y'all talking weeb stuff in #development
yeah
in all honesty i was about to ask if there was a simplier way to do a sql call with multiple lines
as in, multiple inserts
usual format is usually (query, [])
there usually is, with transactions
INSERT INTO table (id, timestamp, foo, bar) VALUES ($1, $2, $3, $4), ($5, $6, $7), ($8, $9, $10)
for example
ok yes but are you using mysql2 or pgsql or better-sqlite3 or ... what
pg.query(`INSERT INTO table (id, timestamp, foo, bar) VALUES ($1, $2, $3, $4), ($5, $6, $7), ($8, $9, $10)`, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
Ah, pg. ok .
you pass 4 field but 3 args
timestamp is auto inserted
ah ok
Thing is it's going to be multiple queries
it doesnt need multiple queries
but those queries are going to be run within one batch
what i did works but its not good
oh wait, "append multiple values" I thought you meant write multiple rows. aight nevermind
the proper way would be to repeat() on the string and do [...array]
to destructure the array into the correct chunks
so [[1,2,3], [1,2,3], [2,3,4]] => [1,2,3], [1,2,3], [2,3,4]
and the query uses VALUES ($1), ($2), ($3)
adding only the ($NumberOfShards)
yall know a way to do something like that?
what's that?
be more specific
well clearly you made it white with html and css?
should look red normally
send ur code here

1 minute
@leaden iron bro when u got badge
cuz I have a bot
@umbral zealot hmm i want
u can't
WEll you can't get it.
@umbral zealot whyy
because of people that only wanted bots for the badge, like you. Go pay for nitro if you want a special badge.
I make bots not only i want badge
is that inside your longdesc?
you can't. Period
discord made it legacy
yes
so it's 101% impossible to get it
@lyric mountain
comedy
@leaden iron which is your bot?
@leaden iron why
remove the whole <doctype> and html and all that jazz. Keep only the <style> tag and its contents, along with your html. You should not be putting the entire html in here, as you're writing code that's already on a page
I have made
Bot music one
It is online
24/7
But How To Make it Go In Vc 24/7
oh sorry
is there a way to do Object.assign() but only merge properties present in the Source?
The fix for the error is in the error message
I'm guessing that's because the port's already in use? 😛
no
You should probably ask in #general
unless you want programmed love
const love = input || 0;
Defaults to 0
Oof
Development and developers should show me some love
let give em chance to change
Emotions are wack
You don't get free love. Do you have a programming-related question?
Am a programmer for United States
wow you work with us gov?
other way around 
const love = 0 || stdIn
Yes dear
oh yeah i forgot to mention i tried like 4 other ports
I have been a ghost staff for over 5 years together with USA support
Sounds like you're starting multiple instances so the first works and the second one fails because they're configured on the same port
yeah no I'm saying you're configuring the port once and using it twice
oh oh i see
it's starting twice is my theory
It's gotta be that, there is literally no other reason for all the ports to do the same thing. Something's starting it twice.
And you're seeking validation from some random people on discord?
@dusky mason run netstat in your terminal
should work on linux and windows afaik
either cmd/shell or linux prompt
check if it has the one you looking for
the same u trying to open with lavalink
that'll tell you the app using it
Not really dear# I Neva a wrong
the ports i was using is not on the netscan list
Start it, and when it gives you that error, run netscan again
then you should be able to run it on that port
ssh tunneling can mess with ports fyi
cuz it redirects port traffics
keep that in mind
yeah port 8080 still in use
i usually use that for my debuggers so i can run it locally
i
will
absolutely
fucking
slap you
isnt 8080 reserved?
8080 is the normal 80 port isnt it
they were using 2333 before, not sure why 8080 now
i mean
i use 8080 port too
you asked for
because it's easy to type
me to try other ports
no port 8080 is often used internally for webservers in development
it's not a reserved port in any way
oh i was just on stack and saw other people use 8080 for lavalink
nvm me then
i would still not recommend using it
its too much used
8080 is for proxy iirc
its too much unecessary traffic passing through them
2333 in use
it should be really simple tho
I don't see any other way
java -jar lavalink.jar
thats all
of course, make sure ur in the same dir
or point it to an absolute path
fuser -n tcp -k 2333
java -jar lavalink.jar

yeah thats what im using
why not use the default yml file with it?
yml?
yes
i use it
actually
just run what i sent
he didn't refer to my msg
oh
With my API and webhook for votes as you know it returns the api, but when I use other parts of my api for example user/:userID sometimes it give me the GuildMember object and let me@use their username and others it won’t, is there anyway to fix this or actually make it more consistent
(i should've used reply)
so you just running it with java - jar lavalink?
yeah
messy context

just got this
honestly, as long as you use an uncommon port, you could just create a bash file with those two commands
that way you ensure the port is open
Hello, I am making a login/signup system, and I'm currently using cookies to store their username for usage around the site. Is there a better way of knowing who is signed in, and not need them to keep logging in for every new page the visit/leave? (nodejs)
<html>
<head>
<title>blynox</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Blynox</h1>
<p><h4>The new google</h4></p>
<button id="btn1">Like</button>
<script src="code.js"></script>
<p id="text">Click the button</p>
<script src="code.js"></script>
<button id="btn2">Color</button>
</body>
</html>```
my code
```js
document.getElementById("btn2").onclick = function() {
document.getElementById("text").style.color = "blue";
}```
help guys
code.js:5 Uncaught TypeError: Cannot set property 'onclick' of null
Wehre are you putting your code though
?
if that's your entire html file where's the javascript
nop
OH! wait it's the script tag, IS ee
ok
basically one of these is not like the other, and it's the one that fails 😛 ```html
<button id="btn1">Like</button>
<script src="code.js"></script>
<script src="code.js"></script>
<button id="btn2">Color</button>
@earnest phoenix why have you called the same script twice?
Good, though, you should absolutely delete the first one since you shouldn't run the same code twice 😛
kk
@earnest phoenix also, it'd be a good idea to keep ur script tags after the body element.
i did
Ok
pls how to randomize color here
here you can't
document.getElementById("btn2").onclick = function() {
document.getElementById("text").style.color = "blue"
}```
in that code, just use RGB format instead of names
?
#RRGGBB
will it works
try it and see
it'll only change color on button click tho
btw, #RRGGBB is not a valid hex
ok
just in case
idk if it'd work, but if you're able to use CSS colors there you could try rgb(R,G,B)
it'd be easier than using hex
kk
`rgb(${Math.floor(Math.random() * 256)}, ${Math.floor(Math.random() * 256)}, ${Math.floor(Math.random() * 256)})`
basically
oh, forgot about the byte way
show your code
document.getElementById("btn2").onclick = function() {
document.getElementById("text").style.color = Math.random() * 0xffffff
}
make it a string
and floor it
huh
?
were did i remove it
ok
make sure to use the correct radix
is there a way to do Object.assign() but only merge properties present in the Source?
like I have objects a and b
let a = {_1: 1, _2:2, _8: "three" };
let b = {_1:0, _2: 0, _3:0, _4: 0};
I want the result to be -
{_1: 1, _2: 2, _3: 0, _4:0}
i a and b have same property name. one of them will be replaced
I want it to retain the values of target i.e. a
if (prop in b) b[prop] = a[prop];```
Object.assign(b, a)
that would merge all data
yes
let me try this
I only want it to retain the keys present in b
but since you want to ignore B data if it exists in A, there's no reason not to use Object.assign()
not extra keys in a
I am asking for another way
there
ok let me check flaz
@old cliff
👍 thanks
thanks... I got that too
I just upgraded npm to latest version and now im getting this error
lmao
mmh yes jython
also how can I do it multi level? like object in object?
does anyone knows how to make a new server log? Like, when the bot joins or quit a server, he sends a message with info and etc about it.
And also a command with server list
(Js)
i just found that the custom emoji used on discord developer reference (https://discord.com/developers/docs/reference#message-formatting) is
from this server
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
just listen to event client.on("guildMemberAdd") or client.on('guildMemberRemove').
that's complicated
Quite a neet project although stuck with py 2
let intersection = arrA.filter(x => arrB.includes(x));
just found this on medium
would be shorter than that loop
why dont you just use a set
@earnest phoenix
nvm
angry noises
and then for example, to get the guild ID I do guild.id, and guild.memberCount for members?
Anyone who can help me with my python problem?
I have created an .env file to store tokens and keys. I use the following code to call the token:
client.run(os.getenv("TOKEN"))
But I keep getting the error
AttributeError: 'NoneType' object has no attribute 'strip'
Anyone familiar with this?
what loop
ig it's time to add the websocket shit to my lib and then i could publish v0.1.0
not guild.memberCount. it's guild.members.cache.size
are you using replit
Was using it, now I switched to a Linux VPS
see your vps' methods for reading .env
@waxen bough and how can I make the bot sending it to a specific chat?
well at that point you might as well read the docs https://discord.js.org
that one about object intersection, but idk if you can use .filter on objects
that's why I said "nvm"
but i will tell you it's message.channel.send("message")
im going to read discord docs for websocket gateway
Okay, I'll see what I can find
lol
I can probable use lodash merge for that
oof an extra module just for that?
@robust moth guys i think its a scam
lodash is useful though
can you tell some more uses?
ok, ty
You can do it with a recursive function
@waxen bough
client.on("guildMemberAdd", () => {
var content = `New server: ${guild.name}, ${guild.id}, with ${guild.members.cache.size} members.`;
var channel = client.guilds.cache
.get("774041271655333928") // Id do Servidor
.channels.cache.get("821474350619688970"); //Id do canal onde a mensagem será enviada
channel.send(content);
console.log("New server");
})```
// obj1 is your target
// obj2 is your source
function merge(obj1, obj2) {
for (const key in obj1) {
if (typeof obj2[key] === "object") obj1[key] = merge(obj1[key], obj2[key]);
else if (key in obj2) obj1[key] = obj2[key]
}
return obj1;
}
is the code ok?
You will have to do a little more checking to ensure that the property is really an object and not an array or something else
What.. so all the log will be in a specific channel in a specific server?
yes, that's what I wanted
a new server log on my server
so I know the servers my bot joins
.-.
well, I invited him to a server to test it but he didn't send the log
F
well if you just want to log your bot only then try adding if(member.user.id!==client.user.id) return;
wdym?
and also the member agument is not passed
adding this where?
all users will be logged there
above client.on?
.-. ok
client.on("guildMemberAdd",(member)=>{
const channel = client.guilds.cache.get("774041271655333928")
?.channels.cache.get("821474350619688970");
if (member.user.id!==client.user?.id) return;
channel.send(`New server: ${member.guild.name}, ${member.guild.id}, with ${member.guild.members.cache.size} members.`);
console.log("new server");
});
amazing
you check for cache
but not for channel
lel
const channel = undefined
undefined.send('New server...)
because it could return undefined and it could return error
read what i said, cuz it will still error
but it's asking declaration now
you also can directl get channels from client
instead of fetching guild
client.channels.cache.get()
your formatter be like```js
client . on ("guildMemberAdd", ( member ) => {
const channel = client . guilds . cache . get("774041271655333928")
?. channels . cache . get ("821474350619688970") ;
if ( member . user . id !== client . user ?. id ) return ;
channel . send ( `New server: ${ member . guild . name }, ${ member . guild . id }, with ${ member . guild . members . cache . size } members.` ) ;
console . log ("new server") ;
} ) ;```
this, i dont like this
please stop
i feel oppressed
but yeah i just don't do that anymore
pog
should this work?
client.on("guildMemberAdd",(member)=>{
const channel = client.guilds.cache.get("774041271655333928")
client.channels.cache.get("821474350619688970");
if (member.user.id!==client.user.id) return;
channel.send(`New server: ${member.guild.name}, ${member.guild.id}, with ${member.guild.members.cache.size} members.`);
console.log("new server");
});```
that was a little exaggerated though
i just installed eslinter
you don't need guilds.cache.get actually i forgot about that
client.on("guildMemberAdd",(member)=>{
const channel = client.channels.cache.get("821474350619688970");
if (member.user.id!==client.user.id) return;
channel.send(`New server: ${member.guild.name}, ${member.guild.id}, with ${member.guild.members.cache.size} members.`);
console.log("new server");
});
oops
i literally told you about that
,
you don't need guilds.cache.get actually i forgot about that
client.on("guildMemberAdd",(member)=>{
const channel = client.channels.cache.get("821474350619688970");
if (member.user.id!==client.user.id) return;
if (channel)channel.send(`New server: ${member.guild.name}, ${member.guild.id}, with ${member.guild.members.cache.size} members.`);
console.log("new server");
});
haha yeah he pointed out
bot don't even go on whit that
i edited it is it okay now
ok
wdym
client.on("guildMemberAdd",(member)=>{
const channel = client.guilds.cache.get("774041271655333928")
if (member.user.id!==client.user.id) return;
//.get() can return undefined, check if there IS A CHANNEL before sending, otherwise undefined.send() is not a function;
channel?.send(`New server: ${member.guild.name}, ${member.guild.id}, with ${member.guild.members.cache.size} members.`);
console.log("new server");
});```
didnt work
bruh
guildMemberAdd is for new member joins
bruh
oh no! it's icrawl's birthday!
guildCreate is the event for new guilds
ok

oh mann. i'm sorry this is my fault
client.on("guildCreate",(guild)=>{
const channel=client.guilds.cache.get("774041271655333928");
if (member.user.id!==client.user.id) return;
channel?.send(`New server: ${guild.name}, ${guild.id}, with ${guild.members.cache.size} members.`);
console.log("new server");
});
ok
ReferenceError: guild is not defined
at Client.<anonymous> (/home/runner/BulbaBot/index.js:83:43)
at Client.emit (events.js:314:20)
at Client.EventEmitter.emit (domain.js:483:12)
at GuildMemberRemoveAction.handle (/home/runner/BulbaBot/node_modules/discord.js/src/client/actions/GuildMemberRemove.js:22:51)
at Object.module.exports [as GUILD_MEMBER_REMOVE] (/home/runner/BulbaBot/node_modules/discord.js/src/client/websocket/handlers/GUILD_MEMBER_REMOVE.js:4:36)
at WebSocketManager.handlePacket (/home/runner/BulbaBot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
at WebSocketShard.onPacket (/home/runner/BulbaBot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
at WebSocketShard.onMessage (/home/runner/BulbaBot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
at WebSocket.onMessage (/home/runner/BulbaBot/node_modules/ws/lib/event-target.js:132:16)
at WebSocket.emit (events.js:314:20)
client.on("guildCreate",(guild)=>{
const channel=client.guilds.cache.get("774041271655333928");
if (member.user.id!==client.user.id) return;
channel?.send(`New server: ${guild.name}, ${guild.id}, with ${guild.members.cache.size} members.`).catch(console.log);
console.log("new server");
});```
or
```ts
client.on("guildCreate", async (guild)=>{
const channel=client.guilds.cache.get("774041271655333928");
if (member.user.id!==client.user.id) return;
await channel?.send(`New server: ${guild.name}, ${guild.id}, with ${guild.members.cache.size} members.`).catch(console.log);
console.log("new server");
});```
what in the
which one
read the word in between the 2 snippets
? is conditional chain
it's short for if (channel)channel.send
this is giving error in my code
but discord.js already changed their requirement for d.js to use node 14 or higher
bruh
ok
it says right there
node 14 or higher
probably not the error. i see it's 83:43 is this the code node referring to
The ?. operator functions similarly to the
. chaining operator, except that instead of causing an error if a
reference is nullish (null or
undefined), the expression short-circuits with a return value of
undefined.
node 14, like i said
if you running d.js, you are on 14+
fuck messed up again
client.on("guildCreate", (guild)=>{
const channel=client.channels.cache.get("774041271655333928");
if (member.user.id!==client.user.id) return;
channel?.send(`New server: ${guild.name}, ${guild.id}, with ${guild.members.cache.size} members.`).catch(console.log);
console.log("new server");
});
i put client.guilds instead of client.channels
damn this is imbarrasing rn
how to install it
i think you already have node 0.14 or above. unless you are met with the warning message unsupported engine node 0.1x.x
bruh
@median moss open cmd and run node --version
then why I cant use it
what did it say
--version said as unexpected identifier
but when I open it it says Welcome to Node.js version 14.60
v14.16.0
then its supported
wtf
i edited it because i messed up
can I see which line did you put this code on index.js?
oh boy
channel?.send don't work
oof
and you can't do anything afaik
but is there any other way to do this?
anyone used double counter bot?
ok
@opal plank (node:1557) UnhandledPromiseRejectionWarning: ReferenceError: member is not defined
(node:1557) 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:1557) [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.
i have never used it
remove the if (member.user.id!==client.user.id) return;
ok
now no error, console log, but didn't send the message I wanted
did you re-invite the bot again?
yes
bruh
I tried adding to another server
but didn't work thought
the arguments are right
client.on("guildCreate", (guild)=>{
const channel=client.channels.cache.get("774041271655333928");
if(channel) channel.send()(`New server: ${guild.name}, ${guild.id}, with ${guild.members.cache.size} members.`).catch(console.log);
console.log("New server");
});```
bruh
wait why is it send()(
did you add client.login() somewhere in your code?
that's the problem
i assume in the end of your code. client.login("your-secret-token"). You need to login with your bot's token
oooo
And also you didn't notice your bot was offline?
I have this
he is on
I thought you were talking about putting on this code we are trying to do
client.login(process.env.TOKEN);
you saw a green dot on its avatar?
he is on bruh
I have him for like 5 months
lmao
that's one way to get a bot token alright
yeah, so that's not the problem
what do i need to do so the "Test Message From test.txt" shows
const Discord = require("discord.js");
const test = require('../txt/test.txt');
exports.run = async (client, message, args, utils) => {
message.channel.send(`${message.author.username} Heres Test.txt ${test}`)
}
the txt
["Test Message From Test.txt"]
client.on("guildCreate", (guild)=>{
const channel=client.channels.cache.get("774041271655333928");
if(channel) channel.send(`New server: ${guild.name}, ${guild.id}, with ${guild.members.cache.size} members.`).catch(console.log);
console.log("New server");
});```
if that was triggered then it should at least write "New server" in your log
he did it
ohh?
oh
hahaha
it should work now this time.
821474350619688970 this the id?
Anyone know how I can call a json value using a variable?
Like:
let name = "me";
console.log(json.name);
It doesn't work though.
json[name]
Ah ok
called when the send() throws error
thanks
ahaha just the id \
thanks <@&330168063729074177>
bruh
@waxen bough
why do I keep pinging wrong person
i'm sorry if it took ages to solve it. I'm just tired rn I'm gonna sleep after this. I was just waiting for your code to work
what is the key for removing bot
dont worry mate
Umm-
yes
ok, thx
so the website css is just loading half of the background
a month ago it loaded it entirely but seems like the site updated and now it just shows half of it
ive tried some stuff but got no idea what it is
anyona knows what could it be?
are you sure if the background is actually the size of the full page
if not, then try enabling bg-repeat
background-repeat: repeat-y;
Anyone know how I can push an array into a json file?
Here's what I have:
index.js:
const userdb = require("./userdb.json");
let email = req.body.email;
let username = req.body.username;
let password = req.body.password;
let userarray = {
email: {
u: username,
p: password,
v: 0
}
};
await userdb.push(userarray);
await fs.writeFile("userdb.json", JSON.stringify(userdb), function(err) {
if (err) throw err;
});
userdb.json:
{
"email@gmail.com": {
"u": "email",
"p": "password",
"v": 0
}
}
ok
@pale vessel I changed it to this, but now it says Unexpected token o in JSON at position 1.
index.js:
const userdb = require("./userdb.json");
let email = req.body.email;
let username = req.body.username;
let password = req.body.password;
let userarray = {
email: {
u: username,
p: password,
v: 0
}
};
JSON.parse(userdb).push(userarray);
fs.writeFile("userdb.json", JSON.stringify(userdb), function(err) {
if (err) throw err;
});
userdb.json:
{
"email@gmail.com": {
"u": "email",
"p": "password",
"v": 0
}
}
const discord = require("discord.js");
module.exports = {
name: "ban",
category: "moderation",
description: "Ban anyone with one shot whithout knowing anyone xD",
usage: "ban <@user> <reason>",
run: async (client, message, args) => {
if(!message.member.hasPermission("BAN_MEMBERS")) {
return message.channel.send(`**${message.author.username}**, You do not have perms to ban someone`)
}
if(!message.guild.me.hasPermission("BAN_MEMBERS")) {
return message.channel.send(`**${message.author.username}**, I am do not have perms to ban someone`)
}
const target = message.mentions.members.first();
if(!target) {
return message.channel.send(`**${message.author.username}**, Please mention the person who you want to ban.`)
}
if(target.id === message.author.id) {
return message.channel.send(`**${message.author.username}**, You can not ban yourself!`)
}
if(!args[1]) {
return message.channel.send(**${message.author.username}**, Please Give Reason To ban Member)
}
let embed = new discord.MessageEmbed()
.setTitle("Action : Ban")
.setDescription(`Banned ${target} (${target.id})`)
.setColor("#ff2050")
.setThumbnail(target.avatarURL)
.setFooter(`Banned by ${message.author.tag}`);
message.channel.send(embed)
target.ban(args[1])
}
}
My bot can't ban members
What flazepe meant was, instead of storing an object in the json, store an array
Huh? You mean to transfer the contents of the json file to an array, then rewrite the json file with the modified array?
Instead of
{
"email@gmail.com": {
"u": "email",
"p": "password",
"v": 0
}
}
do
[
{
"u": "email",
"p": "password",
"v": 0
}
]
sorry i sent wrong
ah ok
wait
but then how would we know what email has what password, username, and such
Array#find
I'd like the end result to look something like this:
{
"email@gmail.com": {
"u": "username",
"p": "password",
"v": 0
},
"diffemail@gmail.com": {
"u": "username",
"p": "password",
"v": 0
}
}
If you want to stick to objects then just do dbObj[user.email] = user
ah, but is it not possible to keep it as i did?
it is, if you want to stick to the format you sent, add objects like this: dbObj[user.email] = user
ok
Lol
they get outdated pretty fast
For JS, there's An Idiot's Guide https://anidiots.guide/getting-started/getting-started-long-version
iam using ban commands and san I get an error
Any advice here?
try to fix your way of asking things
What am I supposed to say to somebody asking for advice without any context
I have this
It's message.channel
repeatchannel is defined as message
@client.command()
async def buy(ctx,item,amount = 1):
await open_account(ctx.author)
res = await buy_this(ctx.author,item,amount)
if not res[0]:
if res[1]==1:
await ctx.send("That object isn't there!")
return
if res[1]==2:
await ctx.send(f"You don't have enough money in your wallet to buy that! {amount}")
return
await ctx.send(f"You just bought {amount} {item}")
async def buy_this(user,item_name,amount):
item_name = item_name.lower()
name_ = None
for item in lvlshop:
name = item["name"].lower()
if name == item_name:
name_ = name
price = item["price"]
break
if name_ == None:
return [False,1]
cost = price*amount
users = await get_economy_data()
bal = await update_economy(user)
if bal[0]<cost:
return [False,2]
try:
index = 0
t = None
for thing in users[str(user.id)]["level"]:
n = thing["item"]
if n == item_name:
old_amt = thing["amount"]
new_amt = old_amt + amount
users[str(user.id)]["level"][index]["amount"] = new_amt
break
index+=1
if t == None:
obj = {"item":item_name , "amount" : amount}
users[str(user.id)]["level"].append(obj)
except:
obj = {"item":item_name , "amount" : amount}
users[str(user.id)]["level"] = [obj]
with open("economy.json","w") as f:
json.dump(users,f)
await update_economy(user,cost*-1,"wallet")
return[True,"Worked"]
yeah
not message.repeatchannel
Thee fields on the level card with 1 should not be there
show your new code
I have %work gets money then you can %buy levels
They are displaying incorrectly
how should they display?
do you know how deconstructing an object works?
Then why are you attempting to use it?
I just want the top 2 to go up un number each level they buy
alr I get it
now
show where you make the embed
you're storing them somewhere, if you don't want the 3 bottom rows showing then remove them from wherever you're storing them
you don't have to deconstruct the message object in order to get the channel
brb
@client.command()
async def level(ctx):
await open_account(ctx.author)
user = ctx.author
users = await get_economy_data()
try:
level = users[str(user.id)]["level"]
except:
level = []
em = discord.Embed(title = f"{ctx.author.name}'s Level",color = discord.Color.blue())
for item in level:
name = item["item"]
amount = item["amount"]
em.add_field(name = name, value = amount)
await ctx.send(embed = em)
message is your message object:
const myChannel = message.channel; // Same as above, without deconstructing, variable name can be whatever
so you don't want the last 3 showing right?
No I dont
then don't store them
literally where you define level
get_economy_data
when you buy a new level
don't store the basic ones
Should I make a new json?
I'm not too sure what you're trying to do here
no, just don't store them
sorry if I'm not making too much sense
Its ok its me I think
I'm a school and can't quite think right
whatever you do inside the get_economy function










