#development

1 messages · Page 37 of 1

rustic nova
#

aka interaction.options.getString and so forth

#

that should do the trick

#

Eh nevermind, seems to be wrong

knotty quartz
#

Yeah. i have options.getString

#

It just can't get it to get the choice and send the correct array.

rustic nova
#

getString has an argument named name, which should be category in your case

#

it should then get the choice the user provided

#

aka in your case either gif_cat or gif_dog

#

Is what I'm getting from the docs at least

#

and is what I'm seeing within your code already

#

could you log the content of value?

knotty quartz
rustic nova
#

ohh

#

You could technically have a main variable named gif or something, having a if condition set the value of gif to the for example cat[Math.floor(Math.random() * cat.length)] you have already present, so

initialize a new variable called gif

through an if condition, check if the variable "value" is "gif_cat"

if yes, set gif to what is currently in image_cat
if no, set the gif to what is currently in image_dog
#

and then just simply reply the interaction with gif

knotty quartz
spark flint
#

People who have premium subscriptions for their bot: How do you do it? I'm trying to find the best way to automate payments, looking at Chargebee because of its API

#

going to have a /redeem command

earnest phoenix
#

Does anyone know why this is screaming at me?

rustic nova
#

type has to be an int

#

aka enum containing that int

boreal iron
#

I mean it obviously says GUILD_TEXT isn’t an integer but a string

rustic nova
#

its happening

boreal iron
#

Either use djs enums as said above or simply pass the integer which represents the type guild text

#

Which you can find in the API docs

lyric mountain
#

ok so, if the mods put "Final Countdown" to play exactly at 9:58 AM PST, the riff will start the very moment a million bots crash from the lack of intent approval

boreal iron
#

It will start then, yeah even if not every bot will be disconnected immediately

#

But I guess since discord knows exactly how many servers are bot is in mostly smaller bots will be disconnected short after each other

#

And larger ones been handled with care

eternal osprey
#
    let timeembed = await target.send({embeds: [embed1]})
    timeembed.embeds[0].edit({embeds:[embed2]})```Its telling me that timeembed.embeds[0].edit isnt a function.Why?
#

Using v13

wheat mesa
#

Because embeds[0] is an embed object, and embed objects don’t have an edit function

#

I believe you meant to do timeembed.edit()

boreal iron
#

editing a message will also return a promise, so await it

#

Just to say

#

Also your var timeembed actually isn’t an embed but a message object send() returns

#

You might confuse yourself with that var name

wheat mesa
#

Yeah I would do something like const timeMessage = await ...

#

Good variable names may seem like a small change but they make a big difference in readability sometimes

bright thorn
#

somehow now my vps is not giving much memory to nodejs

#

idk why

sharp geyser
#

@civic scroll angular question you available?

civic scroll
#

@sharp geyser here

sharp geyser
#

I am trying to setup ngx-socket-io with angular, but when I do so the page content no longer loads

#

Its just a white space

#

I even tried commenting out my changes and still nothing

civic scroll
#

anything appear in the console / build logs?

sharp geyser
#

Forgot Angular even logs shit in the dev tools console

#
Uncaught ReferenceError: Cannot access 'ChatService' before initialization
    at Module.ChatService (chat.module.ts:14:18)
    at 818 (chat.module.ts:16:15)
    at __webpack_require__ (bootstrap:19:1)
    at 1470 (chat.module.ts:14:18)
    at __webpack_require__ (bootstrap:19:1)
    at 2226 (app.module.ts:19:15)
    at __webpack_require__ (bootstrap:19:1)
    at 5041 (app-routing.module.ts:8:25)
    at __webpack_require__ (bootstrap:19:1)
    at 6747 (app.component.html:2:21)

How the fuck do I use services in angular

civic scroll
#

you import them in class constructors

sharp geyser
#
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ChatComponent } from './chat.component';
import {ChatService} from "./chat.service";

@NgModule({
  declarations: [
    ChatComponent
  ],
  imports: [
    CommonModule,
  ],
  exports: [
    ChatComponent
  ],
  providers: [ChatService],
})
export class ChatModule { }
#
import { Component, OnInit } from '@angular/core';
import {ChatService} from "./chat.service";

@Component({
  selector: 'app-chat',
  templateUrl: './chat.component.html',
  styleUrls: ['./chat.component.scss']
})
export class ChatComponent implements OnInit {

  constructor(private chatService: ChatService) { }
  
  sendMessage(msg: string) {
    this.chatService.sendMessage(msg)
  }

  ngOnInit(): void {
  }

}```
civic scroll
#

the component is fine

#

it's just improper import in to module

#

hang on lemme check

#

@sharp geyser can i see the service declaration decorator for ChatService

sharp geyser
# civic scroll <@957347862314905610> can i see the service declaration decorator for `ChatServi...
import { Injectable } from '@angular/core';
import {Socket} from "ngx-socket-io";
import {map} from "rxjs";
import {ChatModule} from "./chat.module";

@Injectable({
  providedIn: ChatModule
})
export class ChatService {

  constructor(private socket: Socket) {}

  sendMessage(msg: string) {
    this.socket.emit('message', msg)
  }

  getMessage() {
    return this.socket.fromEvent('message').pipe(map((data: any) => data.msg))
  }
}

I think this is where I am going wrong with the providedIn

civic scroll
#

it doesn't look wrong, at least to me

sharp geyser
#

Interesting

civic scroll
#

@sharp geyser

#

try this

#

"emitDecoratorMetadata": false in tsconfig.json

#

then restart the dev process

sharp geyser
#

changing providedIn: ChatModule to providedIn: 'root' works ig

#

idk if this is the most efficient fix

#

but

civic scroll
#

no

#

chat should be lazy-loaded

sharp geyser
#

interesting

civic scroll
#

did my change fixes the problrm

sharp geyser
#

one sec

sharp geyser
#

same error in dev tools console

#

Actually I should be sleeping soon rip

#

1am got school tomorrow

civic scroll
#

okay

crystal wigeon
#

Hey umm anyone use auto code?

#

everything was working fine until today, the bot suddenly not responding to commands on auto code

#

and when i type the command i dont see any logs as well

rustic nova
#

-intents

gilded plankBOT
#

Why does my bot tell me it needs a "message content intent"?

