#development

1 messages · Page 1450 of 1

hollow sedge
#

im jking

crimson vapor
#

the code isn't that bad

quartz kindle
hollow sedge
#

ill look into it tho

solemn latch
#

wrong one

quartz kindle
#

Lol

solemn latch
#

rip tim

#

that one

#

lol

opal plank
#

why is query like that and why you putting it in {} ?

stark viper
#

hello Guys can someone tell me how i let the bot create an Invite to the channel ?

hollow sedge
#

lol

earnest phoenix
#

May someone fix this and help me https://repl.it/join/kqxucznf-alf128mills

hollow sedge
#

oh god

solemn latch
#

docs @stark viper

hollow sedge
#

you used it in your own bad-discord-bot

stark viper
#

i searched but it doesnt work

elder loom
#

got your token @earnest phoenix

crimson vapor
#

yes I did

quartz kindle
solemn latch
#

what did you try

earnest phoenix
#

It hasn’t in it @elder loom

hollow sedge
#

ngl this is pretty cool

crimson vapor
#

to use it actually and see how shit it is

opal plank
#

you dont need it that way

hollow sedge
#

like it sucks

#

but its cool

quartz kindle
#

from the jsdoc website

hollow sedge
earnest phoenix
#
crimson vapor
#

yes

hollow sedge
#

maybe add tmp to your gitignore if you arent going to put anything in it

