#development

1 messages · Page 1604 of 1

misty sigil
#

thank you.

mighty ember
#

i don't know how

brazen stone
#

A bot can intercept a webhook if you know how - although I just wrote a mini express server that runs next to my bot and interacts with it

misty sigil
#

run a webserver with your bot

#

and do shit with the request

mighty ember
#

how do i do that though?

brazen stone
#

Also, another way people do it is have a 'claim' command so when people vote they get the role and you do '!claim' to do the reward

#

Which is much easier IMO

blissful coral
#

You still need a Webhook

wicked pivot
#

""

brazen stone
wicked pivot
#

To put it simply, when I click on a specific button it redirects me to another page is it possible to interact with the second page if so how? @brazen stone

earnest phoenix
#

Python question:

I have a config.json setup like this

{
    "traders" : {
        "userid1" : "user1schannel",
        "userid2" : "user2schannel"
    }
}

and have:

with open('./trader.json', 'r') as cjson:
    config = json.load(cjson)

traders = config["traders"]

How would I be able to do an if statement to do something if ctx.author is a user id in traders

brazen stone
wicked pivot
#

how can I do it because to tell the truth I did some research and it speaks of scraping something that interests me not

mighty ember
#

could someone give me the docs for server votes?

wicked pivot
#

the part of the code that redirects me to the other page

await Promise.all([
      await page.click('#app > main > div:nth-child(2) > div > div > div > div.vote.vote-now.text-center.position-relative.mb-4.px-3.py-5 > div.h-100 > a:nth-child(2)')
  ])```
brazen stone
#

You should be able to do await page.waitForSelector('...something on the new page') then after that interact with the new page

misty sigil
brazen stone
misty sigil
#

JSON body’s main keys are guild (server id) and user (user id)

earnest phoenix
#

That's basically equivalent to

channel = traders.get(str(ctx.author.id))
if channel:
  ...
earnest phoenix
quartz kindle
#

there are examples for how to receive webhooks. once you receive them, what to do with them is up to you. you can easily do something like client.get_channel().send()

earnest phoenix
#

Ah, then the second one should do

#

okay thank you i will take a look

quartz kindle
#

all i see is this

blissful coral
quartz kindle
#

yes

#

because require is not a thing on browser side

blissful coral
#

oh...

#

then how can I do that?

quartz kindle
#

for axios use the browser version

#

for mongodb you cant

blissful coral
#

ok

#

hmmm

#

Oh Ik a workaround

quartz kindle
#

mongo should be done server side only

blissful coral
#

yea

misty sigil
#

you can make a rest api

#

to do shit

blissful coral
#

That is my workaround

#

lmao

misty sigil
#

thats the right way imo

blissful coral
#

Just so it is there while I make the rest api

#

or do I just do my function inside of html instead o fjs

earnest phoenix
#

that should work right

#

no, that's pointless really

#

just keep it as it was, there's no point in tracking the keys since you can retrieve the keys in the first place.

#

gotcha thank. appreciate it

#

one more thing im running into, when im running the bot, cant seem to load the json, saying no such file

#

when they are in the same direcotry

#

which is weird because ive never seen that happen before

#

try printing os.listdir() and os.getcwd()

#

ahh working directory is my user folder

#

weird

quaint wasp
#

I'm back.

#

Did ya'll miss me?

#

no..?

small zenith
#

Is it possible to edit messages older than 30 days? If yes whats the limit a month, a year? If no how to edit it..??? I have seen many giveaway bots editing giveaways older than 30 days.

quaint wasp
#

and...

#

you cant?

mellow kelp
#

if you can edit old messages in the discord client, you most likely can with bots, too

small zenith
#

Oo thanks 😄
I was just confused cuz of the 2 week limit in message deletion i thought this has a limit too

mellow kelp
#

np

brittle horizon
#

I have a
on_message_delete

Event which sends a message whenever someone deletes a message but whenever the bot deletes a message it counts itself too, is there any way to fix this?

#

Will this work: if message.author == client.user: Return

old cliff
#

@brittle horizon

brittle horizon
#

lol

brittle horizon
#

Thx for the help

old cliff
#

convert it to py version

brittle horizon
#

k

old cliff
#

don't compare the user objects... compare the ids

brittle horizon
#

ohk

cursive pewter
#

Anyone here have any experience with discord logins for dashboards? And making them work despite cloudflare?

earnest phoenix
old cliff
#

still a tip doe

#

for better speed

earnest phoenix
#

Tryin to get slappey to work. Every time I copy my token it comes up as one * instead of all of them Help?

#

Nvm

#

was another issue

snow niche
misty sigil
#

no need for :4000

snow niche
#

ok

icy skiff
#

Im trying to stablish an webhook with Patreon but it needs an SSL certificate and now i have no ideia what to do

#

halp

crystal wigeon
#

hey umm

drifting wedge
#

at all

#

what lib you using?

crystal wigeon
#

in sql, query, how do i pass params for "in" something like this,

select * from table where row_number in ($2)

drifting wedge
#

/ lang

cursive pewter
#

Reactjs

crystal wigeon
#

yeah

drifting wedge
#

backend...?

cursive pewter
#

It seems to remove the cookies and only use cloudflares

crystal wigeon
#

i made my dashboard

#

with react

cursive pewter
#

You can go see for yourself, link in my status as for what it does

drifting wedge
#

BRUH

#

@crystal wigeon no backend?

snow niche
# misty sigil no need for :4000

Hey so for my webhook. I just want it to send a message whenever a user votes. how would I do that with the new sdk.

And also do I need a middleware()

crystal wigeon
#

iam

drifting wedge
#

how did you run it then?

crystal wigeon
#

nextjs

#

backend

drifting wedge
#

oh

cursive pewter
#

In development mode the login works fine however in production it does not

drifting wedge
#

ye thats what im asking

#

@cursive pewter WHAT LIB U USING FOR BACKEND

cursive pewter
#

Nextjs

crystal wigeon
#

lol

drifting wedge
#

alr ur on ur own

crystal wigeon
#

whats the problem btw?

cursive pewter
#

Login doesn’t work in production mode

#

But in development it does

crystal wigeon
#

whats your redirect uri in prod and dev env?

cursive pewter
#

Both the same

crystal wigeon
#

like does the auth page doesnt open at all?

cursive pewter
#

Go to the link in my status and try log in

#

It just sends you back to the main page

crystal wigeon
#

sus link

#

send ss

earnest phoenix
#

if i split it up like im doing it should circumvent all problems

cursive pewter
#

Hence why I figured it was the cookies

#

How’s it sus… it’s an https

#

Got an SSL

crystal wigeon
#

atleast type it out

cursive pewter
#
snow niche
#

I get unauthorized

#

I get {"error":"Failed to lookup view "docs" in views directory "/var/botlist/views""}

#

Im trying to get my token

crystal wigeon
blissful coral
#

cant call inviter or channel?

#

its undefined?

crystal wigeon
#

you're not handling isAuth

cursive pewter
#

Does your avatar display at the top right

crystal wigeon
#

by logged me in

#

i mean it redirected me back to home page

#

nop

#

have you handled it tho?

cursive pewter
#

Oh nah then it didn’t work

#

Yeah

crystal wigeon
#

i'll need a ss of it then

#

of the working one

cursive pewter
#

It does it in development fine

snow niche
#

Hello?

cursive pewter
#

This is in development mode

crystal wigeon
#

you're using the same domain name for dev also?

cursive pewter
#

Doesn’t make a difference, production doesn’t work locally or on the domain (as in the log in doesn’t)

#

Development works on both

crystal wigeon
#

well, redirect uri makes a lot of difference

#

are you actually check if the data came back?

cursive pewter
#

Yeah it does

mellow kelp
#

um

crystal wigeon
#

you can see the logs in prod mode as well?

mellow kelp
#

that's not what the redirect uri should be

cursive pewter
#

Everything is fine code wise which is why I assumed it would be cloudflare

crystal wigeon
#

nop, cloudflare is fine

cursive pewter
#

No page rules need adding?

crystal wigeon
#

wait, how are you handling auth?

mellow kelp
#

react gang

crystal wigeon
#

i have my own microservices and cookies to handle auth and sessions

#

nextjs gang

#

xd

mellow kelp
#

oh yeah i wanted to learn next

spare portal
#

how would i send a message once the bot joins a server? an example is the yggdrasil bot i believe

cursive pewter
#

I’m not sure, I’m not the main web dev.

crystal wigeon
#

lol

cursive pewter
#

We have simply tried everything else

crystal wigeon
#

well, i'll need to see some snippets

mellow kelp
#

i swear every time i hear yggdrasil i can only think of overlord

crystal wigeon
#

same

#

there's an event called guildAdded

#

or something

mellow kelp
#

guildCreate

crystal wigeon
#

that ^

spare portal
#

ah ok ill check it out

crystal wigeon
#

someone help with my query

#

;-;

snow niche
#

I get unauthorized in my webhook.

when I go to https://top.gg/api/docs#mybots I get {"error":"Failed to lookup view "docs" in views directory "/var/botlist/views""}

Im trying to get my token to see if it will fix my unauthorization

blissful coral
snow niche
#

Ok

stark abyss
#
setTimeout(reset, midnightTime())
 function reset(){
    setInterval(async function(){ 
      var d = new Date();
      var weekdays = new Array(0, 1, 2, 3, 4, 5, 6);
      var today = weekdays[d.getDay()];
      if(today == 0){
        //weekly reset here
      }

      //daily reset here
    }, 86400000);
}
function midnightTime() {
  var midnight = new Date();
  midnight.setHours( 24 );
  midnight.setMinutes( 0 );
  midnight.setSeconds( 0);
  midnight.setMilliseconds( 0 );
  return (midnight.getTime() - new Date().getTime());
}```
#

