#development

1 messages ยท Page 1596 of 1

opal plank
#

it should be allowing you to import then

mellow kelp
#

well uhh

quartz kindle
#

js code is processed and variables are exported

opal plank
#

you need to use default though

#

.json is always defaulted

mellow kelp
#

is it possible to get rid of browser properties in the vscode intellisense?

#

i still get autocomplete for window objects

#

and it's really confusing

quartz kindle
#

set it in your config

grizzled raven
#

i'd imagine json is almost like a simple json.parse, whereas js code is actually executed plus stuff has to be explicitly exported

outer perch
grizzled raven
#

but eh, probably no difference

opal plank
#
import * as botConfig from './botConfig.json'```
opal plank
#

its the same as this

#
function blah(a) {}
outer perch
quartz kindle
opal plank
#

should be working

mellow kelp
grizzled raven
outer perch
#

reloading VSC

#

gonna search

#

oh

#

my

#

freaking

#

god

crimson vapor
#

my favorite thing ever is using tsc -w and getting a circular error

#

its so fun

mellow kelp
#

what was the -w flag again

outer perch
crimson vapor
#

watch

mellow kelp
outer perch
crimson vapor
#

like nodemon but for tsc

#

no

#

runing tsc

#

like compiling

solemn latch
#

why do you even need to restart vsc

mellow kelp
#

ts-node-dev

outer perch
mellow kelp
#

kekw

crimson vapor
#

ehh

#

ill keep using tsc -w

crimson vapor
#

stop closing vsc

#

just restart eslint

#

lol

outer perch
#

F1 > Reload Window

mellow kelp
#

hmm im gonna check

outer perch
mellow kelp
#

you can't use backticks on imports

#

or anything dynamic

outer perch
#

gotta be require

mellow kelp
#

you can use dynamic imports

#

import('thing').then(importedStuff => { ... })

outer perch
#
Argument of type '{ type: string; project_id: string; private_key_id: string; private_key: string; client_email: string; client_id: string; auth_uri: string; token_uri: string; auth_provider_x509_cert_url: string; client_x509_cert_url: string; }' is not assignable to parameter of type 'string | ServiceAccount'.
  Type '{ type: string; project_id: string; private_key_id: string; private_key: string; client_email: string; client_id: string; auth_uri: string; token_uri: string; auth_provider_x509_cert_url: string; client_x509_cert_url: string; }' has no properties in common with type 'ServiceAccount'.
#

the code:

import serviceAccount from './serviceAccountKey.json';
admin.initializeApp({
  credential: admin.credential.cert(serviceAccount),
  databaseURL: 'nope.com',
});
glacial pagoda
#
    
    const Goodbyechannel = guildMember.guild.channels.cache.get('678048512822476804')
    
    Goodbyechannel.send(`<@${guildMember.nickname}> Just Left The Server ![AnimeCry45](https://cdn.discordapp.com/emojis/808375412383809567.webp?size=128 "AnimeCry45")`);
    console.log(`MEMBER LEFT: A Member Has Left Dogey Army!`);
});```
#

How Do I Make It Not Null?

#

Idk What I Should Replace With guildMember

outer perch
#

<@${guildMember.id}>

#

not nickname

#

xD

glacial pagoda
#

ok

#

Wouldnt that show the mention in numbers?

outer perch
#

no

pale vessel
#

If the user isn't cached yes

glacial pagoda
#

since the member is not in the server anymore

#

oh

outer perch
#

@glacial pagoda

#

this is the escaped version

#

@glacial pagoda

#

this is what will show if cached

glacial pagoda
#

oh

#

ok

outer perch
#

const serviceAccount: Object = import('./serviceAccountKey.json');

#

it works with this I guess

unreal kiln
#

not sure for mod bots but 100% for music bots

crimson vapor
#

bruh

glacial pagoda
#

@outer perch ```client.on('guildMemberRemove', (guildMember) => {

const Goodbyechannel = guildMember.guild.channels.cache.get('678048512822476804')

Goodbyechannel.send(`<@${guildMember.id}> Just Left The Server ![AnimeCry45](https://cdn.discordapp.com/emojis/808375412383809567.webp?size=128 "AnimeCry45")`);
console.log(`MEMBER LEFT: A Member Has Left Dogey Army!`);

});```

#

Got another error

#

What If I Take Out guildMember.?

#

from goodbye

outer perch
stark abyss
#
            const doesExist = {
              text: `SELECT * FROM clanusers WHERE id = $1`,
              values: [Array.from(addIds)[i]]
            }

            var doesExistData = pool.query(doesExist, (err) => {if(err) return console.log(err)})```
I keep getting undefined idk why I made sure everything is correct addIds is a set btw
glacial pagoda
#

from const Goodbyechannel = guildMember.guild.channels.cache.get('678048512822476804')

outer perch
#

wait

glacial pagoda
#

It no work

#

same error

outer perch
#

wait

glacial pagoda
#

Ok

stark abyss
#

you sure that channel id is correct AHWeirdChamp

glacial pagoda
#

yeah

lyric mountain
#

Hardcoded id...

glacial pagoda
#

What

outer perch
#

const Goodbyechannel = guildMember.guild.channels.cache.find(channelID => channelID.id === '678048512822476804')

#

try this

glacial pagoda
#

ok

lyric mountain
#

Guikdmember.guild will not work

#

Member is no longer a member

outer perch
#

I am wondering

glacial pagoda
#

shoudnt i take away guildMember from the statement then?

outer perch
#

but guildMemberRemove only returns Member

pale vessel
#

it's the old member object

#

so it does have guild

pale vessel
#

discord.js won't trigger the event if the member isn't cached

zenith terrace
#

client.channels.cache.get('ID')

#

is what I have and works fine

glacial pagoda
#

client?

#

ok

zenith terrace
#

you do have client defined dont you

glacial pagoda
#

yes

pale vessel
#

member.client if you don't have access to client

zenith terrace
#

hi flaz 2DCuteWave

drifting wedge
#

yo

#

how can i run a dpy instance and flask in the same file?

#

or how can i use flask with dpy client?

pale vessel
#

why not

glacial pagoda
#

Same Error WigglePensive

#

nvm i mispelt

#

gimme a sec to restart

drifting wedge
pale vessel
#