stark viper
#
channel.createInvite({maxAge: 0})``` this @solemn latch
crimson vapor
#

no

opal plank
crimson vapor
#

read the code

earnest phoenix
#
hollow sedge
#

i read it

#

lol

crimson vapor
#

there is a placeholder for a reason tho

earnest phoenix
#
misty sigil
#

@earnest phoenix please can you stop

earnest phoenix
#

But help @misty sigil

#

Pls

quartz kindle
#

yours doesnt show anywhere either

misty sigil
#

you're literally spamming

opal plank
#

theres no need for whatever the heck that {} does lmao

quartz kindle
#

then why does jsdoc have it

#

lmao

opal plank
#

im not even sure what it does

quartz kindle
#

its jsdoc typings

solemn latch
#

@stark viper i dont see anything wrong with that. Did it error?

quartz kindle
#

probably for when you generate docs from jsdoc

stark viper
#

no

opal plank
#

i assume so too

#

maybe its used internally?

quartz kindle
#

but logically it should show somewhere in vsc too

stark viper
#

how can i send the invite then

opal plank
#

usually {} or {{}} are fillers, i guess its internal

#

i have no idea what it does tbh

quartz kindle
#

so i'll need to manually write typings in the param description

#

what a pain

pure lion
#

i have a headache

#

why wont this work

#

bbbbbbbbbbbbbbbbbbbbbb

opal plank
#

so using params is abolutely useless

solemn latch
#

@stark viper it just creates the invite, it doesn't send it.

opal plank
stark viper
#

so how i send it

opal plank
#

doing @param just gives me intellisence, but the actual type comes from the interface

quartz kindle
#

yes they show correctly in the typings thingy, just not in the jsdoc description

crimson vapor
#

@hollow sedge you should write a wrapper that introduces schemas

stark viper
#

put it in a variable ?

quartz kindle
#

they show correctly up there

solemn latch
#

Channel.send(invite.url)

hollow sedge
#

ok

#

that sounds fun

crimson vapor
#

lol

hollow sedge
#

i just have to learn node.js first

crimson vapor
#

oh

#

you don't know node

hollow sedge
#

jk i already know some JS

opal plank
#

yeah the one above is fine, ts being good ts, the issue is the bottom, i guess its a alias?

crimson vapor
#

oh ok good

solemn latch
#

Createinvite is a promise, so it'll need to be awaited/then

hollow sedge
#

i think i can figure it out

opal plank
#

lemme do a 5 min research about it rq

crimson vapor
#

ima go shower rn

#

have fun reading my code even more

opal plank
#

OH

#

@quartz kindle

crimson vapor
opal plank
#

its 2 different things

hollow sedge
#

ok

#

oh god

opal plank
#

type and name

hollow sedge
#

why do you h ave your own logger

opal plank
#

{type} Name

quartz kindle
crimson vapor
#

loggers

quartz kindle
#

just wondering why type doesnt show anywhere

opal plank
crimson vapor
#

thats why

opal plank
#

i assume this is the shitty version of ts where you import types and assign them as a different thing

hollow sedge
#

lol

opal plank
#

like my example here

hollow sedge
#

i guess i got to install millions trash modules

#

to add to his trash db

#

no offense

opal plank
crimson vapor
#

it was made as a joke

opal plank
#

Query is the new type, but its an extension of a primitive type string

crimson vapor
#

so no offence taken

opal plank
#

thats at least what im interpreting from this

hollow sedge
#

ok good

quartz kindle
#

some blog post is saying to just remove jsdoc types

#

that they are useless

#

lmao

opal plank
#

imagine typing that for structures that are dynamic from apis?

#

like calling parents

solemn latch
#

Mom? Hello?

opal plank
#

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 mmulu

quartz kindle
#

im not using ts

opal plank
#

d.ts

#

technically ts

quartz kindle
#

technically

#

but still js

#

i dont have ts installed

#

lmao

opal plank
#

duit

stark viper
#

in js how to do im new in js ...

quartz kindle
#

nu

opal plank
#

imagine not ever again having to change code

#

new flavour of js came?

quartz kindle
#

by the way

opal plank
#

boom, transpile

quartz kindle
#

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
opal plank
#

code needs to run on older browser? boom, transpile to targetted flavour

#

lets see

pure lion
#

@opal plank i wrote a poem

#

i called it "declare module 'Ourcord'"

opal plank
opal plank
quartz kindle
#

this has nothing to do with discord lmao

opal plank
#

but eris though

stark viper
#
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 ...?
quartz kindle
#

Eris is an asteroid / minor planet

hollow sedge
opal plank
#

OOOH

#

yeah, galacticraft taught me about eris

hollow sedge
#

this forces you to use a string as a key

quartz kindle
#

xD

fair scaffold
#

guys how i can add my bot in top.hh .._..

quartz kindle
#

basically there is a database of asteroids that has 500k+ items

opal plank
#

performance on asteroids though

quartz kindle
#

ye

opal plank
#

you spiked my interested

quartz kindle
#

js strings are fast

opal plank
#

how do you even calculate a performance of an asteroid?:

umbral zealot
#

How isn't it working, Luke? What's the problem?

quartz kindle
#

the performance is in searching for an asteroid by name

opal plank
#

ik KekDoggo

quartz kindle
#

i'll asteroid you

opal plank
#

imagine not using postgres

stark viper
#

the problem is the bot is sending nothing... and the error says there is something at createinvite

opal plank
#

actually cassandra might be best for it

quartz kindle
#

can postgres do full string seach in 0.3ms

opal plank
#

elasticsearch + cassandra

#

hmm lemme run a query with index

quartz kindle
#

without indexing

opal plank
#

then it becomes an issue, also, why the fuck do you not index it?

earnest phoenix
#

whats a good place to host bots

quartz kindle
#

thats the whole point

earnest phoenix
#

?

opal plank
#

hmmm fuzzy sesarch right?

#

or just includes?

quartz kindle
#

true full text seach cant really index properly without wasting a ton of memory

opal plank
#

which one do you want a test on?

quartz kindle
#

im just doing what grep does, but in memory

opal plank
#

i could try redis for memory performance test

quartz kindle
#

sure

opal plank
#

lets see

quartz kindle
#

well of course a fully featured db will probably be faster

#

but then you have network overhead

stark viper
#
    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

opal plank
#

then IPC should be really performant

quartz kindle
#

there's still a minimum overhead

opal plank
#

hmmm

main trench
#

@stark viper CreateInvite doesn't seem to be a function

opal plank
#

im now curious

#

let me query this rq

main trench
#

Try createInvite

#

The first letter is usually lowercase

stark viper
#

i`ll try

main trench
#

@stark viper ohh

#

Your missing guild

umbral zealot
#

There's also the fact that channel is undefined

main trench
#

And message

umbral zealot
#

It's first() not first when getting the first thing in a collection. it's a method not a property.

stark viper
#

okay

main trench
#

So essentially just ```let Channel = message.mentions.channels.first()

Channel.createInvite({maxAge: 0});```

opal plank
main trench
#

Deep

pale vessel
#

no performance.now() REEEE ERWIN

main trench
#

Actually not even mention its just message.channel.createInvite

pale vessel
#

I demand precision

quartz kindle
opal plank
#

lets see

#

actually

#

nono

#

you want big?

#

i'll give you big

#

one sec

#

imma pull stats from the twitch abuser

quartz kindle
#

Lol

stark viper
#

i try it now

earnest phoenix
#

owo what's Temporal

quartz kindle
#

anyway we're comparing apples with oranges here