Does anyone spot a problem, I am not getting any errors or anything but this isn't exactly something that I can test precisely

lyric mountain
#

what's the expected vs reality result?

mellow kelp
#

why are you making an array with the Array constructor kek

#

also, Date.getDay already returns the week day from 0 to 6, so there's no need for another array

stark abyss
mellow kelp
#

(unless you're gonna use it later tho)

old cliff
#

what kind of bot has never been made ?

stark abyss
#

you are right -- ty for that feedback

mellow kelp
#

np

old cliff
#

how do I make a child process in nodejs and send some objects as data to the process?

delicate shore
#

Adding python to path

#

in ubuntu

grave mist
#

Hi @restive silo (contacting you here since I couldn't in DMs nor can I see any better channels in our mutual servers), I saw https://github.com/DevYukine/Kurasuta and wanted to give it a try once, is there any suggested amount of servers I should have per cluster?

Like for sharding, it's suggested to start around 2000 - 2500 servers and one shard can have up to 2500 servers in it, is there anything like that for clusters so that like x amount of servers per cluster is good and when it crosses y, you should consider adding one more cluster?

Or does it work in a different way which I don't know about yet?

Thanks in advance

crimson vapor
#

I can't answer the lib specific questions but generally clustering is done to lower load on the bot host, sharding, on the other hand, is for discord's load

#

so it really depends more on your bot and how you deal with events

#

if you require every event and do lots of operations, might want to go a bit lower. for example, censorbot (tracks most user input events) does 5 shards per cluster

#

bass (music bot) has 2 shards per cluster

#

chip does the same

grave mist
#

I don't really know much about clusters yet but I've heard that it's possible to host the bot in multiple servers when clustering which I really want to try once since that's more better sometimes like when bot gets ratelimited with 1 hour temp ban, I could avoid having the whole bot offline, instead could just have a part of the bot offline

grave mist
crimson vapor
#

im not sure, not too familiar with kurasuta nor much clustering

#

iirc cf ban is 50req/s

#

any competent library should keep requests under that

#

even with shitty code

opal plank
grave mist
#

Yea I mean it's hard to hit that but I was talking about just in case + I could also do it better since multiple servers means more internet speed so you wouldn't have to have all requests in one server and I also want to give this a try since hosting a bot in multiple servers seems like a magic to me so I more like also want to try it out and see how it works

crimson vapor
#

it doesn't make sense for many bots tho

grave mist
hollow thorn
#

What is the best module to use for welcome/goodbye messages, that shows a picture with the users avatar and name in it?

nocturne topaz
#

canvas zoomeyes

hollow thorn
#

ok cool, thanks 🙂

crimson vapor
#

bit of a learning curve

hollow thorn
#

yeah

west pine
#

can i copy paste code from vs code to repl.it?

grizzled raven
#

yes you can

stark abyss
faint nebula
#

could i get some very small help

#

random parts of my python file keep disappearing

#

ctrl z or ctrl y dont bring it back

stark abyss
#

Random parts of a file keeps disappearing?

earnest phoenix
#

cache

faint nebula
stark abyss
#

@earnest phoenix show code

#

Ok cool

lusty quest
#

explain closed?

stark abyss
#

I am sorry I don’t know, was it on and working before

lusty quest
#

like offline or doesnt respond to commands

stark abyss
#

Well he says no error in code so probably is offline

#

So it’s offline now right

#

Idrk what could be causing this but perhaps someone else might help u

lusty quest
#

are you sure there are no errors?

#

why Ping ok?

#

ok. did you updated your discord token after regenerating it

#

why did you have an express server running that just pings stuff?

#

did you pasted the code into your bot?

restive furnace
#

you really should 1) get a proper host 2) learn js properly before hopping into bot development -> pins

