#development
1 messages Β· Page 1750 of 1
so u use ts-node to make bots
https://www.typescriptlang.org/tsconfig/#paths you can read more here
From allowJs to useDefineForClassFields the TSConfig reference includes information about all of the active compiler flags setting up a TypeScript project.
i do
i dislike having to compile it everything with tsc
how can i make it work with require-all package
i would need to check what require-all even is
it requires all the packages in a directory.
No way, in prod too?
correct
bruh
why would you need that?
the difference i get is about 500ms in difference
its completely irrevelant for me
and it only affects startup
I'm requiring all the files in the commands folder, and making a map of it, assigning it to client.commands
why not do it the normal way instead of breaking your whole dev configs in favor of a single package?
for (let file of fs.scanDir('/cmds').filter(name => name.endsWith('.ts'))) client.commands.set(require('./cmds' + file).name, require('./cmds' + file));
this is gross, but its one line
also, since you are using typescript, i'd recommend using detritus for your library
this is all you would need to scan ur commands folder with detritus
I've used, commando. Now making a new bot for slash commands
commando is an insult to be compared with detritus
would definitively recommend using detritus if you starting a new bot tho
ok, then I hv to chekc it then
inline:false
name:'PROGRESS'
value:'**Level**: 53 (19.74%)\n**XP**: 69,320/351,125\n**Area**: 7 (Max: 7)\n**Time travels**: 2'```
how do i get all the contents that comes after the word: Time travels?
With regex or other, how do you check if a message contains an url (and not just https: // but a real clickable link)
thx
string.slice(-1, (string.toLowerCase().indexOf('time travels'))
If you're using Node.js, I think the url module should be suitable.
What language are you using?
You'll want to use tasks.
https://discordpy.readthedocs.io/en/latest/ext/tasks/index.html
ok thnx
erwin, ts-node will start the bot, how do I restart it on file changes, do I hv to use nodemon for that?
I donβt understand a lot of this package doc lol
why do you need to restart on file changes?
so, I could test the changes i hv made, instantly
again, why do you NEED file cahnges?
the code will get compiled either way, and you already using ts-node
so, i dont see the point of needing to use nodemon here at all
it seems you only using nodemon to keep the app alive
i've sent u my vsc config exactly so you can recompile it easily
,
You can probably find articles and guides on using the module. The point of the module is to represent a URL programmatically (as opposed to having a regular string). To construct a URL: https://nodejs.org/dist/latest-v14.x/docs/api/url.html#url_the_whatwg_url_api
I dont want rerun the dev script, everytime I make changes.
nodemon could do that for me, if it sees changes in the files
what it does is exactly what i said, but automatically
recompiles and re-runs it
can be annoying specially when you save stuff and it restarts the bot without you intending to
aslo, you should use a debugger with vsc attached to the node for proper testing/development environments
aka, press f5 while in vsc
Hmm i tried it and logged the intents but it returned me [object undefined]: js const heyhey = toString(m.embeds[0].fields[0].value.slice(-1, indexOf(m.embeds[0].fields[0].value.toLowerCase().indexOf('Time travels'))))
so can we make node . also to recompile itself when it sees changes
i edited the thing a long time ago, also check what it does before simply blindly copying code
dunno why you would need that
hey
if(response.includes())```how do i check if it contains a number between 2-19?
yeah i saw that in the docs already! Thanks!
I'll just one thing, it's not very nice you call a video shit. Nothing more.
that won't work
as response is a string
and i just read in the docs that it is only for arrrays
Ah, that
You can use regex
I haven't watched the video myself so really I didn't call it shit for its quality or anything. I'm simply used to using the word itself often, that's all
@eternal osprey
Software rot is the grim reaper to programmers.
string.match(/\d+/g)?.some(n => ...)
Maybe there's a way to check if there's a number between a range via regex... not sure
@eternal osprey if the string only features a number and nothing else, you can use parseInt(..., 10) to convert the string to a number.
Has anyone here worked with Pypy and its compatibility with CPython?
Wanted to try it, but I need walrus so bad, so haven't tried it 
you're lacking a package-lock.json
im using yarn, soooooo......
return message.channel.send(
"Only server owner can perform this action"
)```
i dont have ownership but command is still working
you put it in the right place?
yeah
if (args[0] === "create") {
if(message.author.id !== message.guild.ownerID)
return message.channel.send(
"Only server owner can perform this action"
)
message.channel.send(new MessageEmbed()
.setTitle("Success")
.setColor("RED")
.setDescription(`Successfully **created backup** with the id \`${ID}\`\n**Usage**\`\`\`${prefix}backup load ${ID}\`\`\`\n\`\`\`${prefix}backup info ${ID}\`\`\``))
}```
hmm, try logging the IDs console.log(message.author.id, message.guild.ownerID);
return message.channel.send(
"Only server owner can perform this action"
)
console.log(message.author.id, message.guild.ownerID);```
π didnt logged anything
my guess, it may not be reaching the if(message.author.id !== message.guild.ownerID)
i want that command require ownership of the server
log it before that if condition
^
ok
Also that is not what I am saying, basically saying that arg[0] may not be equal to "create"
might be owner id is not cached, so you need to fetch it
Pretty sure you have to fetch the owner first. Not entirely sure.
if (args[0] === "create") {
console.log(message.author.id, message.guild.ownerID);
if(message.author.id !== message.guild.ownerID)
return message.channel.send(
"Only server owner can perform this action"
)```
still nothing
um
command = backup
args 0 = create/delete etc
what um? I dont understand
wait
if (command === "backup") {
if (!args[0]) {
message.channel.send(
new MessageEmbed()
.setColor("BLUE")
.setAuthor(
message.author.username,
message.author.displayAvatarURL({ dynamic: true })
)
.setTitle("Commands")
.setDescription(
`something stuff etc`
)
);
return;
}
if (args[0] === "create") {
if(message.author.id !== message.guild.ownerID)
return message.channel.send(
"Only server owner can perform this action"
)
message.channel.send(new MessageEmbed()
.setTitle("Success")
.setColor("RED")
.setDescription(`Successfully **created backup** with the id \`${ID}\`\n**Usage**\`\`\`${prefix}backup load ${ID}\`\`\`\n\`\`\`${prefix}backup info ${ID}\`\`\``))
}```
@prime glacier you have to fetch the server owner first. message.guild.members.fetch(message.guild.ownerID) <- something more like that
fetch return a promise too
^^
um like
if(message.guild.members.fetch(message.guild.ownerID))
return message.channel.send(
"Only server owner can perform this action"
)
?
oh
no
fetch the owner id, then check if the user that is typing the command matches the id
okie
if(message.author.id !== owner)
return message.channel.send(
"Only server owner can perform this action"
)```
@prime glacier@wheat mesathe heck you both going on about?
guild.ownerId is already there
not cached
why you fetching the owner just to gte the ID you ALRADY have
so it null
guild.ownerId is already there tho
wait what?
Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
message.guild.members.fetch(message.guild.ownerID)
console.log(message.guild.ownerID)
``` Outputs the ID of the owners, but ```js
console.log(message.guild.ownerID)
``` Outputs `undefined`
Β―_(γ)_/Β―
Still no need to fetch if you already have it
let d
let timeout2 = 86400000
if(daily !== null && timeout2 - (Date.now() - daily) > 0){
let time2 = ms(timeout2 - (Date.now() - daily));
d = `:alarm_clock: | \`Daily\` (${time2.hours}h ${time2.minutes}m ${time2.seconds}s)`
} else if (daily === null && timeout2 - (Date.now() - daily) < 0) {
d = ":white_check_mark: | `Daily`"
}```
I have used quick.db cuz I made the whole bot using it and dont wanna change it (too lazy) so the problem is.. it is showing undefined... I defined them rlly nicely but still
If you don't have it it won't work
https://pastebin.com/YK2FHXeq
I'M having a start error
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.
thats what i dont get, they are fetching the member to get his id?
like, whats the point?
guild already has the id
how can i solve this error?
also wtf is this
how do you even FETCH the owner if u dont have their id?
Nevermind, it's outputting correctly now
Yeah lmao
Everyone makes mistakes lol
My bot kept logging it as undefined when I tested it
Ummm
thats all u need @prime glacier
then it worked when I cached it
Β―_(γ)_/Β―
Now it's working without caching it
odd
probably did a typo
probably
the thing i did was
if(message.author.id !== message.guild.ownerID)
return message.channel.send(
"Only server owner can perform this action"
)``` but it acutally work without ownership π
that looks right
but π¦ idk why its working
Looks like your using broadcastEval on something null.
but you said its working
probably a null shard
ahh its working but i dont have ownership
maybe they're not sharding
I'm trying to view the 'shard'
what about the rest of the code? also, did u restart ut bot and saved the changes?
I've got some problemos with chakra ui
I tried to use Text inside a MenuItem with the align="right" prop but it still renders on the left side:
<MenuList>
{hist.map(h => (<MenuItem m="5px">
<Text
fontSize="xl"
align="right"
fontFamily="Fira Code">{h}</Text>
</MenuItem>))}
</MenuList>
(hist is an array of strings)
https://cdn.discordapp.com/attachments/660865137137156146/843154935969218600/unknown.png
Hmm... so let's say I have the string "\n" in javascript, is there a function which I can use to escape all the special characters? So it would become \\n
yeah
hi anyone know how to reload a json file? (into discord.js)
String.raw`string`;
Try logging your boolean values before the if statements
wait a sec π
You can also use parenthesis if you hate tagged functions
Error: val is not a non-empty string or a valid number. val=undefined
nice better discord
@opal plank What's the difference between Extract and Pick?
Doesn't work
in which context?
TS
tsconfig?
Try paranthesis
Types which are globally included in TypeScript
why not just do a simple regex replace
hmmm i rarely use those, so i dont really know
it is escaping correctly in the second one
most of the times i use classes to protect stuff
seems to work
it worked