yes

drifting wedge
#

why not?

#

wdym?

pale vessel
#

just setup the server and bot under one file

#

like in js

#

i'm sure that's possible in python too

drifting wedge
#

it is

#

wait

#

ok so flask uses a wsgi

#

to "run it"

#

do i run the bot there?

glossy spoke
drifting wedge
#

i need to access the client in the flaskapp

#

so how can i do that

glacial pagoda
glossy spoke
earnest phoenix
#

@everyone

glossy spoke
zenith terrace
jolly mortar
#

does anyone know how to show when the command was ran just like you do in embeds with .setTimestamp*()

cerulean pebble
#
let [{ MessageEmbed }, { help, discordserver }] = [require(`discord.js`), require(`../config.json`)]

module.exports.run = async (bot, message, args) => {
  if (message.author.id !== `523877466486472714`) return message.reply(`\`๐Ÿ“›\` You don't have permissions to execute that command.`)
  
  try {
    await bot.guilds.cache.forEach(guild => {
      let embed = new MessageEmbed()
        .setColor(`0xC3824C`)
        .setThumbnail(message.guild.iconURL({ format: `png`, dynamic: true, size: 2048 }))
        .setAuthor(`Service Announcement`, bot.user.displayAvatarURL({ dynamic: true }))
        .setDescription(args.join(` `))
        .addField(`Need support? Let's join Shiro server yeahh`, `${discordserver}`)
        .setImage(help)
        .setFooter(`Service Announcement sent by ${message.author.tag}`)
        .setTimestamp()

      guild.channels.cache.filter(c => c.type === `text` && message.guild.me.hasPermission([`SEND_MESSAGES`, `EMBED_LINKS`, `VIEW_CHANNEL`,])).first().send(embed)
    
    })

    message.delete({ timeout: 1000 })
    message.channel.send(`Message sent successfully to ${bot.guilds.cache.size} guilds`)

 
  } 
  catch (e)  {
    console.log(e)
    message.reply(`I cannot send the broadcast.`)
  }
}```
cerulean pebble
#

2021-02-17T02:16:51.353894+00:00 app[worker.1]: (node:4) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Access
2021-02-17T02:16:51.353895+00:00 app[worker.1]: at RequestHandler.execute (/app/node_modules/discord.js/src/rest/RequestHandler.js:170:25)
2021-02-17T02:16:51.353896+00:00 app[worker.1]: at runMicrotasks (<anonymous>)
2021-02-17T02:16:51.353896+00:00 app[worker.1]: at processTicksAndRejections (internal/process/task_queues.js:93:5)
2021-02-17T02:16:51.353953+00:00 app[worker.1]: (node:4) 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: 35)

#

how to filter channel in right wait

jolly mortar
opal plank
#

nono, i know that

pale vessel
#

on message content?

opal plank
#

but you already know about setTimestamp

#

so im not sure what you are asking

jolly mortar
#

i meant in a normal message

pale vessel
#

yea

jolly mortar
#

not in a embed

pale vessel
#

it won't be dynamic though

opal plank
#

you cant, but you can convert the timestamp to new Date()

#

use new Date(timestamp)

opal plank
#

THOUGH, i think discord timestamps are in ISO string

#

which should work fine

jolly mortar
#

alr

opal plank
#

its odd that you need to send ISO strings but somehow d.js returns a timestamp int

#

but should work just the same

cerulean pebble
#

://

#

lol no one helo it is sad

stark abyss
#

I finally figured out what I was doing wrong zpicydog

drifting wedge
#

what does this mean?

#

if __name__ == "__main__":

sudden geyser
#

It's a way of saying, "If this Python file was run as the main root, do something"

drifting wedge
#

can i just not have that?

#

will if affect anything?

sudden geyser
#

Like if I do import that.py it'll run everything top to bottom

mellow kelp
#

you can use it to prevent something from executing if you're importing the file

sudden geyser
#

but the if clause is there it won't try running that block

drifting wedge
#

alr

#

im trying to run a dpy bot in the same folder as flask

#

so i can use bot resources

#

but im having issues

#

like what happens is one works and the other doesnt

#

and they never "both" work

limber flume
#

example

sudden geyser
#

that's vague

drifting wedge
#

ill try to give code?

limber flume
#
def yeet():
    print("yeet")

if __name__ == "__main__":
    yeet()
#

yeet!

opal plank
#

@quartz kindle is it fine if i yoink that code you posted to start using that for my deep clones?

drifting wedge
#
app = Flask(__name__)
botClient = commands.Bot(command_prefix = ".")


(a bunch of flask routes)

if __name__ == "__main__":
    app.run()
    botClient.run("token")```
#

then

#
from flaskapp import app

