#development
1 messages Β· Page 1814 of 1
interop capability too
uses webview2
on windows at least
since it's c# it has native ability to interact with c++
so it's really powerful
electron without the node part
like many others out there
whaat? electron without node??? illegal
theres a full list
i wish node was natively multithreaded
the only reason why i'm using c# for my apps is because it isn't
worker thr-
I don't know the specifics of it at all other than knowing they can't really direct access each others memory
kind of like a child process with ipc
worker threads defeat the whole point of multithreading; synchronization
shared mutable state 
move your threading to c++
I mean can't you say that for every language
good point
I prefer async as much as I can lol
but that's the most common thing you'd use multi threading for
synchronization != synchronous execution
what is the reason for not? 
wym
likely too much book keeping
is there a reason why it's not natively multithreaded
v8 has an insane amount of statefulness for every single js value
i have no idea
it would be hell to make it thread safe
a few documents i did read on it stems from js roots
the fact that for a long period of time js execution would run on a single thread in the browser
web workers got introduced to fix that problem though
js being a thread safe language is a nice dream
Is it a pipe dream doe
in another universe, js strings are mutable
imagine if someone made cpython for node
they'd practically have to rewrite node
and js probably
would be sick though and I would be a customer
maybe v9 will
v8 v10
@vivid fulcrum
With v9.2, the default is changed such that all Isolates within a process share the same 4GB virtual memory cage. This was done in anticipation of prototyping experimental shared memory features in JS
V8 release v9.2 brings an at method for relative indexing and pointer compression improvements.
array.at(-1) as a shortcut for array[array.length-1]
lel
thats so nice if it does
they also added Object.hasOwn(obj, prop)
as a better alternative to Object.prototype.hasOwnProperty()
isnt that like doing 'prop' in object or something?
Hi y'all
Can someone help me with a script?
const { PREFIX, LAVA_HOST, LAVA_PASSWORD, LAVA_PORT } = require('../../config');
const { MessageEmbed } = require("discord.js")
module.exports = async bot => {
console.log(${bot.user.username} is available now!)
setInterval(() => bot.user.setActivity(Upcoming is cool | ?help (Also custom!), { type: "WATCHING"}),5000)
};
That's what my friend sent me to set a costum status for your bot
Like update every x minute?
Delete that screenshot from here.
sorry
Because you exposed your repl.
Oh
Anyone can see it.
right XD I'm dummy
And there is a error in your console can you send that here.
That also works for inherited properties
oh
@pale vessel lol hello
Like "toString" in {}
@peak patrol in your console
Uh
Can you copy paste that here.
Okay
How can I use async functions to wait for my database to connect before global scope variables are defined? ```js
//Required
require('dotenv').config();
const uri = process.env.MONGOURL;
const MongoClient = require("mongodb").MongoClient;
const mongo = new MongoClient(uri, {useNewUrlParser: true, useUnifiedTopology: true});
let bname = "Beyblade";
let datas = {}
mongo.connect((err) => {
console.log("MongoDB connected for Beyblade.js");
});
/*let ids = mongo.db("main").collection("ids");
const id = ids.find({});
Promise.all([id]).then(data => {
let beys = data[0];
beys.forEach(bey => {
datas[bey._id] = {
latest: bey.latest,
name: bey._id
}
});
console.log("Updated data!");
});
setInterval(() => {
mongo.db("main").collection("ids").updateOne({_id: bname}, {$set: {latest: datas[bname].latest}});
}, 600000);*/
class Beyblade {
constructor(name, type, image, firstOwner, id){
this.name = name;
this.type = type;
this.image = image;
this.firstOwner = firstOwner;
this.level = 1;
this.xp = 0;
this.specials = [];
this.passives = [];
this.aliases = [];
this.gen = 1;
bname = name || this.name;
/* if(id) this.id = id;
else {
if(this.name !== "Buddy Bey"){
if(datas[this.name]){
this.id = datas[this.name].latest || 1;
datas[this.name].latest = (datas[this.name].latest || 1) + 1;
}else{
mongo.db("main").collection("ids").insertOne({_id: this.name, latest: 2});
datas[this.name] = {latest: 2};
this.id = 1;
}
ids.updateOne({_id: this.name}, {$set: {latest: datas[this.name].latest}});
}
}*/
}
async init(){
return true;
}
}
module.exports = Beyblade;```
the commented out part is commented out because of a mongodb error, since it won't wait for it to connect
Guild ID
message.guild.id
me when no has permissions for doing this
π
everyone -> message.guild.id
Shouldn't it be an array of overwrites? https://discord.js.org/#/docs/main/stable/class/TextChannel?scrollTo=overwritePermissions
Custom status is only for users doe
not really
no need
I think?
sec
yeah no need
Curb your not really
Example from docs
Yeah
Yeah
What version of Discord.js are you using?
Did you recently update?
Where did you get that code then?
message.author.displayAvatarURL
That would be valid in v11
Yep!