blazing sage
#

Hi

near stratus
#

hello

proven lantern
#

can i get the reason for kick from the guildDelete event?
client.on('guildDelete', async (guild) => {});

latent heron
#

.reason?

#

idk how d.js handles it

#

have you considered checking the docs?

proven lantern
#

the guild object doesn;t have a reason field

restive furnace
#

you can't get the reason

#

unless it's emitted in the raw event

proven lantern
#

dang, i'm still looking around.

pale vessel
#

The reason is only for audit logs iirc

proven lantern
earnest phoenix
#

not like you can get it anyways

#

you don't have access to the guild anymore

old cliff
#

Either the guild was deleted or the bot was kicked/banned/integration removed

earnest phoenix
#

ohh

#

my bot was integration removed

#

my bot detected as kick but it still can acsess the guild

old cliff
#

the guild can't be accessable

#

it can be in cache

#

but not guild.available

old cliff
#

can I share a package I made ?

delicate shore
#

Hey so
I made some stuff in html
I need to use nodejs with html as well to do some stuff
Any way how can I do that

old cliff
#

ejs express

#

@delicate shore

delicate shore
#

oh

#

how

#

waits

old cliff
#

:\

delicate shore
#

nvm

#

I figured it out

#

Thanks

old cliff
#

if you are not having dynamic content then just use express static

#

@delicate shore

delicate shore
#

lmao

delicate shore
old cliff
#

Like content taken from a database

#

or which changes based on user input

#

or discord login

delicate shore
#

it does change at user input

old cliff
#

like ?

delicate shore
lusty quest
#

or learn React and build a nice app with it

old cliff
#

yeah thats fine

delicate shore
delicate shore
#

not an easy task

lusty quest
#

i know but quite powerful and probably make some of the best looking stuff out there

old cliff
#

use ejs if you know how to integrat your voice ai

delicate shore
#

I will learn it after I am done with my finals

old cliff
#

ok mine r starting from 1st

delicate shore
#

Mine from 2nd

#

India?

old cliff
#

yes

delicate shore
#

same

lusty quest
#

mine where finished like 4ish years ago

old cliff
#

add me @delicate shore

delicate shore
#

👍

delicate shore
lusty quest
#

wait this where my 2nd finals, the first ones are about 8 years ago

old cliff
#

wait you know royal gamer ? @delicate shore

delicate shore
#

idk

#

many people send me fr

#

I accept it

old cliff
#

ok lol

delicate shore
#

lol