Starting from <t:1662031440:D>, Discord has made the content within messages a privileged intent you ** are required** to apply for if your bot depends on it. You can read more about that change here.

To avoid our channels being flooded with said questions, we would ask you not to ask questions regarding the intent within this server and ask in discord.gg/discord-developers instead. Thank you.

rustic nova
#

@earnest phoenix first one btw

boreal iron
crystal wigeon
boreal iron
#

You can only help yourself in this case

#

Did you read the article aurel mentioned?

crystal wigeon
boreal iron
#

Unverified bots can just enable the intent in the developer portal

#

With the enforcement this should have happened automatically

crystal wigeon
#

thanks

boreal iron
#

Check the developer portal

#

And take a look if the privileged message content intent switch is enabled

forest wave
#

Hi

crystal wigeon
forest wave
#

The Reason It's Still Unconfirmed I think is the tail.

#

A new bot is constantly coming out, which I call a tail, so people are having difficulties.

boreal iron
#

You have to wait until it’s verified by topgg

#

It’s in a queue with lots of other bots

#

So wait patiently until they’ve done their job and test your bot

forest wave
#

very long

#

My bot is currently on hold

#

pending My bot heh

worldly yoke
#

anyone knows vuepress here? if yes please ping me, have some fuck up to discuss

eternal osprey
#

hey guys

#

the inclusive or is true when either p or q is true, or both are true right? And the exclusive or (XOR) is only true when either p or q is true, but not both?

boreal iron
#

XOR requires 1 input to be true (1) and one to be false (0) yes

#

While OR can have both inputs being true (1)

#

To output true (1)

earnest phoenix
small tangle
#

i guess he's talking about the intents thingy

eternal osprey
#

Ah I see, thanks fake

bronze dragon
#

;;join

wheat mesa
#

The day of reckoning is upon us

earnest phoenix
#

Oh God, here they come; it's all gonna about the intents

#

The command that worked yesterday started giving an error today.

const reqPermMember = client.commands.get(interaction.commandName).command.reqPermMember.replace("Administrator", "Administrator").replace("ManageChannels", "Kanalları Yönet").replace("ManageRoles", "Rolleri Yönet").replace("ManageMessages", "Mesajları Yönet").replace("ManageGuild", "Sunucuyu Yönet").replace("ModerateMembers", "Üyelere Zamanaşımı Uygula").replace("BanMembers", "Üyeleri Yasakla").replace("KickMembers", "Üyeleri At")

#

I use regPermMember here

#

Ow,, I made a little mistake.

quartz kindle
#

3 and a half hours left guys

#

for the apocalypse to begin

stable eagle
earnest phoenix
#

I'm dealing with a weird issue, and I'm quite confused. I send an embed with a button via DM, and in the button handler to delete the embed once an option is chosen, I call interaction.message.delete() but it's unable to find the message in the DMchannel: [ChannelNotCached]: Could not find the channel where this message came from in the cache! Ideas on how to fix this?

lyric mountain
fossil bronze
#

Imgur links stopped embedding, anyone know if that's a bug or intended? Or if it will come back?

lyric mountain
#

hm, wait

#

no, they indeed broke for some reason

fossil bronze
#

Yeah that was not the case before, any imgur link would embed

#

And linking to a mp4 like that would still make it say gif

#

It's a real shame they really need to let everyone embed mp4/webm as "gif" not just a few whitelisted sites

#

Imagine the terabytes of bandwidth wasted every day on gif

lyric mountain
#

if anything, I'd prefer if discord supported apng/webp instead, since they're the modern sucessors of gif

fossil bronze
lyric mountain
#

I meant the video -> gifv conversion

#

And the embedding

#

Discord doesn't "whitelist" anyone, it's the sites that pass an OG tag containing embed data

fossil bronze
#

When you link to a imgur or gifycat "gif", discord embeds it in chat as a html video element (that is playing a mp4) that autoplays and says "gif" in the corner

#

No it's not about OG tags or metadata, it should be, but it's not

fossil bronze
#

No it doesn't, a actual gif file just shows a gif file

lyric mountain
#

Don't think so, all gifs I ever saw always had that in discord

fossil bronze
#

Yes actual gif files

#

What I am talking about is embedding mp4s and making them work like a .gif

lyric mountain
#

They are just encoded as gifv

#

(not gif)

fossil bronze
#

gifv isnt a format

lyric mountain
#

Imgur does that for all videos

lyric mountain
fossil bronze
lyric mountain
fossil bronze
#

Yes as you can see there it's not an actual format

lyric mountain
lyric mountain
fossil bronze
#

Here is an example of a direct link to a mp4 file

lyric mountain
#

A gifv yes

fossil bronze
#

No just a mp4

lyric mountain
#

...it's a gifv

#

Imgur and alikes use that to show videos as gifs

fossil bronze
#

What nmakes you say that

lyric mountain
#

U can do it urself

lyric mountain
pale vessel
#

It's just a looped video with GIF label

fossil bronze
#

No it's just a Mp4 file

pale vessel
#

Yes a video

#

MP4

fossil bronze
#

And the response from the server is just sending the file

#

a gifv is a html page

lyric mountain
#

I won't argue, image providers used that since always to provide hd gifs from videos

#

That still isn't a discord whitelist, anyone can do that

fossil bronze
#

If you can show me how to do it I offer 50 dollars

#

it would be extremely useful

lyric mountain
#

Save your dollars, just google

#

W3schools has tutos for that iirc

fossil bronze
#

No

earnest phoenix
#

Should I use process.exit(0) to restart the bot?

lyric mountain
#

No what?

lyric mountain
#

You can't "restart" a process from within

fossil bronze
#

No, there isn't. Ok I can bet you 100 bucks, but I can't do more than that.

lyric mountain
#

I mean, u can, but u lose the attachment to it

earnest phoenix
lyric mountain
lyric mountain
fossil bronze
#

I've already done that

lyric mountain
#

Even the headers?

quartz kindle
#

anyone has experience with node.js native modules on aws lambda?

fossil bronze
earnest phoenix
lyric mountain
#

That isn't restarting the process

#

When I say "another process" I mean a truly external process with the sole purpose of controlling the desired process

#

Like pm2

lyric mountain
fossil bronze
#

This is a normal response from a non-whitelisted server

lyric mountain
#

By response I mean headers + body

