#development

1 messages · Page 1855 of 1

green kestrel
#

thats some of lugaru

raw gust
#

If I use the mute command or it is reported as lacking permissions, is there a way to check the bot's permissions with the rights of the person who is muted?

latent heron
#

that's not bad source code

green kestrel
#

it is 😄

latent heron
#

that's an atrocity of mankind and programmers alike

#

there's a difference

green kestrel
#

its completely unmaintainable, unreadable

latent heron
#

one of them has a basic level of being distinguishable

#

the other one is what i would see my sleep paralysis demon write

#

and that is the latter

green kestrel
#

go read this lol

#

i mean thats one of many 10,000 line source files LUL

#

but the entire game logic, its models, its animations, everything is hard coded into the games C++ code 😄

cinder patio
#

typical for old games

latent heron
#

oh my god

#

it's so mortifying and bad

boreal iron
#

Looks like a lot of tabs lmao

earnest phoenix
#

how do I fix this repl process died unexpectedly: signal: killed

vivid fulcrum
#

you're running out of memory

earnest phoenix
#

I deleted all my repls

latent heron
#

you know it's bound to be bad when your RAM usage flies up to 90% with it open lmao

earnest phoenix
#

I only have one repl running and still it says that

#

I don't get it

#

wym

vivid fulcrum
#

rent a proper vps 🤷‍♂️

green kestrel
#

that one repl is too much memory

#

or there are too many other beginners using repl

earnest phoenix
#

well I will but for now what do I do

vivid fulcrum
#

optimize your bot's ram usage

earnest phoenix
#

how do I do that

vivid fulcrum
#

🤷‍♂️

#

don't cache unnecessary things

earnest phoenix
#

well

vivid fulcrum
#

and don't use node mmLol

earnest phoenix
#

I'm using py

green kestrel
#

"i cant get food in my mouth"
"use a fork"
"how do i do that"

this is as much a silly question as "how do i optimise my code" - you tell us, your code!

earnest phoenix
#

bruh I mean I don't even understand what you mean by "optimize your bot's ram usage" here

green kestrel
#

make it use less memory

boreal iron
#

How much RAM do you even have?

earnest phoenix
#

8 Gb

boreal iron
#

Brain is still alive. Haven’t seen you for a while.
Hmm haven’t seen Erwin, too for a while now

vivid fulcrum
boreal iron
#

Would be funny if he repeats that

vivid fulcrum
#

assuming they're using repl free plan

#

they have 500mb

green kestrel
#

its repl

boreal iron
#

Oh for free nvm then

green kestrel
#

its like complaining theres no space in your home, but then you find out youre on the 'home free plan', which is a small wooden box on a street

#

@earnest phoenix turn off any and all caching, wherever you can. sorry, cant tell you how, as i dont do python

green kestrel
#

hey there @boreal iron 😄

boreal iron
#

Dumped up?

#

Hello 👋

near stratus
earnest phoenix
earnest phoenix
green kestrel
#

we're preparing to move home, so discord has been lower down the priorities, just keeping triviabot ticking over really till im settled in new place. its got a literal man cave!

#

17080s cellar with sandstone walls!

boreal iron
#

Sounds poetic

green kestrel
#

dunno how im gonna even get cat6 down there mind

#

or power lol

boreal iron
#

God thanks I have placed cat 6 cables into each wAll when I was renovating my house and garage

#

As well as sat cables and others
Found out later I was a genius doing that earlier

boreal iron
near grotto
shrewd hazel
slender thistle
midnight oriole
#

i have a simple python script that draws text n stuff using pillow

#

but the text gets kinda weird if i run it on windows

#

like this for example

#

i think the text gets a bit wider and there is a 12px y offset whenever i draw one

#

can anyone help me if they have an idea

slender thistle
#

I wonder if it has to do with DPI

#

Or API calls

low bone
#

Something like that

let maxSymbols=15
let bar="emoji1".repeat(maxSymbols).split('').map((v,i)=>i==Math.trunc((playedTime/duration)*maxSymbols)?"emoji2":v).join('')

Replace emoji one and emoji two
And try
Sry I'm on phone so can't code long one
playedTime and duration should be replaced with your variables

worthy ivy
low bone
#

Yeah

#

It will be string

worthy ivy
#

so like

low bone
#

Put it anywhere you want

worthy ivy
#

.addField() the bar variable right?

low bone
#

Yeah or in description

worthy ivy
#

i see

#

thanks!

low bone
#

or even footer

worthy ivy
#

ill just check what on earth every function does

#

btw

#

should it be in like

#

a specific time?

low bone
#

There's another version but I can't write it since I'm on mobile

worthy ivy
#

not formatted tohh:mm:ss

low bone
#

playedTime and duration should have same unit

#

Seconds or minutes

#

And be number not text like 55:44

earnest phoenix
#

you do realize they spoonfeeded you

worthy ivy
#

but i will be still learning on how it works

midnight oriole
brave garnet
#

can i have a fast question here very NOT related to bots? but about development =p

vivid fulcrum
#

yes

brave garnet
#

someone know how to install apple configurator ON LINUX ? wine i have broken btw

#

👀

#

•_• noone? ;-;

green kestrel
green kestrel
brave garnet
green kestrel
#

sounds hacky lol

earnest phoenix
#

Use brainfuck

#

I've said my peace thanks for coming to my tex talk

green kestrel
#

you mean ted talk

#

or is it in texas

earnest phoenix
#

No it's tex talk

#

Budget cuts had to change our name

brave garnet
# green kestrel sounds hacky lol

a little. but app is generally legal. nothing else except wine for linux? or something to install macos appstore app under this linux?

green kestrel
#

no

brave garnet
#

;-;

#

or other linux version?

cinder patio
#

broken wine?

green kestrel
#

you cant run an osx app under linux, unless its made to run in linux and you have source code to rebuild it

high crown
#

what to do with it.....I'm completely clue less

brave garnet
# cinder patio broken wine?