if __name__ == "__main__":
    app.run()``` wsgi
limber flume
#

yea

#

that code seems working

placid iron
#

I'm losing my mind

limber flume
#

rovi

#

loosing head

drifting wedge
#

to me?

#

well the bot isnt running

limber flume
#

i don't even know

#

oh?

drifting wedge
#

but flask is

limber flume
#

You don't have intents?

drifting wedge
#

wdym intents?

#

this is a test bot

limber flume
#

bruh.

drifting wedge
#

so it wouldnt even need intents

limber flume
#

here is a example

drifting wedge
#

like it does have intents

#

i have em enabled

#

too

placid iron
#

Do you not understand

#

Omg

#

Bro

#

The flask app is blocking

drifting wedge
#

oh

placid iron
#

When you call the run command

drifting wedge
#

@placid iron well now i did

#

i am not the smortest

limber flume
#
from discord.ext import commands
from discord import Intents

main = commands.Bot(command_prefix="yeet!", intents=Intents.all())

main.run("token")
drifting wedge
#

@placid iron its not the dpy

limber flume
#

why is flask blocking?

drifting wedge
#

its the flask

placid iron
#

You aren't going to have a good time trying to run 2 functions which both block the rest of the code at once

drifting wedge
#

fuck lol

#

uhh

placid iron
#

Luckily

drifting wedge
#

i can use quart?

placid iron
#

You can run the bot without blocking

drifting wedge
#

how?

#

async?

placid iron
#

I can't remeber

#

I googled it

#

Lol

drifting wedge
#

i found this

#

and i could use quart

placid iron
#

I use aiohttp and never have once used flask or quart so I can't help

drifting wedge
#

ah

#

alr

#

wdym aiohttp?

placid iron
#

Async webserver lib for python

#

It is also a client

drifting wedge
#

ah

#

ye

#

u can host webservers?

placid iron
#

Yes?

drifting wedge
#

oh cool

#

u use that for ur website?

placid iron
#

Yes

drifting wedge
#

cool

#

quart is async

#

would that fix the blocking issue?

placid iron
#

Yeah, you would have to work out how to start then both too but sure

#

Oh also

#

Are flask routes sync

drifting wedge
#

quart isnt "sync" per say

#

flask*

#

quart is flask but async

#

its faster

#

like 3x faster

#

but flask isnt sync

#

its slow

#

i guess you could say

placid iron
#

Are the routes in flask defined as async or sync

drifting wedge
#

sync

placid iron
#

Okay

drifting wedge
#

oh lol

placid iron
#

How did you expect to do stuff with the bot and the API with await

drifting wedge
#

๐Ÿคฆโ€โ™‚๏ธ

placid iron
#

Gj

drifting wedge
#

i dont wanna do anything with the bot

#

just use bot resources

#

like getting info

placid iron
#

Like what

drifting wedge
#

like getting a server name based on the id

#

without using db

placid iron
#

Ok

drifting wedge
#

tho

#

making it do stuff

#

would work too

#

ok so lets say i wanted it to do stuff

placid iron
#

O

#

Ok

drifting wedge
#

like for example send a message

#

i would then use quart?

#

which is async

placid iron
#

Yes

drifting wedge
#

ok

#

and that would work?

lucid prawn
#
client.on('guildCreate', async message => {
      var vc = new Discord.MessageEmbed()
        .setDescription("This bot will help you and it be updated alot and we are trying to give 75 server so can u help us!!")
        .setColor('RANDOM')
        .setTitle(`Thank You for inviting me`)
        .setImage("https://media1.tenor.com/images/d185187feba0e4daa627f344d07cfad7/tenor.gif?itemid=14465470")
        message.channel.send(vc)
      })

Why not working

drifting wedge
#

tysm @placid iron

sudden geyser
#

You may be missing the GUILD_CREATE intent (from observing your code).

lucid prawn
opal plank
#

@lucid prawn cuz guildcreate returns a guild not a message

#

guild.send() is not a function

#

and stop using var's

#

they are bad for your code

#

so is embed builder

lucid prawn
sudden geyser
#

embed builder's not that bad

crimson vapor
#

@opal plank in ts, what should I do if I have something such as msg.guild_id that I KNOW is defined as I have intents but the typings say it might not? should I add a useless check and return, or do as Snowflake, or something similar?

mellow kelp
crimson vapor
#

embed builders suck

sudden geyser
#

I have many wars pending

crimson vapor
#

now Erwin will help me pog

mellow kelp
#

lmao KEKW

zenith terrace
#

dont say embed builders are not bad around Erwin KEKW

mellow kelp
#

use !

crimson vapor
#

I have intents meaning I only get guild messages

mellow kelp
#

msg.guild_id!

opal plank
#

well yeah

crimson vapor
#

o

#

ah ty

mellow kelp
#

it's basically screaming at typescript YOU DUMBASS THIS IS OBVIOUSLY GOING TO BE DEFINED ARE YOU AN IDIOT

opal plank
#

! works just to say its there

#

only use if you are 100% certain its there tho

#

thats an easy as fuck wya to make bugs

mellow kelp
#

yea

crimson vapor
#

yeah

zenith terrace
#

waiting for the embed builder war with Erwin

crimson vapor
#

but its better than your favorite as any

mellow kelp
#

it's useful for express additional request properties

opal plank
zenith terrace
opal plank
#

theres no war btw, its shit, one sided

zenith terrace
opal plank
#

sounds kinky, i'll pass

mellow kelp
#

according to node, my process is using about 20mb of ram

#

but i can't find anything in the task manager

solemn latch
zenith terrace
#

how to avoid getting bonked

opal plank
zenith terrace
#

tell erwin to bonk harder

#

he'll think its kinky

sudden geyser
#

nah

opal plank
#

it is

#

and i have proof

sudden geyser
#

define proof

crimson vapor
#

bro erwin

#

your proof is hot

zenith terrace
#

too hot

opal plank
#

10ms vs 300, its 30x less performant than simply sending an object directly to .send()

#

theres no argument to use it

#

also less footprint

#

no requires using cache

#

no importing or destructuring modules

#

just an ol' vanilla js object

#

less ram footprint, more performant, cleaner

#

gimme 1 reason why would anyone use embed builder apart from trying to trigger me like @zenith terrace

sudden geyser
#

If all you're looking at is speed then sure plain objects is better, but embed builders are usually safer with validation and get the message out. Plus tbf you probably don't truly value performance when writing javascript

mellow kelp
#

i don't think they have validation tho

#

do they?

opal plank
#

wdym you dont value performance? you gonna write less performant code for no reason?

sudden geyser
crimson vapor
#

Some do

opal plank
#

at that point why not use ```ts
client.on('message', message => {
if(message.content.startsWith(prefix + 'help')) {}
});
client.on('message', message => {
if(message.content.startsWith(prefix + 'hi')) {}
});
client.on('message', message => {
if(message.content.startsWith(prefix + 'ping')) {}
});

at that point why not do this? it clearly works
#

ยฏ_(ใƒ„)_/ยฏ

crimson vapor
#

Fast

opal plank
crimson vapor
#

Erwin

#

Cleaner is an opinion

opal plank
#

the other two are facts tho

crimson vapor
#

but the other points are all facts

opal plank
#

ยฏ_(ใƒ„)_/ยฏ

crimson vapor
#

Phones suck ngl

mellow kelp
#

ew discord mobile

crimson vapor
#

Hard to type

#

Pls help

opal plank
#

even the checks are worth it

#

just use a type on ts, thats about all you need

sudden geyser
#

wdym you dont value performance? you gonna write less performant code for no reason?
I wouldn't say it's for no reason, but I'd rather use embed builder for safety + more ethical for some. I personally prefer classes when writing code that does the same stuff over raw objects.

opal plank
#

it'll screech at you for adding properties it doesnt have