fossil bronze
#

I even bothered discord staff with this before and they said it's whitelisted

#

long ago

#

I'm not sure what you mean, the body would be the file

lyric mountain
#

That's really weird then, the video is usually encoded at the origin

fossil bronze
#

Im not sure what you mean tbh

ancient nova
#

poggers

quartz kindle
#

1 hour remaining

#

:^)

gilded plankBOT
#

Why does my bot tell me it needs a "message content intent"? Why has my bot stopped responding to any chat messages?

Starting from <t:1662031440:D>, Discord has made the content within messages a privileged intent you ** are required** to apply for if your bot depends on it. You can read more about that change here or read more [from the official announcement regarding the changes](#697138785317814292 message)

To avoid our channels being flooded with said questions, we would ask you not to ask questions regarding the intent within this server and ask in discord.gg/discord-developers instead. Thank you.

quartz kindle
#

tbh its not gonna be that bad

#

since it only affects verified bots

solemn latch
#

thankfully ^_^

fossil bronze
spark flint
#

it has started

#

in replit server

sudden geyser
#

can you show where you create your bot instance

solemn latch
#

The developer portal

fossil bronze
#

Especially in replit

#

Anyway my offer stands, $100 reward for someone that can show me how to get your videos(meaning mp4/webm) to embed as gif (Meaning autoplay, no video controls) in discord with your own site/host that is not imgur/gfycat etc

wheat mesa
#

Yes because we definitely trust that you will pay us 100 dollars for something you can google in 35 seconds

fossil bronze
#

I'm confident that you can't, thats why im making the offer

fossil bronze
#

Thats a gif

spark flint
#

embed as gif

fossil bronze
#

Videos

pale vessel
fossil bronze
#

webm and mp4

#

Gif always embeds

fossil bronze
#

Yeah see

pale vessel
#

Not a GIF

wheat mesa
#

Have you considered the fact that discord doesn’t auto play videos for a reason? Why would you ever even want to do that?

fossil bronze
wheat mesa
#

Because they’re trusted

fossil bronze
#

That is the whole point I've been talking about

fossil bronze
#

You yourself said it's something you google in 35 seconds

wheat mesa
#

Not going to waste my time on a fictitious reward :p

fossil bronze
feral aspen
#

How do I modify my IntelliJ plugin settings?

fossil bronze
#

I mean I dont know but there's a cog there

flat copper
#

how can i run my app forever in my android even after i close it

fossil bronze
#

If you dont have any money maybe use replit

flat copper
#

turned into .apk

fossil bronze
#

Maybe there is a way, but phone OSes are designed to close apps and conserve power and absolutely not run them forever

#

Is it a bot?

#

or webserver

lyric mountain
flat copper
#

then how can i run it in background?

quartz kindle
#

you're hosting your bot inside your phone?

#

lmao

fossil bronze
#

Run it on a server

#

That is by far the best option

lyric mountain
flat copper
lyric mountain
#

not worth it, you'll constantly fight with android to keep your process alive

#

and you lose the most vital thing

quartz kindle
#

did you create the app yourself?

flat copper
#

yes

lyric mountain
#

imagine literally ignoring all the warnings to focus only on what u want to see

quartz kindle
#

if you used android studio you have to look into how to code background apps on android

#

if you used some bot maker app that makes the apk for you, then you cant, its a limitation of whatever app you used

boreal iron
fossil bronze
#

As much as I do t like replit and dont think people should use it, it seems reliable

earnest phoenix
#

Replit is fine for testing simple projects or just hosting them, such as static websites and such, or even the complex ones (but not too complex)

#

People shouldn't use it for things like Discord bots

light ingot
#

i host my lavalink servers on it KEKW

earnest phoenix
#

That's even worse

boreal iron
#

even worse is an alias of this channel

#

*one alias

earnest phoenix
#

whats the right perms for mute/unmute?

lyric mountain
#

whatever is required to use timeout

earnest phoenix
lyric mountain
#

or if ur still using old-school muting, MANAGE_ROLES

earnest phoenix
#

the until= thing gives me errors alot for some reason

lyric mountain
#

ur probably setting an invalid duration

earnest phoenix
#

ill see

earnest phoenix
lyric mountain
#

then until should be passed as positional, not named

lyric mountain
#

function(positional, {named: value})

earnest phoenix
#

oh

#

okay

lyric mountain
#

ur passing the parameter wrongly

earnest phoenix
#

cuz im tryna do until=

boreal iron
#

... the syntax of bash is close to be as horrible as python

#

for real...

#

ik that will put it into a bad light, but still

fossil bronze
#

I've found that JS can do what I did with bash before

fossil bronze
boreal iron
#

I have to

#

creating scripts for firewall updates resolving dynamic hostnames

#

on root level ofc

fossil bronze
#

Well maybe you have to idk

#

What I do is I exec

#

So maybe you can have a little thing in bash that does the change and the rest in js

boreal iron
#

well yeah... besically using any language to execute any shell command and handling the output to send another shell command

#

it's much more efficient here to directly create a shell script

fossil bronze
#

Alright

#

Also while on the topic I want to talk about how nice it is to promisify exec

boreal iron
#

it's not like I do really struggle with bash, but tbh I don't like it and don't create scripts real often using it

fossil bronze
#

I used to try to use ffmpeg frameworks

#

It was hard to figure out how they wanted you to do thing and advanced options didn't work

#

Exec is sooo much easier

boreal iron
#

yeah using exec to execute a shell command using your language of choice might look easier in the first place

earnest phoenix
boreal iron
#

I already feel enough pain Mr voltrex

fossil bronze
#

Oh cool is a game updater in js

#

/ts

earnest phoenix
#

It's basically Steam Proton with bleeding edge dependencies for better support

fossil bronze
#

I also used to do text manipulation with sed and grep with bash and that was kinda hard because they all had non-standard regex
But with JS it's standard regex so you can use sites like regextester to learn

boreal iron
#

yeah I feel that, also using regex to match strings

earnest phoenix
#

Working with shell scripting languages such as Bash to do command-line operations and manipulation is just absolute pain

rustic nova
#

"Why is my bot not working anymore" counter: 0

boreal iron
#

had to figure out it's some other sort of regex, too

boreal iron
#

shame on you, you missed that

rustic nova
#

I missed the second one?

#

sadge

earnest phoenix
#

I'm surprised a lot of them didn't come here, it's hell let loose in the discord.js support server

rustic nova
#

why is my djs v8 bot not working anymore please help

earnest phoenix
#

"Why does discord.js not support extremely old versions of Node.js???????????????"

#

Man these people

boreal iron
#
cache=/tmp/auth-hosts-cache
tmp=${cache}.tmp


# resolving hostnames

for hostname in "${hostnames[@]}"; do
        iplist=($(dig +short "$hostname" A))

        for ipaddr in "${iplist[@]}"; do
                echo $ipaddr >> $tmp
        done
done

if [ ! -f "$tmp" ]; then
        exit 1
fi

if [ "$(cat $tmp)" == "" ]; then
        rm $tmp

        exit 1
fi

my eyes are getting cancer, I swear

spark flint
#

omg guys why is my bot returning null for content panic

wheat mesa
#

help why is my bot not working anymore

spark flint
#

/j

boreal iron
#

you have to delete your application and create a new one

#

known bug

#

all your servers will surely carray over, don't worry

spark flint
#

new dev tos

#

o not live yet

boreal iron
#

2020... the new 2022

#

bun much on point today

spark flint
#

nah

#

there was a popup

boreal iron
#

ye ye... bun smoking too much

#

be a good boy and put it away

sudden geyser
spark flint
#

see

#

ignore the fact i had to pull out my alt

boreal iron
sudden geyser
#

hey don't diss our buddy python

boreal iron
spark flint
#

lol

boreal iron
#

QUICK QUICK CLICKING DISMISS AND WHEN IT'S LIVE TELL EVERYONE I NEVER GOT A NOTIFICATION

wheat mesa
#

You know, my bot shouldn’t be working at this point, but it still is

sudden geyser
#

let the games begin

wheat mesa
#

I’ve got the opposite problem: why is my bot working

sharp geyser
#

Ez fix

sharp geyser
boreal iron
#

it's a "rollout"

#

imagine 10000s of disconnects and reconnects at the same time

#

gateway goes brrr

lyric mountain
#

meanwhile me:

#

opencv takes an eternity to build

spark flint
boreal iron
#

well I'm getting closer

#
#!/bin/bash

hostnames=("..." "...")

cache=/tmp/auth-hosts-cache
tmp=${cache}.tmp


# resolving hostnames

for hostname in "${hostnames[@]}"; do
        iplist=($(dig +short "$hostname" A))

        for ipaddr in "${iplist[@]}"; do
                echo $ipaddr >> $tmp
        done
done

if [ ! -f "$tmp" ]; then
        exit 1
fi

if [ "$(cat $tmp)" == "" ]; then
        rm $tmp

        exit 1
fi


# cache

if [[ ! -f "$cache" || "$(cat $cache)" != "$(cat $tmp)" ]]; then
        if [ -f "$cache" ]; then
                rm $cache
        fi

        iptables -F auth-hosts

        while read ipaddr; do
                iptables -A auth-hosts -s "${ipaddr}/32" -p tcp -m tcp --dport 22 -j ACCEPT
                iptables -A auth-hosts -s "${ipaddr}/32" -p tcp -m tcp --dport 113 -j ACCEPT

                echo $ipaddr >> $cache
        done < $tmp
fi


# exit

if [ -f "$tmp" ]; then
        rm $tmp
fi

if [ ! -f "$cache" ]; then
        exit 1
fi

exit 0
#

while I dislike bash much it works quite well

#

and pretty much catch and handles empty results etc.

#

so... somebody requested it and I think he gets what he wants

#

OH NO

#

found the first issue

#
$ cat /tmp/auth-hosts-cache
ipaddr
ipaddr
ipaddr
ipaddr
ipaddr
#

forgot to turn ipaddr into a var

lyric mountain
boreal iron
#

yeah I feel like exactly the same tbh

#

fine works now pretty well

#

without uselessly update the firewall rules if the IPs are still the same as my cache holds em

#

@boreal iron You did that one beautiful!

#

I know. Very much thanks!

#

@boreal iron No problem, Sir!

#

Appreciate your feedback, FakE!

#

<3

#

I should probably check if the chain auth rules exist

lament rock
boreal iron
#

Well… basic

#

But functional I guess

lament rock
#

Songs in the queue appear below the current track

boreal iron
#

Responsive design?

lament rock
#

Yeah. Websocket based

boreal iron
#

Uhh I got interrupted

lament rock
#

You can ban Discord from your servers

#

like. Actually Discord

boreal iron
#

Yee I remember that

lament rock
#

643945264868098049

boreal iron
#

But doesn’t the system still sends messages to me?

rustic nova
#

lmao

lament rock
#

I think you can block if you manually make a request

#

haven't tried

boreal iron
#

I would guess I will still get notifications by the system as long as the account is linked to an application

earnest phoenix
#

system deez nuts

boreal iron
lament rock
#

Oh yes. Mobile looks fine

boreal iron
#

Well then regarding the fact you said you’re new to this, it looks quite nice

#

I mean redesigning it later isn’t an issue as long as functionality is already a thing

lament rock
#

err sorta responsive

#

The Discord interface is already responsive and nice to look at. Mobile literally has no purpose in using the dash

lyric mountain
#

discord system dm spam tf

lament rock
#

flagged as scam

boreal iron
#

Yet another delay for anyone who still haven’t noticed yet

#

I can’t believe this

boreal iron
#

You got some work to do

lament rock
#

It's almost like they've been threatening this happening for a long time!!

#

I can’t believe bots I don't own are being broken. Gonna write an angry post on twitter to the 5 followers I have

boreal iron
lyric mountain
lament rock
#

if people still need more time after the 2 years or so of delay, then there's issues

boreal iron
#

Wait for it…
People who haven’t noticed yet, in October, will get a delay until 2023

lament rock
#

but Discord!1!!!

rustic nova
#

taking bets

#

will get until May next year

boreal iron
#

Aye

#

I keep 50% as fee

#

Makes me rich

lament rock
#

5 freedom units says they'll essentially tell devs to cope and seethe

grim aspen
#

I’m soon to blocking discord’s dms

boreal iron
#

To get one of this boys who never have been notified about changes?

grim aspen
#

No they annoy me

boreal iron
#

There will only be a few hundred delay messages in the next weeks

#

Don’t worry

knotty quartz
#

How do you call two arrays so it chooses one and sends a meme for random?

boreal iron
#

For people who didn’t get it yet

grim aspen
#

Or you can use the Reddit meme api (which I don’t know if it still works)

knotty quartz
lament rock
#

Your question is confusing. Calling two arrays? Arrays are not "Callable" in the literal sense (functions)

boreal iron
#

Merging two arrays together and get a random item of it?

grim aspen
#

You can do fetch api though?

lament rock
#

Arrays are linked to an api?

#

this is news to me

#

I need to reconsider my outlook on js

boreal iron
#

[…array1, …array2][some random key]

knotty quartz
#

That is the one I'm looking for.

#

Thanks!!!

lament rock
#

array1.concat(array2) merges the two arrays together (non mutative)
array1.push(…array2) mutates array1

boreal iron
#

The issue is you won’t know the length the here

#

(For my example)

#

Or is maybe… this in that scope a thing?

#

[…][this.length-1]

#

Maybe?

knotty quartz
#

Thanks, I'll have a try.

boreal iron
#

Idk

#

Wait for someone to reply knowing js better than me

#

Probably isn’t a thing

knotty quartz
boreal iron
#

But anyways margin the arrays together can be archived by using the spread operator

#

Like I mentioned above

knotty quartz
#

Ok! Thanks for the help!

boreal iron
#

Then simply create a var

#

To access the length

#

To do a math random between 0 and the length

#

Minus 1

lyric mountain
#

do not be afraid to make vars, if it isn't necessary the compiler will remove it anyway

boreal iron
#

Would be neat

boreal iron
#

let merged_array = […array1, …array2, …];

#

In your case

#

Then use the var u crated

wheat mesa
#

ngl my computer science knowledge just clutched up on a calculus quiz I just took

#

holy shit I feel alive after that

boreal iron
#

lol

lament rock
boreal iron
#

Sadness

#

Ok screw JS

grim aspen
#

I know fetch or reading .json works

#

Unless message intents ruined it

wheat mesa
#

what

wheat mesa
#

Spotify has custom integration with discord, I don’t believe so

rigid maple
#

Like adding a button to a website embed

sudden geyser
#

Not possible since it's custom for Discord and Spotify

rigid maple
#

oh ok thanks

ancient nova
#

I'm planning a good new feature for my bot

lyric mountain
#

ohno

ancient nova
#

🗿 you don't even know what it is yet

wheat mesa
#

I don’t think we need to in order to be afraid

sudden geyser
ancient nova
#

it will be "suspicious" behaviour detection type of thing. I have a few ideas for detection types. For example if the account is completely new it can be suspicious, have been in the server but only spam similar messages / don't type any message at all? Either an abondoned or spam account. I'm planning to come up with more stuff later

#

is this a good idea?

spark flint
#

doesn't discord basically have that

#

native

ancient nova
#

feels very fitting given my bot will be an anti raid bot

wheat mesa
ancient nova
spark flint
#

part of their spam account detection is things like an account going inactive for a period of time then becoming very active, things like new accounts spamming

#

its not instant

ancient nova
#

😳

spark flint
#

ok

#

what about things like false flags

ancient nova
#

good idea, will allow moderators to decide whether they're suspicious or not in the very end

wheat mesa
lyric mountain
wheat mesa
#

anti-discord server

ancient nova
slate hollow
#

Hi , what could be the cause of getting as an error while trying to implement the topgg webhook think

ancient nova
#

it will be a good idea, trust me

#

I'll first try making an example command out of it

#

then i will integrate to detect automatically

#

I'lll have options to notify owners / moderators, or ping staff in the bots modlog channel

idle cave
#

Hey 🙂

#

Do you have somme clue for caching stuff ?

#

To have one cache for all shards

#

I try express api -> not very convincing

#

I got some : FetchError: request to http://127.0.0.1:3002/players failed, reason: connect ECONNREFUSED 127.0.0.1:3002

#

There is other type of communication Thonkang ?

#

Like socket ?

lyric mountain
ancient nova
#

remember how you guys hated me for this code

#

it's not even that bad

wheat mesa
#

The biggest problem is the fucking formatting dude

ancient nova
#

I kinda see why it would be bad, but it's not that bad if you actually look at it

wheat mesa
#

It is that bad when I look at it

ancient nova
#

it's easily readable

wheat mesa
#

It’s really not though

#

It’s not as readable as it should be

sudden geyser
#

wait

#

are you not using a mono font

boreal iron
#

Very close

wheat mesa
boreal iron
#

Gooood

ancient nova
#

dude what's the stone hedge emoji called on PC

#

I can't find it

boreal iron
#

I always stop immediately when I’m texting don’t worry

earnest phoenix
#

FakE driving once again, how common

ancient nova
boreal iron
#

THE PIC HAD ANOTHER REASON

spark flint
ancient nova
spark flint
boreal iron
#

Now hate Baes code not me driving pls

#

Damn bun not smocking

ancient nova
#

guys

#

guys

#

I can't belive this

#

maybe I'll finally be able to get the presence intent

#

I found a great feature to add that will use it

boreal iron
#

Weeeeeeoooooowwww

ancient nova
#

I will monitor peoples presence as a part of the "suspicion" detection thing

earnest phoenix
ancient nova
#

not yet how, but I'm having a few ideas rn

earnest phoenix
#

I seriously don't get why some people don't use code formatters, it's just stupid

ancient nova
#

maybe to listen to their game presence, maybe whether they're on browser/mobile maybe try detecting a self bot that way

ancient nova
earnest phoenix
#

"indexer"?

ancient nova
#

indenter*

#

give a scrambled piece of code I'll show you how it does

#

it's pretty good

earnest phoenix
#

That indentation is rather ridiculous

ancient nova
earnest phoenix
#

I'm pretty sure you don't have your own indenter, probably just supplied custom indentation options to the code formatter

#

And why would you indent it that way?

ancient nova
#

but for me it's readable and I have no issues with it

earnest phoenix
#

For you it might be, but while showing it to others it's pretty bad, considering the 0 index indentation for the operator expressions

rose lance
#

hey, so I wondering if there is a way in SQL to join one table with multiple tables individual at once

table 1: id, date, reason
table 2: id, moderator, user
table 3: id, moderator, channel, amount

the result could be something like the one below I could imagine, but I have no idea how to achieve this
id, date, reason, moderator, user / none, channel / none, amount / none

boreal iron
ancient nova
#

if I have a number, or rather a bunch of numbers, say 4 and all were 27, how do I not make them go over 100?

#

do I just round it up or?

boreal iron
#

There are different types of JOINS depending on what you wanna do

#

But yes it’s doable easily

ancient nova
#

I don't think there is a function to force the number to stay between certain values in JS is there?

#

if it's over 100 just stay at 100 is it's below 0 just stay at 0?

#

guys? 😐

#

ok I'll code it myself, let me know if there is a more efficient way later moai

boreal iron
#

Import crypto and call randomInt()

#

You can specify a min and max value

ancient nova
rose lance
lyric mountain
#

yk you can't simply say "I'll use it in the algorithm" and hope for discord to fall for it

surreal sage
#

A random "undefined" in my console sobby

I log either true or false after each log made using my function (Exception for questions, identifiable using [?])

ancient nova
# lyric mountain how...exactly will you know if someone is suspicious from presence alone?

for example if someone has a self bot, their broswer presence is bound to be on for 24/7 since that's how bots work. if a bot is connected through a gateway they will have the broswer presence on, furthermore if someone has 2 presences at the same time, they can be using a selfbot and be on their phone and/or desktop so they will have both. I'm aware that it can be a fluke but it's a good way to actually tell if someone is self botting

lyric mountain
#

yk, some people don't turn off the internet at night

ancient nova
#

yeah that's why i said it can be a fluke, that's why I can also tell if their browser is on 24/7 but the other devices are on periodically

surreal sage
ancient nova
lyric mountain
#

they won't approve for that reason

#

you'll need to find a better excuse

ancient nova
lyric mountain
surreal sage
#

mb

lyric mountain
#

keep thinking

ancient nova
#

bruh I literally told you my reason, a possible self bot detector

lyric mountain
#

ye, not good enough

surreal sage
#
const log = {
    info: (string, success) => {
        console.log(`[${success ? colors.green.bold("INFO") : colors.cyan.bold("INFO")}] ${string ?? "Undefined"}`);
    },
    warn: (string) => {
        console.log(`[${colors.yellow.bold("WARN")}] ${string ?? "Undefined"}`);
    },
    err: (string) => {
        console.log(`[${colors.red.bold("ERROR")}] ${string ?? "Undefined"}`);
    },
    ask: (string) => {
        console.log(`[${colors.blue.bold("?")}] ${string ?? "Undefined"}`);
    },
};

let config = null;
function checkForConfig() {
    if (fs.existsSync(process.cwd() + "\\config.json")) {
        try {
            config = JSON.parse(fs.readFileSync(process.cwd() + "\\config.json"));
            log.info("Config(.json) found", true);
            console.log(true)
            return true;
        } catch (err) {
            log.err(err);
            console.log(false);
            return false;
        }
    } else {
        fs.writeFileSync("config.json", "[]");
        log.warn("Config(.json) wasn't found. I've created the file for you, please fill it out.");
        console.log(true);
        return false;
    }
}

let cookie = null;
if (checkForConfig()) {
    rl.question(log.ask("Cookie"), function (ckie) {
        cookie = ckie;
        startClient();
    });
}

async function startClient() {
    log.info("Starting client");
    console.log(false);```
Looks good enough for me
"undefined" comes after rl.question(log.ask("cookie"))
ancient nova
lyric mountain
ancient nova
#

ok let's wait for FakE he seems to be typing a long sentence

#

nvm he stopped

surreal sage
lyric mountain
surreal sage
#

You talking about const log = {?

lyric mountain
#

yes

surreal sage
#

Can come later

lyric mountain
#

you're printing only the error message, not the error stacktrace

surreal sage
#

Main problem is the undefined in my console

bright thorn
#

Hey guys

ancient nova
bright thorn
#

I want to start some shard which is down

#

Without client restart

surreal sage
#

Was thinking some dependency

bright thorn
#

Any idea how can I

lyric mountain
bright thorn
#

By evaluating

lyric mountain
#

you don't need it, you want it

ancient nova
#

well this is what I've done so far

#

a simple embed and a first factor

#

gonna make it look better soon

lyric mountain
boreal iron
lyric mountain
#

it's like finding a pizza in italy

bright thorn
#

Please see my msg

boreal iron
#

I feel like you wanna merge tables together rather than using join to get a combined result of multiple tables

surreal sage
#

damn

lyric mountain
#

it's made for that

bright thorn
#

Umm i don't want to start whole client

surreal sage
lyric mountain
surreal sage
#

question is how

lyric mountain
#

see the docs on how to properly restart a single shard

lyric mountain
surreal sage
lyric mountain
#

the error isn't a string, it's an object

#

and, if it follows the standard convention, it overrides the toString method to show the error message

#

which might not exist depending on the error

ancient nova
#

should I make it say true or false or yes and no?

#

not sure which one looks better

surreal sage
lyric mountain
#

you can't have "slightly true"

#

it is

lyric mountain
surreal sage
#

It'd start with "[ERROR]"

surreal sage
ancient nova
lyric mountain
#

nowhere else could print undefined

lyric mountain
#

please use a proper logging library, they include essential info on each line

surreal sage
#

No extra log

#

There isn't an error

lyric mountain
#

I cannot help u

ancient nova
#

wait @lyric mountain is it even possible to check how many messages a certain user sent?

lyric mountain
#

only if u track in the database

ancient nova
#

so there is no way to check how many messages the user has sent without tracking?

#

like doing something along message.member.messages.count ?

lyric mountain
#

no

ancient nova
#

you can check the count by doing

#

so how come a bot can't do that?

#

also whoa I sent so many messages here

boreal iron
#

I feel like you wanna merge tables together rather than using join to get a combined result of multiple tables

#

Yikes… internet dead

#

Omg

lyric mountain
boreal iron
#

Now it’s sending

lyric mountain
#

they can because it's their own api

boreal iron
ancient nova
boreal iron
#

Just had no internet to send it

earnest phoenix
lyric mountain
ancient nova
#

ok I have an idea on how to do that

boreal iron
#

Living on the EDGE in 2022

#

I like it

ancient nova
#

I could fetch only 10 messages

#

and if it fetched less than 10

#

flag the user

lyric mountain
#

...newcomers?

ancient nova
#

well what about dead accounts or alts that haven't sent anything?

#

u wanna kick them, right

lyric mountain
#

you're overthinking it and will end up having more false-positives than actual positives

lyric mountain
ancient nova
#

but they're in the server but have never ever sent anything in it

#

what's the point of them being there

earnest phoenix
#

Actually the discord.js server did that, but using the prune functionality

boreal iron
earnest phoenix
#

Kicked like thousands of people

ancient nova
#

they're 100% a dead account, and that could be a thing that I could flag

ancient nova
earnest phoenix
#

No, just use the prune functionality Discord provides, no need for such an additional feature

ancient nova
#

haven't done much yet

sudden geyser
#

Please use a mono-spaced font

sharp geyser
#

Damn we now busting his balls on the font

ancient nova
sharp geyser
lyric mountain
#

it's gonna be one hell of backfire

ancient nova
ancient nova
sudden geyser
#

No, seriously.

#

It looks bad.

#

Every time you take a screenshot.

ancient nova
#

if it's gonna flag it's only gonna flag it to around 25% every factor the bot will detect will add 25% to the final suspicion rate

lyric mountain
ancient nova
#

I will do that if it's over 75% then notify the owners

earnest phoenix
lyric mountain
#

if you're gonna accuse someone, u need solid evidences

ancient nova
#

what else besides messages then? I also wanted to check for similar messages spam

#

I may still be able to

#

if the last 10 messages are the same / really similar flag

#

is that at least good enough?

earnest phoenix
#

What even are you marking the users as suspicious for?

rose lance
ancient nova
#

I will use that in my anti nuke module later, right now I'm making it to be a function as an example

#

it won't do anything yet, but later I will make it do stuff automatically

#

basically a test command

lyric mountain
ancient nova
#

check for suspicious links in those 10 messages? :[

boreal iron
#

He doesn’t seem to understand that detection is not just a few statements but an advanced algorithm being updated constantly which already has as many use cases and edge cases to decide and detect if something matches your conditions or not

ancient nova
#

okay what else could be the factor then. I'm not looking to write a super extreme complicated algorithm just yet. I'm making an example command of how it could work

boreal iron
#

If you do provide 2 example tables structures I can show you how to use JOIN

#

Just need a few columns and the ID column all tables share

#

Somehow readable on mobile pls

spark flint
#

ok urgent one

#
                const channel = await modal.guild.channels.create(`appeal-${data.data[0].id}`, {
                    permissionOverwrites: [
                        {
                            id: modal.user.id,
                            allow: [Permissions.FLAGS.VIEW_CHANNEL, Permissions.FLAGS.SEND_MESSAGES, Permissions.FLAGS.ATTACH_FILES, Permissions.FLAGS.EMBED_LINKS],
                        }
                    ],
                    parent: serverConfig.appealsCategory
                })```
#

permissionsOverwrites isn't working

#

its granting Everyone perms to see the channel

boreal iron
#

Don’t u need to deny the everyone role to see the channel?

ancient nova
ancient nova
#

I had to do that

spark flint
#

o

#

i looked at docs and it didn't mention that kek

ancient nova
#

just add this

                   {
                        id: message.guild.roles.everyone,
                        deny: ['VIEW_CHANNEL', 'SEND_MESSAGES', 'READ_MESSAGE_HISTORY']
                    }
spark flint
#

apparently it should fallback on the default category option

boreal iron
#

I mean if everyone has the permission to view channels by default you will most likely need an overwrite for this role to deny it for this channel

#

Thinking logically about this

#

But yeah I’m not really into channel management or permissions

ancient nova
#

can you check if the account is verified? somehow?

boreal iron
#

But I do assume I’m right. About that one

ancient nova
#

I think not being verified by email and/or number could be suspicious

#

is there a way to check that in discord.js?

boreal iron
#

Go to the docs, select the user or guild member class and check the existing properties

#

Instead of letting somebody else do the job for you

#

In the first place

ancient nova
#

sure

#

oh my fucking god why is it so slow

sharp geyser
#

first time on the docs page always slow

ancient nova
sharp geyser
ancient nova
#

also it's not loading

sharp geyser
#

discord.js issue

ancient nova
#

well it's not loading so I can't check it

#

can someone just tell me

#

:]

sharp geyser
#

What are you wanting to know

ancient nova
#

if you can check if the account is verified by email/ phone number

sharp geyser
#

Not without oauth

ancient nova
#

hmm I see

boreal iron
#

I mean you can

sharp geyser
#

email is a prop you get with the identify scope

ancient nova
#

I don't want to check email

sharp geyser
#

so without that its hard to tell

ancient nova
#

I just wanna check if the account is verified

sharp geyser
#

I was sure it needed oauth

ancient nova
boreal iron
#

If a guild enforces a specific security level and a guild member is typing you indirectly know he at least matches this security level

sharp geyser
#

Thats a roundabout way

boreal iron
#

Yeah

sharp geyser
#

Not the most ideal

boreal iron
#

Not meant you can directly check it

sharp geyser
#

It is definitely a way to check though

#

But this relies on the guild having any sort of security level

ancient nova
#

how would that actually work code wise I cannot imagine that

sharp geyser
#

You could do it when they send a message, or when they join the guild

boreal iron
#

But without a guild enforcing some sort of security level you won’t know anyways

sharp geyser
#

Yea but this also still relies on the guild even setting a security level no?

boreal iron
#

So yeah not much reliable

ancient nova
#

I see

sharp geyser
#

If it isn't reliable I wouldn't do it

#

its a waste of time

boreal iron
#

True

sharp geyser
#

At least for your use case it is

boreal iron
#

But speaking about security built into discord or a bot and not enforcing the given options you have doesn’t make much sense, too

ancient nova
#

I need more ways to check the trust though, do you guys have any ideas?

sharp geyser
#

One thing you can do is make a website with oauth and have it as a "verification" thing

#

they visit, click a button to see if they have an email/phone number linked to account and if so they can interact with the community but again

#

this is pointless as discord already has this

ancient nova
#

so far I check the date of the account and the appearance of it, only 2 factors. You guys rejected checking messages so that's off as well

sharp geyser
#

this is only if you are adamant on implementing this

boreal iron
#

The rules feature or however it is called

#

You have to agree to

sharp geyser
#

yea

#

also I dont even think you can get the phone number in oauth

#

so even then it'd be one less way of checking for verified phone numbers

ancient nova
#

it's fine, it was just an idea, I'm not too keen on implementing that

#

I do need some other ideas though, those that are actually useful

boreal iron
#

If there’s an app redirecting me inside discord to a website outside discord to use the OAUTH flow to get verified I’m gonna quickly leave the server again

sharp geyser
#

yea

ancient nova
#

so what is why I'm not going to do that

sharp geyser
#

thats also reliable

ancient nova
#

how do I turn a string into a bool?

#

I wanna check a variable

#

that returns a string

#

not specifically true or false but values

#

if the string is null (empty) it should be false, if it's filled with something it should be true

#

I know how to do that but it would probably be inefficient

sharp geyser
#

I mean technically a string can already be considered a bool as it is a truthy value

#

even "empty" strings return true

ancient nova
#

yeah that's why I would check for length, hence it being inefficient

#

any better ideas?

ancient nova
sharp geyser
#

if its length is 0 its false if its 1 or more its true

wheat mesa
#

Can you elaborate on what you’re trying to do

ancient nova
#

no the actual variable will return null if there isn't any string being sent

ancient nova
#

I wanna check if the user is active on browser

sharp geyser
#

Wait a sec

wheat mesa
#

What

sharp geyser
#

is "" actually a falsey value?

wheat mesa
#

Yes

sharp geyser
#

I thought even empty strings were truthy

wheat mesa
#

You’re thinking of empty arrays

sharp geyser
#

Oh right

#

Mixed up

#

ty waffle for clarifying

wheat mesa
sharp geyser
#

yea

#

also

#

Live Tucker Reaction

wheat mesa
#

Yes

boreal iron
sharp geyser
#

I mean

#

It is a fairly good idea

#

Just not fit for discord at all

#

Some servers do require you to show your ID with everything but the DOB and Picture of you blurred

#

that's only the 18+ servers tho

wheat mesa
#

I would never ever give that information away

sharp geyser
#

same

#

porn aint worth that

#

I will just google that shit

boreal iron
#

Not even then I would give it away tbh

sharp geyser
#

Yea nah

#

but he had a good idea

#

just the setting was wrong

#

If it would of been for some other company like a security company or smth

#

by all means go for it

ancient nova
#

worked fine

boreal iron
#

Authorizing a payment or fullfilling a contract to indentify you as person, yes but not for any other use case

sharp geyser
#

yea

sharp geyser
ancient nova
#

should I still check the last 10 messages as well? I can just check if they contain malicious links that's it

sharp geyser
#

forcing a bool conversion is unnecessary in a lot of cases

wheat mesa
#

Ah it’s not a terrible practice so long as you understand the caveats

sharp geyser
#

Oh?

#

I thought forcing a conversion should be avoided if possible

wheat mesa
#

I’ve used it a few times personally to check string length in a shorthand and cleaner way

ancient nova
#

lol the way I did it would probably make you guys cry

sharp geyser
#

most likely

wheat mesa
#

Otherwise I would be doing if(string.length === 0) which I’m too lazy for

sharp geyser
#

Also who the fuck knows rxjs

wheat mesa
#

So I just used if(!!string)

sharp geyser
#

I don't get this shit

wheat mesa
#

But it’s definitely not a good idea if you don’t know the type conversions well and you don’t necessarily know if a different type will be present

ancient nova
#

!!member.presence?.clientStatus?.web
the first !! is obviously to convert it to a boolean
the first ? is because if the user is completely offline clientStatus won't show so it will return undefined
the second ? is because if the user isn't explicidly on web it will return null, not undefined
hence my confusion

#

but I do get it now

wheat mesa
#

Is this a selfbot..?

ancient nova
#

no I just check if the user is on the website before doing the actual checking

sharp geyser
#

this is only cause a presence could not exist on a member

#

especially if its a partial member object

#

and clientStatus may just not exist on presence at all cause of some other wacky shit

wheat mesa
#

What

ancient nova
#

for now I'll just let it stay this way

sharp geyser
#

From my understanding of how djs does it, presence is nullable cause it could not exist either cause they don't have one (or whatever) or its a partial member object

#

Unless we are talking about different things

#

then ignore me

#

:)