I think it's username first though
And then the icon
Since your username, Lyp isn't a valid protocol (http(s))
That's where the error came from
Now what in the world just happened
O.o
Am I dyslexic?
Some text just disappeared
I hope
Like magic
I got this dilemma where I want to make my repo public, but somehow pissed when someone just Ctrl + C, Ctrl + V my not so good codes but learn by myself and they claim it's them. But if it stay private, hard for me to progress learning and ask people for direction. Any idea/ recommendation? like .gitignore some of it etc?
Someone I knew had their bot open source but some jackass decided to clone it and claim it's theirs
So he had to make it private
It's either public or private, you choose
Licensing might help too
Mine is private solely for that reason
Haha, but if your bot is well known enough, maybe most people will recognize it
Maybe you make it open source at that point
I'm deciding to .gitignore my /dependancy and /data which I placed most my barebone command to work properly. not sure if that a good idea
Something like the Manga I meant, I don't mind each command module that much since that is the same thing as discord.js guide
Sounds good
Make the core public, and all the crucial commands/data that makes your bot the way it is (unique/good) private
That's what Berry did with his censor bot
The bot itself is public, but the filters are private
Since that's what actually makes it good
How do I make an Embed?
An embed for text + pic
Are you using some sort of a library?
Node.JS? Err, Discord.js I guess?
probably djs
{ embed: { title: "this is an embed" } }
{ embed: { title: "this is an embed" } } 
{ embeds: [{ title: "this is an embed" }] } 
That's it.-?
Yeah
We still don't know what library you're using but that's what it would look like raw
???
A library is a package that you use for interacting with Discord's API/gateway
I c
You can pass that to your send method, like message.channel.send({ embed: new MessageEmbed().setTitle("A title") });
why not just likejs message.channel.send( new MessageEmbed() .setTitle('A Title') )
Imma try
It had problems #development message
That's for edit doe, probably work just fine for sending
Like? : message.channel.send(
new MessageEmbed()
.setTitle('Something')
)
Yeah
is it best to cache the per guild prefixes so i wont have to keep fetching from the db 
Yeah
I know someone who doesn't do that and it's just as fast
But it's nice to cache
thx 
kyoso?
Ye
flexing
its basically how big your bot is
the more guilds, the mods shards
its required at 2500 guilds
shards r basically multiple clones of ur bot right 
Itβs an api connection
i dont understand what u meant
If you have 2 shards you have 2 active connections to the API, with your servers split across each connection to ease the load
discord forces bots to separate into multiple ws connections (shards) to help them load balance
what scopes do i need for adding a rich presence?
to set a bot's presence? no scopes needed
Bots can't have rich presence though π©΄
i meant a user's rich presence
That's not how it works
im new to rich presence 
how do they work then 
NM
I didn't think you need one
You use your client ID and secret to obtain the RPC token
if i did that the rich presence would just appear on my profile?
Err, no. You need a transport which could be IPC or a WebSocket
I've never worked with RPC before so I don't know much either
wtf is an IPC 
how would i do that 
RPC is deprecated in favor of Game SDK
please read the documentation regarding this instead of begging for help
But I guess you can take a look in docs
everything you have asked would be very easy to figure out if you put some time and effort into reading the docs
https://discord.com/developers/docs/game-sdk/sdk-starter-guide You'd want to use Game SDK instead if possible
you know shits bad when you seg fault in js 
I was working on an update when I saw my bot added to a verification server
Literally chills
What does that mean?
Means my bot just got verified 
how do I delete a saved pm2 process?
pm2 delete processid
β id β name β mode β βΊ β status β cpu β memory β
ββββββΌβββββββββββββββββββββΌβββββββββββΌβββββββΌββββββββββββΌβββββββββββΌβββββββββββ€
β 0 β index β fork β 0 β online β 0% β 232.4mb β
β 1 β index β fork β 0 β online β 0% β 122.7mb β
β 2 β index β fork β 0 β online β 0% β 20.0mb
is id the 0 1 2
nope
I just pm2 save
just delete em all
It should be 2 than
how tho