earnest phoenix
#
let menumsg = await message.channel.createMessage({embed: menu})
      .then(msg => {
        console.log("here1")
        message.channel.awaitMessages(test => test.author.id == acted.id && reqmet.includes(parseInt(test.content.trim())), {maxMatches: 1, time: 60000}).then(spmove => {
          console.log("here2")
          menumsg.delete().catch(err => {console.error(err)});
          spmove[0].delete().catch(err => {console.error(err)});
          console.log("here3");
        }
    }
``` Can someone help me here? The function terminates at one of the .delete()s and console.log("here3") is never reached.
old cliff
#

oof - u r using djs11 code in djs12

earnest phoenix
#

also there are no errors

blissful coral
#

I have a few alignment issues I got to fix, but what do you guys think?

old cliff
#

instead of createMessage use send

earnest phoenix
old cliff
#

than idk

earnest phoenix
#

nvm i fixed it somehow

scarlet stratus
#

Or am i just retarded

pulsar bone
#

what is that tracker

earnest phoenix
tired panther
#

but this will just give a boolean?

signal summit
#

Hey @earnest phoenix mind if i ask you something about repl.it? Is the hacker plan good so far? Does the bot stays 24/7 or does it unexpectedly resets still?

old cliff
scarlet stratus
cinder patio
tired panther
silver lintel
#

Why?

cinder patio
#

NaN === null

#

is false

silver lintel
#

When I eval number hi tho

#

It does null

#

And it is still false even when I do === NaN

#

It's only correct when I do !Number('hi')

cinder patio
#

¯_(ツ)_/¯

#

you check if something is nan with the isNaN function

#

NaN === NaN is false because maybe behind the scenes it compares 2 different instancees of NaN, that should be the only reasonable explanation

#

!Number("hi") returns true because NaN is a truthy value

silver lintel
#

Interesting Think3

cinder patio
#

Actually it's the opposite, it'll return true not false

#

but still

#

actually wtf

silver lintel
#

number("hi") returns null or nan

#

When I eval it's null

cinder patio
#

It returns NaN

silver lintel
#

Well that doesn't make a diff if doing !Number()

#

Oh

cinder patio
#

NaN is actually a falsey value, I thought it was truthy

silver lintel
#

well it's not a number

#

It should be falseu

#

Falsey

#

Oof my eval is broken

cinder patio
#

Do you JSON.stringify the output

silver lintel
#

yes

#

is that what's making it wrong?

cinder patio
silver lintel
#

Hmm I wonder why it stringifies to null

cinder patio
#

because there's no NaN in JSON

#

NaN is definitely one of the wtf moments in JS

silver lintel
#

yeah

cinder patio
#

NaN should be a symbol

#

not some weird object

silver lintel
#

Symbol?

#

Like §

#

That type.of symbol?

cinder patio
#
const NaN = Symbol("NaN");
if (Number("hi") === NaN) ...
silver lintel
#

oh

fierce ether
#

anyone any good at computer science?

earnest phoenix
opal plank
#

@cinder patio do you know what the proper name for "externalising a function" ?

#

not refactor

cinder patio
#

what do you mean by externalising?

opal plank
#

make it external

#

taking afunction

#

and exporting it on another file

#

and requiring on the intial one

#

to clean it up

jovial nexus
#

how can i send text as a file?

quartz kindle
#

.send({files:[{attachment: "text here", name: "file.txt"}]})

jovial nexus
#

that says app/text here is not a file or directory

cinder patio
#

maybe try .send({files:[{attachment: Buffer.from("text here"), name: "file.txt"}]})

quartz kindle
#

yes that should work

jovial nexus
#

yay thanks guys

hot violet
#

can someone help me with playing my spotify playlist when i type in the commands it gives me an error

icy skiff
#

What error

hot violet
#

15

#

let me see if i can post it

#

Invalid command
Undefined argument 'super' on command 'play'.
$spotify $list $super playlis
^
Failed at: 15

Is this not supposed to be an argument? Botify interpreted it as one because it started with the argument prefix ('$' or your custom argument prefix defined with the property command). If this was a mistake and the argument prefix is supposed to be part of the command input you can escape the prefix by putting a \ in front of it. E.g. play $spotify $trackname.

icy skiff
#

I could be wrong but i think It's the blank space between super and playlist

#

Try using _ and replace everything properly

#

Oh wait

hot violet
#

Undefined argument 'superplaylist' on command 'play'.
$spotify $list $superplaylist
^
Failed at: 15

Is this not supposed to be an argument? Botify interpreted it as one because it started with the argument prefix ('$' or your custom argument prefix defined with the property command). If this was a mistake and the argument prefix is supposed to be part of the command input you can escape the prefix by putting a \ in front of it. E.g. play $spotify $trackname.

icy skiff
#

Can you send the code

hot violet
#

what code?

#

the code im using?

icy skiff
#

Ye, for the command that's giving an error

hot violet
#

.play $spotify $list $superplaylist

#

i changed the prefix to .

icy skiff
#

Bro, that's not what i meant by code

#

What r u doing the bot with

hot violet
#

oh trying to play my spotify playlist

icy skiff
#

No bru i mean

#

What language r u using

hot violet
#

english

lusty quest
#

coding lang

icy skiff
#

K u mest be memeing

earnest phoenix
#

they aren't

#

they are using another bot

#

lol

hot violet
#

im not using any coding

icy skiff
#

U r using one of those softwares?

#

That makes a bot for u?

hot violet
#

no the BOtify bot

earnest phoenix
#

go complain to the bot developer, this is not a support channel for bots

hot violet
#

they told me to come here

icy skiff
#

Bro

#

This channel is for development support

signal summit
#

@earnest phoenix I did hosted by discord bot in the same manner using flask server and uptime robot. Though it wasn't as smooth as expected and free repl server unexpectedly reboots itself every often in a one day. It was fine enough to host if the problems you face doesnt matter to you.

Yeah i dont mind hacker plan free or not, I just want to know if Hacker plan repls truly stays uptime 24/7.

hot violet
#

sorry

earnest phoenix
#

that pricing is such a scam lol

#

you can probably find a provider with the same specs for 3 or 4 bucks cheaper

#

i.e. scaleway

earnest phoenix
signal summit
#

oh okay then

signal summit
earnest phoenix
#

yes

jovial nexus
#

is posible to read the attachment file without downloading it localy?

earnest phoenix
#

download it to your memory

restive furnace
#

✨ buffers ✨ (on js)

earnest phoenix
#

ok

jovial nexus
#

can you explain how?

earnest phoenix
#

5083 devs ?

#

omg

earnest phoenix
jovial nexus
#

js

#

djs

earnest phoenix
#

you can use node-fetch

jovial nexus
#

so ```js
fetch(attachment)
.then(res => res.buffer())

#

?

earnest phoenix
#

you need to fetch the attachment url but yes

jovial nexus
#

and then how do i read it?

earnest phoenix
#

like you would any other buffer

severe cedar
#

So i am making a join command but whenever I do bw.join then specify a channel it doesn't work. Any ideas why?

@client.command()
async def join(ctx, channel):
    voiceChannel = discord.utils.get(ctx.guild.voice_channels, name=channel)
    voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
    await voiceChannel.connect()```
and is there anyway i can like
make it so it connects to the channel I am in?
This is in discord.py
scenic shale
#

hello, i'm new to bot development ... how can i add my bot to the top.gg list?

signal summit
pale vessel
signal summit
earnest phoenix
#

Hey i have a problem with a bot , i cant vote im log in top.gg but i dont see the vote section

icy skiff
#

Of course you need to handle in case the user is not in any vc

earnest phoenix
icy skiff
#

First, think that's a matter for #support, not development

earnest phoenix
#

Ok thanks

eternal osprey
#

holy shit!
I just got a message that i had to start a discord verification process. Does it require a picture of my id/passport? The problem is, i am under 18 (currently 17 years old). Will that be an issue?

icy skiff
#

Congrats on the 75 servers mark

#

And I don't know about the underage thing, sorry

#

But i don't think It's mandatory to be over 18

severe cedar
#

wait nvm

#

i thought you said it is mandatory

icy skiff
#

kek

#

Discord said my bot was sus and now i have to wait to get it verified
pandasad

tawdry oracle
#

i need to dowload an attachment and then read it without storing it localy, someone knows?

dusky sundial
severe cedar
#

what is PyNacl

#

it says i need it to connect to a voice channel for my bot

quartz kindle
tawdry oracle
#

i need to Dowload the file ( but not localy ) -> Read the content and check if its valid -> Store it on a DB

quartz kindle
#

what type of file is it?

tawdry oracle
#

i have all already done but storing the file localy, and i cant do that

#

its a js file

dusky sundial
quartz kindle
#

which library are you using for downloading?

tawdry oracle
#

i was downloading it with ```js
request.get(url)
.on('error', console.error)
.pipe(fs.createWriteStream(./rawConfigs/${message.guild.id}.js));

quartz kindle
#

the request library?

tawdry oracle
#

yep

#

let request = require(request);

quartz kindle
#

that library hasnt been updated in 2 years and is currently abandoned, so i'd suggest using a different one

young flame
#

@quartz kindle edited the lib

quartz kindle
#

anyway if you dont want to, its possible to still do it on it

young flame
#

i forgot to add events so its been running off fucking functions the whole time

tawdry oracle
#

how?

#

and what library do you recomend me to use?

young flame
#

node-fetch

#

for https request

#

or node-superfeth

#

fetch*

dusky sundial
quartz kindle
#

popular libraries include: node-fetch, got, axios, superfetch, bent, undici, and many more

severe cedar
eternal osprey
#

hey tim, i changed the image but it still doesn't work?

severe cedar
#

and i'm done?

eternal osprey
#

It still doesn't show the background

young flame
#

what are you using to display it?

tawdry oracle
#

hmm, and how do i donwload a file not localy and then read it with node fetch??

dusky sundial
severe cedar
#

ok

young flame
#

there request npms

#

if your downloading it you should use a file reader

tawdry oracle
#

i cant modify my vps and i need to dowload and read the file without it being stored localy

young flame
#

well

quartz kindle
#

instead of creating file streams, read the response as a buffer or as text

#

all libraries can do that

#

example from node-fetch

icy skiff
#

In cmd

severe cedar
#

yeah i fixed it

#

thanks doe

slender thistle
#

wait fuck

#

FUCK

#

I'm a moron LMFAO

#

You familiar with how hex numbers are in ASM?

#

That was the answer here, hex number

lusty quest
#

gg

sudden olive
#

Hello

#

How can i add

#

The Code of Join message in my bot

#

From Javascript

scenic shale
slender thistle
tulip ledge
#

I'm gettin g this error after I took my bot from my VPS since I switched PC's I did "npm install" and now i get this error:

quartz kindle
#

did you copy the node_modules folder?

tulip ledge
#

no

#

I did npm install

quartz kindle
#

do npm rebuild

feral aspen
#
            const response = [
                `**Output:** \`\`\`js\n${this.clean(inspect(evaled, { depth: 0 }))}\n\`\`\``,
                `**Type:** \`\`\`ts\n${new Type(evaled).is}\n\`\`\``,
                `**Time Taken:** \`\`\`${(((stop[0] * 1e9) + stop[1])) / 1e6}ms \`\`\``
            ];

(node:3768) UnhandledPromiseRejectionWarning: TypeError: this.clean is not a function

tulip ledge
quartz kindle
sudden olive
#

Pls

#

Tell

#

How can i add join message

#

With javascript coding

tulip ledge
young flame
#

is it like

#
this.clean = string/function
quartz kindle
young flame
#

?

sudden olive
#

No one help me sadJAM

tulip ledge
quartz kindle
#

sigh...

young flame
#

you sent it twice

quartz kindle
#

then do npm i -g node-pre-gyp

sudden olive
#

i am ignored

young flame
#

bro

quartz kindle
tulip ledge
#

yup working now

sudden olive
quartz kindle
#

library, not language

#

what do you require()

feral aspen
#

This one errors.

sudden olive
#

iam creating from starting

young flame
feral aspen
smoky thorn
#

Oop

quartz kindle
opal plank
#

im amazed luca didnt yoink that

young flame
#

like this ```js
this.client = require('./settings.json')

smoky thorn
#

I didn't mean to post my invite

#

Lol

young flame
#

thats an identified

smoky thorn
#

Hol up lemme fix that

young flame
#

identifier*

opal plank
#

huh?

#

identifier?

quartz kindle
quartz kindle
#

what is this.clean?

feral aspen
young flame
#

lol

young flame
#

thats where i get it from

#

you use this clean

#

i was showing an example of what to look for

quartz kindle
#

where did you create the clean function?

young flame
smoky thorn
#
async def invite(ctx):
    await ctx.message.delete()
    url = url.request("*link*")```

and getting the error of


  ```File "C:\Users\beast\Desktop\Windex.py", line 111, in invite
    url = url.request("*insert my website here*")
UnboundLocalError: local variable 'url' referenced before assignment

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\beast\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 902, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\beast\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 864, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\beast\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: UnboundLocalError: local variable 'url' referenced before assignment
#

How do I make it like

#

open the url

opal plank
#

@slender thistle WE GOT A PY USER

smoky thorn
#

or an api thing

#

I want it to do a btc api

quartz kindle
smoky thorn
#

you say "//btc" then it sends the btc price

#

ik that Idk how to define it

#

lol

quartz kindle
#

you cannot do a = a.b because a doesnt exist

smoky thorn
#

True true

quartz kindle
#

you have to do a = something else, not a

feral aspen
modest maple
#

If you don't know how to then you probably shouldnt be doing d.py

quartz kindle
smoky thorn
feral aspen
opal plank
#

ah

#

that clean

quartz kindle
#

well the tutorial probably did

#

and you skipped it

#

clean is not a built-in function

smoky thorn
#

Mans got hacked then someone made "clean" as a function to fuck his code up

opal plank
#

clean is this tim

#

i only seen clean being brought up in an eval twice

feral aspen
#

Yes, that.

opal plank
#

this is probably what it is

young flame
#

oh

quartz kindle
#

why type it as any if it can only be used for text?

opal plank
#

shhh

young flame
#

oh

#

i just noticed that

opal plank
#

old code

#

ssssshhh

young flame
#

dw erwin

smoky thorn
#

So how do I make an API request for it, Idk the code for it

young flame
#

your still my number 1 for simping

feral aspen
opal plank
#

eeeey les go

#

i dont even know what error u getting

outer perch
young flame
#

this clean is not defined

#

lol

opal plank
#

postgres and redis

#

the rest is shit

outer perch
#

😮

opal plank
#

define clean then

feral aspen
#

(node:1360) UnhandledPromiseRejectionWarning: TypeError: this.clean is not a function

young flame
#

told you

opal plank
#
clean(text: string) {
    if (typeof text === 'string')
      return text.replace(/`/g, '`' + String.fromCharCode(8203)).replace(/@/g, '@' + String.fromCharCode(8203));
    else return text;
  }```
#

there

#

spoonfed

young flame
#

erwin bad

opal plank
#

lul

slender thistle
young flame
opal plank
#

its the same from the guide they were supposedly copying from

#

they just skipped it

#

also was in the pic i sent, was only gonna make them manually copy it

feral aspen
#
    clean(text) {
        if(typeof text === 'string') {
            text = text
                .replace(/`/g, `\`${String.fromCharCode(8203)}`)
                .replace(/@/g, `@${String.fromCharCode(8203)}`)
        }
        return text;
    }