i installed dotnet 40 but when i try to install dis shit it throws that i dont have service pack of dotnet 3.5

earnest phoenix
#

Dotnet 40?

brave garnet
#

so i just have it broken

#

yep

green kestrel
#

dotnet 4 doesnt replace 3.5

brave garnet
#

prefix both 32 and 64

green kestrel
#

they all install alongside each other

#

you can have dotnet 1, 2, 3, 3.5, 4 and 4.5

brave garnet
#

yep

green kestrel
#

iirc

brave garnet
#

but shouldnt 4.0 install also previous versions?

green kestrel
#

no

brave garnet
#

?!

#

wut?

green kestrel
#

theyre like versions of java

#

having one doesnt imply you need the ones before it

vivid fulcrum
#

the same way windows 10 doesn't install previous versions of windows

brave garnet
#

god. pls no JAVA !!!!!

vivid fulcrum
#

it doesn't make sense

quartz kindle
#

theres already dotnet 5 and 6 lol

brave garnet
#

this ik also

high crown
vivid fulcrum
#

.net framework is different from .net core which is different from dotnet

earnest phoenix
brave garnet
#

dotnet. and service pack 1

green kestrel
brave garnet
#

from 3.5

high crown
#

can anyone help me?

#

please

vivid fulcrum
green kestrel
#

as far as we know

brave garnet
#

all windoz is dos based?

vivid fulcrum
#

no

brave garnet
#

all versions. even 11

green kestrel
#

havent you found that bit of code that hides the dos stuff kek_laugh

vivid fulcrum
#

from windows xp and beyond it no longer runs on dos

high crown
#

can't you read my messages?

#

hello?

green kestrel
#

windows NT and windows 2000 didnt have dos either

#

the command prompt is not DOS

brave garnet
#

SO HOW FCKIN CMD WORKS ?!

vivid fulcrum
#

you have a misconception

green kestrel
#

command promot is just uh... a command prompt 😄

vivid fulcrum
#

dos is a kernel

earnest phoenix
#

Magic

brave garnet
#

yep. same as unix and linux :/

green kestrel
#

wanna see something funny?

brave garnet
#

unix - kernel , linux - system 😂

#

dos - kernel , windoz - system

#

now u know?

green kestrel
#

this is a hex edit of cmd.exe

near grotto
earnest phoenix
slender thistle
#

Br9

#

Bto

#

Bro

brave garnet
slender thistle
#

If something required is missing

#

What do we do?

near grotto
#

get it

quartz kindle
#

lol

near grotto
#

but how to get that?

#

idk wtf is it

green kestrel
#

send the intents you need

quartz kindle
#

which library are you using?

near grotto
#

djs

quartz kindle
#

which version?

near grotto
#

latest

quartz kindle
#

which is?

near grotto
#

lemme see

high crown
near grotto
#

v13

quartz kindle
# high crown Need help

The HyperText Transfer Protocol (HTTP) 410 Gone client error response code indicates that access to the target resource is no longer available at the origin server and that this condition is likely to be permanent.

quartz kindle
near grotto
#

where?

quartz kindle
#

where you create the client

high crown
quartz kindle
#

new Client()

near grotto
#

can u gimme an example code?

quartz kindle
quartz kindle
#

intents are required in v13

near grotto
#

like where and how to require intents

high crown
quartz kindle
near grotto
#

ok

high crown
quartz kindle
#

no lol

high crown
quartz kindle
#

that code is not for v13, thats old code

quartz kindle
#

doesnt mean he did

high crown
near grotto
#

what code should I write then?

quartz kindle
near grotto
#

ok

quartz kindle
near grotto
#

thx

earnest phoenix
#

Do they really make you do that long ass definition of intents now

#

Or can you still just use strings to define the intents

quartz kindle
#

you can still use array of strings

#

or the entire bitfield and a number

earnest phoenix
#

Oh thank God

earnest phoenix
high crown
#

can't we simply write
const { CommandoClient } = require('discord.js-commando');

#

isn't that ez?

earnest phoenix
#

If you're using commando ig

high crown
#

or I'm stupid

high crown
#

I use commando

lone creek
#

Any help

earnest phoenix
#

You can destructrue yes

quartz kindle
earnest phoenix
#

Okay

#

I understand it completely now

#

I assume that number represents the intents bitfields added up?

quartz kindle
#

ye

earnest phoenix
#

Makes sense

#

I'ma do it that way from now on so no one understands my code

near grotto
#

it's still showing that fuckin error

quartz kindle
#

show code

high crown
#

hey hey

#

u know what

near grotto
earnest phoenix
#

Hey Tim how's your raw lib coming along?

high crown
#

that error vanished when i restared the code

quartz kindle
#

so add it

near grotto
#

how?

earnest phoenix
#

Bro

quartz kindle
#

you added GUILDS

near grotto
#

ohh

#

yes

quartz kindle
#

add more

#

you can add as many as you want

#

its an array

#

separated by comas

high crown
#

[a, b, c] like that

near grotto
#

it works @quartz kindle thank you 👍

earnest phoenix
#

Just note the guild members and presence intent requires it to be enabled in the dev portal

rigid maple
#

no matter what i do it looks like this

high crown
#

its blur on my pc

quartz kindle
earnest phoenix
quartz kindle
#

decisions decisions

#

the best memory efficiency is achieved with arrays

#

but then you cant access caches by id

high crown
#

hey u can't leave space when you are using let

quartz kindle
#

and thats kinda needed in most cases

earnest phoenix
#

Can't you take a page out of djs books

high crown
#

print it out

#

lmao

rigid maple
# rigid maple

Hey Tim, if you remember I solved this problem because of you. but now i faced a problem like this

earnest phoenix
#

Or just use djs collections

#

Or is that not what you mean by caching

quartz kindle
#

you have to change the height to be equal as well

#

the height is still 30

rigid maple
#

wow

#

worked

#

thanks

quartz kindle
#

its how you put everything together

earnest phoenix
#