#

theres no safety with embed builders

crimson vapor
#

Ts is poggers until you get a tsc failure

opal plank
#

with a IDE or editor you should be picking up errors a lot before

#

look

crimson vapor
#

By the way

#

What do I do if my ts code wonโ€™t transpile?

mellow kelp
crimson vapor
#

asking for a friend ofc

#

Iโ€™ve never had a circular dependency or anything like that ofc

opal plank
#

check this lite

#

no adding extra shit on code

#

extra checks

#

more ifs

#

increasing complexity checking what should or should not be there

sudden geyser
#

oh there is no validation, thought there was

opal plank
#

make it a type and catch it before you even run the function

#

im telling you

#

embed builedrs are absolutely useless

crimson vapor
#

In my opinion no

sudden geyser
#

I don't think they're useless

opal plank
#

i do, they just create an object for you

#

the ONLY thing you might argue in their favor is their easy to understand method names]

#

which just proves the point nobody reads the API docs

crimson vapor
#

They are especially good for beginners

opal plank
#

to see what a message request is like

opal plank
crimson vapor
#

because they donโ€™t know how to use the raw api

#

I do all my requests raw

opal plank
#

d.js is good for beggingers, but not only does it do that, i spoils devs already early on, to the point they struggle to move to something else cuz they had their asses wiped and powdered by d.js's poorly performance

crimson vapor
#

because berrys lib

sudden geyser
#

Maybe I'm just too used to type-safe languages (other than TS) to not see the value in MessageEmbed

opal plank
#

d.js has the types for you already

crimson vapor
#

yes

opal plank
#

import { MessageEmbed } from 'discord.js'

#

thats a class

crimson vapor
#

Djs maintains a really poggers api types lib

opal plank
#

check if the object is isntance of messageEmbed class

#

thats literally it

crimson vapor
#

itโ€™s really good

sudden geyser
#

That's not really what I meant

crimson vapor
#

Java?

opal plank
#

the one complain i hear about java and c# is the innability to have any like ts

#

makes a pain to typeguard api requests n shit

crimson vapor
#

donโ€™t they have var but itโ€™s memory inefficient?

opal plank
#

i think so

sudden geyser
#

You don't need any type usually

#

Just generics and abstraction if you want

crimson vapor
#

I never learned these big words

sudden geyser
#

Using any imo is bad practice unless you absolutely need it

opal plank
#

Observable<T>

#

you probably seen it quite a few times

#

Class Something<T> {

}

#

abstraction we use the abstract class for

#

though i dont quite think they are exatcly the same from java

sudden geyser
#

It's roughly the same

mellow kelp
#

they're more or less the same thing

#

unimplemented methods basically

sudden geyser
#

What's the real difference between an interface and an abstract class christmasthink

opal plank
#

asbtract class doesnt get initialised

#

by itself, at least

#

when another class extends it, then the new class is intialised

#

but you cant use an abstract class iirc

mellow kelp
#

an interface describes an object and its properties, while an abstract class is just a class with unimplemented methods

opal plank
#

here it is, quite about what i just said

crimson vapor
#

Send link pls

#

Iโ€™m on phone

crimson vapor
#

Ty

mellow kelp
#

why does this look like w3schools but blue

opal plank
#
class something {
  name: string;
  adress: string;
  cellphone: number;
}
class somethingElse {
  name: string;
  adress: string;
  cellphone: number;
  car: string
}
mellow kelp
#

im getting the sabe vibes

opal plank
#

imagine this scenario

crimson vapor
#

Extend the abstract class instead of that shit?

#

Erwin

sudden geyser
mellow kelp
#

they do

#

well

#

you can do that with both abstract classes and interfaces

crimson vapor
#

How do you load files inside of a function? Is it a bad practice to use require?

mellow kelp
#

i use dynamic imports since i use ts

sudden geyser
#

require? dynamic import? I've always used require

crimson vapor
opal plank
#

you shouldnt import files inside functions, but you could

#

you can use both

#

import and require

cinder patio
#

it depends on where it's usee but I wouldn't call it a bae practice

opal plank
#

they work almost the same

crimson vapor
#

a command loader function

mellow kelp
#

they only difference is that import returns a promise

#

require is synchronous

opal plank
#

then you'd likely wanna use import

cinder patio
#

Then required shouls be good

opal plank
#

which is async

#

i assume your commands are in ts

crimson vapor
#

how would I do that?

crimson vapor
opal plank
#

so you should be using import over require

#

unless you wanna transpile them first

mellow kelp
#

also depends if you're using import or require in your project

crimson vapor
#

Import

cinder patio
#

All your commands should get loaded before your bot starts, so use require

opal plank
#

import will import them as ts file

mellow kelp
#

use import then

opal plank
#

or you could transpile beforehand and require them as js files

#

use import()

crimson vapor
#

They get loaded after the process started

#

Like

#

WS

opal plank
mellow kelp
#

since you're using es6 import/export, use dynamic imports

crimson vapor
#

how do you do a dynamic import?

opal plank
#

import()

#

you did command handler in js no?

#

with d.js

crimson vapor
#

Sec Iโ€™ll link

opal plank
#

simply change require to import()

#

just remember, its async

#

so chain it

mellow kelp
#
import('something')
  .then(imported => {
    const { default: defaultExport, someOtherExport } = imported;
    // Do stuff
  })
crimson vapor
mellow kelp
#

or use await like a champ

opal plank
#

yeah

#

that

crimson vapor
#

Current

opal plank
#

forEach

#

reeeeeeee

crimson vapor
#

Shhhh

opal plank
#

for of

crimson vapor
#

I just learned for of

cinder patio
#

Require would be better in the case of commands because it's sync and you don't risk one of your commands getting loaded after your bot strarts ul

novel hollow
#