``` It's like this..
smoky thorn
feral aspen
#

I didn't skip it.

opal plank
#

though now that i think about it, that make sure they understood what it does

#

where did you put that in then?

slender thistle
#

API requests are HTTP requests

smoky thorn
#

Ohhh

feral aspen
#

Outside the run function

smoky thorn
#

Shhh I'm retarded lol

opal plank
#

then you cannot use this. on it

#

this. refers to the object its inside of

slender thistle
#

No problem

opal plank
#

(it doesnt, but its easier to explain this way)

feral aspen
#

Oh, then what can I use instead?

opal plank
#

just define the function and call it inside

#

you CAN call stuff from outseife the module.export

#

or whatever

#

as long as they are in the same file

#

just dont use ``this` keyword unless you are in an object

#

(again, doesnt work like that, but for the sake of explaining, im referring to it as that)

#

in your case, it does work like that, but this is a very confusing thing to get a hold of

#

basically

feral aspen
opal plank
#
function a() {}


function b() {
 a();
}
#

this is valid

#

they are in the same file

modest maple
#

Js scopes r v weird in places

opal plank
#
module.exports = {
 a:() => {};
 b:() => {
  this.a()
}

}
``` this is valid
#

this refers to the module exports in this case

#

this is very confusing, i'd avoid using it if i were you

#

you basically DONT use this

#

you call the function as is

#

like you would normally

gray barn
#

Why i cant login for vote ?

feral aspen
#
const { MessageEmbed, MessageAttachment } = require("discord.js");
const { red, cyan } = require("../../other/colors.json");
const { Type } = require("@extreme_hero/deeptype");

module.exports = {
    config: {
        name: "eval",
        aliases: ['ev'],
        usage: "!eval",
        category: "owner",
        description: "Evalues a command!",
        noalias: "No Aliases",
        accessableby: "Attitude Developers"
    },
    run: async (bot, message, args) => {

        // My code here...
    },
    clean(text) {
        if(typeof text === 'string') {
            text = text
                .replace(/`/g, `\`${String.fromCharCode(8203)}`)
                .replace(/@/g, `@${String.fromCharCode(8203)}`)
                .replace(new RegExp(process.env.TOKEN, 'gi'), '****')
        }
        return text;
    }
};