pm2 delete all
bro im a noob cuz I just knew about pm2 3 days ago
Ok sure
problem fixed I just deleted the file that pm2 saved
then restart vps
hi how do we lock a channel for a role after a certain time?
i have this currently which will unlock the channel
return message.channel.updateOverwrite(roleId, { SEND_MESSAGES: true }) .then(message.channel.send(`GoodLuck`))```
add timers, for persistent timers over process restarts i would suggest to use redis with ttls
I am looking to shorten how much code I am writing, starting with my config, so I want to take an array of userids, and see if the authors ID is in the array, I've written an example of what I could think of and what I would think it would look like, and I was wondering what I should really do because I don't think it is right at all.
config.admins = [ /* Array of userids*/ ]
if(message.author.id === config.admins) {
// Do something
}
else {
return message.channel.send('You do not have permission to run this command!');
}
array.includes might be the thing you search for
your way would probably not work bcs you check a string against an Array and will be always false
Is there any way to get the last repositories a user has made commits to via the github REST api? π€ I've been searching the API for a while now and I can't find anything
see first take input from use with the welcome message and store it in a database or something
then
Wait wait wait I'm on mobile currently ;-;
This sounds like stuff to do on pc
yes, see welcome msgs need to be stored somewhere cause if by chance the bot goes offline the msg will have to be set again
Alright I'll try to show this to the server owner when he gets on and maybe he can speak to you on trying to fix it more

anyone know how would i make the avatar image on the creator area bigger? i tried increasing the size but it just zoomed in the image
nope sorry, also how do u put such good backgrounds when i put mine it looks tooo blurred and zoomed
Would message.content work if I set that as a embed message? For example someone wants to βsaveβ text but not pin so theyβd enter β!save <msg>β and it sends a embed to a channel called βsaved informationβ title would be βUser saved this:, description: message.contentβ doable?
message.content would be null if there is only a embed and no content in that message
let roles = client.data.boostRoles.map(r => {
message.guild.roles.cache.get(r.role).name
}).join("\n")
```
Why its not showing?
The names
you are not returning
x => something
is equal to
x => { return something }
you are doing x => { something }
yea so either remove the curly braces or add return before the message. ...
hey guys anyone know what this error is about? ( im using ytdl-core)
MinigetError: input stream: Status code: 403
at ClientRequest.<anonymous>
at Object.onceWrapper (events.js:483:26)
at ClientRequest.emit (events.js:376:20)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:647:27)
at HTTPParser.parserOnHeadersComplete (_http_common.js:126:17)
at TLSSocket.socketOnData (_http_client.js:515:22)
at TLSSocket.emit (events.js:376:20)
at addChunk (internal/streams/readable.js:309:12)
at readableAddChunk (internal/streams/readable.js:284:9)
at TLSSocket.Readable.push (internal/streams/readable.js:223:10)
at TLSWrap.onStreamRead (internal/stream_base_commons.js:188:23) {
statusCode: 403
}
Hi I want to show up on the bot servers site.
The written language is BotJS.
What should I do?
Just make the element bigger and use a pseudo class to overlay it with a higher resolution version of your pfp. You'll have to update it manually every time you change pfp though.
see any issues with this balance teams function?
const balanceTeams = ({players, numOfTeams}) => {
let playersDescendingRank = [...players];
// highest rated at index 0
playersDescendingRank.sort((a, b) => b.rating - a.rating);
const teams = [];
for (let i = 0; i < numOfTeams; i++) {
teams.push({
players: [playersDescendingRank[i]],
totalRating: playersDescendingRank[i].rating
});
}
playersDescendingRank = playersDescendingRank.slice(numOfTeams);
while (playersDescendingRank.length) {
for (const team of teams) {
if (!playersDescendingRank.length) {
console.log("uneven teams");
break;
}
const playerWithLowestRating = playersDescendingRank.pop();
team.players.push(playerWithLowestRating);
team.totalRating += playerWithLowestRating.rating
}
teams.sort((a, b) => b.totalRating - a.totalRating);
}
return teams;
}
const players = [
{
playerId: "123",
rating: 1000
},
{
playerId: "123",
rating: 1050
},
{
playerId: "123",
rating: 1100
},
{
playerId: "123",
rating: 1150
},
{
playerId: "123",
rating: 1200
},
{
playerId: "123",
rating: 1250
},
{
playerId: "123",
rating: 1350
},
{
playerId: "123",
rating: 1400
},
]
console.log(balanceTeams({players, numOfTeams: 2}))
module.exports = balanceTeams;```
how can i write text on image in discord.py ex:welcome image with user id on image
PIL
idk about py but in js I use canvas
Can you send me any reference or tutorials ?
I can manipulate image but Idk how to write something on that image
Idk about js :(
Tnxs
bot.on('clickButton', async (button) => {
if (button.id === 'basic_drone') {
const user = button.clicker.user.id;
const { pick } = gacha.simple(lootTable);
await button.channel.send("<@" + user + ">\nCongrats , you opened a Basic Drone Pack just got a " + pick.name);
}
})
Am I doing something wrong in this handler code for discord-buttons? It works fine but it always gives this little red error below.
P.S. It's my first time working with buttons.
You have to respond to the interaction
you need to respond to the interaction
thou hast to respond to the interaction
After evaluating all possibilities, the decision to respond to the interaction manifests itself
has everyone prepared their bots about me section yet?
Yeah
nice
Update ur discord
lemme see, if github copilot knows π€£
Check out /users/:username/events (The event type should be PushEvent)
omg thanks
can you also give me a docs link pleaseπ₯Ί
I found it it's under "Activity"
so unorganized jesus
how do i make the object shown as a string cuz im trying to make an eval cmd and when im mentioning/logging an object it says [Object object] and I will always go to the console and see what the output is..
any fix for this?
Simple way is to use the inspect method from util
I think JSON.stringify() would also work but it's less customizable (you can't specify depth/show inenumerable props)
json method kidna stinky 

const util = require("util")
module.exports = {
name: "ev",
category: "hidden",
run:async(msg,args,client,cache)=>{
if (msg.author.id!==client.application.owner.id) return msg.channel.send(`Only **${client.application.owner.tag}** can use this command!`)
const code = args.join(" ")
if (!code) return msg.channel.send("Bruh just input something")
try {
const evaled = await eval(code)
console.log(evaled)
msg.channel.send(`\`\`\`\n${util.inspect(evaled)}\n\`\`\``)
} catch(e) {
console.log(e.stack)
msg.channel.send(`\`\`\`\n${e}\n\`\`\``)
}
}
}
oh its utils 
It's util, my bad
still wont work
Check your console
its just the error
You're only sending the error message there
this one
But it's the whole stack trace
You had console.log(e.stack)
Check what method the error originated from
usually when most js parsers see opening and closing brackets with a: b in it in a place where they expect a statement they interpret it as a block and a label
you need to wrap it in parentheses to force it to interpret it as an expression
oh so ill just add parenthesis in the eval thing like
yes
eval(`(${code})`)
only if your code is supposed to be an object literal
I mean you could add the parentheses in the arguments for the command, but I guess it doesn't really matter
wait it does matter
it won't work if your code is a statement
this is the same reason why if you do
console.log(stuff.map(thing => { thing }))
you're gonna get a bunch of [undefined, undefined] unless you do
console.log(stuff.map(thing => ({ thing })))
just do ({ name: "John" }) as the argument
because otherwise it thinks you're doing
stuff.map(thing => {
thing;
return;
})
thx!
π©
now i forgot why i need eval 
Looking good like this? I mean the interaction on each command from searching manga -> details -> recommendations The button doesn't look so interesting though
being someone who serves alot of this sorta stuff to users
they generally only look at / care about the description in summary, the title, the image, genres and rating
everything else is just basically entirely ignored
hmm, I usually couldn't care less about rating though π€
rating is important
Tends to be what alot of people look at when you're searching for something new
thats what i do ^
Maybe good idea to include rating, genres I agree, but api for recommendation is that limited to only link/images. sadge
The downsides of not using your own api 
MAL api is lacking, and I don't think I want to scrap MAL for that. kekw
MAL's api basically just doesnt exist lol
Jikan already scrapes MAL for you though, even has more info than MAL's official API
well, that is the recommendations api from jikan
pog
Why not just make your own btw
rec api. 
Fetch the anime by ID then
Why not just make your own btw
I can, but don't think I have the time to tinker around scrapping MAL
does this look like a good way to balance teams? anyone see anything i can do to improve it?
anime focused or manga focused?
for manga, i find mangaupdates much better than MAL, but they dont have an api, its easy to scrape them tho
tend to focus more on anime nowadays
What does Your Name. have to do with the police
IDEK
unless my name's going to be on a list after watching
Maybe
Hey! Can anyone help me really quick with some javascript?
Sure
I need to export from a command the id of the author who ran the command and use it in another file. This is generally what the command looks like:
module.exports = {
async execute(message, client, args) {
const cmduser = message.author;
module.exports = { cmduser };
},
};
And the other file looks like this:
const { cmduser } = require('../commands/admin/options.js');
module.exports.run = async (menu) => {
console.log(cmduser);
};
But when I run the second file, cmduser gives me invalid. Any idea why so?
It generally looks correct to me.
That's not possible
what you can do is store the ID in the client object
client.someUserId = cmduser;
then in your second file you'd do client.someUserId to get the id
The second file exports a command right?
Can't they just assign the ID as the value of a property to the exports?
Then call that in the second file... Ok yeah that makes sense
An event
no because exports are cached
and you'll import the command WAY before it gets executed
100000iq ez
What are you trying to do?
I mean, you can delete the cache and require it however; but gotta do some other stuff then, but yea you should store the ID in the client object or something
you still can't
I need to export the message.author object to another file
const { MessageButton } = require("discord-buttons");
module.exports = {
name: "b-test",
description: "A new buttons command.",
aliases: [""],
usage: "",
categoery: "test",
run: async (client, message, args) => {
const embed = new MessageEmbed()
.setTitle(`Discord Buttons`)
.setDescription(`**TEST MESSAGE 01**`)
.setColor(`RANDOM`)
const FirstButton = new MessageButton()
.setStyle(`green`)
.setLabel(`Yes`)
.setID(`12345`)
const SecondButton = new MessageButton()
.setStyle(`red`)
.setLabel(`No`)
.setID(`234`)
message.channel.send({ buttons: [FirstButton, SecondButton], embed: embed });
client.on("clickButton", async (button) => {
if (button.id === "12345") {
button.defer()
button.channel.send("id 12345")
};
if (button.id === "234") {
button.defer()
button.channel.send("id 234")
};
});
}
};```
idk what ive done wrong can someone help me. the message is being sent but no buttons
idk if im just stupid or what
Thought this would work, but it does not
Attach it to your client.
There's no property called buttons that MessageOptions accept, you have to pass it to the components option
Uhhh why are you putting events in a command?
though even attaching it to your client is not ideal because if two people use the same command then client.someUserId is going to be the ID of the last person who used the command
preferably put all IDs in an array which is attached to the client
or a map
i see
Ok, thanks for the help <3
I think this look better than previous one π P.s, no rating for mangas
i'd avoid text walls
Its a description of the book. Pretty sure its needed if you are searching info about it
ohh i see
oh whats that? (Sorry this is my first time in this channel)
what's what?
I dunno what your bot is but it looks cool
Thank you for the compliment, it moving on tortoise level
I mean the development of it, since I'm working adult
I know that feeling, I just finished re-writing my bot today
Is it possible to replace a file inside node_modules or edit it so it uses my custom code. Ik it is possible through using a repo link
fork the repository and use your repo instead of the node module
The design could use improvements.
I assume you're relying on AniList or MyAnimeList as your data source, but I just don't think the embed looks that great.
Like putting the ID in the title
Or trying to use the description field as both the score and synopsis, prioritizing the score first
Or the use of colons in the fields when it should be clear they have a value associated with them
Or the use of the cover image in the image and thumbnail fields.
Or how the ID is duplicated in the title and footer while the ID in the footer has no meaning to it.
I'm not saying you should strictly follow the semantic meaning of the fields, but I just think the design could use improvements.
It used for next button interaction, but I removed it afterward, I mean for the id on footer
But in the end opinion are opinion, x can say x, y can say y
require the file, resolve it, delete the cache , replace it with your file
hello, How is it done in the photo?
var next = new MessageButton()
.setStyle("blurple")
.setLabel("Next")
.setID("next");
Nodejs - Discordjs
are you sure
set your style to "danger"
only for custom emojis
How to make next emoji, back emoji and refresh emoji long question?
you are right thank you
What's the difference between process and worker ?
a process is a process
a worker is a thread or isolated instance inside the same process
Code: js let quest = client.quests.Math.random()
Error: xl Cannot read property 'random' of undefined
client.quests.Math is undefined
hey im gonna host my website on repl.it and this is a test but where do i put the code on the bottom
what? but I'm cetain it is.
show where you define it
//blablabla
client.quests = new (Discord.Collection || Map)();
//blablabla
const questFiles = fs.readdirSync('./quests').filter(file => file.endsWith(".js"));
for (const file of questFiles) {
const quest = require(`./quests/${file}`);
client.quests.set(quest)
}```
sorry it took a while i had to do something
noice
ah, i will try that
Hello! I am having a small issue. Feel free to tell me that I am dumb at any point.
I have an array, and I want to move all the strings in that array to a different array, and at the same time edit the string to include more info-ish.
This is the code that I have so far (messy, I know)
const userinfo = [ 'accountid', 'accountname', 'accountrole', 'accountbalance,', 'verifiedtof' ];
const options = [];
const createOptions = async (item) => {
const pushme = { value: item, description: `Enabled: ${await db.get(`${message.guild.id}_${item}`)}` }
options.push(pushme);
};
Can someone help me with why the array options will return empty?
You're creating a function and not calling it
Oh its called in a piece of code I didnt copy
serious question: do you know what you're doing?
serious answer: partially
well show us how you call the function
if(args[0] == 'userinfo') userinfo.forEach(createOptions);
I am still in the process of learning javascript
And where are you console logging options? Is it after the call or before that
After calling it
then it shouldn't be empty
const userinfo = [ 'accountid', 'accountname', 'accountrole', 'accountbalance,', 'verifiedtof' ];
const options = [];
const createOptions = async (item) => {
const pushme = { value: item, description: `Enabled: ${await db.get(`${message.guild.id}_${item}`)}` };
options.push(pushme);
};
if(args[0] == 'userinfo') userinfo.forEach(createOptions);
console.log(options);
Are you sure args[0] is equal to userinfo
only the userinfo.forEach(createOptions) part wouldn't run, unless you're checking somewhere else
and if you are, then that check in the code you showed is pointless
Thats the only point I am checking for userinfo in the args
If you want I can even show both the code and my terminal
console.log(args[0] === "userinfo") place this right before the if statement\
oh it's cause createOptions is async
forEach and async don't mix well
you can't wait for the forEach to finish
bruh
use a for loop
Ok, Ill use that now
ah fair
Finally got it to work how I wanted it, thanks @cinder patio <3
in ur dns
Yeah
Create a cname
Make sure proxy is dns only
And when it connects, u can change proxy to proxied
:)
i gues its here i am going to ask about reaction role
I N T E R E S T I N G
any way to place the box shadow below the lightbulb
I guess an invisible div with a width and height as the lightbulb could do
nvm I used the drop-shadow function
are any of you using the top.gg api? Can you check to confirm the vote check endpoint is working for you again?
Where can i get a list of recommended cooldowns for Discord requests like ?
Role add/remove
Nickname change
Channel edit
You'd have to look at raw request response headers for making requests
There is no list somewhere
does raw req response return guild id or user id?
Some requests do
You'd have to look at docs for routes you use to see their return value
Hello @earnest phoenix :p
oh thx
2500
2500 servers max per shard
Input: abc123
Output: Yes
Input: abc123#
Output: No
Input: aBc123
Output: Yes
Input: aBc123#
Output: No
Input: 123.,*/-+
Output: No
How can i do that?
I want the output to be "no" if anything other than letters and numbers
regex only a-Z and 0-9
regex
i know that
o
but i don't know how it's done
idk regex either
You know but you don't know
i know the regex but i don't know how to do it
regex.test(string)
^[A-Za-z0-9] but how can i check
any site that has "regex" in its name will let you test it
if (!message.content.includes(/^[A-Za-z0-9]+$/) return; is it good?
you know regex but you don't know js 
includes doesnt accept regex
only strings
for regex you need to use match or test
or replace
?
string.replace accepts regex, so does string.match and string.search, and regex.test
Obviously i'm making a mail system and i don't want the mail address to contain anything other than letters and numbers.
you can use any of those functions
Use this method to test the regex on the strings, assuming you already have the regex or you know how it works...
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test
is there any way to make your bot send a message in a channel when it goes offline or online
u think
Listen to the ready event and send a message to the desired channel
If you want to send details about the bot changing states (e.g. a system failure), you'll need to record the cause and use it when sending the message.
Like writing to a file.
i see
Hey! Whats the best package for the new slash commands? I dont exactly want to update my discord bot to v13 discord.js atm
hey so is this channel only related to topgg api or can i ask a general question related to discord api too?
general questions about development I guess
this is general development
ok thanks
#topgg-api is for the api
wdym
thanks
π
None, the best thing to do is to use raw API requests without the usage of a bloated package if you're not willing to update to the dev branch of discord.js
Well fuck
When I input this into my code:
let questc = new (client.quests.get(quest.name))();```
I get this error:```xl
TypeError: client.quests.get(...) is not a constructor```
I looked it up and I'm pretty sure this is the right way to do this.
Hey Everyone
hi
hi @everyone
how do i sort an array of obj via a string..
like this
[
{
name: "Jhon",
age: 21
},
{
name: "Jake",
age: 20
}
]
this is just an example btw 
so you want jake to show up first?
localCompare sorts alphabetically(it doesnt sort, but can be used to sort), but also sorts accents
so it may not work entirely the way you want

you can replace non alpha chars
thx it works!
Iβm pretty sure no coding language has dictionaries like that.
Yes
dictionary or something idk I finished English
That doesn't look "shorter"
Who is pinging me!
Not me
Doesn't JavaScript use quotes?
const dictionary = {
"1": 1,
"2": 2
}```
params : {
platform,
type,
'sort-by' : sort,
},``` This is some cases where quotes is needed
internally it does. Users don't have to specify keys as strings as they auto get converted to strings
Oh.
Is that possible with JSON.py?
idk. I dont use py
I'm debating to use duckduckgo IA api or not.. but it look tempting
why does // notes cause errors in my bot's css?
like if i do
// the nav bar
.class{ font-size: 100rem }
this css does not get executed
/* This is a css comment */
any one help me to setup aws
pls
i cant know how make intance and also deploy
so pls help me
Is it possible to add hyperlinks to non-embedded messages?
like markdown links?
Sure.
I thought Iβve seen it in a regular message before. (Webhook).
Well what does surrounding a link with <> actually do?
next.js is driving me nuts
dev build literally takes a minute to load, wtf?
and the strange thing is that it wasn't like this yesterday
Hey, when temp ban with @ZeroTwo bot and if the bot went down or rebooted
will the user still get unbanned after the specified time when reboot?
I did temp ban with d.py with deafult code. i.e,
@bot.command()
async def ban(ctx, user:discord.User, duration: int):
await ctx.guild.ban(user)
await asyncio.sleep(duration)
await ctx.guild.unban(user)
It won't
You have to store the ban info in a database and redo the process on startup by fetching your DB
if its a popular bot, it does
yeah so anothor DB chunk for temp bans and temp mutes
mutes are normally temporary
hmm.. I guess i will save only bans
Generally you should save all data that has to do with timeouts for persistency, no matter how long it may be. Once you restart your bot, everything will be reset
Hello, i've had this issue for a while and i just kinda left it until now, the margin-top is broken on my website but it only breaks when the website is on the host that i use, when i locally host it, it's fine, i contacted the host to see what was up, and he said it's never happened before and he doesn't think it's there end and i should try clearing cache, i tried it and it did nothing
there's no way a hosting service break / change the layout of the page, unless they change the code themselves
are you sure your local files are the same as the files that are on your host?
The files are exactly the same
and on the website the MT-5 IS THERE it's just not effective in the Same way
the margin on t he local hosted one seems to just be lower then on the hosted one
Can anyone help me with an idea I have for my discord bot? (discord.py)
I am trying to make it so that the bot works in direct messages, where it asks you some questions and you provide answers.
Then depending on your answers, it gives you a role in the server.
https://discord.com/developers/docs/resources/channel#attachment-object How many attachment we can attach to MessageObject didn't found anything on the documentation
Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
Try it and see 
DiscordAPIError: Maximum number of allowed attachments in a message reached (10).
10
Yeah, got confirmation from discord developer server
It got the limit of 8mb too
https://discord.com/developers/docs/topics/opcodes-and-status-codes specifically, here is where it stated
Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
what are you trying to do
hey! Is there any way to directly write this object to like a txt file?
whats the best db for a like smoll bot/project 
hm
mongodb is good enough
if its a small bot just use sqlite
quick.db
whats sqlite 
i mean i already made a mongodb acc so ye just gonna have stick with mongodb 
How do I define discord.js client in app.js file?
required the module?
what
require*
no
Instantiate the client
what kind of question is that
There are codes for my bot in index.js and there are codes related to top.gg in app.js
and?
i dont get what u mean 
me ^ jk
I want to do something using the client in index.js in app.js
i don't understand you
i suggest maybe export client in a separate file thats what i do
Make app.js a function and execute it in index.js (with client as parameter), maybe
i think he meant he want to import the client from index.js?
yeah
just export the client in index.js or what flazepe said
thx
np
How can i check if the message contains anything other than letters and symbols
What kinda symbols
I wrote an api for the non-authorization part of my site, but anyone can access it by doing example.com/api/blabla, how can I make it safe?
hey i have tried to use this api: https://www.npmjs.com/package/@google-cloud/speech
but does anyone know how to authenticate myself?
i already have my desired key but got no clue where to put it
#-*+/_Γ’Γ Γ¨Γͺ
check it with regex
like if all the characters match a certain unicode range, return true otherwise false
var regex = /^[a-z]+$/
regex.match(...)```?
yeah sort of
hello
thanks
is it possible to host a bot that edits and reads from json files on hosting platforms like heroku?
all the guides i've watched only shows hosting a single index.js file
i think you can if you require it
require it and then still use fs to read and edit it?
dont use json as a "database" heroku deletes all files if the process restarts, or gets updated
it's temporary for now, as i have other things to work on, but maybe use replit for now then? they recently added an "always on" feature.
u wanna buy the plan?
:/
and its not "recent"
lmao
i have the plan through school
i don't know much about it though, like limits etc
why would my school mind me using a feature integrated in the replit plan
huh, it's not like they're gonna pay any extra for it
lmao imagine they do
HHAAA-
they don't
lol, im 100% sure it's not a problem
Hellp
Error: MongooseError: The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()`
Not Connected MongoDb
did you check the parameters to .connect/.createConnection
mongoose.connect(Config.mongoDB, {
useNewUrlParser: true,
useUnifiedTopology: true
}).then(() => {
console.log('Connected to MongoDB')
}).catch((err) => {
console.log('Unable to connect to MongoDB Database.\nError: ' + err)
})
interesting lol, no it wont die, I will maintain it , as long as I will live...
so what is Config.mongoDB
Mongodb Connection Liink
try logging it
I'm glad to know that! π I'm definitely going to try it out at some point
Well, I'm trying, I can't get this error
How do we know u won't die tomorrow
After 30-days inactivity in #general , you can confirm it
pointless mongoose just told you it's undefined
Why aren't there any updated version of passport-discord
sirs how do i make a webhook
How do we know u won't die tomorrow
lol
The point is to show them explicitly that it's undefined.
that's a slow point to make
Sometimes the slow path is the fastest path
Same
How about posting your issue?
Yesss :))
Instead of screaming for help...
For JS, PY, PHP... ?
Mean XD XD (jk)
Using Discordjs?
Yup
Thanks
setPresence is capable of updating the client's status
client.guilds.cache.forEach(g => {
try {
client.channels.cache.get(data.globalChat).send(embed)
} catch (e) {
return;
}
});```
I want it to send message to all channels which are in db but its spamming
Bad idea. Of course it's spamming, therefore API abuse
How can I fix this?
By not sending the message to all guilds?!
globalchat imo is a really bad idea
a foreach loop for that is a really bad idea too
badΒ² 
webhooks would be better than using a bot
fixed
yo dream boy, don't avoid the problem
Me?
I dunno
but I'm gonna guess that you can't
it took me a second to search on google
Imagine using Google
imagine taking you more than a second to quote that reply, respond to it and find a specific emoji and then posting it, most likely taking you more than a second therefore you have played yourself and wasted your time
Imagine writing that text ... 
aye... seems to be the right time for alcohol
Hey guys, can anyone help me with some discord.py stuff?
I am trying to make a sort of 'questionnaire' / 'survey' bot where if you DM it, it will respond with a question - you answer said question - and then it gives you another question
and repeats until the end
Where can I find the discord.js v13 docs?
sucks to suck because of discord
discord kinda fucked a bunch of devs by denying some of their intents on verification
i shut my bot down because of that lol
The process should be even more strict, accepting ages 18+ only
v13..
master = v13
Ohh.
"Docs settings" top left corner
I was looking for that, thanks!
Select the branch
Goodness dude, the changes. π
They've just changed their design, making the website uglier
Ngl, I agree.
The old website was so much better.
.. I can't even press back, so you'll have to go back by RESTARTING.
i love the new docs ;-;
Which js library is good for doing POST requests?
any http lib. If you want something lightweight, try centra
reques-
I was assuming a masochistic answer from Papi
const https = require('https')
const data = JSON.stringify({
todo: 'Buy the milk'
})
const options = {
hostname: 'whatever.com',
port: 443,
path: '/todos',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': data.length
}
}
const req = https.request(options, res => {
console.log(`statusCode: ${res.statusCode}`)
res.on('data', d => {
process.stdout.write(d)
})
})
req.on('error', error => {
console.error(error)
})
req.write(data)
req.end()
Aye
Imma just use node-fetch
It's simple enough
isn't node-fetch deprecated
Request is
ah
The npm one
Hello. π
.. so I'm seeing some really advanced detailed websites, but whenever I see the source, it's like 1 line of code.
.. may I ask what they use to do that?
its never 1 line of source code
Here's a random portfolio I found.
.. the source is legit 8 lines.. but it's supposed to be more.
just loads a JS app
if you wanna see the source code of the files, you have to follow the links
Ohh.
This website is legit crazy good.
I'm an experienced web engineer living in London. Currently learning tricks as a Senior Software Engineer in ASOS.
I mean you can shrink your code to one line only... why not
minimal script version are a little bit smaller, missing all the spaces and line breaks
yep, inbuilt browser screen shot app, cant screenshot in dev tools π
The are using a builder, for loading the html
Ahh.. I see.
funny, they didnt everything with hand coding
There are some decent programms for creating complex images and animations
They cost something lol
I know.. but like which website does that?
fancy seeing you here