Ah I see

quartz kindle
#

for example djs puts channels both outside and inside guilds

#

and uses a lot of nested collections

#

guilds have a collection of channels, which have a collection of messages, which have a collection of mentions, etc

#

that quickly ramps up to millions of instances of collections, which is extremely inefficient

steep reef
#

Hi I'm new discord user

quartz kindle
#

if you put things inside arrays instead of collections, for example a guild having an array of channels instead of a collection of channels

#

it would make a huge difference in memory usage

#

but then you lose access by id

#

you have to use array.find for everything, which wastes cpu

#

im trying to go for an intermediate solution inspired by sql tables

#

but theres a lot of work involved to keep the relationships together

near grotto
#

how to print 'hello world' in python

earnest phoenix
#

Did you really just ask that

quartz kindle
#

print("hello world")

#

lol

near grotto
#

jk lmao

earnest phoenix
#

Yea sure

pale vessel
#

"How do I console.log "hello world" in JS?"

earnest phoenix
#

Well Tim I hope you figure it out my brain not big enough to help

#

Lawl

lone creek
#

guys why i got this error every month lol

quartz kindle
#

i put it on hold for now, since its not that important

#

people can simply create their own caches anyway

earnest phoenix
#

Ew effort

quartz kindle
#

lel

earnest phoenix
#

I'd just use a map and call it a day

quartz kindle
#

i am using maps

#

and an extended map i call doublemap

earnest phoenix
#

Doublemap

#

It's a map with twice the power

quartz kindle
#

lel

#

its a map with 2 ids

#

for guildmembers for example

earnest phoenix
#

Wait wha

quartz kindle
#

members.get([guild_id, user_id])

earnest phoenix
#

Well okay that makes sense

#

Wait

#

Couldn't you just bind members to guild and neglect the need to provide a guild id yourself or?

quartz kindle
#

thats the issue

#

if you put a map inside a guild, or create a separate map for each guild, with 1000 guilds you have 1000 maps

earnest phoenix
#

Mmm true

quartz kindle
#

1 map for combined guild id and user id, plus an array of member ids inside guilds is more memory efficient

earnest phoenix
#

Yea

#

It's not a big deal really tbh

#

Providing the id yourself is nothing

quartz kindle
#

you can easily have methods on a guild object that does it for you if you want

earnest phoenix
#

True but I don't see the point

#

Alot easier just passing the guild id and user id yourself

high crown
#

hey

#

when I try to play a specific song on my music bot, it shows status code 410 and when I play other songs, it plays them well

near grotto
earnest phoenix
#

Hi all

near stratus
high crown
near grotto
#

how to fix?

earnest phoenix
#

I have a feeling this is copy pasta

high crown
#

it happended with me a lot of times

earnest phoenix
high crown
#

juts make a false file in your code, delete it, restart the website and again run the code

earnest phoenix
#

From v11

quartz kindle
near stratus
quartz kindle
#

lol

#

they say in their readme to use another repo

high crown
#

lol

quartz kindle
#

the other one seems to be up to date tho

high crown
quartz kindle
#

Androz2091/discord-music-bot

near stratus
quartz kindle
#

or effort

earnest phoenix
#

or knowledge

quartz kindle
#

or wisdom

earnest phoenix
#

Or tim

near stratus
#

they have Tim tho

quartz kindle
#

Lol

earnest phoenix
#

No

#

Tim is gone

#

Tim should have a special role with how much he's in development

#

Homie only has a little less than 20k messages outside of the dev channel

#

75k/93k

near stratus
#

@earnest phoenix there's a package.json code in #topgg-api check it

#

nvm removed

earnest phoenix
dense spire
#

can @slash.slash be put above/with @bot.command so that the command will be added to both slash and prefix commands.

#

this is for python

slender thistle
#

Try it

tawdry oracle
#

how can i split the message content to two messages when the content is too big?

#

automaticly

tulip ledge
#

split the string, then check the left if it exceeds a certain number slice it into equal chunks and put it all back together

tawdry oracle
#

how?

tulip ledge
#

I told you how

shrewd hazel
#

Broadcast bot

#

24H.

#

Insert lore innit

jovial nexus
#

How can i make a variable for each 5 objects inside an array

lyric mountain
#

you mean extract variables from object?

#

if so, let {a, b, c, d} = obj

jovial nexus
#

No, i have an array of, for example 70 strings, and i want to make a variable for each 5 of them containing the 5 strings

lyric mountain
#

like chunking?

jovial nexus
#

idk i guess

lyric mountain
#

for example, split 20 entities into 4 arrays of 5

#

this?

jovial nexus
#

YES

split hazel
#

very enthusiastic yes

lyric mountain
#

there's a way of doing it with reduce, but idk how it works exactly

#

the way I do is by iterating over the array and creating sub arrays

dense spire
#

Does anyone know where i can find the documentation of the line of code to recieve button responses? Or just a basic tutorial on buttons for python? The button documentation tells me how to make them but not what to do after sending them.

jovial nexus
#

i dont know how that the thing

lyric mountain
#

I can show how I do it, but it'll be java code

jovial nexus
#

i know a little bit of java, maybe i can transale it to ts, but first i need to know how its done

lyric mountain
#

actually

#
public static <T> List<List<T>> chunkify(List<T> list, int chunkSize) {
    int overflow = list.size() % chunkSize;
    List<List<T>> chunks = new ArrayList<>();

    for (int i = 0; i < (list.size() - overflow) / chunkSize; i++) {
        chunks.add(list.subList(i * chunkSize, (i * chunkSize) + chunkSize));
    }

    if (overflow > 0)
        chunks.add(list.subList(list.size() - overflow, list.size()));

    return chunks;
}
#

here, better

jovial nexus
#

thank you!