Ok, I did it like that, so?

feral aspen
modest maple
opal plank
#

change clean() to clean: () => {}

#

then call it with this.clean

feral aspen
#

Ok.

opal plank
#

in your case using this is valid

#

otherwise

#
const { MessageEmbed, MessageAttachment } = require("discord.js");
const { red, cyan } = require("../../other/colors.json");
const { Type } = require("@extreme_hero/deeptype");
function clean(text) {
        if(typeof text === 'string') {
            text = text
                .replace(/`/g, `\`${String.fromCharCode(8203)}`)
                .replace(/@/g, `@${String.fromCharCode(8203)}`)
                .replace(new RegExp(process.env.TOKEN, 'gi'), '****')
        }
        return text;
    }
module.exports = {
    config: {
        name: "eval",
        aliases: ['ev'],
        usage: "!eval",
        category: "owner",
        description: "Evalues a command!",
        noalias: "No Aliases",
        accessableby: "Attitude Developers"
    },
    run: async (bot, message, args) => {
      clean()
        // My code here...
    },
   
};
#

this is also valid

#

PS: too lazy to go format that, deal with it

feral aspen
#

K!

tawdry oracle
#

hey @quartz kindle are you here?

young flame
#

js seems weird now

#

also

#

@opal plank making a pog lib

opal plank
#

am i?

young flame
#

no me

#

lol

opal plank
#

what does it do

feral aspen
young flame
#

it's really useless

feral aspen
#

this.clean is not a function

opal plank
young flame
#

or maybe the other way arounD

opal plank
#

yes, thats what eval() from utils is for