hollow sedge
#

sounds like some time travel thing

earnest phoenix
#

smth mentioned on the MDN pages for JS Date

stark viper
#

so how to create a invite to a guild with guild.

main trench
#

I think just message.channel.createInvite will work @stark viper

stark viper
#

not with guild.channel ?

main trench
#

You can try it with that

#

I don't think that will work though

stark viper
#

in the docs they say it should work

#

but it does not work

earnest phoenix
#

@stark viper you arent requiring any argument in your functions to be message

opal plank
earnest phoenix
#

So message should be undefined in your function

opal plank
#

15 million entries

#

800+ ms on 15 mil, 11 on estimate

earnest phoenix
#

It is pointless to get guilds or channels from the args since you can just do message.guild or message.channel

stark viper
#

what do youz mean im new in js sry

opal plank
#

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!

earnest phoenix
#

Did you just copy paste the pins

stark viper
#

i understood js but not how to work with the create invite

opal plank
#

createInvite() should return a string iirc

#

not sure whats the fuss

quartz kindle
#

but anyway thats just counting them right? just iterating over them and incrementing a value, not doing a string search

opal plank
#

almost 4 times as performant ?

#

oh

#

i forgot

#

let me do a fuzzy search

#

let me pick my own user id from the db

quartz kindle
#

the asteroids data im working with is 500k items

#

although they are small items, around 10-20 chars each

stark viper
#

yeah and then invite.url right ?

quartz kindle
#

about 10mb total

opal plank
#

imma test on 15 mil, should be a good match

quartz kindle
#

a full regex string search takes ~4ms

stark viper
#

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));

};```

crimson vapor
#

@hollow sedge you can't add a number to an object's property can you?

hollow sedge
#

oh

#

is that true

#

i think you can

#

idk anymore

opal plank
#

we may have a problem

crimson vapor
#

what is the problem

earnest phoenix
#

Why would it not

opal plank
sudden geyser
earnest phoenix
whole knot
#

😂

stark viper
#

i tried it multiple times and this is why im asking

crimson vapor
#

did it work?

earnest phoenix
#

Do you get any errors

#

@crimson vapor is that JSON

crimson vapor
#

yes

earnest phoenix
#

Bruh JSON puts property names in double quotes

stark viper
#
    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)```
crimson vapor
#

bruh ik lol

earnest phoenix
#

@stark viper channel is undefined

#

Your command handler is setup wrongly TBH

opal plank
#

hmmm im fucking something up

hollow sedge
#

nvm

#

yeah that didnt make any sense (million)

stark viper
#
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

crimson vapor
#

did you start work on the wrapper?

hollow sedge
#

idk did i?

crimson vapor
#

idk did u?

hollow sedge
#

idk did i?

opal plank
earnest phoenix
#

@stark viper bruh that function is not run

crimson vapor
#

lets ask Erwin

earnest phoenix
#

Read the line where you defined the variable channel

#

Tell me if it looks correct

opal plank
#

im busy comparing apples and asteroids with @quartz kindle

crimson vapor
#

why

#

apples are asteroids

hollow sedge
quartz kindle
crimson vapor
#

wdym

hollow sedge
#

why not just JSON.stringify it

crimson vapor
#

umm

lucid mirage
crimson vapor
#

because key is a fucking string or number

hollow sedge
#

but why are you splitting on "." then?

crimson vapor
#

for nesting objects

opal plank
#

string[]

earnest phoenix
#

@lucid mirage bruh collection.first is a function and there are no parenthesis after the word function

opal plank
#

or number[]

#

or any[]

crimson vapor
opal plank
#

since you didnt declare what Type that is, it shows as any

hollow sedge
#

oh

earnest phoenix
#

Wait is first even a function?

crimson vapor
#

yes

#

grabs the first of an array

hollow sedge
#

why tho

#

why is it a function

stark viper
#

but if we type .first() it says its not a function

earnest phoenix
#

I mean if you forget the parenthesis JS should put the function as the variable value

quartz kindle
earnest phoenix
#

But channel's value is undefined

earnest phoenix
hollow sedge
#

@crimson vapor idk if i can do this lol i cant even understand what this is

crimson vapor
#

oof

stark viper
#

Yes

earnest phoenix
#

Can you show me your command handler

crimson vapor
#

if you don't want to then don't

quartz kindle
lucid mirage
quartz kindle
#

do i need to declate an interface for iterable? i thought its built in

stark viper
#

:panik:

earnest phoenix
#