near stratus
# tawdry oracle how can i split the message content to two messages when the content is too big?
const limit = 1000
const texts = []
if(message.content.length <= limit){
  for(let a = 0; a < Math.celi(message.content.length / limit); a++){
    let tmp;
    if(a === 0){
      tmp = message.content.slice(0, limit)
    } else {
      tmp = message.content.slice((a*limit), (limit * (a + 1)))
    }
    texts.push(tmp)
  }
} else {
  texts.push(message.content)
}

There's a 420% chance this code won't work but still. It'll automatically create as many arrays needed

lyric mountain
#

but it's really just looping over the master array breaking into mini arrays

#

then creating a final array containing the leftover elements

signal estuary
#
if (!msg.guild.me.permissions.has("SEND_MESSAGES")) return

He still throws an error that he cant send messages

#

@modern sable

#

id 668861966147911700

lyric mountain
#

marco?

signal estuary
# lyric mountain marco?

idk he was on the top on the list and und that there were bots, so I thought there arent moderators on the server 🥴

#
if (!msg.channel.permissionsFor(msg.guild.me.permissions.has("SEND_MESSAGES"))) return

Now he always returns no matter if he has the permission or not

lyric mountain
#

I don't really know how to explain how wrong that is

#

but basically, remove msg.channel.permissionsFor

errant flax
#

how to calculate ram in nodejs

quartz kindle
#

lmao

quartz kindle
errant flax
#

thx

#

why is the number so big

quartz kindle
#

its in bytes

errant flax
#

how do i convert it into mega bytes?

quartz kindle
#

mb or mib?

#

1 mega byte is 1 million bytes, so just divide by 1 million

smoky kelp
#

Hi! I have an easy question (i think) about javascript:

// INPUT
let array = {};

array["color"].push("blue")
array["color"].push("red")

array["place"].push("italy")
array["place"].push("argentina")

console.log(array["color"])
console.log(array["place"])

// OUTPUT
["blue" , "red"]
["italy" , "argentina"]

I want to do this; use .push in an array but, in a specific argument. Can I do that?

PD: the code that I show you, doesnt work

lyric mountain
#

and yes, you can

#

howeber you need to instantiate the array before attempting to push else it'll fail

dense spire
#

Does anyone know how to use buttons well in python?

#

This is my loop for button detection but it simply says that "This interaction failed" when either of the buttons are pressed. I am not sure why.

while True:
    try:
      interaction = await wait_for_component(bot, components=action_row, timeout=30)

      if interaction.component.custom_id == "2":
        cur_index += 1
        if cur_index >= len(embedList):
          cur_index = 0
        await interaction.edit_origin(embed=embedList[cur_index])

      elif interaction.component.custom_id == "1":
        cur_index -= 1
        if cur_index < 0:
          cur_index = len(embedList)-1
        await interaction.edit_origin(embed=embedList[cur_index])
    except asyncio.TimeoutError:
        break
#

im not getting errors in my console for it either

lyric mountain
#

you need to acknowledge the interaction asap

#

and a loop? why?

dense spire
#

so the buttons stay active for the time frame and the users can press them as much as they want to navigate

earnest phoenix
dense spire
#

Im transfering over from using reactions

#

so I just kept it. Would there be a better way?

lyric mountain
#

buttons have their own event, just listen there

#

not even reactions required a loop to work

dense spire
#

but then how would i keep track of the index

round cove
#

Give them actual IDs lol

lyric mountain
#

store the pagination object somewhere so you can track its state

wanton flicker
#

how do you ping a role?

wary flame
#

<&id>

wanton flicker
#

oh ok

dense spire
#

then id have to store the data class to hold the max, min and index into a dict with the identifier being the actual pagination object :/
Also how would I allow for time out? So I don't have to permanently store the pagination objects and delete them upon a certain time frame of in-activeness and also remove the buttons while im at it.

#

the whole point of using the loop was so that I could infinitely have it whilst also allowing for timeout

round cove
tulip ledge
# jovial nexus YES
let array: number[] = [1, 2, 3, 4, 5, 6];
let chunk = 2;
let output: number[] = [];
for (let i = 0; i < array.length; i+=chunk) {
  output.push(array.slice(i, i+chunk));
}
console.log(output) // [ [1, 2], [3, 4], [5, 6] ]
#

Or with reduce:

let array: number[] = [1, 2, 3, 4, 5, 6];
let itemsPerChunk = 2;

let chunks = array.reduce((chunks: number[][], item: number, index: number) => {
  const chunk = Math.floor(index / chunk);
  chunks[chunk] = ([] as number[]).concat(chunks[chunk] || [], item);
  return chunks;
}, []);
console.log(chunks) // [ [1, 2], [3, 4], [5, 6] ]
#

Not 100% sure that last one works tho haven't tested it

lyric mountain
tulip ledge
#

There, now the reduce one should work

earnest phoenix
lyric mountain
#

that exists for pretty much any lang afaik

#

I use it on java

#

actually, every cache lib will have a self-expiring map

earnest phoenix
#

Can Java scripts run in the browser?

lyric mountain
#

probably, using scriptlets

earnest phoenix
#

weebassembly

lyric mountain
#

while you can embed java into browser it'll result in a relatively big file

#

that's why javascript was created

earnest phoenix
#

The creation of JavaScheme, colorised

wheat jolt
lyric mountain
#

try-catch it

wheat jolt
#

it would catch nothing

#

because nothing is thrown

lyric mountain
#

it does throw, else it'd not say "Uncaught error"

modest maple
#

he's saying why does it work on v16

#

and not v14

wheat jolt
#

^^

modest maple
#

v16 doesnt raise any errors, it binds twice with SO_REUSEADDR

lyric mountain
#

reuseaddr is the right way to do if you wish to reuse the port

#

else it'll stay alive for some time after shutting down the process

wheat jolt
#

I'm confused

modest maple
#

Im assuming they're refering to Unix

#

which you appear to be on windows

wheat jolt
#

ah I get it now

modest maple
#

Linux and windows behave pretty diffrently with how they handle it

#

im surprised they actually enabled it for windows tbh

wheat jolt
#

the reuseaddr?