class Main {
  public static void main(String[] args) {
    System.out.println("Hello world!");
  }Head
}html```
mellow kelp
#

but can't he just use await?

crimson vapor
#

Bro

mellow kelp
#

that's the whole point of async functions

crimson vapor
#

My commands load after everything else

opal plank
#

thats why you'd use sync for loops feud

#

so its blocking

#

oh, then you fine million

#

@novel hollow use the corresponding language

crimson vapor
#

Iโ€™m redoing the base because shit code

opal plank
#
import jdk.javadoc.internal.doclets.formats.html..Head;

class Main {
  public static void main(String[] args) {
    System.out.println("Hello world!");
  }Head
}html
mellow kelp
#

im switching to detritus

opal plank
crimson vapor
#

Ah

opal plank
#

detritus best lib

mellow kelp
#

in spite of a lack of docs

novel hollow
crimson vapor
#

Berry doesnโ€™t like it

#

Hmm

opal plank
#

cuz hes bithcing about its cluster

#

which i personally enjoy quite a lot

crimson vapor
#

Yep

sudden geyser
crimson vapor
#

he has a fair point

#

but nonetheless

mellow kelp
#

i just realized the detritus support server icon is the missing unicode character

#

why

novel hollow
#

Bans a member from the server.
%help
Displays all the commands of the server.
%mute <@user>
Mutes a user in the server.
%unmute <@user>
Unmutes a user in the server.
%afk
Set's an AFK message for a user.
%warn <@user>
Warns a user.
%warnings <@user>
Displays all the past warnings of a user.
%clearwarnings <@user>
Clears all the warnings of a user.
%status
Changes the status of the bot.
%report <@user> <option reason>
Reports a user.
%suggest <suggestion>
Logs a suggestion to the server.
%invite
Generates the invite link for the bot.
%kick <@user>
Kicks a user from the server.
%say <message>
Broadcasts a message in the channel.
%addrole <@user> <role>
Adds a role to a User.
%removerole <@user> <role>
Removes a role from a User
%softban <@user> <reason>
Soft bans a user from the server.
%purge <no. of messages>
Deletes a number of messages in a channel.
%ping
Gets the ping of the server and bot```
crimson vapor
#

Uh

sudden geyser
#

Yeah but what are you trying to do

mellow kelp
#

did you copy your whole help command

novel hollow
#

Currently trying to make a trading bot

opal plank
#

i dont think they are coding

#

seems like they are trying the codeblock sytanx

crimson vapor
#

I love how clean that looks ngl

opal plank
#

YOUUU

zenith terrace
#

lol

opal plank
#

STAPH

crimson vapor
#

Go to stats.ts Erwin

#

No balls

novel hollow
#

Its hard making a Economy bot

crimson vapor
#

No

mellow kelp
#

why does context have an embed method hashflushed

opal plank
#

yikes

crimson vapor
#

jpbbitch

opal plank
#

thats all im gonna say

crimson vapor
mellow kelp
#

yikes

crimson vapor
#

On phone

#

Looks way better on pc

mellow kelp
#

ew mobile monospace

crimson vapor
#

ikr

mellow kelp
#

so today i uninstalled chalk from my project

#

and instead decided to

crimson vapor
#

colors?

mellow kelp
#
const reset = '\x1b[0m';
const func = (code: string) => (s: string) => code + s + reset;

const chalk = {
    reset: func(reset),
    bright: func('\x1b[1m'),
    dim: func('\x1b[2m'),
    underscore: func('\x1b[4m'),
    blink: func('\x1b[5m'),
    reverse: func('\x1b[7m'),
    hidden: func('\x1b[8m'),

    black: func('\x1b[30m'),
    red: func('\x1b[31m'),
    green: func('\x1b[32m'),
    yellow: func('\x1b[33m'),
    blue: func('\x1b[34m'),
    magenta: func('\x1b[35m'),
    cyan: func('\x1b[36m'),
    white: func('\x1b[37m'),

    bgBlack: func('\x1b[40m'),
    bgRed: func('\x1b[41m'),
    bgGreen: func('\x1b[42m'),
    bgYellow: func('\x1b[43m'),
    bgBlue: func('\x1b[44m'),
    bgMagenta: func('\x1b[45m'),
    bgCyan: func('\x1b[46m'),
    bgWhite: func('\x1b[47m'),
};
mellow kelp
crimson vapor
#

I mean

#

I use colors lib

#

Works well

opal plank
#

chalk

#

omg

#

frick u

crimson vapor
#

lemme grab logs

opal plank
#

pls dont

mellow kelp
#

i created basic chalk in 32 lines

#

what else do you want

opal plank
#

i made my logger in 1

mellow kelp
#

console.log

opal plank
#

yeah

#

and colored

mellow kelp
#

elegant solution

opal plank
#

without the need for chalk

mellow kelp
#

i just like keeping the colors named

#

i can't remember every single color code

opal plank
mellow kelp
#

you're using raw color codes right?

opal plank
#

me? yes

mellow kelp
#

aight fine

zenith terrace
#

@opal plank yo my code no work pls help

const embed = new discord.MessageEmbed()
.setDescription(`hi Erwin <3`)
.setField(`Erwin is`, `gonna be mad`)
message.channel.send(embed)```

pls no block Erwin ๐Ÿฅบ
opal plank
#

blocked

zenith terrace
mellow kelp
#

so uhh

crimson vapor
mellow kelp
#

i said i was going to use ClusterClient right?

crimson vapor
#

That was PAIN

opal plank
#

hmmm table could be an option tbh

mellow kelp
#

what could i use redis for

opal plank
#

everything cache related

crimson vapor
#

I donโ€™t use redos for anything

mellow kelp
#

hmm aight

crimson vapor
#

only thing I would do it multi process

#

And no need yet

mellow kelp
#

but why would i use redis instead of just memory cache

opal plank
#

cuz then you have persistent cache after restarts

crimson vapor
#

Persistence and multi process

mellow kelp
#

true true

opal plank
#

its like using a database thats a LOT faster than a database

mellow kelp
#

well another one to my todo-list

opal plank
#

its meant to be super efficient and fast

crimson vapor
#

I just cache my dB

opal plank
#

keep in mind its not object friendly

mellow kelp
#

oh noes

opal plank
#

you'll have to learn hashes

crimson vapor
#

Stringinfy it

mellow kelp
#

i'll probably use json

#

yeah

crimson vapor
#

or hashes

mellow kelp
#

should i use base64

crimson vapor
#

Strings easier tho

mellow kelp
#

i remember serializing base64 with java

novel hollow
#

I mean coding for suggestions is easy

sudden geyser
# opal plank *blocked*
class Embed {
  constructor(embed) {
    this.embed = embed
  }
}

let messageEmbed = new Discord.MessageEmbed()
  .setTitle("Erwin")
  .setDescription(":)")

let embed = new Embed(messageEmbed)

message.channel.send(embed.embed)```
novel hollow
opal plank
#