ancient nova
#

it won't exist if 1. the user isn't online at all or 2. is connected through a different device I think

#

or the user isn't cached, if they aren't you can simply fetch them anyway

sharp geyser
wheat mesa
#

No

sharp geyser
#

Same

wheat mesa
#

I’ve just been making a stack machine in rust

sharp geyser
#

nice

boreal iron
#

stack machine?

#

Somehow sounds like slot machine

ancient nova
#

integrated the suspicion count into the whois command as well

#

looks like it fits

#

gonna have to think of a couple ways to automate the detection

lyric mountain
#

I surely hope the suspicion score isn't global mmLol

rustic nova
#

sus score

boreal iron
#

How about No instead of False

#

Tf

ancient nova
#

why tf?

#

people won't know what true/false means?

rustic nova
#

replace Created with the unix time

#

same thing

ancient nova
#

also the permit thing broke again...

#

just noticed

boreal iron
ancient nova
#

😭

#

easy fix though

ancient nova
boreal iron
#

Also I feel like this might be another stringified boolean in your database

#

Am I Right?

ancient nova
boreal iron
#

That’s a yes?

#

If so I would call it pet code cruelty

ancient nova
#

looks great

boreal iron
#

Storing booleans as string isn’t bad? Wut

#

You’re drunk or on crack?

ancient nova
boreal iron
#

Ok both

ancient nova
#

I've never experienced any slowness because of this

boreal iron
#

@earnest phoenix get your ass here and explain this

ancient nova
boreal iron
#

Ok you’re under code arrest until he explains himself

#

Go into jail now and don’t take the 200 bucks

boreal iron
#

Touching code again and you will be sentenced

#

You should rename is suspicious into sus-o-meter

sharp geyser
#

I am being dumb again

#

I am also not used to Angular

boreal iron
#

We know, we know

ancient nova
sharp geyser
#

so I am majorly fucking up