A good dev should know

lucid mirage
#

Yea, but explain pls

crimson vapor
#

he wants to know how you handle commands

earnest phoenix
#

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

crimson vapor
#

my json file is almost 50kb

#

loggers

opal plank
opal plank
#

specially with objects

stark viper
#

i dont find it

quartz kindle
#

so 27 for 1.5mil, 9 for 500k

opal plank
#

still less performant than yours

stark viper
#

so basicaly i dont even know what you mean

opal plank
#

thats quite an accomplishment, looking that this is an official postgres addon

earnest phoenix
#

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

stable eagle
#

lol

#

i have the same

crimson vapor
#
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
stark viper
#

we dont have it like this

umbral zealot
#

lol the command handler mostly everyone uses

stable eagle
#

is there any better one

crimson vapor
#

nah command handlers should handle everything except the execution of the command

#

I mean like perms checks

quartz kindle
#

i need to type it with the type

#

string | Iterable<string>

opal plank
#

im fancier

#

my command handler

opal plank
#

array should automatically pickup

#

try

type thing = string | string[]
quartz kindle
#

its all of them

#

data?: string | string[] | Stringbase | Iterable<string>

opal plank
#

string[] alone should work

#

in ts at least

quartz kindle
#

it works as an iterable?

opal plank
#

[] just means array, string[] array of strings

#

yeah

quartz kindle
#

so string | string[]

#

does all of the above

opal plank
#

yup

quartz kindle
#

cool

crimson vapor
#

Tim why not just learn ts?

quartz kindle
#

fek ts

#

i mean, technically im learning it rn

#

even without having it installed

opal plank
#

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

quartz kindle
#

seems to be working

#

z.value() still gives any but i guess thats to be expected

opal plank
#

its what i said, usually its like that with objects

#

try to avoid Object.assign() and .push()

#

those get ignored

quartz kindle
#

loops work so its fine

opal plank
#

on those when it returns any, even though you dont want it, just type cast it

quartz kindle
opal plank
#

watch this

earnest phoenix
#

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'
  }
]
quartz kindle
opal plank
#

push() can also be finicky

#

those are the 2 major watch out for on ts

quartz kindle
#

as in array.push?

opal plank
#

yup

#

if you do array = array.concat([this]) its fine iirc

quartz kindle
opal plank
#

you can also push just fine

earnest phoenix
opal plank
#

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

sudden geyser
opal plank
sudden geyser
#

You also don't need to wrap it in a promise because there's no promise returned.

earnest phoenix
#

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?

opal plank
#

69 million presences parsed in 10 days

quartz kindle
#

you're insane

opal plank
earnest phoenix
#
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.

opal plank
#

why not just set?

earnest phoenix
#
    date: 2020-12-13T20:37:45.210Z
...
    date: '23:37'

the date is changing.

opal plank
#

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

sudden geyser
#

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.

opal plank
#

also if any of those comes in there, its either a bot or a modded client

#

users cannot send embeds

earnest phoenix
#

for bot

opal plank
#

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

crimson vapor
#

don't cache everything

#

just cache content author and time

#

and purge cache after an hour

sudden geyser
#

Try it out and see.

#

anyway where are you getting message from

crimson vapor
#

what the fuck

sudden geyser
crimson vapor
#

im in dev

#

shit

sudden geyser
#

also that prefix + the ping command is a bit suspect

crimson vapor
#

tysm @sudden geyser

cunning stream
#

hey

#

i need some help with my music bot

#

it's with ytdl

#

and there is no code for making it play

opal plank
#

@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

crimson vapor
#

huh

opal plank
#

Wdym huh

crimson vapor
#

what are you responding to

hollow sedge
#

i dont think the cache should be purged every hour

#

that doesnt make sense

opal plank
#

The messgaes thing

crimson vapor
#

oh

opal plank
#

don't cache everything
just cache content author and time
and purge cache after an hour

crimson vapor
#

yeah

#

ok

quartz kindle
opal plank
#

first one is cleaner with one line<, but it overflows, so second one

obtuse jolt
crimson vapor
#

wait do what?

opal plank
obtuse jolt
#

edit the message

opal plank
#

if even ONE of those things fail you fucked

obtuse jolt
#

yeah I know

opal plank
#

use conditional chaining or proper checks

quartz kindle
#

lmao

obtuse jolt
#

just give me the code

#

ill deal with that later

opal plank
#

spoonfeed, rules

obtuse jolt
#

fucking

opal plank
obtuse jolt
#