wheat jolt
#

makes sense now

#

anyways, now I'm wondering how I can disable SO_REUSEADDR

#

I just don't wanna reuse the port and get an error when the port is bound

brave garnet
#

can i ask smth now or channel busy?

sudden geyser
#

You can always ask a question.

brave garnet
#

k, thk

#

from this thingy:

l = []
scam = requests.get("https://script.googleusercontent.com/macros/echo?user_content_key=V1VRkcLy79NqRzGszzki5IwoqgfiRS0CPnpSth1jVdX0Z88w39o7tC71MMkAARMFYXSZIe5ysMkkTdp_V8q-gLFNUefAtxy5m5_BxDlH2jW0nuo2oDemN9CCS2h10ox_1xSncGQajx_ryfhECjZEnA1zRMJcOWhp5p8-TrasYiLfc8s82yHYvncMdEYM4VMzrAWyr3_vgWcPkd2qwPRs1bz0TAVXLS4Dleb--x_lwbJ0QrOacq8a_9z9Jw9Md8uu&lib=Mvhguv8KrjGlroshaZkuz2rjldAiTUHuJ")
Data = scam.json()
for i in Data:
   for key in i:
       l.append(i["put here stean scam: ↓↓↓"])


@bot.listen("on_message")
async def scam(ctx):
    global l 
    for thing in l:
      if thing in ctx.content():
        ctx.delete()

i got this error:

Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 37, in scam
    if thing in ctx.content():
TypeError: 'str' object is not callable

is it possible to fix?
PS: friend was helping me so some bugs might be made by him =p

rose warren
brave garnet
#

its not api key but a database. public ofc

rose warren
#

Ok

brave garnet
#

if ya want - enter there. but it contains mal links to filter

wheat jolt
#

stean scam

brave garnet
#

indeed

#

so someone know how to fix bug?

#

or nope?

sudden geyser
#

The error is coming from line 37

#

but I feel like ctx.content() is not correct

earnest phoenix
#

Does Context even has content attribute doe. Well, regardless, ctx.content seems to be a str object which doesn't implement __call__ method. So, the fix is just don't call it lawl

brave garnet
sudden geyser
#

It's not

brave garnet
#

if != for

sudden geyser
#

ctx is really a Message

brave garnet
#

this type content. ctx is correct

earnest phoenix
#

Ah, lawl, I didn't even realize it's on_message

brave garnet
#

and line 37 at me is if thing in ctx.content():

earnest phoenix
#

Thought it's a command, mb. Yeah, it's a str, you're not supposed to call it

brave garnet
#

so how to get from db?

sudden geyser
earnest phoenix
sudden geyser
#

and .content is a property—not a method

brave garnet
#

i know this ye? i just want to know how to do it. this one works. now i only have a smol problem with similar with db
this what works alr:

with open("bad-words.txt", 'r') as f:
    global badwords
    words = f.read()
    badwords = words.splitlines()

@bot.listen("on_message")
async def swears(ctx):
    msg = ctx.content.lower()
    for word in badwords:
        if word in msg:
            await ctx.delete()
earnest phoenix
#

Because you don't call the str object

brave garnet
#

?

earnest phoenix
#

You can't do ""()

earnest phoenix
#

Because str objects are not callable

#

Because you don't call the str object

#

Say ctx.content were an empty string, you're doing "".lower() which is valid

brave garnet
#

anyways - here is a messup i see - im gonna ask somewhere aelse

earnest phoenix
#

They're gonna tell you the same thing though

brave garnet
earnest phoenix
#

Just don't lower it

#

Can't you see the obvious difference?

brave garnet
#

yep. in one is lower and in second isnt

#

and i dont want lower this time

earnest phoenix
#

Well, pretend .lower() doesn't exist

tulip ledge
#

if you dont want lower just do ctx.content()?

earnest phoenix
brave garnet
#

isnt that done same as u say virgin?

tulip ledge
earnest phoenix
#

It's their code...

tulip ledge
#

ohhh

#

it content a property?

#

or a method

earnest phoenix
#

Yes, a property

tulip ledge
#

then just do ctx.content

brave garnet
#

without () ?

tulip ledge
#

yes its a property

brave garnet
#

kay... gonna try

#

gimme a moment

earnest phoenix
#

Literally what Klay and I have been telling ya

brave garnet
#

kay. now works (and i also forgot bout await. like always)

latent heron
#

.content is a property

brave garnet
#

I DIDNT SAID ALREADY THAT AT ME IS DONE?! STAHP TALKIN BOUT DIS !!!

fleet ibex
#

Help my starting my bot

wheat mesa
#

Provide context about your problem instead of saying something vague please

jovial nexus
#

How is the new form of joining a voice channel?
channel.join() does not exist now

tulip ledge
#

You will have to look into the docs of your library

jovial nexus
#

im using djs v13

#

on v12 you could do .join()

tulip ledge
#

this link shows all the changes

jovial nexus
#

now its a external module

earnest phoenix
#

can we clear cache in discord.py while the bot is running

lyric mountain
#

probably

earnest phoenix
#

how

lyric mountain
#

you just need to find out how to access it

earnest phoenix
#

I do know how to access it

lyric mountain
#

and tbf, you can ONLY clear the cache while the bot is running

earnest phoenix
#

wait actually idk

lyric mountain
#

once you find out how to access the cache, just clear the collection

earnest phoenix
#

with the .clear()

#

method

lyric mountain
#

yes I guess

earnest phoenix
#

well okay so

#

first thing how do I access it

#

like

#

is it like a dict or sum

lyric mountain
#

you need to find that out yourself

#

or ask someone with more experience with d.py

earnest phoenix
#

mm

#

alrightt

#

thanks tho

latent heron
#

have you considered looking at the d.py source code

#

it is open sourced mimu_yathink

earnest phoenix
digital ibex
latent heron
#

which cache are you looking for

#

d.py stores all cached information into object classes

#

you need to be way more specific

#

and what are you trying to do?