everyone blocked now

novel hollow
#

Im try to do giveaway/trading bot

crimson vapor
#

LOL wait for sharding

crimson vapor
crimson vapor
#

Ok

#

Iโ€™ve got to sleep

#

Itโ€™s 12

opal plank
#

@novel hollow i dont accept random friend requests

crimson vapor
#

gn embed builder lovers @opal plank @sudden geyser @zenith terrace

novel hollow
#

I thought it wasn't gonna work tbh

mellow kelp
#

@opal plank does detritus expose the ClientEvents enum?

#

oh nevermind

opal plank
#

you can import it

mellow kelp
#

wait actually yes mind

opal plank
#

idk why you need it but

zenith terrace
opal plank
#

should be under detritus-client

mellow kelp
#

aight found it

crimson vapor
#

@mellow kelp use discord-rose gn

mellow kelp
#

it's in the constants file

#

good thing every file has declarations

novel hollow
#

Patreon is hard ๐Ÿ˜ฆ

opal plank
#

and using deprecated --save

#

amazing

mellow kelp
#

seriously i can't get over how useful is the fact that every file has declarations

#

gotta love typescript libs

earnest phoenix
#

can anyone say how to lock to lock all text channels?

opal plank
earnest phoenix
opal plank
#

dunno py, so not me

earnest phoenix
opal plank
#

i know, and i said i dont know python

earnest phoenix
#

ohk

opal plank
#

i know what you need to do, im familiar with discord api, but i cant tell you what to use in discord.py

river sedge
#
/// it is running even when last_monthly_claimed == 0
if(last_monthly_claimed !== 0){

}```
drifting wedge
#

i just moved from flask to quart
and my wsgi needs to be asgi


if __name__ == "__main__":
    app.run()```
 this is wgsi