I genuinely might leave this server it's that helpful

opal plank
#

nobody stopping you

#

learning js before doing a bot is usually a good idea

crimson vapor
#

imo kinda

hollow sedge
#

yeah i hate this server

opal plank
#

i can point you towards the right direction but blatently asking for code is just a bit too much

crimson vapor
#

not 100% but enough

hollow sedge
#

they never let me copy and paste code

#

it sucks

crimson vapor
#

just paste examples

opal plank
crimson vapor
#

they have a few I think

#

wait

#

was that sarcastic?

opal plank
#

i was being sarcastic

hollow sedge
#

nice job

crimson vapor
#

ok ok

opal plank
#

they usually have 2-3 examples per thing

hollow sedge
#

the discordjs.guide thing literally tells you everything

obtuse jolt
#

I know how to code I just really cba to sit here for 3 hours trying things until I get it right

hollow sedge
#

it takes time to create stuff

#

so maybe do that

obtuse jolt
#

you dont say

opal plank
#

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

obtuse jolt
#

yeah beacuse I don't

hollow sedge
#

there are two things you can do when you get stuck:

  1. Take a break
  2. Learn how to do it properly
obtuse jolt
#

this command doesnt affect my bot in any way if it fails

opal plank
obtuse jolt
#

whitenames

crimson vapor
#

who just dotposted

hollow sedge
obtuse jolt
#

begging for code is a new kind of low

#

im not there yet

crimson vapor
#

alright

opal plank
#

but you.... nvm

crimson vapor
#

client.channels.fetch('ID').then(e => if (e) e.messages.fetch('ID').then(f => if (f) f.edit() ) probably

opal plank
#

wrong

crimson vapor
#

damn

#

rip

opal plank
#

that'll error

crimson vapor
#

wait how

opal plank
#

fetch() returns either a channel or undefined

#

undefined.messages => boom, error

crimson vapor
#

bruh

opal plank
#

cannot read property messages of undefined

#

try it

viscid leaf
opal plank
#

still callback hell and you might stop at the first bit

#

use await for the love of god

hollow prawn
#

are discord audit logs reliable to use rn?

opal plank
#

erm

#

yes and no

#

for the majority of stuff? yes

hollow prawn
#

in what case is the no

crimson vapor
#

no

opal plank
#

invites, bans, kicks, no?

crimson vapor
#

why would I use await for an example?

opal plank
#

why would u use a callback hell instead of async?

#

rule of the thumb, never use more than one .then

hollow prawn
#

hmm then how would I go around for the invites, bans and kicks for audit logs?

crimson vapor
#

its an example I would never chain callbacks in real code

#

looks ugly

opal plank
#

looks ugly, is ugly, callback hell, stinky

#

Promise.resolveAll() is a thing btw

#

so you dont have to do that ugly looking thing

crimson vapor
#

never used Promise.anything

opal plank
#

you should

#

promises are important to js

crimson vapor
#

ye ik

opal plank
#

actually

#

race might be better

#

but not even i used that more than once

#

actually, nvm

#

thats not used in this case

pale vessel
#

promise.all is so good

crimson vapor
#

I think ive only used it once

quartz kindle
#

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

opal plank
quartz kindle
#

lmao

opal plank
#

absolutely valid use-case

#

i asked u before, why the heck u promisifying it?

quartz kindle
#

let item of* database

#

xD

opal plank
#

i mean, what if it returns an object?

#

yes

#

also that'll never work

#

id === true/false?

#

that'll never work

quartz kindle
#

lmao

opal plank
#

you are comparting a string to true or false

crimson vapor
#

LMFAO

quartz kindle
#

promisifying that wont help with anything

#

you can directly return the thing

#

no need for promise

opal plank
#

^^^^^^^^^^^^^^^^^^^^^^^^

quartz kindle
#

if you want to return a promise response from a sync function, there is Promise.resolve()

pure lion
#

i cannot deal with this bullshit any more

#

it was working and now its not

opal plank
#

he doesnt even need a promise in that case though, as long as the member is cached

#

otherwise he'd have to fetch it

crimson vapor
#

no reason for message.member to not be cached tho right

opal plank
#

yes

#

intents?

#

using dj-light?

quartz kindle
#

ye but if hes using the check function in a promise way, because some other instance of check needs to be a promise

crimson vapor
#

oh right

quartz kindle
#

he can do that

opal plank
#

he could just return though

#

rather than resolve

crimson vapor
#

hmmm

opal plank
#

lemme double check, but im fairly certain you can

crimson vapor
#

im pretty sure he is gonna ask the same question again

quartz kindle
#

yes you can

#

but you know, semantics

opal plank
#

hmmmm this is quite annoying ngl

quartz kindle
#

for example

pure lion
#

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

crimson vapor
#

oh no

opal plank
#

.then only chains on promises, i could've sworn.......

sudden geyser
#

where are you getting message from

opal plank
#

holdup

sudden geyser
#

and why are you using assignment over comparison

opal plank
#

@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!]