digital ibex
earnest phoenix
#

lemme read that first

latent heron
#

jfc

zealous trellis
#

thank you I'll try it out later today

earnest phoenix
#

how do I clear that

latent heron
#

okay

#

let me try and explain how it actually works lol

#

there's a on_socket_response event in the gateway, that occurs when there's a new detected event that is dispatched by the websocket connection

near stratus
latent heron
#

when that happens, it dispatches it to an internal class method to call for the right object to have its class data set

#

the "cached" data changes because of every new event dispatch

#

you can't really clear the cache if you want the simple answer.

earnest phoenix
#

hm

#

I see

latent heron
#

the term "cache" is really referring to class instances being set with values from the last declared event dispatch

#

it's not as you're seeing it

#

if you want to "clear" cache you can do del ctx.message to completely erase it

#

but it will then no longer work, and you should only delete for globals.

earnest phoenix
#

hmmm

latent heron
#

it helps if you actually read the source code to understand this that the cache cannot be cleared through conventional methods

earnest phoenix
#

alright I'll read the source

#

thankss

latent heron
#

have fun

#

there's about 30 files stringed together to the gateway lafh

#

@round cove

#

also

#

i can't really think of a reason of why you'd really need to clear specific parts of the objects d.py provides

modest maple
#

what are you trying to do KannaWhat

#

also the gateway handling is in more like 1 - 2 files

earnest phoenix
modest maple
#

with another file for the HTTP / session handling

modest maple
earnest phoenix
#

how do I do that

#

I wanna set it to 100

modest maple
#

the limit is already 1000 why do you want it lower?

latent heron
#

the object class itself will still have been given set values, you're only removing the identifier that points to it

earnest phoenix
#

There's max_messages parameter afaik

latent heron
#

hence why there's no actual "clear caching" solution

earnest phoenix
latent heron
#

oh he's using deque that's smart

modest maple
#

You'll find that alot of the libs that arent discord.js tend to be pretty well developed

latent heron
#

alright smarty pants

#

wait

#

okay nvm, that's just an odd name

#

"none()" made me go stare what

earnest phoenix
#

I have a question

how the fuck does discord calculate intents and what the heck is << >> | &

latent heron
#

<< and >> are bitshift operators

#

<< doubles IIRC and >> halves

#

| is an operator to conjoin/combine intflags, & removes?

#

which is a little funny because in my mind they should be the other way around

#

iirc d.py does something like default = GUILD_MEMBERS | MEMBER_PRESENCES

#

but that should be an anti intflag if done right

modest maple
#

they're called bitflags

#

if you want to learn more

#

and they are incredibly useful

latent heron
#

mb, used to calling them intflags ¯_(ツ)_/¯

modest maple
#

basically:

FOO = 1 << 0 
BAR = 1 << 1
ALL = FOO | BAR

permissions = 0

if permissions & BAR != 0:  # user has this permission
  ...

latent heron
#

i wonder how d.js coded partials though

lyric mountain
latent heron
#

yes

lyric mountain
#

0110 << 1 becomes 1100

latent heron
#

im sure that means it would double

#

yeah so it doubles lmao

#

because that's registering a higher value

lyric mountain
#

saying it just moves the bits to the left/right makes more sense, helps understanding why it exists

latent heron
#

"shift" is in the name for that

#
class Intents(IntFlag):
    GUILDS = 1 << 0
    GUILD_MEMBERS = 1 << 1
    GUILD_BANS = 1 << 2
    GUILD_EMOJIS_AND_STICKERS = 1 << 3
    GUILD_INTEGRATIONS = 1 << 4
    GUILD_WEBHOOKS = 1 << 5
    GUILD_INVITES = 1 << 6
    GUILD_VOICE_STATES = 1 << 7
    GUILD_PRESENCES = 1 << 8
    GUILD_MESSAGES = 1 << 9
    GUILD_MESSAGE_REACTIONS = 1 << 10
    GUILD_MESSAGE_TYPING = 1 << 11
    DIRECT_MESSAGES = 1 << 12
    DIRECT_MESSAGE_REACTIONS = 1 << 13
    DIRECT_MESSAGE_TYPING = 1 << 14

this is how i wrote mine atm

#

but im really curious as to how d.js implemented partials for specific intents

lyric mountain
#

you mean like GUILDS_MEMBERS | GUILD_BANS?

latent heron
#

i can't remember

#

but thinking about it i'm pretty sure that's how they're most likely doing it

lyric mountain
#

they probably just use the bitflags to define what should be retrieved into the partial

digital ibex
#

im still having the formdata issue, does anyone know why its not like getting the form data?