young flame
#

well

opal plank
#

or require()

young flame
#

not you dont need another file

opal plank
#

then eval

#

but continue

young flame
#

with discord-jts you get all of ts in js and js in ts

#

very pog

opal plank
#

then you didnt save it

feral aspen
#

The error is this.

Discord.Boats, successfully posted your server count.
(node:10824) UnhandledPromiseRejectionWarning: TypeError: this.clean is not a function
    at Object.run (C:\Users\hajji\Desktop\Attitude Database\src\commands\owner\eval.js:61:66)
    at module.exports (C:\Users\hajji\Desktop\Attitude Database\src\events\guild\message.js:35:33)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:10824) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:10824) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Basically meaning that this is erroring

        } catch (err) {
            return message.channel.send(`Error: \`\`\`xl\n${this.clean(err)}\n\`\`\``);
        }
young flame
#

it also has a chance to fail 30% of the time due to mixing good lib with shitty one

opal plank
#

this.clean is not a function

#

guess what?

#

in the code i sent you

#

there no this.clean

young flame
#

lol

cinder patio
opal plank
#

so whatever you did, its on you

young flame
#

i told them what was wrong

feral aspen
#

🤦‍♂️

young flame
#

lmfao

young flame
#

i said

#

there is no this.clean

#

unless you add a this.clean and put your clean behind it then they said

#

"what"

opal plank
#

i explained BOTH so they would understand both methods

young flame
#

i even sent a damn example

opal plank
#

both would work, not mixed

young flame
#

this clean = clean()

young flame
#

they said and i quote

young flame
#

"no"

feral aspen
#

Do I remove this. from all the codes?

#

Or just the part that is erroring?

opal plank
#

we said it 5 times by now

#

check chat

quartz kindle
#

if you dont understand what this means, dont use it

opal plank
#

we're just repeating ourselves by this point

feral aspen
#

This is what I am trying to do, I am trying to remove all the this from all the code.

#

One second.

#
            const response = [
                `**Output:** \`\`\`js\n${this.clean(inspect(evaled, { depth: 0 }))}\n\`\`\``,
                `**Type:** \`\`\`ts\n${new Type(evaled).is}\n\`\`\``,
                `**Time Taken:** \`\`\`${(((stop[0] * 1e9) + stop[1])) / 1e6}ms \`\`\``
            ];

I also have this this.

#

Should I remove it as well?

cinder patio
#

You should read up on this and decide for yourself

modest maple
#

this.is.not.how.that.works

#

Valid js btw

tulip ledge
#
To https://github.com/ChickenDevv/MMBot.git
 ! [rejected]        main -> main (fetch first)
error: failed to push some refs to 'https://github.com/ChickenDevv/MMBot.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

What do I do here?

#

I did git push origin main

modest maple
#

It tells you

tulip ledge
#

but I dont wanna pull

modest maple
#

Then you cant push

#

This is the whole point of version control

#

So shit cant get mixed and overriden

quartz kindle
#
String.prototype.this = { is: { not: { how: { that: { works: false } } } } }
cinder patio
#
Object.defineProperty(this, "is", {value: {not: { how: { it: { works: false } } } }});
this.is.not.how.it.works;
#

this.is = {not: { how: { it: { works: false } } } }; also works

young flame
#

^^^

#

also

#

