#development
1 messages Β· Page 1673 of 1
Angular is arguably the most advanced frontend JavaScript framework ever created. Learn the basics of Angular in 100 Seconds. https://fireship.io/courses/angular/
Docs https://angular.io
#webdev #js #100SecondsOfCode
Install the quiz app π€
iOS https://itunes.apple.com/us/app/fireship/id1462592372?mt=8
Android https://play.google.com/store/ap...
React is a little JavaScript library with a big influence over the webdev world. Learn the basics of React in 100 Seconds https://fireship.io/tags/react/
How I make these Videos https://youtu.be/N6-Q2dgodLs
#react #webdev #100SecondsOfCode
Install the quiz app π€
iOS https://itunes.apple.com/us/app/fireship/id1462592372?mt=8
Android https://p...
i definitely suggest watching these
const Discord = require('discord.js')
module.exports = {
name: 'approved',
run: async (message, args) => {
const sayMessage = args.join(" ")
let embed = new Discord.MessageEmbed()
.setTitle("Approved")
.setDescription("has been approved")
.setColor("#00ff00")//it's aco's green color hehe
message.channel.send(message.mentions.members.first(),embed)
}
@frigid mountain
This is it
const Discord = require('discord.js')
module.exports = {
name: 'approved',
run: async (message, args) => {
//Mention
function getUserFromMention(mention) {
if (!mention) return;
if (mention.startsWith('<@') && mention.endsWith('>')) {
mention = mention.slice(2, -1);
if (mention.startsWith('!')) {
mention = mention.slice(1);
}
return client.users.cache.get(mention);
}
}
const sayMessage = args.join(" ")
const approved = getUserFromMention(args[0])
const approvedM = message.guild.member(approved)
let embed = new Discord.MessageEmbed()
.setTitle("Approved")
.setDescription("<@" + approvedM.id + ">" + " has been approved")
.setColor("#00ff00")//it's aco's green color hehe
message.channel.send(embed)
}
}
thanks! will do
wait
i think i will go with react people suggest it to me alot
@solemn quartz this is it, right?
oh wait, i wanted to reply my own message
Wait what
this
i was talking to @frigid mountain
Thx
yeah but the way i sent it is the best i think, not sure tho
@vivid fulcrum sorry for the pong but would ejs be a good option too?
@frigid mountain
oh alright
Sorry for the ping btw, just wanna help
i would still recommend using a UI framework/library like react though
it's very good for complex and/or multi page apps
hi what if someone doesnβt have Nitro and using animate emoji with help of bot (bot creates web-hook of that author name and post with animated emoji) << is this cool or against discord TOS?
it's allowed
Guys i need help, i (maybe) figured out how to make the bot edit a message, but i need help making it edit the msg after a certain amount of time
so how do i do that?
interval or something
give me a moment
k
.then(msg => {
what
you need a timeout actually
yeah
.then(msg => {
msg.delete({ timeout: 5000 })
})
here is a message delete case
message.channel.send("Lol").then(msg => msg.edit("Test", { timeout: 10000 })
Thank you, im gonna try it rn
how to create a space between these words if (command === 'help' + 'balance') I want that the command will be !help balance but as is now it is !helpbalance I have already tried if(command === 'help' + ' ' + 'balance') and if (command === 'help balance') but still nothing
nope
Show me your code
wait
and the error
u need to put another ) behind the line of code
Thank you! It worked
np
but how to do it if i want the message to get edited multiple times?
do i need to just add && ?
u want to edit it again?
theres 2 options:
- You add more .then() callbacks (which just makes it callback hell so I wouldn't recommend doing this)
- You work with async/await
no he means just add more .then
thank you it works perfectly now
No I did not
the 2nd option dickhead
aye cunt tf is wrong with u
so await basically makes it so the js code "stops" and waits for the promise to resolve right, and when you send a message it's a promise as it takes time to complete
i was literally bout to say "Not to be rude" but i cant even talk
alright?
hmm
yeah i wouldn't say that at all but anyways
sorry ig
So what you want to do is assign you sending a message to a variable while also awaiting with sending the message and then after that u can edit that variable using await <variable>.edit() get it?
actually no, lol
it's like what u did up here
yeah i saw that from a yt tutorial
u say
let msg = await message.channel.send(...); // Send ur initial message
await msg.edit(...); // Edit it
i just added async at the message thing and then copy pasted that line
And u can repeat the msg.edit as many times as u want
Yeah but there is no timeout
so just like this?
if (message.content.toLowerCase().startsWith(config.prefix + "test")) {
let msg = await message.channel.send('test1');
await msg.edit('test2', {timeout: 50000});
await msg.edit('test3', {timeout: 50000});
}```
should work yes
just tried it, doesnt work
you do know thats in ms right?
so thats 2 minutes
did you ACTUALLY wait for those 2 minutes to pass by?
yeah
for it to ACTUALLY edit the message, you should've waiting 2 minutes until it actually executed the edit
then you arent sending the whole thing
now ill add another 0 and i'll see
also
my dude
i dont think edit() can take that timeout
its usually for delete()
just do this instead
setTimeout(async () => {await msg.edit('blah')}, 120000)```
this is the equivalent of you're trying to do
use that instead[
it should wait for 2 minutes
replace your msg.edit() with that
thank you, lemme try it
@opal plank h moment
q moment
so this should be good?
yeah, that
wait i cant
why not?
the msg await isnt in the async function
it gives an error lol
cant i just do this
no
One message removed from a suspended account.
dont write more than 1 event listener
hug
you didnt fix what i told you
One message removed from a suspended account.
what why?
cuz you getting an error?
,
One message removed from a suspended account.
you do
One message removed from a suspended account.
One message removed from a suspended account.
setTimeout(Function, timeout)
function needs to be async for it to use await keyword
if you dont explicitly state it, it'll simply error with cannot use await outside of top level expression
interesing find of the day: js functions are fast
its faster to make a ton of small functions than few big functions
@quartz kindle Should make a book of useless things probably nobody is ever going to remember or use, make it 3 volums long and make it so when they are side by side, the image shown says embed builders are bad
lmao
check out this shit
ignore the undefined things, i only defined what im testing
this shit made my function 30% faster
than putting all of this inside a single function
this is the big function before
isolating the switch cases and the ifs into their own functions made it 30% faster wtf
command handlers are good precisely because you're isolating each command into its own function
but you get more mileage if you isolate each conditional step into its own function
this is basically C-style functional programming
would <error>.type return the type?
i dont think an error object has a type property
does every error have a type though?
what would it return, do you know?
where?
so if its an api error? it would return DISCORD_API_ERROR?
depends what you want to do
there is no right or wrong way, you literally chose how you want to do it
error({message}, error) {
if (error instanceof Error) {
const createErrorEmbed = new FailureE()
.setTitle(error.name)
.setDescription(error.message)``` its only a function for handling errors
looks fine
ok thx
@hoary crown you gotta transpile first
either use tsc transpiler or install ts-node lib
uncacheGuilds() {
each([...this.client.guilds.values()], guild => {
if (guild.id === this.config.guild) return;
if (!utils.regionEnabled(guild)) {
this.client.uncacheGuild(guild.id);
}
});
}```
this would uncache guild correct?
cuz u clearly didnt use it
node ts-node src/index.ts
or if you installed it globally
just use ts-node src/index.ts
no idea
those functions are not built-in
whats best way to cache guilds then?
just do ts for(let guild of [...client.guilds.cache.values()]) delete guild
done
dont do that tho
you cant delete it like that lul
why do you want to uncache guilds?
aight fine
for(let guild of client.guilds.cache.keys()) client.guilds.cache.delete(guild)
happy now?

what ref?
even tim got outplayed??
for(let [key,val] of client.guilds.cache.entries()) {delete val; client.guilds.cache.delete(key)}
the object should be referenced no?
nah
the object will be garbage collected
https://github.com/missive/emoji-mart anyone know something in a similar appearance to this that's useable in normal JS as I'm not using react
i found some jquery ones but the physical appearance of them is....lacking
How can I get my bot to leave all the servers
guild.leave()
ok thx
alright
client.guilds.add(guild);
^
TypeError: client.guilds.add is not a function```
never seen this before?
Is there a way that my kick command won't let me kick myself?
Like sends the message error: You cannot kick yourself.
if(args[0 or 1] === message.author.id) return mesage.reply(''You cannot kick yourself)
:D
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.609 s
[INFO] Finished at: 2021-03-27T21:27:34-04:00
[INFO] ------------------------------------------------------------------------```
Praise it
While it lasts
roast my code
imagine not using formatter
Is it possible in html eg: https://pertinentsparklingfolder.dragondev15.repl.co/test.html
Hi.
To change the top link?
using meta
What do they mean by, βan I modified version of a botβ?
const embed = new discord.MessageEmbed()
^
TypeError: Cannot read property 'MessageEmbed' of undefined
at Manager.<anonymous> (/app/src/index.js:49:31)
at Manager.emit (events.js:196:13)
at Node.trackStart (/rbd/pnpm-volume/6aa01aae-6f57-434c-8446-c7b36c7ba822/node_modules/.registry.npmjs.org/erela.js/2.3.2/node_modules/erela.js/dist/structures/Node.js:228:22)
at Node.handleEvent (/rbd/pnpm-volume/6aa01aae-6f57-434c-8446-c7b36c7ba822/node_modules/.registry.npmjs.org/erela.js/2.3.2/node_modules/erela.js/dist/structures/Node.js:206:18)
at Node.message (/rbd/pnpm-volume/6aa01aae-6f57-434c-8446-c7b36c7ba822/node_modules/.registry.npmjs.org/erela.js/2.3.2/node_modules/erela.js/dist/structures/Node.js:190:22)
at WebSocket.emit (events.js:196:13)
at Receiver.receiverOnMessage (/rbd/pnpm-volume/6aa01aae-6f57-434c-8446-c7b36c7ba822/node_modules/.registry.npmjs.org/ws/7.4.4/node_modules/ws/lib/websocket.js:825:20)
?? What is this π
Can anyone help me π
what is discord
a miserable little pile of bugs
use: let embed = new Discord.MessageEmbed()
how do you do multiple attachments? im trying to use 2 different local files for a thumbnail and main image respectively
const attachment = new Discord.MessageAttachment(`./cards/${vv+ss}.png`, `${vv+ss}.png`);
const attachmentB = new Discord.MessageAttachment(`./cards/back.png`, `back.png`);
const embed = new Discord.MessageEmbed()
.setTitle(`${valNames[posValues.indexOf(vv)]} of ${suitNames[posSuits.indexOf(ss)]}`)
.attachFiles(attachment, attachmentB)
.setImage(`attachment://${vv+ss}.png`)
.setThumbnail(`attachment://back.png`);
msg.channel.send({embed});
but this only shows the title and main image, no thumbnail
is the .attachFiles section not formatted correctly?
You should've put a Capital D in the beginning of the name Discord
@earnest phoenix fixed
And have you added const Discord = require('discord.js')
Const embed = new MessageEmbed()
Worked
Yes I have added that π
K.
okay in response to my problem i figured it out for anyone who's also having that problem
you cant attach multiple in one function for some reason
.attachFiles(attachment)
.attachFiles(attachmentB)
.attachFiles(attachmentC)
you have to do this
which i mean you would probably only need two, one for image one for thumb
that's one of the issues of accepting an arbitrary amount of params Β―_(γ)_/Β―
you can, what did you try?
it's called attachFile"s"
i did do attachFiles
in full i did attachFiles(attachment, attachmentB)
@spare portal have you tried attachFiles([attachment, attachmentB])
that was just to imply that it supports multiple attachments
error ({ t, message, channel, prefix }, error) {
if (error instanceof Error) {
const createErrorEmbed = new FailureE()
.setTitle(error.name)
.setDescription(error.message)
return channel.send(createErrorEmbed)
}
console.error(error)
}
}``` never sends embed for error always just sends console error
then error isn't an instance of Error
module.exports = class CommandError extends Error {
constructor (message) {
super(typeof message === 'object' ? 'EMBED_ERROR' : message)
this.embed = typeof message === 'object' ? message : null
}
}```
thats Error
what's the error
throw new Error(t(opts.errors.guildOnly))
help me
when i try to install sodium it gives me this err
PS C:\Users\justi_8vy6ryi\Downloads\MuDiBot-master\MuDiBot-master> npm i
> sodium@3.0.2 preinstall C:\Users\justi_8vy6ryi\Downloads\MuDiBot-master\MuDiBot-master\node_modules\sodium
> node install.js --preinstall
MS Version: 2019
C:\Users\justi_8vy6ryi\Downloads\MuDiBot-master\MuDiBot-master\node_modules\sodium\install.js:312
console.log('Invalid msvs_version ' + msvsVersion + '\n');
^
ReferenceError: msvsVersion is not defined
at errorInvalidMSVSVersion (C:\Users\justi_8vy6ryi\Downloads\MuDiBot-master\MuDiBot-master\node_modules\sodium\install.js:312:43)
at checkMSVSVersion (C:\Users\justi_8vy6ryi\Downloads\MuDiBot-master\MuDiBot-master\node_modules\sodium\install.js:329:9)
at Object.<anonymous> (C:\Users\justi_8vy6ryi\Downloads\MuDiBot-master\MuDiBot-master\node_modules\sodium\install.js:353:5)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
npm ERR! code ELIFECYCLE
npm ERR! sodium@3.0.2 preinstall: `node install.js --preinstall`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sodium@3.0.2 preinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\justi_8vy6ryi\AppData\Roaming\npm-cache\_logs\2021-03-28T05_58_32_720Z-debug.log
PS C:\Users\justi_8vy6ryi\Downloads\MuDiBot-master\MuDiBot-master>
PS C:\Users\justi_8vy6ryi\Downloads\MuDiBot-master\MuDiBot-master> npm i
sodium@3.0.2 preinstall C:\Users\justi_8vy6ryi\Downloads\MuDiBot-master\MuDiBot-master\node_modules\sodium
node install.js --preinstall
MS Version: 2019
C:\Users\justi_8vy6ryi\Downloads\MuDiBot-master\MuDiBot-master\node_modules\sodium\install.js:312
console.log('Invalid msvs_version ' + msvsVersion + '\n');
^
ReferenceError: msvsVersion is not defined
at errorInvalidMSVSVersion (C:\Users\justi_8vy6ryi\Downloads\MuDiBot-master\MuDiBot-master\node_modules\sodium\install.js:312:43)
at checkMSVSVersion (C:\Users\justi_8vy6ryi\Downloads\MuDiBot-master\MuDiBot-master\node_modules\sodium\install.js:329:9)
at Object.<anonymous> (C:\Users\justi_8vy6ryi\Downloads\MuDiBot-master\MuDiBot-master\node_modules\sodium\install.js:353:5)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
npm ERR! code ELIFECYCLE
npm ERR! sodium@3.0.2 preinstall: node install.js --preinstall
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sodium@3.0.2 preinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\justi_8vy6ryi\AppData\Roaming\npm-cache_logs\2021-03-28T05_58_32_720Z-debug.log
PS C:\Users\justi_8vy6ryi\Downloads\MuDiBot-master\MuDiBot-master> node install.js --preinstall
Hmmm, What issue is it?
@everyone
no
I am creating a guildCreate event
I wrote .addField("Server owner", `${guild.owner.user.tag}`) so it's giving me error
Cannot read property of user?
The guild owner isn't cached
Fetch it by using guild.members.fetch(guild.ownerID)
It's a promise so you have to await it
how would i get the dbl api?
name: 'help',
description: "This command will provide you with some assistance.",
execute(message, args, Discord) {
const newEmbed = new Discord.MessageEmbed()
.setcolor('#e10600')
.setTitle('Greedy Lobster Help Menu')
.setURL('discordinvite')
.setDescription('You may see a list of commands with help for them in this embed.')
.addFields(
{name: '?ping', value: 'It is a simple command that does nothing but respond to you with Pong! :ping_pong:'}
)
.setFooter('Join the support server for additional help :)')
message.channel.send(newEmbed);
}
}
I am using JavaScript and did the node thing. When I ran the command in my server, it gave me an error at, const newEmbed = new Discord.MessageEmbed(). I can send the main.js bit if it'll help. I've also tried to uncapitalize the 'm' in MessageEmbed, but it gives the same error.
do you have a const Discord = require('discord.js')
yes
@prisma wren remove discord just use MessageEmbed
k
you never sent the error
@prisma wren do want I said
I did, it didn't work.
I wanna mass delete Something with MongoDB
I have a schema - "user info"
It has an element voter
i want to set ALL RECORDS's voter element to false
Any way to do it
I remember someone told me how to do that but I forgot
userinfo.update({"voter": yes}, {"$set":{"voter": no}}, (err, writeResult) => {});
This won't work 
But it still doesn't work
what are you trying to get out of it? the callback is empty
wait
const mongoose = require('mongoose');
const userinfo = new mongoose.Schema({
prefix: {
type: String
},
voter:{
type: String
},
premium:{
type: String
},
UserID: String
});
const MessageModel = module.exports = mongoose.model('users', userinfo);
My schema
let userinfo = require("./models/user.js")
const userdetail = await userinfo.findOne({
UserID: msg.author.id
})
yeah alright, but i feel like its printing out the promise which might be interpreted as [object Object] instead of the result in the callback
I want to set the VOTER Field for each DOCUMENT(AKA USER) as no
and another problem is that
There is no voter field
I don't know how
wait, so you want to set all voters to "no"? like a reset?
it's not showing up tho
I don't know why
Also, why does it says undefiend
undefined means the field doesnt exist at all
you miss the voter field in your shema
I didn't
so the filter wont work as it wont find anything
you do?
how did you call the update query?
when a user votes?
ye
const userdetail = await userinfo.findOne({
UserID: vote.user
})
if (!userdetail) {
let newData = new userinfo({
UserID: vote.user,
voter: "yes"
})
newData.save()
} else if (userdetail) {
if (userdetail.premium === "yes") {
await userinfo.findOneAndRemove({
UserID: vote.user
})
let newData = new userinfo({
voter: "yes",
premium: "yes",
UserID: vote.user
})
newData.save();
} else {
await userinfo.findOneAndRemove({
UserID: vote.user
})
let newData = new userinfo({
voter: "yes",
UserID: vote.user
})
newData.save();
}
}
like this
so you create a new Dataset everytime someone votes?
why?
i don't know
tbh wouldnt it just be
db.collection.updateMany({}, {
"$set": {
"voter": "no"
}
})
to fully force every document to have voter: no
userinfo.updateMany({}, {
"$set": {
"voter": "no"
}
})
also what did ou want to do?
if someone votes give him access to certain stuff. what is the restriction to get the vote negated?
I kept it that vote once to remove the message for 1 month
many restrictions
if you want to remove the stuff after a certain time you could use TTL
TTL?
i use this for my bot for vote rewards
Like this
and if you want to check if someone voted. just check if the document exist, if no document exist he doesnt voted
you just need then a document with the userid and the TTL
so like If I am enabling this right now, will it automatically delete every document after 1 week or will it only delete the ones made after this change
it will delete after 1 week
all of em?
only the one where the TTL runs out
like someone voted yesterday
i am making change in code today
createdAt: { type: Date, expires: "30d", default: Date.now }, i have it currently this way
will it still delete that someone's record
creates a Document, sets the current timestamp as time and waits 30 days until it gets deleted
only the One document that runs out
so it won't affect the old ones
nope not the old ones
only the new ones
ohok
anyway to fix that problem?
but you maybe could update the old ones
createdAt: { type: Date, expires: "1w", default: Date.now },
using update many?
alright
Thanks β€οΈ
makes stuff way easyer
also you dont need such bloated schema
like i said, you just need the userid and the createdAt field
then just add a document if a user voted
euu
lol, my code is a mess
I have 7 schemas and my index file has 3k lines of code even tho I have command handler
when i will get my bot verified π¦
wtf
can anyone say
k
anyone can say after how many server my bot joned that it will become verified ??
usually 2w
2w means ?
userinfo.updateMany({}, {
"$set": {
"createdAt": Date.now()
}
})
this should work right?
you have probably to add the TTL to it too
oh
also you probably have to deal with people who vote more than once
oh yeah
shit
userinfo.updateMany({}, {
"$set": {
"createdAt": { "status": 1 }, { expireAfterSeconds: 10000 }
}
})
why don't I just remove every record after 10 seconds
and everything past this will be streamlined
why not remove all documents without the timestamp?
how?
$exist:false
userinfo.updateMany({}, {
"$set": {
"createdAt": { "Date": Date.now() }, { expireAfterSeconds: 10000 }
}
})
But that will wipe off 80k documents from my database
but wait
that's what I wanna do
Thanks
db.inventory.find( { item : { $exists: false } } )
ohh
db.inventory.deleteMany( { createdAt : { $exists: false } } )
in theory this should remove all documents where the createdAt field is missing
well you probably froze it bcs it told the database to yeet 80k documents
Hey, so anyone worked with discord.py on_member_update here?
I have an issue, which everytime someone does a thing. The event getting called 3 times.
Hello,
For the purchase of a VPS for my discord bot, I have to choose its location.
Currently living in the European Union, I have the choice between The European Union and The United States.
What should I use!
Thank you
i dont know py, but did you have mutiple event listeners?
no ofc
it doesnt really matter
i have 100ms and its fine
pick a location that's in san francisco/closest to it
while my host is in the EU
So, US or EU?
us
It gets called for the same member 3 times because that user is in 3 mutual guilds with your bot

Ayo.
In discord python, there is something called as context modification, is there also for JS?
hi
how should i get the id from this?
resolved: {
users: { '689724254883020810': [Object] },
members: { '689724254883020810': [Object] }
}
id from users or members
it doesn't matter
They are both returning the same ID.
what did resovled.users return?
{
'269095564317163520': {
username: 't33o',
public_flags: 64,
id: '269095564317163520',
discriminator: '3615',
avatar: '27c5094878688abc34ec34cb5f961794'
}
}
this
from where did you get this?
intercation.data.resolved.users
bcs the first id is the key for the entire sub object and it can be a bit annoying to use this way
did you know the userid?
and intecation
is from client.ws.on('INTERACTION_CREATE', async (intercation) => {
if yes you could probably pass the userid
resolved.user.269095564317163520 would be the path
Can someone help me?
whats your issue?
just use topgg-autoposter
I am now working with shards and I dont know how api.setStats whould know which one is a shard and how many servers and so on
what?
Topgg API
An API wrapper for https://discordbots.org/api/docs that works in Java - top-gg/java-sdk
topgg-autoposter is for js
I am using java
Should i use a loop and send Nr.2 multiple times or how should I get all the servers for you?
im not too sure, I don't use java
Javacord
I have them in a hashmap
Shards as a Value and the ID of it in a key
I tried that:
futureApi.thenAccept(api -> {
top.setStats(api.getCurrentShard(), shardCollection.size(), api.getServers().size());
});
});```
Is that correct like that?
I am looping through every shard
@opal plank I need some ts help with template literal types. discord-api-types (a package berry uses because he is too lazy to type everything and its already done here) defines Snowflake type as `${bigint}`, if I were to do guild.id ?? 'dm', I get RangeError: Maximum call stack size exceeded from ts and it breaks. https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html has the examples using types as constants, which doesn't have the same issues. Ex. I compiled ts type Snowflake = `${bigint}` interface Example { id?: Snowflake } const example: Example = {} console.log(example.id ?? 'no id') and it failed with the range error. Doing ts type test = 'string' type Snowflake = `${test}` interface Example { id?: Snowflake } const example: Example = {} console.log(example.id ?? 'no id') had no issues. Is discord-api-types making a mistake by using template literals like this or is there something else? https://github.com/discordjs/discord-api-types/commit/549a6f023698f05829f1dfdf1190c027a994d6cd was the commit which added Snowflake and here is current code https://github.com/discordjs/discord-api-types/blob/main/common/index.ts#L160
did you guys see me typing for like 3 minutes lol
lol
So its ok to send thousends of data to top.gg?
No i dont but i just wanna ask if I would have 2000 shards...
-_-
I am not faking that xD
ok
rn? 1
I wanna make my Bot future save...So i dont have to write new stuff if it gets more servers
Or how many shards does Discord recommend for 200 servers?
1
oh ok
then 1
ok nice
Nah i dont wanna be mee6.....I wont crash Discord and I dont wanna be shit like that bot xD
yep
Every 20min
xD
Yay
Nah i am using completable future....So I am fine
I changed my framework to javacord only for async tasks and completablefuture
Trust me Its way better
no .queue at the end
yep thats why i switched to javacord
Not now π¦ And the AudioSupport is also ez but does have one bug...In the next update , they will bringt both the slash commands and the audio reconnect fix
yep
yes it is....But I had less code on audio and it also reconnects automatically on every problem...They managed it very good
I think so...Never tried lavalink...
how do i escape usernames with special cahracters
TT
its messing
with the embeds
how to don't let the bot to don't answer to any command in dms?
check if <Channel>.type is equal to dm
let items = [];
fs.readdir(path.join(process.cwd(), "data", "items"), (err, files) => {
if (err) throw err;
files.forEach(file => {
items.push(file.split(".")[0]);
});
});
Anyone knows why this logs an empty [] even though when I log file.split(".")[0] there are like 6 items
because fs.readdir runs after you console log
oh
You need to put the console log in the callback
you can do readdirSync if its not important
or you can promisify it
there is fs.promises
Hello Tim
I made a last minute decision to keep the bot online
Do you know anything about template literal types in ts?
ok so the big question is if you can do ```ts
type x = `${bigint}````
no
Around 2 weeks
does Array.filter change the array itself?
shouldn't
@dusky sundial
hello Erwin
Because there is a lot of bots in the queue
Who thr fuck uses bigint for id types? Use string. Also wtf, using tmeplate literals for type is retarded
damn it
look man I agree with you on this one, I can't do any logical operators on my code because the fucking shitty types
Fock
@opal plank can you confirm what GoogleFued said that ```ts
type Snowflake = ${bigint}
wouldn't work
and is stupid
yell at advaith or whoever did it
let myid = '12874918287115';
let bigint = BigInt(myid); //this is big int now
let converted = bigint.toString();
who's the idiot that uses template literals for bigint convertion?
its so stupid
for types its strings
period
api returns strings
period
you want bigints, you do it in ur code
Hey uhm you said you use lavalink.....Do you also use a IPV6/64 block?
theres no types in it at all
cuz there isnt any to be done
so why even type it
discord api only uses it as string
the only integers discord returns are permissions
and opcodes and some other shit
not snowflakes
the name snowflake infers its a chain of numbers
this was likely their reason
typing it like that is stupid
should I make an issue or just pr it back to a string?
if you getting issues with it, yes
so issue, right?
,
im really tired and can't tell whether people are saying yes to the first part of second most of the time
alr
mhm
type Snowflake = \`${bigint}\` | \`${number}\`
dunno if it turns into primitive
good morning
ohaio
dafuq
retarded ngl
I couldn't find anywhere any case of someone using ${string} let alone fucking bigint
well
string is dumb
but you know what I mean
{bigint} === string
Generating mapping types which change properties via template literal strings.
that works yes
oof localhost stopped working it was just fine yest
today it can't open up the liveserver
thats what they define it as
i know its used, but its stupid
I think its cool
i mean if you think about it, it makes sense
ye
how else would you define a string that can only contain numbers?
with a regex type?
parseInt()
Hi
as a type
I want to make a discord bot
just don't be stupid, right?
Can anyone teach me how to make discord bot?
@earnest phoenix #502193464054644737 message
do you have any programming experience?
When pip decides to be a bitch, --force-reinstall
No@quartz kindle
@opal plank yo when you install tsc on ubuntu, its sudo npm i typescript -g?
I am here to learn how to make bots
#502193464054644737 message
Read this
making bots requires knowledge of programming / coding
Ohk than i will learn coding
its something that'll take a couple months btw, keep that in mind its not something quick to do
But where?
Before you make a Discord Bot, you should have a good understanding of JavaScript. This means you should have a basic understanding of the following topics:
- proper syntax
- debuging code
- basic features (vars, arrays, objects, functions)
- read and understand docs
- nodejs module system
As much as we d like to assist everyone with making their bots, we rarely have the time and/or patience to handhold beginners through learning javascript. We highly recommend understanding the basics before trying to make bots, which use advanced programming concepts.
Here are good resources to learn both Javascript and NodeJS:
Javascriptinfo: https://javascript.info/
Codecademy: https://www.codecademy.com/learn/javascript
FreeCodeCamp: https://www.freecodecamp.org/
Udemy: https://www.udemy.com/javascript-essentials/
Eloquent JavaScript, free book: http://eloquentjavascript.net/
You-Dont-Know-JS: https://github.com/getify/You-Dont-Know-JS
NodeSchool: https://nodeschool.io/
CodeSchool: https://www.codeschool.com/courses/real-time-web-with-node-js
Evie s Accelerated JS: https://js.evie.dev/
Please take a couple of weeks/months to get acquainted with the language before trying to make bots!
@earnest phoenix
@opal plank thanks
so ig the issue was fixed inbetween versions 4.1.5 and 4.2.3
I just wasted my time
CIRCULAR IMPORTS ARE PAIN
Why do you even have circular imports 
http.py from . import __version__
init.py from .http import HTTPClient
because fuck you

What is circular?
a requires b and b requires a
Basically a recursion
4head
Ok
node:450) UnhandledPromiseRejectionWarning: Error: connect ETIMEDOUT 88.202.181.104:443
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1144:16)
(node:450) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:450) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I started getting this error just now and now my bot isnt working any help please
@brittle hamlet which library u using?
discord.js
one thing i can think of causing that is the domain change for discor
which version you're using?
one sec
aight
How to find the version I think it is the latest
look in your package.json
hmmm im out of ideas tbh
Oh
doubt they would have banned the ip
wdym by this
Oh ok
discord changed from discord.gg to discord.com
Oh
but its been quite a while since that happened
Yeah
Oh ok thanks anyway
Did you enable fetchAllmembers
No
Btw shall I send the code it has only index.js to confirm that it isnt problem from my side?
is this repl.it?
Yeah
I am also facing problem there
Git the error fixed @brittle hamlet
You have to enable both of the intents in the developer portal
Oh wait I didnt do that and submitted for verification
that will also fix the error
How to enable both the intents ? I am not finding it now
go to your application then under the bot tab scroll a little bit above the permissions they are listed
unable to check them
it has no affect whatsoever on ur error
Oh
the error you're getting is that you are getting timeouts when trying to conect to the gateway
intents just dictates what discord should send you in terms of data
unrelated to ur issue
Ok thanks
but when it was disabled that my bot wasnt starting but after enabling them it works
π€
const client = new (require('discord.js')).Client();
client.login('token');
client.on('debug', console.log);
client.on('ready', () => {console.log('ready')})
```@brittle hamlet can u run the above?
this in the basic.js file right
yeah just to debug ur code, run it separate from ur bot
this is just for testing
Ok
It gives error
same error?
No says discord.js module not found
did you install discord.js?
hmmmmmm
const Discord = require('discord.js');
const client = new Discord.Client();
client.login('token');
client.on('debug', console.log);
client.on('ready', () => {console.log('ready')})
what if you try that?
if that doesnt wrk, check ur package.json
Ok
-> npm ci
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/runner/lol/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/runner/lol/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2021-03-28T12_33_57_826Z-debug.log
exit status 254
gives this error now
erm no idea bout that one
npm ERR! enoent ENOENT: no such file or directory, open '/home/runner/lol/package.json'
run the basic.js file inside your main one
Lol is the project name to be clear
ok
ok
this in the main project gives the same error as before but when I use the token of someother bot then it gives the latency of that other application
Preparing to connect to the gateway...
[WS => Manager] Manager was destroyed. Called by:
Error: MANAGER_DESTROYED
at WebSocketManager.destroy (/home/runner/Shinchan-chatbot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:333:54)
at Client.destroy (/home/runner/Shinchan-chatbot/node_modules/discord.js/src/client/Client.js:237:13)
at Client.login (/home/runner/Shinchan-chatbot/node_modules/discord.js/src/client/Client.js:226:12)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:802) UnhandledPromiseRejectionWarning: Error [TOKEN_INVALID]: An invalid token was provided.
at WebSocketManager.connect (/home/runner/Shinchan-chatbot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:133:26)
at Client.login (/home/runner/Shinchan-chatbot/node_modules/discord.js/src/client/Client.js:223:21)
(node:802) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:802) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
This is the error in the main project
Thanks @opal plank for the help but the problem resolved when I regenerated the token
ah, np
I have a problem. When I use client.get_all_members(), the bot only returns it's own name and all the other members are missing. I already enabled the "Privileged Gateway Intents" in the Discord Developer Settings but nothing changed. What I am doing wrong?
did slash command come to discordjs?
not yet
sad
you can still use it if you want
π
there's the raw event where you can use to receive integration create event and respond by using discord's REST API
How I can let the bot don't answet to any dm in private?
check if the message came from a DM
how I can check if it's a dm?
check the channel type
by checking the channel type
oh alright
I am using lavalink
Erela.js
While bot is Playing a song when adding more in queue the current song stops Playing I have to skip it to play another one
What to do.it doesn't showing any error
(node:4) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send messages to this user
if it says this, it means it found the user, but couldn't send a message, right?
permission problems on the user side
Yes dm s locked
but I spoke to the person, which is my gf, and she has the exact same settings as me in the Security options
I thought it could be cuz she had DND status, but it makes no sense, since u can still receive messages
hi

Discord things
so that's server dependant too?
I believe so, yes
when i try adding a url to the interactions endpoint url, im getting this error
Error submitting form. Please try again, or click here to contact support.
someone help plz
try refreshing the page then try again
it didnt work
and now im getting this
Validation errors: interactions_endpoint_url: The specified interactions endpoint url could not be verified.
https://TrimDisloyalLanservers.multi76.repl.co this is the url btw
Then that means the URL is not valid / returning a non OK status code. Make sure the web server is providing a response
I'm pretty sure discord makes a request to the URL and you have to send something back to confirm
@app.route('/', methods=['POST'])
def my_command():
print("ok")
return jsonify({
"type": 4,
"data": {
"tts": False,
"content": "Congrats on sending your command!",
"embeds": [],
"allowed_mentions": { "parse": [] }
}
})
should that work
hm wait
the "ok" msg is being printed
Method Not Allowed
The method is not allowed for the requested URL.
``` but this is also being returned
oh wait a sec
i think i know what the problem is
Is Discord using POST
ye
if request.json["type"] == 1:
return jsonify({
"type": 1
})
i think i need that
but idk how to define what request is
could someone help
does your router provide parameters to the function such as a request object
nope
so should i do that
@app.route('/', methods=['POST'])
def my_command():
if request.json["type"] == 1:
return jsonify({
"type": 1
})
``` in the docs it doesnt do that tho
i think ill have to do a get request or something
Follow the docs for your router lib and how they access request data such as headers or POST body
interactions through the socket 
Discord making HTTP requests to your server

you can follow the structure
you can add choices and options
https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoption you need more than just choices
options[0].name: This field is required
options[0].type: This field is required```
just like the error says
@rustic nova hmm?
@earnest phoenix no thanks
actually
this dude can't even do proper css
Phishing site
Flask?
With Flask you quite literally import request
Quick question, is there an tutorial or way to make an bot send gifs etc?
Like i know bots who send gifs if you do =hug
as a example
and its mixing up random gifs?
why does it take my new bot account 2 minutes to start?
it takes 2 minutes for it to call the ready event
exactly 2 minutes every time
doesn't happen with my old bot account
monox hacked your bot account
how to make the timestamp change on the date, without modifying the embed message ?
in python please
seriously
That bot account...
all old accounts get ready within 5 seconds
Hello,
Could you help me because I don't know how to introduce a command to make it a slash command
and i have another question
How do i do
it like that
that only people with an special role can do the bot commands?
like
there is some commands everyone can do
and some commands only locked for some members
message.author.roles.contains(r => r.name ="moderator")
like smt like this or?
message.member.roles.cache.has(roleID) or message.member.roles.cache.find(r => r.name === "name")
and is there a way to make it like, its hard to explain. So basically there are command like =1- =733 who only 1 Role can do
and as example this command
=Hello, =hug
can do everyone?
Oh ok π¦
how can i code the bot send a message to a specific channel when someone vote it?
is it possible to get data from google docs into javascript discord bot?
Show your code dude
How to host a Discord bot for 24/7 without heroku?
You need a machine that runs your script 24/7. So either have your own computer, or pay for a virtual private server
@dusky sundial ahhhh man...
@dusky sundial how can I keep run computer for 24/7....bruh
Start it, and don't turn it off? π€
And make sure it never crashes.
π
Not sure what other answer you'd be expecting
A bot that runs 24/7 must be hosted on a machine that never goes down and the bot should not crash, that's just... the reality of it.
btw make sure it doesnt go to powersaver mode
I got an Idea
:D
I can run node.js in Glitch and the make a project that pings that bot project file every 5 mins later
but Glitch is shit
Buying a raspberry for a bot π
@quiet topaz π
I hosted my bot on a raspberry pi for months
Glitch isn't just shit, it's against their terms of service to use external ping services.
@umbral zealot π
i agree
Doesn't matter if you agree, it's a fact that does not require anyone's agreement to be a fact.
@umbral zealot omg
or he could make a Glitch project to ping the bot on glitch
(dont do it cuz glitch is shit)
Hi, I am in need of help with discord OAuth2's redirect.
I am trying to redirect it to https://hhe-bot-site.leafyleaf.repl.co/reward.php
Is this correct or incorrect?
So philosophical @umbral zealot
dude just buy a raspberry pi
If you don't want to self-host. A VPS is the way to go
Does it work? If it works, it's correct. If it doesn't work, it's incorrect.
module.exports = {
name: 'help',
description: "This command will provide you with some assistance.",
execute(message, args, Discord) {
const newEmbed = new Discord.MessageEmbed()
.setcolor('#e10600')
.setTitle('Greedy Lobster Help Menu')
.setURL('discord link')
.setDescription('you may see a list of commands with help for them in this embed.')
.addFields(
{name: '?ping', value: 'It is a simple command that does nothing but respond to you with Pong! :ping_pong:'}
)
.setFooter('Join the support server for additional help :)')
message.channel.send(newEmbed);
}
}
If it worked I wouldn't be here.
I want to know if it is especially something wrong with the specific link or if it's wrong and I'm not understanding how OAuth works.
The link seems fine, the question is, what specifically isn't working?
like what exact problem are you having
wha-
Where is the Discord.js? const Discord = require('discord.js")
yes in my main.js