#
const form = document.getElementById('changeData');
const formData = new FormData(form);```
#

and formData is just an empty object

#

am i doing something stupid or?

#

changeData is a form

near grotto
#

the error is coming when I'm trying to test a webhook using my bot

lyric mountain
#

you're trying to send a request with the wrong method

#

like using GET on a POST endpoint

near grotto
#

how to send message through a webhook using a bot command

#

like I added a command to my bot which sends message through a webhook

lyric mountain
near grotto
#

thx

boreal iron
digital ibex
#

then whats the better option to not manually send data

quartz kindle
#

just because it shows up as an empty object doesnt mean its empty

#

afaik formdata contents are kinda hidden

#

you have to use formdata methods to access them

boreal iron
#

Not sure how you defined changeData before but try to use this:

const formData = new FormData(document.querySelector('changeData'));

digital ibex
boreal iron
#

wtf did I just copied

brave garnet
#

E.
why this:

@bot.event
async def on_command_error(error, ctx):
    if isinstance(error, commands.CommandNotFound):
        await ctx.send("What was that ?!")
    else:
      raise error

gives me this in terminal instead of message ?!

TypeError: exceptions must derive from BaseException
earnest phoenix
#

It's ctx, error, not the other way around

quartz kindle
brave garnet
#

ah, ok, found on stackoverflow. u know

quartz kindle
#

that code was front end no?

digital ibex
#

? nah

modest maple
digital ibex
#

but im receiving an empty object

quartz kindle
#

ah

#

i thought it was empty when like console logging in the browser or something

digital ibex
#

oh na

quartz kindle
#

what server do you run?

#

express?

digital ibex
#

ye

quartz kindle
#

with multer?

digital ibex
#

is that a middleware?

quartz kindle
#

yes

digital ibex
#

if it is im not

#

yea im not

quartz kindle
#

then you need it for formdata

digital ibex
#

kk

#

thank

quartz kindle
#

np

digital ibex
#

i jus got bakc to my pc and went on the npm page

quartz kindle
#

is your form not using multipart?

digital ibex
#

nope, application/json

#

its not for files

quartz kindle
#

oh

#

can the FormData class even use json?

latent heron
#

i think it can accept json but as raw string

digital ibex
#

idk what u mean, in the body i have that then i have a callback which makes it json

quartz kindle
digital ibex
#

not makes the formdata json but response

quartz kindle
#

formdata is specifically made for multipart

digital ibex
#

oh

#

i thought thats how ur supposed to like

#

not manually send data

#

how am i supposed to not manually send data if that makes sense

quartz kindle
#

just do form.submit()

digital ibex
#

:/

#

okay thanks

#

im so dumb

quartz kindle
#

form submit will use urlencoded

#

but thats not much different from json

#

and express should be able to handle it natively

digital ibex
#

how am i supposed to do it? is it something like js fetch('url', { method: 'post', body: form.submit() .... } ? or something

quartz kindle
#

no

#

fetch is a manual request

#

form.submit can be used without fetch at all

thorn pumice
#

guys

quartz kindle
#

document.getElementById("myForm").submit();

digital ibex
#

yeah now im confused on how it sends to the correct endpoint

thorn pumice
#

i need project replit slash command

digital ibex
#

oh in the form tag i use action?

quartz kindle
digital ibex
#

action="url" ?

#

ah alrighty

quartz kindle
#

<form action="/action" method="POST">

#

for example

digital ibex
#

thank

#

this is so annoying man

#

now the preventDefault it not working

#
document.getElementById('save-btn').addEventListener('click', (event) => {
       event.preventDefault();
       form.submit();
 });```
sage bobcat
#

One message removed from a suspended account.

lyric mountain
sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

lyric mountain
#

🚣‍♂️

sage bobcat
#

One message removed from a suspended account.

digital ibex
#

anyone kno how to fix my issue lol

sage bobcat
#

One message removed from a suspended account.

boreal iron
#

I remember you said you replaced the code with the previous version and it doesn't use arrow functions... if I remember correctly.

boreal iron
#

nope he also posted a code snipped

boreal iron
digital ibex
#

oh, yeah it was workin fine

#

i misread

#

but i thought i had to use formdata, and formdata would not send any data

#

its still not reloading the page, and i change it to form.submit and now it sends the data everything updates and everything

#

but it reloads the page

#

dub

quartz kindle
#

you have to add a submit event to the form

#

and preventDefault there

digital ibex
#

wdym

quartz kindle
#

form.addEventListener("submit", event => event.preventDefault())

digital ibex
#

kk

quartz kindle
#

actually

digital ibex
#

doesnt change anything

quartz kindle
#

that will also prevent the form from being sent lol

#

which means you have to use fetch one way or another

lyric mountain
#

oh, yeah there's that too

#

preventDefault basically invalidates the event

digital ibex
#

im confused

quartz kindle
#

i forgot that submitting forms makes the browser change pages

#

so you have to go back to using fetch and manually sending the data

digital ibex
#

?

#

i dont get it

quartz kindle
#

what dont you get?

digital ibex
#

i fixed it

#

i just added the preventDefault in the save button

earnest phoenix
#

Hello

digital ibex
earnest phoenix
#

How can i vote for probot

#

?

digital ibex
earnest phoenix
#

Thx

digital ibex
#

yw

earnest phoenix
#

What's that?

digital ibex
#

change "probotid" to pro bots id

earnest phoenix
#

Okay

tulip ledge
#

Question, if I make a method on typescript like this:

class Something {
  private onFinish: any;

  constructor() {}

  public start() {
    return new Promise((res) => {
      this.onFinish = res;
    });
  }

  private end() {
    this.onFinish(true);
  }
}

What type would onFinish be and what type would start return?

lyric mountain
#

don't u have to declare method return type?

#

end() would be void for sure since it has no return

tulip ledge
#

Yes

#

But start and the private property onFinish

#

Start would return a promise but with what type?

lyric mountain
#

any

#

it's a promise of any as it seems

#

wait

#

nono, it's a promise of void

#

no return at all

tulip ledge
#

So Promise<void>?

lyric mountain
#

I guess so

#

like, you didn't return anything inside it

sudden geyser
zealous trellis
#

hey is it possible to make slash commands that only certain users can access? like developer / admin commands that only show up for specific IDs or Roles

lyric mountain
#

no but you can check which user used the command before executing it

zealous trellis
earnest phoenix
# zealous trellis hey is it possible to make slash commands that only certain users can access? li...