crimson vapor
#

and why is it a fucking promise

opal plank
#

back on track, its annoying that .then() doesnt work in this case

crimson vapor
#

message.author isn't a promise tho

opal plank
#

im not promisifying it

crimson vapor
#

why would .then work on message.author then

opal plank
#

i assumed .then() would chain the return of the previous statement

#

which it doesnt

crimson vapor
#

I thought you could only .then on a promise

opal plank
#

correct

quartz kindle
#
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
opal plank
#

though i was under the false impression you could use it on functions too

crimson vapor
#

oh

crimson vapor
#

thats actually smart

#

never seen a usecase for that but it makes dealing with data so much easier

opal plank
#

i would personally do it differently though

crimson vapor
#

how would you do it?

opal plank
#
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

earnest phoenix
#

You forgot to wrap the parameters between ()

quartz kindle
#

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

opal plank
#

fair

quartz kindle
#

discord.js has a few cases like that

opal plank
#

i also forgot a return in the new promise

quartz kindle
#

xD

opal plank
#

but that gets the point across

#

and as voltrex said, that ()

crimson vapor
#

Tim do you have computer science degree?

opal plank
#

yeah tim the master of counter strike

crimson vapor
#

lol

opal plank
#

u did write cs though, cant blame me for that one

crimson vapor
#

no

#

I just assumed that in #development cs would stand for computer science not counter strike

#

but you're right ya never know

opal plank
#

acronyms are annoying, sometimes they mean multiple things, context is a bitch lol

earnest phoenix
#

CS could also stand for C#

crimson vapor
#

well

#

ok

quartz kindle
crimson vapor
#

you don't?

#

did you learn from google?

earnest phoenix
#

whats ur major

quartz kindle
#

i never finished highschool

opal plank
#

im a major asshole/idiot

earnest phoenix
#

Oh>

#

Ur a dropout?

quartz kindle
#

ye

crimson vapor
#

bruh

earnest phoenix
#

Any reason for that

#

How is this possible

crimson vapor
#

^

quartz kindle
#

family reasons

opal plank
#

yet here he is, carrying the whole channel/server

earnest phoenix
#

u work somewhere?

crimson vapor
#

oh

#

@opal plank do you have a degree?

quartz kindle
#

im not employed, but i run some personal projects

#

and some freelancing

opal plank
#

degree in what?

earnest phoenix
#

ah okay

opal plank
#

diploma? or univertsity?

earnest phoenix
#

Where do u freelancer for some good cash? @quartz kindle

#

I thought tim worked at NASA

crimson vapor
#

I assumed you would have said "yes I have an X in X"

earnest phoenix
#

MC-Market freelancing isnt so profitable

crimson vapor
#

shjit

#

how

quartz kindle
earnest phoenix
#

Same here..

crimson vapor
#

wrong mention

#

how did that happen

opal plank
#

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

earnest phoenix
#

Discord is just being discord

hollow sedge
opal plank
#

scam the kids for minecraft mods in jeeeeva

earnest phoenix
#

Scamming?

#

Sad fuck

honest perch
#

Voltrex

hollow sedge
#

Oh

honest perch
earnest phoenix
#

Yes

honest perch
#

Everything ok?

opal plank
#

unironically though, mc mods arent easy at all to make

earnest phoenix
#

What

#

I only added a star a single time

#

Github are you ok

quartz kindle
#

jesus you guys are on fire

honest perch
#

I dont think it is

sudden geyser
#

ourcord

hollow sedge
#

"trying to fix"

#

Awesome commit

honest perch
#

Most of the recent ones were from the contributor table

earnest phoenix
#

Wait where are my commits bruv

crimson vapor
#

I always just commit "yes"

#

cba to think of names for commits when I do like 100 changes at once

opal plank
hollow sedge
#

It takes like 5 seconds to write a description

opal plank
#

when the client doesnt give 2 fucks about the code, only about its usability

honest perch
#

Tim btw github darkmode exists

crimson vapor
#