So happy that typescript has macros now 
I have records stored in my database with a key that looks like this.
key=hash([playerId1, playerId2]
Each record stores the rating for that team of players. I am writing a function to create balanced teams given a list of playerIds. Since I'm storing data this way do i need to try fetching every team combination from the DB to find the most balanced teams?
Given this function how quickly does the number of DB calls grow by changing numOfTeams and listOfPlayers?
balanceTeams({numOfTeams, listOfPlayers})
Wait what
does this help with annoying type issues caused by types?
because you are using typescript
Yea noob
i have issues with types in Java
This is a joke java users dont cancel me
not really, I mean, It can have macros
I might be confused on the term macro here
was i right? did you macro some type thing that is annoying?
I am mad cause I have to implement openid into my project
But i have 0 idea how

aspnet core gang
So ima play fallout 4
oh no
one method for any platform that uses openid 
macro is a very board term, think a function which expands into multiple statements
i made a discord + steam auth verification site in like 10 minutes thanks to aspnet core
Yes, true
I am using nodejs though
and I don't like the idea of using an external thing for people to sign up with like auth0 or curity
auth0 is so useful but i don't like using it at all
I would use it if it didn't require them to visit their site to sign up with.
I want them to signup on my site not some external source
any ideas here? if there is a team of like 50 players and they want to balance into 5 teams how many times would i need to call my db?
#development message
Why not call it once to get the 50 players and split them up into even 5 teams?
the db doesn't support querying
what db is it
dynamodb
everything i want to lookup has to be a flat key. anything nested can't be a key or queried on
the players dont have individual ratings, the teams have ratings.
I am confused about what you want
Didn't you wanna split 50 players into 5 teams?
yeah, but the teams of 5 have are what have the rating, not the individual players
so i cant just fetch the 50 players ratings
i have to fetch each possible team combination
then find the 5 teams with the lowest rating difference
Well your initial request made me think each player has a rating
I honestly have no idea what you are actually trying to accomplish so im afraid I can't really help
teams have an Elo rating and i'm trying to place players into teams that are as even as possible
i wrote this assuming there would be ranks for each player.
const balanceTeams = ({players, numOfTeams}) => {
let playersDescendingRank = [...players];
// highest rated at index 0
playersDescendingRank.sort((a, b) => b.rating - a.rating);
const teams = [];
for (let i = 0; i < numOfTeams; i++) {
teams.push({
players: [playersDescendingRank[i]],
totalRating: playersDescendingRank[i].rating
});
}
playersDescendingRank = playersDescendingRank.slice(numOfTeams);
while (playersDescendingRank.length) {
for (const team of teams) {
if (!playersDescendingRank.length) {
console.log("uneven teams");
break;
}
const playerWithLowestRating = playersDescendingRank.pop();
team.players.push(playerWithLowestRating);
team.totalRating += playerWithLowestRating.rating;
team.avgRank = team.totalRating / team.players.length;
}
// keep the team with the
teams.sort((a, b) => b.totalRating - a.totalRating);
}
return teams;
}
const players = [
{
playerId: "1",
rating: 1000
},
{
playerId: "2",
rating: 1050
},
{
playerId: "3",
rating: 1100
},
{
playerId: "4",
rating: 1150
}
]
console.log(balanceTeams({players, numOfTeams: 2}));
module.exports = balanceTeams;```
how can i restart the entire node app with a command?
Just CTRL C it
"with a command?"
Not sure there is such
use pm2 to run node
im using it
since a node process runs until told not to
then pm2 restart [ID]
and with pm2 just use pm2 restart ID
Could of specified that
exec
There is no way to do that really unless you wanna run pm2 restart ID
Which would work and bring the bot back online.
what does this mean
Exception: Request failed for https://discord.com returned code 400. Truncated server response: {"embeds": ["0"]} (use muteHttpExceptions option to examine full response) at onSubmit(Code:54:17)
sassy kitty
B
lol, the cats gesture π