That feature was already planned in the Discord API docs API discussion (https://github.com/discord/discord-api-docs/discussions/3581), so it's not possible yet, the only thing you can currently do is to either wait until the feature is rolled out, or just compare IDs and bailout if it doesn't match

GitHub

Hey all, an update on plans for the API. We've reviewed a lot of your survey responses and messages in DDevs #message-intent. We appreciate your candid feedback and want to offer a peek int...

zealous trellis
#

dammmmmmmmmnnnnnnnnnit

digital ibex
boreal iron
#

Even if these options are available in the future I still prefer handling it using your own command handler since editing the global commands a lot of times sometimes brings issues with it.

quartz kindle
#

@earnest phoenixscam?

#

lol

#

reset your password

rose warren
#

@earnest phoenix please don't share those links

torpid tapir
rose warren
#

@earnest phoenix change your password and activate 2FA

boreal iron
#

How can somebody take ur account by clicking on a link?
It’s not like you’re revealing your login data…

quartz kindle
#

the link they posted literally asks you to type your login and password

boreal iron
#

🤦‍♂️

civic scroll
#

@zealous trellis did you use discord v12 with wrapper?

zealous trellis
#

its a fresh new bot

#

djs 13

civic scroll
#

what ds ver is it

#

then it must have

zealous trellis
civic scroll
quartz kindle
#

and where is it hosted?

wary swan
#

i want to make a O(n) intersection of array function how can i do it in js but i also want to make sure there are not duplicates for example : there is a array of [1,1,1,4,5] then a array of [1,1,2,3,4] i want to make the output [1,1,4] not [1,1,1,4] or something

civic scroll
zealous trellis
zealous trellis
torpid tapir
#

depression

civic scroll
#

i said inspevt it

civic scroll
zealous trellis
#

I can console log oit

#

thats about it

civic scroll
#

VSCode can debug

lyric mountain
civic scroll
#

if you run native js

zealous trellis
#

not a website..

lyric mountain
#

oh wait, O(n)

civic scroll
#

...

#

man

#

does your bot run on Node?

#

if it is then it's js

zealous trellis
#

-.-

#

naw dip sherlock

quartz kindle
torpid tapir
civic scroll
#

running JavaScript doesn't mean the environment is a browser

#

lmao

quartz kindle
civic scroll
#

you literally are using a runtime to run your bot

torpid tapir
wary swan
civic scroll
#

@zealous trellis

#

it's typescript but whatever

#

still same as js

#

you can debug it

zealous trellis
#

I dont see why I need to debug the interaction, I can just log it

civic scroll
#

check if said method is available in interaction object

quartz kindle
#

you are literally running the script that intentionally throws an error

civic scroll
zealous trellis
#

Ive been doing that for years

#

works fine..

#

.-.

civic scroll
#

step up your game

#

also in debug
you can modify values live

zealous trellis
#

damn kids these days with your fancy debug inspectors, ive been manually logging data for years

#

and it works

civic scroll
#

"kids"

zealous trellis
#

lol

civic scroll
#

that's a tool

civic scroll
#

it's really important if you ask me

#

imagine big data set

#

keep scrolling forever

#

but that outta way

#

by any means, inspect the interaction object

quartz kindle
civic scroll
#

and check if said method exists

torpid tapir
# quartz kindle your replit run file should be "node index.js" to explicitly run your index file...

yeah ive did "node index.js" but it sends


internal/fs/utils.js:269
    throw err;
    ^

Error: ENOENT: no such file or directory, scandir './commands/mod/'
    at readdirSync (fs.js:955:3)
    at load (/home/runner/topgames/handler/command.js:7:26)
    at /home/runner/topgames/handler/command.js:14:41
    at Array.forEach (<anonymous>)
    at module.exports (/home/runner/topgames/handler/command.js:14:28)
    at /home/runner/topgames/index.js:30:71
    at Array.forEach (<anonymous>)
    at Object.<anonymous> (/home/runner/topgames/index.js:30:33)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10) {
  errno: -2,
  syscall: 'scandir',
  code: 'ENOENT',
  path: './commands/mod/'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! topgames@1.0.0 start: `node index.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the topgames@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2021-08-24T20_00_00_464Z-debug.log
#

very bad

quartz kindle
#

thats not bad

zealous trellis
civic scroll
#

...

#

path error

civic scroll
quartz kindle
#

i mean, its an error yes, but at least now you now your files are actually running

zealous trellis
quartz kindle
#

before your file was not even running in the first place

civic scroll
#

aka. the first few words before {

quartz kindle
#

now you have to fix your issues

zealous trellis
#

CommandInteraction

#

:P

civic scroll
#

about to go mad

#

alrd wait

zealous trellis
boreal iron
zealous trellis
#

makes ya wanna rip out your hair sometimes

#

or punch a wall

civic scroll
#

okay so <CommandInteraction>.reply()@zealous trellis

zealous trellis
#

yeah?

#

it works

#

Im already using it

civic scroll
#

good grief

#

for the love of god you need to understand inspection

#

also console.log is a bad practice, leave it

zealous trellis
civic scroll
#

since debuggers exist

#

one click of a mouse

#

and that's it

lyric mountain
#

2 actually

zealous trellis
#

if console.log was bad practice, consoles wouldnt have a reason for existing

#

since literally every bash utility logs data to the console

civic scroll
#

1 Trolled

lyric mountain
#

how tf you would set a breakpoint then?

civic scroll
#

not for inspecting

boreal iron
#

Reporting issues to the console also let clients the chance to report them isn’t a bad practice

civic scroll
#

not inspect-friendly

zealous trellis
#

youre just dragging semantics into it for no reason

#

.-.

lyric mountain
#

no, you're console logging

civic scroll
#

on the left of line numbers

#

moment

lyric mountain
#

breakpoints are debug-exclusive

civic scroll
lyric mountain
lyric mountain
#

🥔

#

breakpoint -> debugger -> stops code there and allows u to view where and how it goes
console.log -> logs

zealous trellis
#

.-.

pale vessel
#

console.log gigachad

civic scroll
#

me since 2020 and like

lyric mountain
#

just see me set a breakpoint in this punch card

zealous trellis
#

I just prefer logging something

civic scroll
#

for ts you need deno
or ts-node compiled code with sourcemap enabled

zealous trellis
#

I dont need a TS debugging tutorial

civic scroll
#

huh....

zealous trellis
#

my original problem was that I wanted to cancel an interaction

#

idk how the hell we went this far off on a tangent

civic scroll
#

my extended problem is that you used it for 5 years and still don't use the debugger

zealous trellis
#

dont see the problem

civic scroll
#

fun fact: debugger has logging

boreal iron
#

I’m coding for 14 years and don’t use debuggers so calm

#

Just because n++ doesn’t have a native one lmao