it looks shit tho

#

its unnecessarily blue

earnest phoenix
#

After 12 years, Github finally implemented a dark theme

honest perch
#

Yes but they did it

sudden geyser
#

better late than never :^)

earnest phoenix
honest perch
#

Palace

quartz kindle
#

dark mode finally released? ayyy

crimson vapor
#

you didn't know?

honest perch
#

A couple days ago

quartz kindle
crimson vapor
#

lmfao

earnest phoenix
#

Lol

pure lion
#

I'm crying right now.

opal plank
#

wait whos the owner of ale-bot?

#

ale-bot is in my support server

honest perch
#

Dice

opal plank
#

oooh, i thought it was borboss

crimson vapor
#

umm

#

ok

pure lion
#

@honest perch fix the lib please.

#

Thanks.

honest perch
#

I'm in bed

pure lion
#

h

honest perch
#

@sinful belfry fix lib please.

crimson vapor
#

no h chain today

opal plank
#

dice added his bot on my server and then ditched

#

you mofo

pure lion
#

Her*.

opal plank
#

her

crimson vapor
#

Dice is who?

opal plank
#

still a mofo

#

krista

crimson vapor
#

o

opal plank
#

added the bot on my server and then ditched it there

crimson vapor
#

does highschool even mean anything tbh

pure lion
#

@honest perch can you just revert to before the error happened.

opal plank
#

yes

honest perch
#

No

opal plank
#

it makes getting a job a lot easier

honest perch
#

I'm in bed

crimson vapor
#

LOL

opal plank
#

just change the head to that commit version

pure lion
#

I don't want to fuck shit up further.

honest perch
#

Blame it on matt

pure lion
#

I don't even know when it broke.

crimson vapor
opal plank
#

it would happen anyway if they reverted

earnest phoenix
opal plank
#

wait, theres 4 people on this bot?

pure lion
#

I don't have the energy for this.

opal plank
#

ale is dice, matt, star and misly?

#

wtf

crimson vapor
#

there are a few more than 4

earnest phoenix
#

And me

quartz kindle
#

there are like 10

#

lmao

honest perch
#

Its not a bot

pure lion
#

It's a lib, not a bot.

opal plank
#

wtf

crimson vapor
earnest phoenix
#

Yes

quartz kindle
opal plank
#

why alebot is only in 21 guilds then?

pure lion
#

?

earnest phoenix
#

It's a discord lib

crimson vapor
honest perch
#

Yes

#

Don't ask

crimson vapor
#

no

#

answer me

quartz kindle
#

no idea

opal plank
crimson vapor
#

are you that fucking lazy

honest perch
#

It was meant for npn

honest perch
crimson vapor
#

ytho

quartz kindle
#

this looks like twitch plays discord lib

honest perch
#

Ynot

pure lion
#

Can I outline the error please?

earnest phoenix
#

What's the error bruh

opal plank
#

i doubt their code is trashier than twitch's api

crimson vapor
sinful belfry
quartz kindle
#

have you seen twitch plays pokemon?

crimson vapor
#

how much do you guys have left on the lib?

honest perch
#

@crimson vapor github is broken

opal plank
#

thank god no

honest perch
#

Not the badge

pure lion
#

The import syntax error. When I'm testing it with yarn/npm, it throws the error. Anything else I need to outline?

crimson vapor
#

ik

quartz kindle
#

do it, its marvelous

opal plank
#

am i going to retain vision after seeing it?

quartz kindle
#

yes

opal plank
#

blindness is a concern of mine after looking at cursed code

pure lion
#

@earnest phoenix H_

opal plank
#

EEEEEEEEEEEEEEEEW THEY USING TMI

#

EEEEEEEEEEEW

honest perch
#

Dice, maybe rewrite the whole thing to make it less of a cluster fuck

earnest phoenix
#

h

opal plank
#

EEEW REGEX

crimson vapor
#

slow

opal plank
#

EEEWW

#

its PRIVMSG events not message

#

BRUH WTF IS THIS GARBAGE

crimson vapor
#

smh

earnest phoenix
crimson vapor
#

TIM?

opal plank
#

BRUH

opal plank
#

twitch sends acks and shit to let you know about that crap

#

wtf

opal plank
honest perch
#

Idk, maybe rewrite it to make it less clusterfuck

earnest phoenix
#

Krista

opal plank
#

bruh

pure lion
honest perch
#

Yes it is

limber sable
#

hey

opal plank
#

wtf am i looking at

honest perch
#