this.is = { also: { not: { how: { it: { works: flase } } } };

old cliff
#

no memes in dev

#

but is this a meme ?>

young flame
#

this is not a meme

#

it's a culture

severe cedar
#

I am back and i have another question. So whenever i wanna play a song with this code it doesn't work and gives the error TypeError: 'NoneType' object is not subscriptable. Can someone help me fix this??

@bot.command()
async def play(ctx, *, url):
    player = music.get_player(guild_id=ctx.guild.id)
    if not player:
        player = music.create_player(ctx, ffmpeg_error_betterfix=True)
    if not ctx.voice_client.is_playing():
        await player.queue(url, search=True)
        song = await player.play()
        await ctx.send(f"Playing {song.name}")
    else:
        song = await player.queue(url, search=True)
        await ctx.send(f"Queued {song.name}")```
icy skiff
#

does it show which line the error ocurred?

severe cedar
#

await player.queue(url, search=True)

#

there

icy skiff
#

can u do a favor and write print(player) right before that line

#

and send here what it returns

severe cedar
#

ok

icy skiff
#

so?

severe cedar
icy skiff
#

ye thats about right

#

ur music.get_player is not finding the guild by id

severe cedar
#

same error for some reason

#

hm.

icy skiff
#
if not (voice and voice.is_connected()):
                voice = await channel.connect()
            if not (voice.is_playing() or voice.is_paused()):
                try:
                    voice.play(discord.FFmpegPCMAudio(queues[guild_id][0][1], **FFMPEG_OPTIONS),
                        after=lambda e: self.play_next(ctx, guild_id))
                    while voice.is_playing() or voice.is_paused():
                        await asyncio.sleep(5)
                    await voice.disconnect()
                except discord.errors.ClientException:
                    pass
#

this is my functioning play command

severe cedar
#

ok lemme try it i guess

#

woah

#

those indents doe

#

are the indents correct?

icy skiff
#

no

#

kek

#

just a sec

#

this is the proper indent

#

cause i couldnt fix it on discord formatting lol

#

oh btw

#

voice = discord.utils.get(self.client.voice_clients, guild=ctx.guild)

severe cedar
#

ok

severe cedar
#

this is a regular file

icy skiff
#

just remove the "self."

#

but i strongly recommend doing commands on cogs

severe cedar
#

this is my beta version of my bot

#

the actual bot itself uses cogs

icy skiff
#

oh ok i c

#

just remove the self. then

#

all "self."s

severe cedar
#

ok so there are a lot of red lines

#

pretty much everything is undefined

icy skiff
#

some variables u will need to replace by your own code's context

#

u need to download ffmpeg with pip as well, i forgot about that

#

and there's also this that i also forgot

#
FFMPEG_OPTIONS = {
    'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5',
    'options': '-vn'
}
severe cedar
#

ah-

icy skiff
#

and i also forgot this:

#
    def play_next(self, ctx, gid):
        """
        Plays next song when current finishes.
        """
        voice = discord.utils.get(self.client.voice_clients, guild=ctx.guild)

        if len(queues[gid]) > 1:
            del queues[gid][0]

            try:
                voice.play(discord.FFmpegPCMAudio(queues[gid][0][1], **FFMPEG_OPTIONS),
                    after=lambda e: self.play_next(ctx, gid))
                voice.is_playing()
            except AttributeError:
                pass
        else:
            del queues[gid]
#

damn i forgot a lot of things

severe cedar
#

y-y

#

my smol brain can't comprehend

icy skiff
#

kek

#

dw i spent literally days to code my Music Cog

#

to end up not using it

#

lol

severe cedar
#

lol

icy skiff
#

bro

#

uh

#

just a sec

#

ok so

icy skiff
icy skiff
icy skiff
#

just be sure to remove all "self." and change the variables that u r using with different names

#

also, the queues variable im using is for the bot being able to play on multiple servers without one interrupting others, its a dictionary

tulip ledge
#

so

young flame
#

how do you make a new command in js

#

KEK i forgot

tulip ledge
#

I'm making this API with express to communicate between 2 files but i get this error: Only absolute URLs are supported

fetch(`127.0.0.1/users/259776081316282368`)
.then(response => response.json())
.then(data => {
  console.log(data.uuid);
})
#

how would I fix this?

young flame
#

why are you looking for url's

young flame
#

i was gonna say that after

#

but it said 2 files

#

so

tulip ledge
#

FetchError: request to https://127.0.0.1/users/259776081316282368 failed, reason: connect ECONNREFUSED 127.0.0.1:443

young flame
tulip ledge
#

is it not up yet?

cinder patio
#

try http://

tulip ledge
#

same error

young flame
#

if that doesnt work its your port

tulip ledge
#

no it definitly works in the browser

young flame
#

might be a closed port or something

#

td;lr

tulip ledge
young flame
#

where did you even get the port

#

atually

tulip ledge
#

ah nvm

#

i'm stupid

young flame
#

atually*

tulip ledge
#

I forgot the port

young flame
#

bruhg

tulip ledge
#

now it works

young flame
#

finally

#

still how do you make a commmand in js again

crimson vapor
#

whats your command handler?

#

kekw

young flame
#

no cmd handler

#

thats for weirdos

crimson vapor
#

do you need one?

young flame
#

no

#

lol

crimson vapor
#

so like

young flame
#

i just forgot how to make one

crimson vapor
#

how do you plan to get commands

young flame
#

bruh

#

the normal way

crimson vapor
#

so a command handler KEKW

young flame
#

you dont need a cmd handler for commands lol

crimson vapor
#

the normal way

young flame
#

yes

crimson vapor
#

idk many bots which don't use a command handler

young flame
#

why would you even use a cmd handler in the first place

#

bro

mellow kelp
#

why should you not

young flame
#

im not talking about cmd handlers

crimson vapor
#

so you don't have to repeat 100 lines of code

#

every

#

single

#

command

mellow kelp
#

a command handler lets you dynamically create commands without having to check every single time for the prefix

young flame
#

how the hell do i make a damn command

mellow kelp
#

that's up to you

young flame
#

H

mellow kelp
#

it can be as simple as an object

crimson vapor
#

depends on how you do you comand handler

young flame
#

😔

#

bro

crimson vapor
#
import { CommandOptions } from 'discord-rose/dist/typings/lib';

export default {
  name: 'Berry',
  usage: 'stinky',
  description: 'Berry is stinky.',
  category: 'misc',
  command: 'stinky',
  permissions: [],
  botPermissions: [],
  owner: false,
  exec: async (ctx) => {
    ctx.reply(`@slim heart`);
  }
} as CommandOptions;
#

my commands

young flame
#

idgaf about cmd hanlders rn

#

H now i can't type

mellow kelp
#
const helloCommand = {
  name: 'hello',
  description: 'Says hello dumbass',
  async execute(message, args)  {
    await message.channel.send('Hello');
  }
}
#

this is a basic example

young flame
#

bro

#

im never gonna use a cmd handler ok

mellow kelp
#

wait you're moon

crimson vapor
#

I don't understand

mellow kelp
#

understandable have a nice day

young flame
#

^^

#

elcholo understands why

#

lol

crimson vapor
#

explain wtf

mellow kelp
#

not that i understand

young flame
#

no

mellow kelp
#

but i tried convincing them long ago

crimson vapor
#

I swear

young flame
#

im just

#

no

slender thistle
#

Do you use the message event directly for commands

crimson vapor
#

wtf cringe

young flame
#

well

#

eH

#

not really

mellow kelp
#

this guy makes the whole bot in a single giant index.js

young flame
#

actually

crimson vapor
#

you do permissions checks on each command?

crimson vapor
#

all I gotta do is perms: []

#

so a command handler

icy skiff
young flame
#

i d c

mellow kelp
#

lmfao

young flame
#

bro

#

just answer my question

crimson vapor
#

ok well comand handlers basically just call a shit load of find functions then run the shit

young flame
#

i already know how a cmd handler works

crimson vapor
#

so do a giant switch/case

young flame
#

million.

crimson vapor
#

ezpz

young flame
#

Million

mellow kelp
#

in having yandere dev flashbacks

young flame
#

do you know

#

or not

mellow kelp
#

is moon secretly yandere dev

young flame
#

H

crimson vapor
#

you said you weren't using command handlers

young flame
#

:painsive:

icy skiff
#

Wait

crimson vapor
#

so just switch/case the commands and do shit in index

young flame
#

how

#

if i forgot

#

hwo to make

icy skiff
#

Is this what u want:

young flame
#

a command