how do i make it work for asgi? ping me pls
delicate shore
#
 const ToTalSeconds = (client.uptime / 1000);
        const Days = Math.floor(ToTalSeconds / 86400);
        const Hours = Math.floor(ToTalSeconds / 3600);
        const Minutes = Math.floor(ToTalSeconds / 60);
        const Seconds = Math.floor(ToTalSeconds % 60);
        const Uptime = `${Days} Days, ${Hours} Hours, ${Minutes} Minutes & ${Seconds} Seconds`;
        const MemoryUsage = process.memoryUsage().heapUsed / 1024 / 1024;
        const RamUsed = Math.round(process.cpuUsage().system) / 1024;
        const RamUsage = Math.trunc(RamUsed);
        const BotPlatform = process.platform;
        const MemoryUsed = Math.trunc(MemoryUsage);
        const Os = require('os');
        const OsHostName = Os.hostname();
        const SystemPing = Math.round(client.ws.ping);
        const exampleEmbed = new Discord.MessageEmbed()
            .setColor('#b700ff')
            .setTitle("Bot's Live Status")
            .addField(" \u200B ", "**Bot Uptime** : ` " + `${Uptime}` + " `")
            .addField(" \u200B ", "** Bot's Hot Name** :  ` " + OsHostName + " `")
            .addField(" \u200B ", "**Bot Current Version** : ` " + "1.0" + " `")
            .addField(" \u200B ", "**Global Bot Prefix** : ` " + "s!' + " `")
            .addField(" \u200B ", "**CPU Usage** :  ` " + **RamUsage** + "Mb `")
            .addField(" \u200B ", "**Memory Usage** :  ` " + MemoryUsed + "Mb `")
            .addField(" \u200B ", "**Bot Platform** :  ` " + BotPlatform + " `")
            .addField(" \u200B ", "**System Ping** :  ` " + SystemPing + " `")
            .addField(" \u200B ", "**Channels** : ` " + `${client.channels.cache.size}` + " `")
            .addField(" \u200B ", "**Servers** : ` " + `${client.guilds.cache.size}` + " `")
            .addField(" \u200B ", "**Users** : ` " + `${client.users.cache.size}` + " `")
        message.channel.send(exampleEmbed);
#

I get an error

#

SyntaxError: missing ) after argument list

earnest phoenix
#

You're probably missing a closing ) somewhere

delicate shore
#

nvm

#

it was a typo

#

How can I add total number of members

#

for each guild

#

to a variable

earnest phoenix
#

Loop trough each guild and get it's total number?

delicate shore
#
let guilds = client.guilds.cache
let i;
let bruh;
for(i=0; i<guilds.length; i++){
bruh + guilds[i].memberCount
}
#

I tried something like this

#

it keeps giving -

#

0

earnest phoenix
#

Do you even have intents?

delicate shore
#

mhm

#

I have the member's intent

#

privilged one

#

and all others

#

except the uh presence

outer niche
#

Can anyone help me figure out what a font is from a picture

earnest phoenix
#

There are scanners on internet

#

Where you just put the image and it detects the font

#

Use that

winged mulch
drifting wedge
#

Prob cuz this url so sketch that discord's embed tool doesn't wanna open it

zenith terrace
#

I cant really find any loop to get all members lol

outer niche
earnest phoenix
#

Every scanner does

#

Just send your picture I'll use google for you

#

I know using google is hard sometimes

outer niche
#

Trying to figure out the text at the very top of the website that says welcome to the official website for Echo

earnest phoenix
#

screenshots please...

#

and it's a website

outer niche
#

That's all we have

earnest phoenix
#

so you can read source code and see the font

#

send website

outer niche
#

No we do not have it anymore

earnest phoenix
#

omg

icy skiff
#

Kek

earnest phoenix
#

2 seconds then

#

I'll use google for you

fluid basin
#

that just looks like italic arial tbh

earnest phoenix
#

Might be that:
Monotype Baskerville eText Bold Italic

elfin shadow
#

any alternatives to fetch_user? it takes long to fetch multiple users

solemn latch
#

Tracking the user data in a local database

elfin shadow
#

@solemn latch if i had to add the user's name, what if they change it?

#

i have to fetch_user them during all events in order to keep track if they change their name?

solemn latch
#

Generally you would expire data over time and update it when you need it.

#

It won't be perfect but it won't be slow.

uncut swallow
#

xd

near stratus
#

The status still isn't showing

#

so any solution ?

versed shoal
near stratus
quasi oxide
#

/poll "ะšั‚ะพ ะทะฐ ะฟะตั€ะตะฝะพั ะฑะฐะทั‹?" "ะะปัŒะบะฐั‚ั€ะฐั" "ะขะธัั‹"

near stratus
#

huh ?

versed shoal
near stratus
versed shoal
near stratus
#

bruh
which one is undefined ?
variable , collected or content ?

#

@versed shoal

versed shoal
#

variable.collected.content is undefined

near stratus
#

so content is undefined otherwise it would show Can't read value content of undefined

versed shoal
near stratus
#

oh f it's a map

versed shoal
#

so ?

near stratus
#

hol on

versed shoal
#

i tried variable.collected[0].content but it didn't work

near stratus
#

Map.find(key => key == "811501787281752067")

versed shoal
#

oh

#

i'll try

#

oh wait

#

key ?

#

how can i find a key ?

near stratus
#

wait

#

Map.get("811501787281752067") should be fine

#

since you know the key

versed shoal
#

Does the key not change in every message?

near stratus
#

but it'll not be dynamic

jovial loom
jovial loom
#

You're welcome

near stratus
near stratus
#

array[0]

lethal gulch
near stratus
#

or simply array = Array.from(map) should do in your case @versed shoal

near stratus
#

@lethal gulch did you chmod +X ./start.sh before doing that ?

lethal gulch
#

no

near stratus
#

are you on Linux ?

lethal gulch
#

no

near stratus
#

huh ?
Then where are you trying to run that ?

lethal gulch
#

windows

#

@versed shoal yardฤฑm et lo

#

ingilizce seviyem yรผksek deil

jovial loom
#

sฤฑkฤฑntฤฑ ne

#

?

lethal gulch
versed shoal
versed shoal
#

ne yapmaya รงalฤฑลŸฤฑyorsun

lethal gulch
#

web panel

near stratus
lethal gulch
#

i will try something wait

versed shoal
#

o hata da kฤฑsaca start.sh'yi bulamadฤฑฤŸฤฑnฤฑ sรถylรผyor

#

hiรง web panel yapmadฤฑm

lethal gulch
#

oo

#

oo fixledim

versed shoal
#

tamam

near stratus
#

Google translate : "They are talking Turkish"

versed shoal
#

he said "i fixed it"

near stratus
lethal gulch
#

๐Ÿ‘

#

Can I ask a question about HTML?

versed shoal
lethal gulch
#
<link rel "icon" href="../images/siteicon.png" type="image/x-icon" />```
where is the mistake
#

yanlฤฑลŸlฤฑkla enter bastฤฑm

earnest phoenix
#
1|server  | Unable to connect to the Mongodb database. Error:MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://docs.atlas.mongodb.com/security-whitelist/ error
lethal gulch
#

:(

earnest phoenix
#

What to do with these

#

Huh

lethal gulch
versed shoal
versed shoal
#

i use mongodb but not atlas

#

i think atlas is bad

earnest phoenix
#

@versed shoal it's done already

silver lintel
#

Is there a way to eval python code in js?

deep crater
#

:ruuuuuuuun:

old cliff
#

-eval message.guild.leave()

#

oof wrong server

slender thistle
fluid basin
#

could get something going with exec

#

but be careful to properly sandbox and virtualise code execution context

#

unless you are sure that anything you run is safe

versed shoal
#

How can I use the awaitMessages function in Eris?

sudden geyser
#

You need to listen to the new event listener and use the new message for your awaitMessages logic

near stratus
sudden geyser
#

You should check out the logic behind Discord.jsโ€™ one and write your own abstraction to do it

stuck pike
#

Why my users amount is wrong

#

It always display wrong

#

Like I have 130k users

restive furnace
#

partials

old cliff
#

the message isn't cached

#

so it doesn't trigger the event

#

you can although use raw event and get that...

pale vessel
#

just enable partials

earnest phoenix
old cliff
#

yeah that also works but I don't also share useful tips zzzzz_hehe

exotic vigil
#

s!log

#

Team what @gilded plank Prefix

#

@gilded plank

rustic nova
#
  • is the prefix, it does not have many commands though
exotic vigil
jovial elk
#

I want to implement a feature in my bot to allow server admins to set a "remind" like feature, for example, post a graph every week. I have seen many approaches to this, but i have been wondering what is the best, most effiecent approach?

exotic vigil
#

-log

#

-help

#

!help

#

sp!

rustic nova
exotic vigil
#

luca prefix what

rustic nova
#

still -

exotic vigil
#

ok

rustic nova
exotic vigil
#

ok ฤฑ know

crimson vapor
#

@opal plank you able to help with ts now?

quartz kindle
#

its 8am for him, hes probably sleeping

crimson vapor
#

fuck

#

fuck yes I fixed my problem

#

no clue what it is

#

but I fixed it

quartz kindle
#
for(let mention of message.mentions.users) {
  message.content = message.content.replace(mention, mention.username)
}
crimson vapor
#

thats smart

feral aspen
#

Hello!

crimson vapor
#

hi!

feral aspen
#

I'm writing my question, AHH.

#
// The stuff...
data.money = 0;
data.bank = 0;
data.bankLimit = 1000;

if((args[0] + server.bank) > server.bankLimit) return message.channel.send("Nonono, too much!")

I am trying to make a limit on my economy commands where they cannot deposit coins more than the limit which is 1000.

#

So if someone deposits coins more than the bank limit then it returns, or something like that.

crimson vapor
#

args[0] will be a string or a number

feral aspen
#

number.

crimson vapor
#

what do you do to make it a number?

feral aspen
#

Wait

#

I messed up something, moment.

crimson vapor
#

the standard args = message.content.slice(prefixLength).split(' ')

feral aspen
#

Ok.

warm marsh
#

args[0] should be a string if split from message.content

crimson vapor
#

@quartz kindle is there a way for me to bind a single function to 2 different client.on()s?

#

well

#

I can do client.on('x', y)

feral aspen
#

Basically I had 500 coins in my money and I have 100 coins in my bank, if I deposit my coins and it equals more than the bankLimit then it returns..

crimson vapor
#

and client.on('z', q)

#

thats likely becase strings can be added as strings but will compare value with numbers iirc

crimson vapor
feral aspen
#

Oh

feral aspen
warm marsh
#

You mean parseInt?

feral aspen
#

parseInt?

#

I guess that.

warm marsh
#

parseInt("10") -> 10

crimson vapor
#

parseInt, Number, parseFloat

#

in your case its better to use parseInt I think

feral aspen
#

Yes, used that.

crimson vapor
#

"1000.111111" -> 1000

feral aspen
#

I'm testing again.

lament rock
#

I'd say it's better to use the NumberConstructor to parse numbers

#

unless you're working with floats

crimson vapor
#

the number constructor only converts tho right?

#

so if you need ints

warm marsh
#

If you pass it a float it returns a float so meh.

lament rock
#

new Number();
Number(string);

feral aspen
#

parseInt works!

feral aspen
#

Thank you all!

crimson vapor
#

PapiOphidian you know ts right?

#

is there a way to make a class callable

earnest phoenix
#

uhm what

crimson vapor
#

lol js const x = new Class(); x()

earnest phoenix
#

but that doesn't make sense

#

a class is just a fancy object

#

In python, yes kek

crimson vapor
#

ok

earnest phoenix
#

what do you want to do

slender thistle
#

__call__ gang

crimson vapor
#

im not sure anymore

modest maple
#
async def __call__(self):
  print("extra flare")
slender thistle
feral aspen
#
data.money += reward;
data.beg = Date.now();
data.save().catch(err => console.log(err));

// The part here where I define the /100 chance and check if the user got the number "1", and if so then I would add to his data.money and .save(), but saving doesn't work twice! :(

Usually after this code, which is after the .save() part, I do an if statement to check if the user out of 100 chance got the number 1, then he would win a prize, but unfortunately, I can't .save() twice, so what can I do instead?

warm marsh
#

Do the check before saving?

feral aspen
#
if(user won the /100 chance money) {
give out the money for /100 chance
.save()
} else {
.save()
}
#

Like that? Yea?

#
data.money += reward;
data.beg = Date.now();

While this is not in the if statement but above it?

solemn jolt
pale vessel
#

It doesn't have the permission to

lyric mountain
warm marsh
small tangle
#

When you read a documentation a little bit closer and you can shrunk your method to a simply method call LUL

#

Maybe u should read the docs FeelsAmazingMan

feral aspen
#

From 1 to 50?

warm marsh
#

The amount won?

feral aspen
#

Yes.

#

if(variable === 1 to 50)

warm marsh
#

I'm a little lost.

feral aspen
#

Example, I have a random chance which is out of 100, and if the random chance was equalling from 1 to 50, then it console log yes.

#

But I just need the part of from 1 to 50

pale vessel
#

n >= 1 && n <= 50?

umbral zealot
#

Or just n <= 50

feral aspen
#

if(chance >= 1 && chance <= 50)

#

Like that?

#

if(chance >= 1 && =< 50)

#

Or like that.

pale vessel
small tangle
#

first

umbral zealot
#

the second one is not valid javascript

small tangle
#

=< doesnt exists or?

feral aspen
#

If I want it between 10 and 30, then if(chance >= 10 && chance <= 30)

pale vessel
#

It's like doing if (x == y || z)

misty sigil
#

if z is true it works

#

or something

pale vessel
misty sigil
#

yea ik

#

donโ€™t work does it

pale vessel
#

idk

feral aspen
#

and if I want to make chance if equalling to multiple numbers, then if(chance === ["1", "2",])

umbral zealot
#

no

feral aspen
#

f.

umbral zealot
small tangle
#

concat with &&

umbral zealot
#

Throwing together characters when you haven't learned the language isn't programming, it's button mashing.

feral aspen
#

I can use indexOf, I guess.

small tangle
#

But yes as he says, you have a much better time once you look at the language itself, before you try to build a bot

misty sigil
feral aspen
#

K

cinder patio
#

eh?

rustic nova
#

just ignore Love

lament rock
#

I require a good suggestion for what lib I should use to interface with a postgresql db. Coming from MySQL/Maria
lang: NodeJS

fluid basin
#

use an ORM?

#

e.g. sequelise?

quartz kindle
#

pg

umbral zealot
#

Yeah just literally connect with the pg module, it's fine if you know SQL

lament rock
#

I don't like some of the implementations of ORMs. I was looking at pg and postgres. I wanted to see if a module designed for mysql would work, but I decided against it since I know they're different standards of SQL

fluid basin
#

the syntax is similar but yet still different

quartz kindle
#

its the same

#

but different

#

but still the same

cinder patio
#

I think sequelize is good

earnest phoenix
#

!halp

junior fjord
#

damn yall bot developers

quartz kindle
#

well, this is the development channel for a large discord bots website, what did you expect?

lament rock
#

Does pg not support prepared statements?

#

Ah. nvm. I see that it's prepared statement implementation is different from mysql's. Not using ?s to delimit prepared.

copper cradle
earnest phoenix
#

So

#

I converted drive from MBR to GPT

#

And now

#

When i restart the pc

#

It doesnt boot

outer perch
#

omg, I'm lost

earnest phoenix
#

Its just showing this

outer perch
#

@cinder patio bot.commands doesn't exist, but I tried to extend the client, and said it's undefined when I try to set the command

cinder patio
#

show de code

quartz kindle
outer perch
#
interface Cmd {
  name: string;
  aliases?: string[];
  execute(bot: Client, message: Message, command: any, db: any, lang: any, language: string, prefix: string, args: string[], serverSettings: Object): void;
}

export class botClient extends Client  {
  commands: Collection<string, Cmd>;
}

const bot = new botClient();


const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.ts'));
  if (commandFiles.length === 0) return;
  for (const file of commandFiles) {
    const props = require(`./commands/${file}`);
    bot.commands.set(props.name, props);
  }
#
Cannot read property 'set' of undefined
cinder patio
#

You only specify that botClient has the commands property, but you don't actually create it in the constructor

outer perch
cinder patio
#

it does, but it doesn't have the commands property

outer perch
#

o_O

cinder patio
#

you need to create it in the constructor of the new class