#development
1 messages · Page 1450 of 1
the code isn't that bad
shows this
ill look into it tho
wrong one
Lol
why is query like that and why you putting it in {} ?
hello Guys can someone tell me how i let the bot create an Invite to the channel ?
lol
May someone fix this and help me https://repl.it/join/kqxucznf-alf128mills
Repl.it is a simple yet powerful online IDE, Editor, Compiler, Interpreter, and REPL. Code, compile, run, and host in 50+ programming languages: Clojure, Haskell, Kotlin, QBasic, Forth, LOLCODE, BrainF, Emoticon, Bloop, Unlambda, JavaScript, CoffeeScript, Scheme, APL, Lua, Python 2.7, Ruby, Roy, Python, Node.js, Deno (beta), Go, C++, C, C#, F#, ...
oh god
docs @stark viper
you used it in your own bad-discord-bot
i searched but it doesnt work
got your token @earnest phoenix
yes I did
thats how jsdoc says to do lol
what did you try
It hasn’t in it @elder loom
ngl this is pretty cool
to use it actually and see how shit it is
you dont need it that way
million
Can someone help? https://repl.it/join/kqxucznf-alf128mills
Repl.it is a simple yet powerful online IDE, Editor, Compiler, Interpreter, and REPL. Code, compile, run, and host in 50+ programming languages: Clojure, Haskell, Kotlin, QBasic, Forth, LOLCODE, BrainF, Emoticon, Bloop, Unlambda, JavaScript, CoffeeScript, Scheme, APL, Lua, Python 2.7, Ruby, Roy, Python, Node.js, Deno (beta), Go, C++, C, C#, F#, ...
yes
maybe add tmp to your gitignore if you arent going to put anything in it
channel.createInvite({maxAge: 0})``` this @solemn latch
no
read the code
Can someone help? https://repl.it/join/kqxucznf-alf128mills
Repl.it is a simple yet powerful online IDE, Editor, Compiler, Interpreter, and REPL. Code, compile, run, and host in 50+ programming languages: Clojure, Haskell, Kotlin, QBasic, Forth, LOLCODE, BrainF, Emoticon, Bloop, Unlambda, JavaScript, CoffeeScript, Scheme, APL, Lua, Python 2.7, Ruby, Roy, Python, Node.js, Deno (beta), Go, C++, C, C#, F#, ...
there is a placeholder for a reason tho
Can someone help? https://repl.it/join/kqxucznf-alf128mills
Repl.it is a simple yet powerful online IDE, Editor, Compiler, Interpreter, and REPL. Code, compile, run, and host in 50+ programming languages: Clojure, Haskell, Kotlin, QBasic, Forth, LOLCODE, BrainF, Emoticon, Bloop, Unlambda, JavaScript, CoffeeScript, Scheme, APL, Lua, Python 2.7, Ruby, Roy, Python, Node.js, Deno (beta), Go, C++, C, C#, F#, ...
@earnest phoenix please can you stop
you're literally spamming
theres no need for whatever the heck that {} does lmao
its jsdoc typings
@stark viper i dont see anything wrong with that. Did it error?
probably for when you generate docs from jsdoc
no
but logically it should show somewhere in vsc too
how can i send the invite then
@stark viper it just creates the invite, it doesn't send it.
so how i send it
doing @param just gives me intellisence, but the actual type comes from the interface
yes they show correctly in the typings thingy, just not in the jsdoc description
@hollow sedge you should write a wrapper that introduces schemas
put it in a variable ?
Channel.send(invite.url)
oh god
ok
that sounds fun
lol
i just have to learn node.js first
jk i already know some JS
yeah the one above is fine, ts being good ts, the issue is the bottom, i guess its a alias?
oh ok good
Createinvite is a promise, so it'll need to be awaited/then
i think i can figure it out
lemme do a 5 min research about it rq
also if you are logging stuff use https://github.com/million900o/loggers
its 2 different things
type and name
why do you h ave your own logger
{type} Name
ik
loggers
just wondering why type doesnt show anywhere
thats why
i assume this is the shitty version of ts where you import types and assign them as a different thing
lol
like my example here
i guess i got to install millions trash modules
to add to his trash db
no offense
it was made as a joke
Query is the new type, but its an extension of a primitive type string
so no offence taken
thats at least what im interpreting from this
ok good
this is one of the reasons i hate jsdocs

imagine typing that for structures that are dynamic from apis?
like calling parents
Mom? Hello?
imagine fetching channel, then you need to add interface for guild inside that too cuz channel is child of guild(just an example) and make it optional
omg, yeah, no ty
wait, i just noticed
tim is using TS

@quartz kindle stay on the dark side, we can just transpile our big brein code to vanilla js 
im not using ts
duit
in js how to do im new in js ...
nu
by the way
boom, transpile
if you're wondering wtf am i working on
time = performance.now();
result = array.find(n => n.includes("Eris"));
console.log(performance.now() - time);
console.log(result);
// => 10.449599981307983
// => 136199 Eris
time = performance.now();
result = sb.find("Eris");
console.log(performance.now() - time);
console.log(result);
// => 0.38879990577697754
// => 136199 Eris
// ~ 30x faster
looks like a way to shameless advertise your lib as being better than the other discord js libs

im calling 911
this has nothing to do with discord lmao
but eris though
module.exports = (client, guild) => {
const url1 = (`${guild.iconURL()}`);
const embed = new Discord.MessageEmbed()
.setColor("GREEN")
if(url1.startsWith("https://cdn.discordapp.com")){
embed.setThumbnail(url1)
}
embed.addField("I Joined a New Guild", `${guild.name}`, true)
.addField(`GuildId`, `${guild.id}`)
var channel = guild.channels.first;
var invite = channel.createInvite({maxAge: 0});
embed.addField(`GuildInvite`, `${invite.url}`);
client.channels.fetch(channels["JL-LOGS"]).then(channel => channel.send(embed));
};``` can anyone say me whats wron there ...?
Eris is an asteroid / minor planet
@crimson vapor https://github.com/Million900o/jason.db/blob/e96be3a748a291521b30b06b6cb6fc7dcd136060/lib/Collection.js#L64, this is wrong
this forces you to use a string as a key
xD
guys how i can add my bot in top.hh .._..
basically there is a database of asteroids that has 500k+ items
performance on asteroids though
ye
you spiked my interested
guys?
js strings are fast
how do you even calculate a performance of an asteroid?:
How isn't it working, Luke? What's the problem?
lmao
the performance is in searching for an asteroid by name
ik 
i'll asteroid you
imagine not using postgres
the problem is the bot is sending nothing... and the error says there is something at createinvite
actually cassandra might be best for it
can postgres do full string seach in 0.3ms
without indexing
whats a good place to host bots
thats the whole point
?
true full text seach cant really index properly without wasting a ton of memory
which one do you want a test on?
im just doing what grep does, but in memory
i could try redis for memory performance test
sure
lets see
well of course a fully featured db will probably be faster
but then you have network overhead
var invite = channel.CreateInvite({maxAge: 0});
^
TypeError: Cannot read property 'CreateInvite' of undefined
at module.exports (E:\slodr\Documents\Owlbert Bot\events\guildCreate.js:14:26)
at Client.emit (node:events:376:20)
at Object.module.exports [as GUILD_CREATE] (E:\slodr\Documents\Owlbert Bot\node_modules\discord.js\src\client\websocket\handlers\GUILD_CREATE.js:33:14)
at WebSocketManager.handlePacket (E:\slodr\Documents\Owlbert Bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (E:\slodr\Documents\Owlbert Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (E:\slodr\Documents\Owlbert Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (E:\slodr\Documents\Owlbert Bot\node_modules\ws\lib\event-target.js:125:16)
at WebSocket.emit (node:events:376:20)
at Receiver.receiverOnMessage (E:\slodr\Documents\Owlbert Bot\node_modules\ws\lib\websocket.js:797:20)
at Receiver.emit (node:events:376:20)```
the error
unless you got both locally
then IPC should be really performant
there's still a minimum overhead
hmmm
@stark viper CreateInvite doesn't seem to be a function
code
it is
i`ll try
There's also the fact that channel is undefined
And message
It's first() not first when getting the first thing in a collection. it's a method not a property.
okay
So essentially just ```let Channel = message.mentions.channels.first()
Channel.createInvite({maxAge: 0});```
@quartz kindle 4 miliseconds with a full count search
Deep
no performance.now() REEEE ERWIN
Actually not even mention its just message.channel.createInvite
I demand precision
how big is the db?
lets see
actually
nono
you want big?
i'll give you big
one sec
imma pull stats from the twitch abuser
Lol
i try it now
owo what's Temporal
anyway we're comparing apples with oranges here
sounds like some time travel thing
smth mentioned on the MDN pages for JS Date
so how to create a invite to a guild with guild.
I think just message.channel.createInvite will work @stark viper
not with guild.channel ?
@stark viper you arent requiring any argument in your functions to be message
@quartz kindle
So message should be undefined in your function
It is pointless to get guilds or channels from the args since you can just do message.guild or message.channel
what do youz mean im new in js sry
as much as it pains to me so say this, learn js first
@stark viper 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!
Did you just copy paste the pins
i understood js but not how to work with the create invite
no, i have my own tag #265156322012561408
createInvite() should return a string iirc
not sure whats the fuss
so following that average, it would be 80ms for 1.5 mil, ~25ms for 500k
but anyway thats just counting them right? just iterating over them and incrementing a value, not doing a string search
almost 4 times as performant ?
oh
i forgot
let me do a fuzzy search
let me pick my own user id from the db
the asteroids data im working with is 500k items
although they are small items, around 10-20 chars each
yeah and then invite.url right ?
about 10mb total
imma test on 15 mil, should be a good match
a full regex string search takes ~4ms
technicly this should work right ```js
module.exports = (client, guild) => {
const url1 = (${guild.iconURL()});
const embed = new Discord.MessageEmbed()
.setColor("GREEN")
if(url1.startsWith("https://cdn.discordapp.com")){
embed.setThumbnail(url1)
}
embed.addField("I Joined a New Guild", ${guild.name}, true)
.addField(GuildId, ${guild.id})
var channel = guild.channels.first();
var invite = channel.createInvite({maxAge: 0});
embed.addField(GuildInvite, ${invite.url});
client.channels.fetch(channels["JL-LOGS"]).then(channel => channel.send(embed));
};```
@hollow sedge you can't add a number to an object's property can you?
we may have a problem
what is the problem
No it returns a Promise
Why would it not
?

does it really hurt
😂
i tried it multiple times and this is why im asking
did it work?
yes
Bruh JSON puts property names in double quotes
var invite = channel.createInvite({maxAge: 0});
^
TypeError: Cannot read property 'createInvite' of undefined
at module.exports (E:\slodr\Documents\Owlbert Bot\events\guildCreate.js:14:26)
at Client.emit (node:events:376:20)
at Object.module.exports [as GUILD_CREATE] (E:\slodr\Documents\Owlbert Bot\node_modules\discord.js\src\client\websocket\handlers\GUILD_CREATE.js:33:14)
at WebSocketManager.handlePacket (E:\slodr\Documents\Owlbert Bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (E:\slodr\Documents\Owlbert Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (E:\slodr\Documents\Owlbert Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (E:\slodr\Documents\Owlbert Bot\node_modules\ws\lib\event-target.js:125:16)
at WebSocket.emit (node:events:376:20)
at Receiver.receiverOnMessage (E:\slodr\Documents\Owlbert Bot\node_modules\ws\lib\websocket.js:797:20)
at Receiver.emit (node:events:376:20)```
bruh ik lol
hmmm im fucking something up
module.exports = (client, guild) => {
const url1 = (`${guild.iconURL()}`);
const embed = new Discord.MessageEmbed()
.setColor("GREEN")
if(url1.startsWith("https://cdn.discordapp.com")){
embed.setThumbnail(url1)
}
embed.addField("I Joined a New Guild", `${guild.name}`, true)
.addField(`GuildId`, `${guild.id}`)
var channel = guild.channels.first;
var invite = channel.createInvite({maxAge: 0});
embed.addField(`GuildInvite`, `${invite.url}`);
client.channels.fetch(channels["JL-LOGS"]).then(channel => channel.send(embed));
};```
so it is defined
did you start work on the wrapper?
idk did i?
idk did u?
idk did i?
tip: stop using var and embed builder
@stark viper bruh that function is not run
lets ask Erwin
Read the line where you defined the variable channel
Tell me if it looks correct
im busy comparing apples and asteroids with @quartz kindle
wait what is this
lmao. btw is it normal that if you do string | Array in .d.ts it shows up as any in vsc?
wdym
why not just JSON.stringify it
umm
Think it looks correctly. Working with @stark viper
because key is a fucking string or number
but why are you splitting on "." then?
for nesting objects
Array is not a type iirc
string[]
@lucid mirage bruh collection.first is a function and there are no parenthesis after the word function
thats flaze's code for nesting objects
since you didnt declare what Type that is, it shows as any
oh
Wait is first even a function?
but if we type .first() it says its not a function
I mean if you forget the parenthesis JS should put the function as the variable value
still shows up as any
But channel's value is undefined
So guild.channels.first is undefined smh 
@crimson vapor idk if i can do this lol i cant even understand what this is
oof
Yes
Can you show me your command handler
if you don't want to then don't
ah the Iterable is making it show as any
What do u mean with commandhandler 🤔
do i need to declate an interface for iterable? i thought its built in
:panik:
A good dev should know
Yea, but explain pls
he wants to know how you handle commands
It basically the stuff that automatically handles commands instead of having to go and put the code for if the command is x then run manually for every single command
@quartz kindle 275, 15 million, fuzzy string match
iteratable you need to cast iirc most of the times
specially with objects
i dont find it
not bad
so 27 for 1.5mil, 9 for 500k
still less performant than yours
so basicaly i dont even know what you mean
thats quite an accomplishment, looking that this is an official postgres addon
An example of a command handler:
// when bot start
for (let filename of fs.readdirSync("./commands")) {
let data = require(`./commands/${filename}`);
bot.commands.set(data.name, data);
}
// message event
bot.on("message", (message) => {
// few lines of wizardry
bot.commands.get(command).execute(bot, message, args);
});
OH GOD
I JUST LEAKED MY FUCKING COMMAND HANDLER AAAAAAAAA
function CommandHandler (message, args, command) {
if (!command) return
if (command.requiredPerms && !message.member.hasPermission(command.requiredPerms)) return
try {
command.run(message, args)
} catch (err) {
message.client.logger.error(err)
message.client.responses.errorEmbed(message, err)
}
};
``` command handler
we dont have it like this
lol the command handler mostly everyone uses
is there any better one
nah command handlers should handle everything except the execution of the command
I mean like perms checks
i figured it out
i need to type it with the type
string | Iterable<string>
wait i thought you were doing an array
array should automatically pickup
try
type thing = string | string[]
it works as an iterable?
yup
cool
Tim why not just learn ts?
it knows its an array, so it pulls
you can do custom sets too
MyInterface[]
for example
and it'll know its an array populated of MyInterfaces
its what i said, usually its like that with objects
try to avoid Object.assign() and .push()
those get ignored
loops work so its fine
on those when it returns any, even though you dont want it, just type cast it
is it normal for snipe to record like this?
[
{
author: User {
id: '257062280779268097',
system: false,
locale: null,
flags: [UserFlags],
username: 'aproxthethat',
bot: false,
discriminator: '1018',
avatar: '2e0c002c4c60695c6510e361ad539797',
lastMessageID: '787780806696632350',
lastMessageChannelID: '786338483492749329'
},
content: 'sa',
channel: TextChannel {
type: 'text',
deleted: false,
id: '786338483492749329',
name: 'mekan',
rawPosition: 13,
parentID: '700339359446073384',
permissionOverwrites: [Collection [Map]],
topic: null,
nsfw: true,
lastMessageID: '787780806696632350',
rateLimitPerUser: 0,
lastPinTimestamp: null,
guild: [Guild],
messages: [MessageManager],
_typing: Map(0) {}
},
date: 2020-12-13T20:39:22.061Z
},
{
content: 'sa',
author: User {
id: '257062280779268097',
system: false,
locale: null,
flags: [UserFlags],
username: 'aproxthethat',
bot: false,
discriminator: '1018',
avatar: '2e0c002c4c60695c6510e361ad539797',
lastMessageID: '787780806696632350',
lastMessageChannelID: '786338483492749329'
},
image: null,
date: '23:39'
}
]
lmao rip
as in array.push?
the second one doesnt look normal
you can also push just fine
yeah
but just keep in mind it might not type check the push element
so assure that you are pushing a correct type, but you aint a noob to do that xD
<GuildMember>.hasPermission(...) is what you're looking for: https://discord.js.org/#/docs/main/stable/class/GuildMember?scrollTo=hasPermission
You also don't need to wrap it in a promise because there's no promise returned.
I did the command called create mute role, but the command creates a mute role and prevents the role from writing to the channels, while clearing/resetting the permissions of other channels. How can i fix this?
69 million presences parsed in 10 days
you're insane
82 in 19
bot.on('messageDelete', message => {
const snipes = message.client.snipes.get(message.channel.id) || [];
snipes.unshift({
author: message.author,
content: message.content,
author_name: message.embeds.author,
title: message.embeds.title,
description: message.embeds.description,
fields: message.embeds.fields,
channel: message.channel,
date: new Date()
})
snipes.splice(10)
message.client.snipes.set(message.channel.id, snipes)
})
is there a mistake I do not understand
sometimes it records incorrectly.
why not just set?
date: 2020-12-13T20:37:45.210Z
...
date: '23:37'
the date is changing.
use a map my man
let snipes = new Map();
on msg delete =>
snipes.set(channel.id, message);
////
on command snipe!
snipes.get(channel.id)
@earnest phoenix you're overcomplicating your code
.set() overrides
message.member is a GuildMember instance, so call .hasPermission() on it with "ADMINISTRATOR" as the argument to check if the user has the admin permission.
also if any of those comes in there, its either a bot or a modded client
users cannot send embeds
for bot
not sure why you want to record bot messages, but you do you
my point still stands
you can do a snipe command in 3 lines
new map()
map.set(channel.id, message)
message.channel.send(map.get(channel.id) ?? 'Nothing to snipe')```
why do you need it to be a promise?
just return the actual value
don't cache everything
just cache content author and time
and purge cache after an hour
what the fuck
also that prefix + the ping command is a bit suspect
tysm @sudden geyser
hey
i need some help with my music bot
it's with ytdl
and there is no code for making it play
@crimson vapor why not? Make an embed with everything you need and then make a setInterval with a check to see if the sentTimrstamp is higher than date.now + 1h, if it is, delete it
huh
Wdym huh
what are you responding to
The messgaes thing
oh
don't cache everything
just cache content author and time
and purge cache after an hour
@opal plank first one or second one?
first one is cleaner with one line<, but it overflows, so second one
how do I do it https://cdn.yxridev.com/u/DJrOl9uw.png
wait do what?
also, you should keep it basic, theres a decent likelyhood im gonna get bored soon and might start getting you some commits if you want
edit the message
this is pure chaos
if even ONE of those things fail you fucked
yeah I know
use conditional chaining or proper checks
lmao
spoonfeed, rules
fucking

I genuinely might leave this server it's that helpful
imo kinda
yeah i hate this server
i can point you towards the right direction but blatently asking for code is just a bit too much
not 100% but enough
just paste examples
Can someone help please?
yeah, d.js has no examples whatsoever in their docs
i was being sarcastic
nice job
ok ok
they usually have 2-3 examples per thing
the discordjs.guide thing literally tells you everything
I know how to code I just really cba to sit here for 3 hours trying things until I get it right
you dont say
well i legit just told you that if your promise fails you will get errors, which instead of fixing, you simply rteplied with i dont care, give me code

yeah beacuse I don't
there are two things you can do when you get stuck:
- Take a break
- Learn how to do it properly
this command doesnt affect my bot in any way if it fails

whitenames
who just dotposted
sorry i forgot:
3. Go on #development and beg for code
alright
but you.... nvm
client.channels.fetch('ID').then(e => if (e) e.messages.fetch('ID').then(f => if (f) f.edit() ) probably
wrong
that'll error
wait how
bruh

still callback hell and you might stop at the first bit
use await for the love of god
are discord audit logs reliable to use rn?
in what case is the no
no
invites, bans, kicks, no?
why would I use await for an example?
why would u use a callback hell instead of async?
rule of the thumb, never use more than one .then
hmm then how would I go around for the invites, bans and kicks for audit logs?
looks ugly, is ugly, callback hell, stinky
Promise.resolveAll() is a thing btw
so you dont have to do that ugly looking thing
never used Promise.anything
ye ik
actually
race might be better
but not even i used that more than once
actually, nvm
thats not used in this case
promise.all is so good
I think ive only used it once
im trying to come up with an example of using my thing in a for loop
but i cant think of any use case
lmao
besides console.logging
for(let item in wholedatabase) twitch.api.send('TwitchSpam goes BRRR, erwin sends his regards' + item);```
lmao
i mean, what if it returns an object?
yes
also that'll never work
id === true/false?
that'll never work
lmao
you are comparting a string to true or false
LMFAO
promisifying that wont help with anything
you can directly return the thing
no need for promise
^^^^^^^^^^^^^^^^^^^^^^^^
if you want to return a promise response from a sync function, there is Promise.resolve()
he doesnt even need a promise in that case though, as long as the member is cached
otherwise he'd have to fetch it
no reason for message.member to not be cached tho right
ye but if hes using the check function in a promise way, because some other instance of check needs to be a promise
oh right
he can do that
hmmm
lemme double check, but im fairly certain you can
im pretty sure he is gonna ask the same question again
for example
ok so i have my ts files in a dir and when i require them it imports the client with all the intellisense but on run i get a SyntaxError: Cannot use import statement outside a module. This was working a few minutes ago but upon recent commits it started throwing that
oh no
.then only chains on promises, i could've sworn.......
where are you getting message from
holdup
and why are you using assignment over comparison
@earnest phoenix 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!]
and why is it a fucking promise
back on track, its annoying that .then() doesnt work in this case
message.author isn't a promise tho
im not promisifying it
why would .then work on message.author then
I thought you could only .then on a promise
correct
function whatever(data) {
if(cache.has(data)) return cache.get(data) // not a promise
else return api.fetch(data) // a promise
}
result = await whatever(x)
``` in this situation for example, await will work for both the sync and the async code. but its more semantically correct to do this instead ```js
function whatever(data) {
if(cache.has(data)) return Promise.resolve(cache.get(data)) // a promise
else return api.fetch(data) // a promise
}
result = await whatever(x) // it will always return a promise, and not only sometimes
though i was under the false impression you could use it on functions too
oh
yeah thats right
thats actually smart
never seen a usecase for that but it makes dealing with data so much easier
i would personally do it differently though
how would you do it?
function whatever() {
new Promise(resolve, reject => {
if(cache.has(data)) resolve(cache.get(data));
else api.fetch(data).then((a) => { if(a) resolve(a) else reject()})
})
}```
i think that should work?
you resolving everything under a single promise
You forgot to wrap the parameters between ()
thats another option yes, but for example if you're gonna do a simple check like if(this.busy) return at the beginning of the function, there is no need to create a new Promise just to immediately return
fair
discord.js has a few cases like that
i also forgot a return in the new promise
xD
Tim do you have computer science degree?
yeah tim the master of counter strike
lol
u did write cs though, cant blame me for that one
no
I just assumed that in #development cs would stand for computer science not counter strike
but you're right ya never know
acronyms are annoying, sometimes they mean multiple things, context is a bitch lol
nope
whats ur major
i never finished highschool
im a major asshole/idiot
ye
bruh
^
family reasons
yet here he is, carrying the whole channel/server
u work somewhere?
degree in what?
ah okay
diploma? or univertsity?
Where do u freelancer for some good cash? @quartz kindle
I thought tim worked at NASA
I assumed you would have said "yes I have an X in X"
MC-Market freelancing isnt so profitable
no idea, i only get stupid jobs and people who hate paying
Same here..
i only finished school in canada, thats about it, i got accepted into some uni's there but being a foreigner and studying there you pay a lot more than national students, so i never done it. Just like tim, im a freelancer
Discord is just being discord
MC-Market?
scam the kids for minecraft mods in jeeeeva
Voltrex
Oh
Yes
Everything ok?
unironically though, mc mods arent easy at all to make
I dont think it is
ourcord
Most of the recent ones were from the contributor table
Wait where are my commits bruv
I always just commit "yes"
cba to think of names for commits when I do like 100 changes at once
think thats bad? checkout my ACTUAL repo for the company im working for rn

It takes like 5 seconds to write a description
same
when the client doesnt give 2 fucks about the code, only about its usability
that's just a crime
Tim btw github darkmode exists
Yes but they did it
better late than never :^)
Btw which guild is that
Palace
dark mode finally released? ayyy
you didn't know?
A couple days ago
the pain
lmfao
Lol
I'm crying right now.
Dice
oooh, i thought it was borboss
I'm in bed
h
@sinful belfry fix lib please.
no h chain today
Her*.
her
Dice is who?
o
does highschool even mean anything tbh
@honest perch can you just revert to before the error happened.
yes
No
it makes getting a job a lot easier
I'm in bed
LOL
you can do it
just change the head to that commit version
I don't want to fuck shit up further.
Blame it on matt
I don't even know when it broke.
I agree with this statement
it would happen anyway if they reverted
Github's linter is too fucking drunk
wait, theres 4 people on this bot?
I don't have the energy for this.
there are a few more than 4
And me
Its not a bot
It's a lib, not a bot.
wtf
https://github.com/ourcord/ourcord @opal plank
Yes
why alebot is only in 21 guilds then?
?
It's a discord lib
what the fuck is this https://github.com/ourcord/ourcord/blob/master/packager.js
no idea
i found a bug, i request colab status now
are you that fucking lazy
It was meant for npn
Yes
ytho
this looks like twitch plays discord lib
Ynot
Can I outline the error please?
What's the error bruh
twitch is the shittiest of apis to hook onto, i absolutely disencourage people from using it lmao
i doubt their code is trashier than twitch's api
how do i run it bruh
have you seen twitch plays pokemon?
how much do you guys have left on the lib?
@crimson vapor github is broken
thank god no
Not the badge
The import syntax error. When I'm testing it with yarn/npm, it throws the error. Anything else I need to outline?
ik
do it, its marvelous
am i going to retain vision after seeing it?
yes
blindness is a concern of mine after looking at cursed code
@earnest phoenix 
Dice, maybe rewrite the whole thing to make it less of a cluster fuck
h
slow
smh
The hell is TMI
TIM?
Fix this first.
h
MY ASS IS MORE MARVELOUS THAN THIS CURSED CODE
Idk, maybe rewrite it to make it less clusterfuck
Krista
Not the issue.
Yes it is
hey
wtf am i looking at
If you rewrote it it wouldn't be bad
The .d.ts file?
declare module "Client" is the error? Wtf is happening
Like everything
https://github.com/ourcord/ourcord/blob/master/src/websocket.ts#L163 good formating guys
Is an error
the very best
That should be the thing that makes it work.
Ask the mobile dev nerd why the formatting is like that
their configs are also config.js which makes 100% sense
Erwin, ts god, please tell me why I can't use es syntax in ts module files

But it was working before

You said yourself that it would work
And it was in fact working
too lazy
No.
yes.
lmao
Eat your words >:(
nom
Pog cat
@misty sigil please fix before I hurt someone.
what needs fixksd
🗿 Wtf
How about the mobile dev fixes it
What's the issue, i don't see it
You know what, fuck ts x84 assembly it is
aye
x86*.
Same thing
Let's rewrite it in binary
0
What happens when you try and run the latest v on npm?
Literally anyone
Like trying to construct a client?
Yes
Lemme see
Even requiring the file
Can voltrex like just sell his house and get a pc
@opal plank https://www.youtube.com/watch?v=P4g8zKRJLbQ
lmaoo
I’m sure voltrex could get a pc
they just want torture
and pain
the code works, but dude, i messed with their api, and this is so garbage https://github.com/hzoo/TwitchPlaysX/blob/master/server.js
twitch doesnt have a message event
since just like us, we have dm's and channels
voltrex will get a pc soon™️
we also have announcements
and a bunch of other shit
also adding events that already already handled by twitch's end
disconnect and reconnect dont need to be bind cuz the library has those events already listed and arent private
this is why i hate ts
Same
use import
Yes, what the fuck.
this is why i love typescript
cuz yall using the wrong import u ducks
I'm so confused, how's that error even happening in the first place
...?
import('./file');
go back to studying
Uhh
thank u
np
Umm
what's wrong with import fml = require()
@tame kestrel im gonna ping you for that
Or Import h from ""
nothing, thats es5 syntax
dice
import > require

import * from e as "h";
maybe we should write this
ok bye
in js
wrong
@earnest phoenix where's the error being thrown from
import * as alias from 'file'
wait fuck minute
Show your compiler config again
im just gonna set back relax and watch the world burn as yall figure out how to do this even though i already gave you the answer

B
its funny isnt it Erwin
ikr
tias
yes I think so
Since when did import() exist
ts is more complex than yall think
it’s complex
never tried ts