If you rewrote it it wouldn't be bad

pure lion
#

The .d.ts file?

earnest phoenix
#

declare module "Client" is the error? Wtf is happening

honest perch
#

Like everything

crimson vapor
honest perch
#

Is an error

crimson vapor
#

the very best

opal plank
#

the keyHandler is fine

#

but their index is horrible

pure lion
honest perch
#

Ask the mobile dev nerd why the formatting is like that

opal plank
#

their configs are also config.js which makes 100% sense

pure lion
#

Erwin, ts god, please tell me why I can't use es syntax in ts module files

earnest phoenix
#

Bruh just put the whole thing into a JS formatter LULW

#

Or TS

opal plank
#

cuz you arent using ts

#

you're using js

pure lion
opal plank
#

use ts with ts

#

period

#

stop trying to load ts into js

pure lion
#

But it was working before

opal plank
pure lion
#

You said yourself that it would work

opal plank
#

use jsdocs for js

#

period

pure lion
#

And it was in fact working

opal plank
#

ts for ts

#

jsdocs for js

pure lion
#

do npm i ourcord@1.1.1

#

See for yourself.

opal plank
#

too lazy

pure lion
#

No.

opal plank
#

yes.

misty sigil
#

lmao

pure lion
#

Eat your words >:(

opal plank
#

nom

misty sigil
#

snacks!

earnest phoenix
#

Pog cat

pure lion
#

@misty sigil please fix before I hurt someone.

misty sigil
#

what needs fixksd

earnest phoenix
#

🗿 Wtf

honest perch
#

How about the mobile dev fixes it

earnest phoenix
#

What's the issue, i don't see it

honest perch
#

You know what, fuck ts x84 assembly it is

misty sigil
#

aye

pure lion
#

x86*.

honest perch
#

Same thing

earnest phoenix
#

Let's rewrite it in binary

misty sigil
#

0

pure lion
#

Literally anyone

earnest phoenix
#

Like trying to construct a client?

pure lion
#

Yes

earnest phoenix
#

Lemme see

pure lion
#

Even requiring the file

honest perch
#

Can voltrex like just sell his house and get a pc

quartz kindle
misty sigil
#

I’m sure voltrex could get a pc

#

they just want torture

#

and pain

opal plank
#

twitch doesnt have a message event

#

since just like us, we have dm's and channels

crimson vapor
#

voltrex will get a pc soon™️

opal plank
#

we also have announcements

#

and a bunch of other shit

#

also adding events that already already handled by twitch's end

earnest phoenix
#
SyntaxError: Cannot use import statement outside a module```
#

What the fuck

opal plank
#

disconnect and reconnect dont need to be bind cuz the library has those events already listed and arent private

quartz kindle
#

this is why i hate ts

honest perch
#

Same

opal plank
#

use import

tame kestrel
opal plank
#

cuz yall using the wrong import u ducks

earnest phoenix
#

I'm so confused, how's that error even happening in the first place

pure lion
#

...?

opal plank
#
import('./file');
crimson vapor
earnest phoenix
#

Uhh

tame kestrel
crimson vapor
#

np

earnest phoenix
#

Umm

pure lion
quartz kindle
#

@tame kestrel im gonna ping you for that

pure lion
#

Or Import h from ""

opal plank
#

nothing, thats es5 syntax

misty sigil
#

dice

opal plank
#

import > require

tame kestrel
earnest phoenix
#

import * from e as "h";

misty sigil
#

maybe we should write this

tame kestrel
#

ok bye

misty sigil
#

in js

earnest phoenix
#

@tame kestrel safe

#

One last time

opal plank
earnest phoenix
#

Go back to learning

#

WAIT

#

FUCK

pure lion
#

@earnest phoenix where's the error being thrown from

opal plank
#

import * as alias from 'file'

earnest phoenix
#

Wait a fucking minute

#

Yep

#

My brain went full idiot mode

misty sigil
#

wait fuck minute

earnest phoenix
#

Show your compiler config again

opal plank
#

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

pure lion
#

B

crimson vapor
#

its funny isnt it Erwin

opal plank
#

ikr

misty sigil
#

what was the answer again

#

I might be able to pull something out my ass if I see it

pure lion
#

import() apparently

#

@opal plank can we assign that shit to a const?

opal plank
#

tias

misty sigil
#

yes I think so

earnest phoenix
#

Since when did import() exist

opal plank
#

ts is more complex than yall think

misty sigil
#

it’s complex

crimson vapor
#

never tried ts