hi anyone know how to reload a json file? (into discord.js)
im starting to see a pattern here
i write code
2 weeks later, i review my old code and curse myself for writing whatever the fuck that is
rinse and repeat
π yeah very common with me too. But I like rewriting code so no harm
Same bro
well yeah, me too, but sometimes i just look at it and think wtf dude, why u wrote this shit?
pun intended?
Itβs harder to read code than to write it.
probably
why you wrote this shit with two backticks
Ugh this is annoying
i legit wrote this 2 weeks ago ```ts
\`\`\text`\`\`\text2`\`\`\
it doesn't display as a code block on mobile
I need JS to understand the "\n" string literally... ok wh-
what a nice time to use eval
eval(`String.raw\`${string}\``);
\ is an escape character
\n in a string doesn't actually mean that the literal characters \ and n are in the string
yeah
I think this is a good read (even if it's not exactly your case). https://www.joelonsoftware.com/2000/04/06/things-you-should-never-do-part-i/
so why are you looking for a backslash when there isn't one in a string
The static String.raw() method
is a tag function of template literals.
This is similar to the r prefix in Python, or the @
prefix in C# for string literals. (But it is not identical; see explanations
in this issue.)
It's used to get the raw string form of template literals, that is, substitutions (e.g.
${foo}) are process...
okay yeah but my string is in a variable
a parameter to be specific, and I need to know the length of the returned value of String.raw, and I don't want the person who uses the function to pass the string and it's length...
in tsconfig, i hv set a rootDir to "src", but ihv some ts files in another folder, which I dont want to be included.
so vsc is complaining, that, these files are not included in rootDirs
There's an exclude option in tsconfig
pass the directory you want ts to ignore
try running this in the console
let string = `bruh\nbruh`;
console.log(string);
let string2 = String.raw`${string}`;
console.log(string2);
aeon is having a stroke running that
oh wait found the error on line 3
Feud, can u ans this
abstract class X {
abstract fn(a: number) : number
}
ah wait you don't want to redeclare the parameters? Nope you cannot do that
class Y extends X {
fn(a: number) { // Here can I avoid giving the type again. As I've already given it abstract method
}
}
well, actually maybe the snippet above will do it, haven't used abstract classes myself
I have a doubt to change the background of my bot's page with a picture where do I have to insert css?
select the element in css, give property
selector {
backgroud: url(your_url);
}
Thanks for the answer but my doubt was where exactly to put this in ?
In the long description section?
yes, inside the style tag
ooh thanks I am bit weak in css is it <style></style> right?
yes that too.
u can also make a new css file, and link that to ur html file
so u hv html and css separated
seems to be the same error as the last error you asked for help with. just what your doing is different.
this time i used a different code
yes, but its the same issue
are you using a sharding manager?
https://discord.js.org/#/docs/main/stable/class/Client?scrollTo=shard
client.shard is null if your not sharding
stuff like fetchclientValues and broadcastEval is one shard communicating with other shards, if you dont have multiple shards, they dont work.
I want help
you can only get help if you pay a fee, which is telling us help with what
you can only make a blue invite in the fields or description
learn more about markdown
Like add me
How to insert link inside the word
Learn about markdown
[title](url)
oh
can you show what you used
I actually did a different approach
I check for a specific word in the string
after that I could remove all the intents from the args
Can anyone tell me which dimension's photo will be ok to replace as the background in the bots page?
If anyone uses Python's apscheduler, which persistent job store do you recommend?
I did not recive a dm from Luca :<
What method should I use for managing temporary mutes
Do I make a thread and make it wait out the time there (might get messed up when its terminated) or do I make it constantly check the time and see if anyones time is up yet
The first one can get messed up a lot for long temporary mutes
rule of thumb is, if something:
A - needs to work regardless of restarts OR
B - needs to be used after a long period of time
you use a db
setInterval/setTimeout are really meant for short-lived tasks only
save timestring / timeinteger in a db and load setTimeouts every the the bot restarts
use redis and use the ttl field, and listen to events send from redis, will tell you when the time is over
'-'
wait what if i just make a thread that waits and if anything goes wrong i just store the time in a database and each time the bot restarts it checks if there is any unfinished buisness?
that's what I do actually
don't use waiting threads
JS is not the brightest thread-user already, plus making one per muted user will kill your bot quite quickly
I don't load threads that are like more than an hour away (Cuz the bot'll load them again in an hour)
still
i prefer to use redis, i can store there the muted users and it will send a event call if a ttl runs out, it also tells me what dataset runs out, makes it easy to manage, also you dont have to run timeouts
just do a simple timestamp check
create a loop that checks timestamp every X minutes
So like A whole database get request per minute ?
if users mute start + length is smaller than current timestamp just unmute
A Whole database ?
that's like 1 request every X mins
yea reasonable, have a nice day
my friend said its bad cuz if 10 people are muted in 100 servers u have 1000 threads
Can bots have a rpc?
no
also remember JS technically does everything in main thread
am using java
sarcastic?
no sarcasm
lies
my friend teached me how to make bots with java
so im still using it
and everyone hates me for it
no joke, like, java is the threading boy
my friend always complains about threading problems they've had developing a music bot
but don't get discouraged because some person online told you not to use it
usually they're only looking at certain surfaces
You should experience it for yourself and make the decision
like, I'm a java programmer too
python and js stand no chance when it comes to threading
js can use worker threads, as some sort of multi threading
but its not as well integrated as in other languages
that's more node-central
ah
also wher can i get the discord reddit thing
didn't know that
Question: An API I'm working with returns data like this data -> id -> stuff
Would JS have a way to let me get the ID so I can store it for use later?
https://scs.twilightgamez.net/AdGn3.png
We're not mee6 support my dude.
data[...]? I'm confused on your requirements.
It's just how it returns the info 
I just want the ID part so I can use it via a URL for an image.
I play playing with Object.keys / entries actually.
Likely the solution but figured I'd ask.
If you mean by the ID being dynamic so you can't just access it like normal, Object.keys like fued said
hey hey, question about anyone who has ever worked and/or is currently working with backups on multiple servers:
So we had a recent case with an ex-developer implementing a backdoor into our system, which was not allowed as stated on their NDA, but that's a different story.
This ex-dev started deleting random files for the past week or so, without us realizing. Due to us not realizing it and us not actively making backups (which was definitely a dumb idea lmao), we lost a large portion of our files, mostly minor ones, yet partially important.
So we're thinking about using off-site backups using multiple backup servers from contabo, especially their Big SSD options, and I'm kinda thinking about getting the vps seen in the screenshot. To note, this will PURELY be used for storing backups for up/downloading.
So I generally need past experiences from users on contabo, aswell as experiences from users who either used backup servers and/or are still actively doing so. (also possibly other hosts that might be interesting)
Thanks
wouldnt something like s3 archival make more sense?
as a vps doesnt nativly have file locking and versioning and all that.
if your fighting rouge people deleting stuff, a lot of these systems can make it so not even you can delete files which are absolutely needed.
you mean the s3 vom aws? Can take a look at it 
Has anyone played around with or used a time-series database (if so, what was your use case)?
I had looked into it once, not really used any though other than stuff for like graphana.
guild.channels.cache.map((ch) => {
if (ch.type === "category") {
categories.push(ch);
} else {
channels.push(ch);
}
});```
how to separate it like
categories separate
voice channels separate
text channels separate
just use filter lol
You want some grouping
though filtering would be O(3)
oh wait
Wouldn't it be more like O(n * 3)
That's still O(n) tho
sleepβ’οΈ
what do you mean π
discord.js has a partition method
which separates a collection based on a condition
The first snippet is exactly what partition does (but with a for loop)
Hi, I didn't get bot because of that code from top gg and now it's out of the code that I'm sending to top gg doesn't answer please what to do now π₯Ί
didn't got you to be honest
Confused.
That just checks when your bot joins a guild/server and leaves if it's under 500 members
I think that top.gg declined their bot because of that
the bot left the test server right away
oh lol
but that's just an assumption
I didn't know it contained Pau Code
If that is the reason, either whitelist the test server, set a deadline before leaving, or (recommended solution) don't gatekeep your bot from joining servers solely because of the member count.
dafuq
most servers your bot will be invited to will have less than 500 users anyway
My boot is taken from top gg and I don't want any more π
here, you can have it back π’
What the
thats what a boot means lol
why would you take his boot π’
no
greennames are cobblers (boot developers)
One message removed from a suspended account.
You know shit got real when you have to measure the speed of your parser in nanoseconds

parser or compiler?
just parser
compilers suck at speed
A?: fn(func: (a: a, b: b)) {
let a = [1, 2, 3, 4, 5, 6, 7];
for i in 0..100 {
print(i);
}
},
b: g
}
324000 nanoseconds to get that ^ parsed - I actually don't know if that's a good thing or no
what lang is that
Parsed a 200-line string in 2ms
My 2 favs
Rust is my fav because deno runs supa fast because of that
I mean... Deno uses V8, which is written in C++
Only the std is written in rust afaik
The std is a repo of typescript modules that bring node features to deno
It has absolutely nothing to do with rust
then what IS written in Rust?
The internals
lmao
The runtime
CLI, core, runtime, etc.
Does anyone knows a good Dark++ them of vs code for sublime text?
The Dark++ theme of vs code
Is it similar to Dark++ ?
searching this kind of sublime theme
you know you could use template literal strings for that, right?
where do I get them?
we are talking about themes, not about the code lol
what does discord developer licens let u do?
One message removed from a suspended account.
???
One message removed from a suspended account.
How do people play it?
btw found one, it is named sublime-vscode-plus
One message removed from a suspended account.
wow
One message removed from a suspended account.
One message removed from a suspended account.
so yes..
One message removed from a suspended account.
One message removed from a suspended account.
you can invite peoples, public
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
o well how do I play them? I dont have them..
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
Where?
One message removed from a suspended account.
One message removed from a suspended account.
@quaint wasp Buy one from the game's discord server
One message removed from a suspended account.
One message removed from a suspended account.
People with the license can put store channels on their server
ummmm u should do it in dms next time..
One message removed from a suspended account.
how can i do that there will be 2 prefixes?
const prefix = ['e!', 'E!']?
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
what command handler do you use
One message removed from a suspended account.
why
i mean, your example of two prefixes can be one.
when you check the prefix normally, just make it lower case, and tolowercase the input.
that will allow e! and E!
and what if i use cases
Which addon is a good code formatter for vs code?
you can use the built in one kekw
you came up with idea to use ones, I alread use alt+shift+f lol
could use prettier
for discord.py, does client.get_user() get rate-limited?
ok thanks
if it isn't async then it's just a cache lookup
discord py also handles ratelimiting
yeah just cache
thanks
const prefix = 'e!'
if(!message.content.startsWith(prefix)){return}
how can i make that even if its E! and not e! it will work as a prefix?
i did and it did not work
hey
client.on("presenceUpdate", (oldPresence, newPresence) => {
const leguild = client.guilds.get("839892155891318854");
const rolemdrr = leguild.roles.cache.find(role => role.id === "839894783928696893");
if (newPresence.activities[0] && newPresence.activities[0].state.includes(".gg/candys")) {
newPresence.member.roles.add(rolemdrr)
} else {
newPresence.member.roles.remove(rolemdrr)
}
});
hi
Did you enable intents?
i think i putted it in the wrong place, where should i put it?
You need to convert the content (message.content is the content of the message as a String) to lower case (.toLowerCase() on a string)
Then you can check if it .startsWith(prefix)
something like
if(!message.content.startsWith(prefix).toLowerCase()){return}
wait no it wont work
re-read what lite said
whats the point of using {} if you are keeping it in the same line?
yes
@sudden geyser its says: client.guilds.get is not a function
client.guilds.cache.get
oki I test
Anyone here use OVH?
client.on("presenceUpdate", (oldPresence, newPresence) => {
const leguild = client.guilds.cache.get("839892155891318854");
const rolemdrr = leguild.roles.cache.find(role => role.id === "839894783928696893");
if (newPresence.activities[0] && newPresence.activities[0].state.includes(".gg/candys")) {
newPresence.roles.add(rolemdrr)
} else {
newPresence.roles.remove(rolemdrr)
}
});
@earnest phoenix remove is undefined
Trying to open a port on OVH for the /dblwebhook, but their firewall settings don't exactly seem to be allowing it from the provider. I just need to open TCP 3000 right?
Well, the port I chose was 3000
Nvm - I'm an idiot
Is there anything simular to os time in java?
yep
k so i just /1000 and i get the second
k nice
wait what type does it return?
a string, int or long
long
cough been called bigint over here 
y'all know what else is long?
bigint and long is not the same thing in java
Anyone know how I could check if a string entered, for example, aakhilv.me, is a valid domain using nodejs?
If you'd like to verify its existence, you'd probably need to send a request to the site.
You can use the url to verify if a URL specified is valid (but not if it's accessible)
Ah, so something like this?
let fetch = require("node-fetch");
fetch("https://example.com")
.then(req => {
if (req) {
// Do something...
} else {
// Do something else...
};
});
I think it would error if it couldn't reach the site for some reason (.catch((err) => {...})).
ah ok, thx
you could use a library like tld-extract to check if the top level domain is valid
https://www.npmjs.com/package/tld-extract
I see, but I'd like to check if the domain is actually hosting content and being used, not if it's just a possible one.
Lite's answer works best I believe.
you could use that library as a pretest so you dont waste connections
css and html work together
they are totally different in how they are used but are essentially two halves of the same thing
html is the architect, css is the designer
What are those
scripting languages used in website development
im trying to make a command to grab system info on the bot like uptime and cpu usage any ideas?
(js)
uptime just store the starting millis when u boot up
then compare with current millis
cpu usage idk
what about cpu suage?
o oki
i've only found out how to log it to console
not in a message
wont work
how so?
then build the embed
saying its not defined
const Discord = require('discord.js');
const Discord = require('discord.js');
var os = require('os');
const osu = require('node-os-utils');
const cpu = osu.cpu
var osutils = require("os-utils");
module.exports = {
name: 'botinfo',
description: 'botinfo',
async execute(client, message, args, command) {
if(message.author.id === "411704274599542794" || message.author.id === "681276518051348509" || message.author.id === "308440976723148800" || message.author.id === "427103309199835138" || message.author.id === "826127445592768602" || message.author.id === "712797947699527711"){
var usedMemory = os.totalmem() -os.freemem(), totalMemory = os.totalmem();
var getpercentage =
((usedMemory/totalMemory) * 100).toFixed(2) + '%'
osutils.cpuUsage(function(v) {
console.log("CPU Usage (%) : " + v);
});
const embed = new Discord.MessageEmbed()
.setTitle(`${client.user.tag} INFO`)
.setColor(3447003)
.addField('Bot INFO Below', '\u200B' )
.addField("Server Count", `${client.guilds.cache.size +1} Servers`, true)
.addField("Total Member Count", `${client.guilds.cache.reduce((a, g) => a + g.memberCount, 0)} Users`, true)
.addField("Bot Latency", `${Date.now() - message.createdTimestamp}ms`, true)
.addField("API Latency", `${Math.round(client.ws.ping)}ms`, true)
.addField('System INFO Below', '\u200B' )
.addField("Used Ram", `${getpercentage}`, true)
.addField("Ram used in GB", `${(usedMemory/ Math.pow(1024, 3)).toFixed(2)}GB`, true)
.addField("Up Time", osutils.sysUptime() + `ms`)
.setTimestamp()
message.channel.send(embed);
}
}
}
how it gets cpiu usuage
osutils.cpuUsage(function(v) {
console.log("CPU Usage (%) : " + v);
});
now the error
1 sec
btw, thats one long if
?
u can see usage at top
and the bottom error is trying to send to embed
oki so
i feel really dumb
i fixed it
Bit late but use an array that has the author id's and check if the id is included in that array instead of doing all of those || statements
const Discord = require('discord.js');
module.exports = {
name: 'ping',
description: "this is a ping command!",
execute(message, args){
const msg = message.channel.send('Pinging...')
const client = new Discord.Client()
const embed = new Discord.MessageEmbed()
.setColor('RED')
.setTitle('Pong!')
.addFields(
{name: `Websocket heartbeat: `, value: `${client.ws.ping}ms.`},
{name: `Roundtrip latency: `, value: `${msg.createdTimestamp - message.createdTimestamp}ms.`}
)
.setTimestamp()
message.channel.send(embed)
}
}``` why doesn't this work
It says NaNms
Not a number
You shouldn't be reinstantiating the client.
wdym?
Your second issue is .send returns a promise
means const client = new Discord.Client() should not be here. you should only have one of those
You should get the client instance through message.client
also yes, await or resolve the send, that's a promise
so uh.
and resolve the promise returned by message.channel.send(...)
which says 'pinging...' right?
yes
alr.
If you don't understand "resolve the promise", see the following resources:
Guides to understand promises:
- Evie's written guide: https://js.evie.dev/promises
- MDN (promise): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
- MDN (async/await): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function
- Discord.js (async/await): https://discordjs.guide/#/additional-info/async-await
ok
you probably only need the mdn references
how do i get the original client instead of making a new client/
cuz i think that's the problem.
Like I said,
You should get the client instance through
message.client
ok.
message was defined as a parameter for your execute function.
I've found the mdn reference to be confusing since it starts with making a promise rather than using one, but it's all in how people actually learn and that's why there's 4 links in there π
let e1 = document.getElementById("serverevents");
let e2 = document.getElementById("botactions");
let e3 = document.getElementById("warnings");
let e4 = document.getElementById("jl");
e1.classList.remove("audit_log_selector_item_selected");
e2.classList.remove("audit_log_selector_item_selected");
e3.classList.remove("audit_log_selector_item_selected");
e4.classList.remove("audit_log_selector_item_selected");
s = document.getElementById(s);
s.classList.add("audit_log_selector_item_selected");```
any way i can do like a loop for this?
for (const id of ["serverevents", "botactions", "warnings"]) {
document.getElementById(id).classList.remove("audit_log_selector_item_selected");
}```
then stuff afterwards
I don't know where you're getting s for your assignment to s though.
${channel.createInvite({ temporary: false, reason: 'Command used.'})} ``` is this right? cuz it doesn't work.
That also returns a promise
Read the resources I linked earlier to understand promises.
It's okayβyou'll learn to use them through more reading and practice.
ok
Me: sends 25 minutes worth of reading
2 minutes later
Them: "I don't get it!"
What am I supposed to read anyway, right?!
So I have email through my web host, but when I route things through Cloudflare it's impossible to hide the origin IP for the email stuff because every time an email is sent the IP is included in the header, so I'm trying to find an alternative solution because I realize that I cannot have my email hosting from my web host because of this
only problem is that all involves spending money. Is it worth it? And does anyone with email on a custom domain have any suggestions as to how to go about this? I was just doing email things through my web host until I realized this was how it all works lol
I just need a new solution now cause I'm no longer comfortable with it now knowing this 
Turn on your DMs then. It's also possible it didn't send it - happens sometimes.
but you definitely did get a ping in #logs though, so, it's fine.
If you wanna host a serious mail service not being marked as spam by the recipient or being blacklisted by global listing services you will have to publish the mail servers IP address.
A valid RDNS record is also required not to issue the problems mentioned above.
As well as SPF, DKIM & DMARC are policies you have to setup to get trusted.
If thatβs nothing for you at all you can actually use global mail gateways by Amazon, Google etc.
I'm not trying to hide the mail server's IP, I just don't want it exposing my entire web server's IP as well.
And my DNS and all that other stuff are taken care of.
The problem is exposure of the web server IP, which is why I need an alternative to using my web hosting for email.
i.e. I just need another mail host or some other way to use my domain for email.
one question. If I publish my bot but it's not finished yet but it has enough things to publish, can it be published?
then update the bot frequently
If you mean submit it to Top.gg, as long as it follows all the guidelines then yes.
Well running the mail server and web server on the same machine is the issue in the first place.
Splitting them up on different (virtual) machines would be the way to go.
If thatβs nothing for you another easy way would be to buy a second IP address for you mr server, bind it to the network interface and let your web server listen to one and the mail server to the other only.
Exactly, that's what I just said.
And I can't just do an additional IP because GalaxyGate doesn't offer that for their web hosting services, only for VPSs.
Well thatβs unfortunate.
I guess you have no other choice than switching the provider or rent a separate server if thatβs necessary.
Splitting up your services like I explained above between IPv4 and IPv6 is also a bad choice due the lack of IPv6 support (still).
At least I donβt know a different way.
Another thing I don't understand is why a secondary IP would help because they both just point to the same server anyway
And if I'm incorrect about that in regards to web/email hosting, then it still holds true to using the same VPS, if I was to go that way instead
As someone who's worked for ISPs in the past : don't try to host your own SMTP server or send emails directly. You do not want to do that.
You said you donβt wanna expose the web servers IP.
Binding these services to two different IPs will end up in the same machine but itβs not possible for the client to detect that.
There are plenty of services for this. Sendgrid being one of them.
I did it before, stopped when my VPS shit itself
You literally just want to use something like sendgrid to send emails, that's it, problem solved.
I can use a different service to send?
well it's going to use an SMTP anyway, of course, but I do believe it's possible to hide the originating IP.
Like I said already or using mail gateways (which will still expose your IP)
I have 11 domains, I need a solution that wouldn't cost a fortune
checked out ProtonMail and it doesn't look like that would be super cost-efficient
I'll take another look at MailChimp and I'll check out SendGrid
I understand there's no way to hide the origin IP, it'll always be exposed, but I just want it to not be my web server lol
And if possible, I'd prefer to hide my own IP as well for when I'm using Outlook and such. Can that be done at all? @umbral zealot
No
Just to say you can even create an AOL email and use the SMTP authentication to send mails from any of your servers.
Which is possible by any (probably) mail provider.
Unless you use a vpn or proxy, obviously
Avoid sending emails at all if you're not on VPN and want to hide your IP.
I mean I'm able to send from RoundCube and only the server's IP is exposed
RoundCube is a mail client not a server
You're missing what I'm saying.
I know it's a client, I'm saying that it doesn't expose my IP, it exposes the server's IP.
The sending process has to follow the protocol
Unlike Outlook and other client apps which expose my IP.
Yeah
Simply test a few services by creating a script to send a test email changing the SMTP authentication credentials to see which one doesnβt
Ugh, why can't these services just be simple and tell me they'll just give me email hosting with custom domains
Gotta be obscure asf and oversimplify by saying "Custom Branding"
Sendgrid and mailchimp don't "host" emails
they just... send. it's marketing services.
See idk anything about that
It's meant to send and track emails
I just want mail hosting ;_;
lol
Making your own email server is fucking hell. don't do it. don't go there.
it's not worth it
Couldn't even manage to do it on Linux, Windows Server was much easier
Most server providers do offer webhosting packages with the ability to send mails using the providers services
Itβs actually not.
That's what I'm dealing with now, it's just that the mail exposes the same IP as the web server
There's no way to separate the two and there's no way for me to purchase another IP to begin with
They only offer that for VPS
Well then switch to a VM
Both web and mail server donβt consume much resources
An IP should be what.. $1 / month
I could just get a VPS exclusively for mail server 
I wonder why your web server needs to be a dedicated server
But then I'd have to look into figuring out how to host a mail server on Linux, again. Like I said, way easier on Windows
Wdym?
What type of server is your server?
Dedicated or VM
VM
Thereβs actually no VM, VPS, Cloud etc.
A server can only be a dedicated one or a virtual machine
I have a web hosting package for all my domains, and I have a VPS
The mail comes with the web hosting package, but it uses the same domain as the web shit itself, so it's impossible to hide the IP unless I use something else for mail
just to say
Look I understand this, a VPS is a VM, who cares whether you call it a VPS or not, it's a VPS
I don't get the big deal
That was not exclusively for you
Ah
Well I mean I have another idea
Why even go through effort to hide the IP at all?
Is it really necessary?
I donβt know.
You said you need it.
I mean yeah, I want my shit to be secure
Hmm just binding the services to different IPs is far away from being secure
God why would GG set it up like this, it makes it impossible for people who actually care about hiding the IP to actually do so and use all the features they're paying for
It's stupid as hell
A proper firewall setup on the machine as well as a dedicated firewall and the required network knowledge will help but will never make you safe
Thatβs how the net is
You know what I mean
I just don't want the web IP out there, makes Cloudflare entirely redundant
Well my first tip was to change the provider in the first place or to switch to another VM (VPS)
Going further supporting SSL for your mail service RDNS will also require a webserver listening to the FQDN
Anything else unsecured is worse then writing a letter by hand and throwing it on the street
Making your own email server is fucking hell. don't do it. don't go there.
Idk why she said that, idk what part about it is hell
Worked out fine for me on Windows
Pretty easy
Even if itβs not heβs a little bit right, too
She*
Well setting the service up is but anything around can get difficult
Y?
Because you haven't ensured that the channel type is one that actually has bulkDelete() @rocky hearth
DM's do not have it, for example.
I checked, if its not dmchannel
lol ts
Doesn't matter, you're working with the same property and the property type doesn't care whether you've already checked if it's a DM
The DMChannel type is included in the type of that property, regardless.
maybe they broke the types
You do realize they can update the types, yes?
Ive used that checks alot.
And?
ooh ok then
If they've changed the types, you have to adapt.
It's the way these updates usually go.
Every major update to Discord.js breaks something. It's been like that for ages.
@umbral zealot When you said that hosting your own mail server is hell, what did you mean exactly?
I mean, if you do eventually figure out how to run all the software required, configure all the systems, the routers, the domains, the records, you realise soon enough that you will be blocked left and right by providers because you're sending mails and they don't know who you are.
One spam report and you're blacklisted.
Itβs actually not that hard but not far away from the truth.
The mailserver will not setup your DNS records, will not configure your firewall, will not do auto backups etc.
My only issue with spam was because RDNS wasn't set up correctly, which I ended up fixing. Everything else was relatively straightforward
I know that lol.
I can set up my own DNS records and I know how firewall works.
hMailServer does have a backup mechanism though.
Only thing is it's for Windows
I know but no auto backup and itβs not meant to handle big database sizes.
That last part may be correct.
The auto-backup part is not.
The integrated backup is to restore your server on a different hmailserver setup not to do redundant backups with integration checks.
Doesnβt mean hmailserver is bad
Weβre moving far away from the original topic... I really need to sleep.
Just one thing...
If you switch to a VPS and wanna go on using hmailserver then choose a provider offering KVM access for the VPS as well as the possibility to install own OS images.
This will allow you to use Windows server without paying ridiculous license fees.
@untold token
I know this
But I have my own Windows Server licenses anyway
I'm not gonna do that
If I Structure a class, what is the proper way of define its extended types and methods? in ts
I'm just gonna point out that the proper wording is to "extend" a class using Structures.extend()
Because Structures is a class, not a method of some sort (i.e. it's a noun and not a verb)
That would be a #support question, but the answer is at least 2-3 weeks. @delicate shore
ok gotcha
Should be the same way as you would with defining any other class.
@boreal iron @umbral zealot So I spoke with my host and got a bit of a clearer answer that I can live with. The IP is pretty well DDoS protected so I can really just live with the added risk of emails exposing it without any huge consequences. I'm just gonna leave the rest of it going through Cloudflare because of the other benefits it provides. Thanks for discussing it with me you two 

No the new methods wont show up, in the instances provided by the library.
Like if I Structure the Message, and define a new method called, reactAllSync()
it wont show up, on the message event
@untold token
SO
I have this
In a JSON format
I need to go through each value and if it starts with command# do something with this
and I can't think about how for some reason
each value or key?
key
then read the value of each key after
so a for loop of the whole thing and inside check if it starts with command# and parse the second part of it if it does
and then do stuff in my db with those values
doesn't this format help u!
{
"command#" : {
"baby": true,
"back": false
}
}
for (const [key, value] of Object.entries(yourdata)) {
if(val === 'on') {
// do something
} else {
// something else
}
};
([key, val]) => ??
ah yes probably
he also want to check if key starts with command#
well they can add that to the condition
the skeleton is there, I'm not gonna write the entire thing for them, yeah?
Object.entries would be the JSON stringified body correct?
or would I pass a normal body?
Object.entries is an actual function
yourdata would be your object
as an object, not as a string, of course. PArsed, not stringified.
Not all classes can be extended that way lol
Only structures can, as implied by the Structures naming
Not all classes are structures
And if I remember correctly, Message is one of them.
Well shit. Message is an extendable structure.
Can you show the code you're trying to use? Also, you have to call Structures.extend before your Client is instantiated. @rocky hearth
all these classes can be exteded
Yes I know this, I checked, and corrected myself above
Again, please share your code
And/or do what I told you, which is to do it before instantiating the Client.
i need a little help
When I run this in console it works
But when I run it inside the validateselect() function it doesn't
^
alr so
i have some commands added in my bot
and if i trigger a command which is not there in the bot its just stops
any idea why it would do that?
show code
i think it has something to do with this
if(command.permissions.length){
let invalidPerms = []
for(const perm of command.permissions){
if(!validPermissions.includes(perm)){
return console.log(`Invalid Permissions ${perm}`);
}
if(!message.member.hasPermission(perm)){
invalidPerms.push(perm);
}
}
if (invalidPerms.length){
return message.channel.send(`Missing Permissions: \`${invalidPerms}\``);
}
}
if(command) command.execute(client, message, args, Discord);```
the error
like i dont have a bite command
so if i do =bite
it gives the error and stops the bot
eh its in parts i am using command handlers
oh wait
i tried using else continue but it doesnt work
according to your case the error should be at command.execute() but it's showing at if(invalidPerms.length)
wait a minute
alr
how is invalidPerms not defined
remove .length
it is
from where
alr ill try brb
I hv imported this file before instantiated the client
This is the message event listener
Your IDE tells you that it doesn't exist because your IDE doesn't know that it exists. It's not like it's going to check whether you've extended the class and added that. What you could do is make the class in another file (make sure to say extends Message), and then run Structures.extend using that class instead of defining a new one. Then I think when you're referencing messages you could use as and reference your extended class. I'm not sure how it all works but I believe that may work.
yeah, that is what I hv tried to do before. But it was hack alot of work.
got pissed of
That's TypeScript for you.
The other solution would be to modify Discord.js itself
Which would result in your adjustments being lost when you reinstall or update Discord.js
what could be done is to extend the interface of each class
and declare all methods there again
If you're redeclaring every single method then you're not "extending" anything, you're just redefining it. You don't have to do that.
will try brb
interface InterfaceOne extends InterfaceTwo {
}
so how do I do it. Is there no proper way? π
why you're extending an interface I have no idea because that won't help you unless you're doing it in Discord.js's files
the solution I gave you above, that is the proper way
I know of no other
TypeScript is a hassle. That's just how it is.
And I believe any other type-supporting language you use would give you the same issue
@rocky hearth I don't have much experience but
Can't you create a different interface extending Message | TextMessage and use the new Interface from then
what u mean by this? modify node_modules
messages wouldn't use it
unless he tweaked Discord.js to do so
yes, you would modify Discord.js in there directly
he should pull a new fork and rewrite it for the best case
if(!command){
return;
}```
i added this
oh yeah that way his changes aren't permanently gone after discord.js updates
^Β°^
I hv tried this before (ignore errors)
And it worked.
But again, had to define method signatures at 2 places
@untold token
@sly sierra thx 
how to change the name of a user in your drive
One message removed from a suspended account.
you mean in Windows ?
yes
You can change the display name of your account by doing this:
1 - Type accounts into the Start menu, then choose the User Accounts link that appears.
2 - Click the option link to change your user name and save the changes.
This will change the name as shown on the login screen (Welcome screen) and the Start Menu. It will not change the folder name, however. This is because the folder is hard-linked to your account in many (hundreds, thousands) of places, and changing the folder name will render your account unusable.
The only way to change the folder name is to create a new account, move your files over to that account, then delete the old account. Don't delete the folder itself, just the account. And only delete it when you're done getting all the files out of it that you want to keep
You can't change the username in folder
Which language ?
JS, Py, C#, Go ?
const Topgg = require('@top-gg/sdk')
const api = new Topgg.Api('Your top.gg token')
api.postStats({
serverCount: client.guilds.cache.size,
})
(Not spoonfeeding)
^^
i need to do it in description
- post stats
- create an wiget
- put the code in description
soory but what
There's a Wiget section in your bot settings page
Create an wiget from there and copy the code in your bot description page
That's only available after you send server counts using their api
How is this not a function
const sayMessage = args.join(" ");
Tying to get a girlfriend hard
cant deny that
args is not an array
Its not hard for me because my software has a auto correct code feature
So what must I do?π
console.log(typeof args);
now
cant say i didnt warn you to give detritusjs a go since its pure typescript lib
I literally just opened this channel...
I'm not using any frameworks. Does that library supports slash-commads?
So disappointed.
any one say pls
it does, cake is currently working on a command client specifically for slash commands, but the setup currently is the same as djs
y'know it wouldnt be #development without erwin advertising the best .js library for discord
can I find any yt video using detritus
you'd be using the docs, not youtube
im thankful there arent youtube videos
otherwise it would become the same mess as d.js
even today there are people looking at youtube tutorials from v11

cn any one tell free vps
try heroku
is this normal or is it just because I don't have something running on localhost:3000
also oauth2 still has thier old logo lol
what language?
Youu can post ur server count using the api
and any of the librarys listed there
lol
don't use dbl if you're python tho, use topggpy
but why
b/c dbl is a broken lib




