#development

1 messages ยท Page 770 of 1

quartz kindle
#

i think most common prefixes get automatically muted in the testing channels

blissful scaffold
#

I don't think bots really should use / as a prefix because it is also used in Discord itself

#

/shrug

short siren
#

I think bots should uses suffixes instead help! :P

hoary elm
#

I need some help with Discord.JS

I have a permissions set up for certain commands that looks something like this


if (admin_role && message.member.roles.has(admin_role.id)) permlvl = 2;``` 

The problem I am having is it doesn't let the commands run if I have them locked to the perm level ๐Ÿค” it was working up till yesterday thought I would ask as I have seen a few people saying they are having issues with Discord.JS
#

No error and no depreciation warning either just randomly stopped working

warm marsh
#

find takes a function

#

You should see a dep warning in the console

#
<Guild>#roles.find(name => name === settings.adminrolename);
hoary elm
#

There is no dep warning

#

No error

#

It was working up untill yesterday

warm marsh
#

Even still, Make it a function so in the future you don't get a dep warning.

#

Also that might not even be the piece of code causing it to void

hoary elm
#

Ok just for the find function

#

Or has to?

warm marsh
#

Nah

#

just find

#

but you could change it into get

hoary elm
#

Yeah I actually just noticed the part causing it is this

#

It's not liking reading my ID that way

warm marsh
#
message.guild.roles.get(settings.adminrole.id);
#

Maybe your settings object/json is broken?

hoary elm
#

Maybe

#

I'll look into it now that I figured out what it is

#

Thanks for your help

warm marsh
#

๐Ÿ‘

hoary elm
#

Do you know an alternative I could use for it using my ID

#

Outside of a JSON

warm marsh
#

A database?

hoary elm
#

True

warm marsh
#

Which is pretty overkill for id storing

hoary elm
#

What about .env?

warm marsh
#

That works

#

Although you could also use the bot

#

client.fetchApplication().owner.id

hoary elm
#

Okay

#

Thanks again ๐Ÿ˜

uneven wyvern
#

js
<Guild>#roles.find(name => name === settings.adminrolename);

@warm marsh

This won't work at all, you can't just do name => name

warm marsh
#
let { owner: { id } } = await client.fetchApplication();

#

My mistake

uneven wyvern
#

Np just to let u know

warm marsh
#

I meant js ...find(r => r.name === ...);

hoary elm
#

@uneven wyvern I was actually just gonna ask about a function option

#

Of nvm wrong thing you were talking about the role ๐Ÿคฆ๐Ÿปโ€โ™‚๏ธ

#

I will change that setup regardless just to avoid future problems.

vague kite
#

Hey guys I needed some help so I'm trying to host a dashboard for my bot, and when I test my dashboard on localhost it works fine but when I test it on my host I keep getting Invalid OAuth2 redirect_uri I'm pretty sure I put the right redirects in but not too sure

restive furnace
#

The error tells you the error, so the redirect_uri isnt right.

vague kite
#

So for the redirects would I need to put in my server IP or can I put my domain for the website

quartz kindle
#

a website shouldnt be using port 3000

modest maple
#

isnt that the port glitch uses

quartz kindle
#

yes, but its behind their reverse proxy

modest maple
#

good point

quartz kindle
#

the external port is actually normal http/https

vague kite
#

It's the port I'm using on Digitalocean

#

Which port should it be using then??

quartz kindle
#

is your website running on express?

modest maple
#

well what port does Digitialocean have open?

vague kite
#

Yeah using express to run it

quartz kindle
#

you should look into using a reverse proxy

#

like nginx

#

and configure SSL

vague kite
quartz kindle
#

ah so you are

vague kite
#

Yeah I set it up already

quartz kindle
#

but its http only right? or do you have https?

vague kite
#

https

#

I set up SSL on it

quartz kindle
#

good

#

then you dont need to specify any port

#

port 3000 is the internal port, its only between nginx and express

#

to connect from outside to nginx, use normal https

vague kite
#

Would I need to specify a port in my config then??

quartz kindle
#

the only place you need to specify a port is in your express server

#

and nginx of course

#

everything else uses http/https which are port 80 and 443 by default, but you dont specify them, the url already does

#

for example, https://alitadashboard.tk automatically uses port 443, because its https. and it conencts to your nginx, that is listening to port 443

#

then nginx forwards it to port 3000, which is express

#

but the outside world doesnt know express exists

#

they only see the nginx server on port 443

vague kite
#

Okay thank you will test that out right now

quartz kindle
#

so basically, all your urls and redirects should not specify any port

vague kite
#

Also in discord dev would I need to put the IP of the server has https://IP or do I just leave that out?

quartz kindle
#

use the domain name

#

nobody needs to know any ip or port, you have a domain name, and you have nginx

#

so you have a perfectly standard website configuration

vague kite
#

Okay thx

earnest phoenix
#

o hello

grizzled valley
#
async def ask(ctx, *,query):
    res = bot.query(query)
    ans = next(res.results).text
    await ctx.send(ans)

results in the following error

Traceback (most recent call last):
  File "C:\Users\S Som\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\ext\commands\core.py", line 79, in wrapped
    ret = await coro(*args, **kwargs)
  File "D:\Saved Pictures\bot.py", line 432, in ask
    ans = next(res.results).text
  File "C:\Users\S Som\AppData\Local\Programs\Python\Python37-32\lib\site-packages\wolframalpha\__init__.py", line 90, in __getattr__
    raise AttributeError(name)
AttributeError: results```
modest maple
#

who ever made that package needs to be shot for such a shit error description

#

but assides from that

#

looks like you dont have an attribute called .results

grizzled valley
#

nope it works sometimes

#

thats the thing

#

and each time the error is different

#

sometimes it says coroutine stopped iterating

#

some time no attribute next

#

wtf is it

modest maple
#

get a better lib

#

problem solved

#

xD

earnest phoenix
#

How can I make the bot use an invite for you? For example you authorize him, and he uses an invite for the user who authorized him to do that. (to get invited in a special-only user discord)

#

Can't find examples on internet.

modest maple
#

you cant

grizzled valley
#

xD

earnest phoenix
#

Well I can.

#

Actually

#

I want to create what other websites did.

modest maple
#

idk what your actually asking tbh

#

do you mean make an invite

#

or what

#

your sentence doesnt make much sense

earnest phoenix
#

Because its weird to explain

#

So, lets say you are premium on a forum. You can join a premium-only discord server, but you have to click a link which authorizes a bot to use invites for you.

#

Then in ~1 min you're in their discord server

modest maple
#

yehhh i dont think bots can actually do that

earnest phoenix
#

Idk how they managed to do this, they are not partners with discord or anything.

#

And it's not the first time a website uses this method

modest maple
#

i think you're looking for oath grants

#

not bots

earnest phoenix
#

Oh?

modest maple
#

it comes up with the same auth screan

#

screen*

earnest phoenix
#

oh, okay. I'll check into that.

modest maple
earnest phoenix
#

ty

modest maple
#

only thing i can think of

earnest phoenix
#

yup

#

there's a scope to join guilds for the user

modest maple
#

its times when making a massive DB that im glad that ORM frameworks exist

#

they save

#

so much time

earnest phoenix
#

ikr

#

i hate handwriting sql because i derp everywhere

modest maple
#

yh

#

i dont mind it for small dbs

#

like 2 column ones

#

but god is orm nice

blissful scaffold
#

I usually write my own SQL

#

so far I haven't erased the DB of my bot

modest maple
#

i aint writing my own sql for a 24 column db which contains objects

#

xD

#

fuck that shit

quartz kindle
#

i just save json as text in one column

#

i only keep separate columns for stuff that needs to be indexed

modest maple
#

what im doing sorta

#

alot of the columns already r in json format

#

but squishing them all together is gonna make it such a mess its easier and cleaner just to have seperate columns for seperating them

snow urchin
#

For my message event, how can I have my bot check if the message contains an embed, and if it does, how can i have the code return the embed title

earnest phoenix
#

in which library

snow urchin
#

discord.js

snow urchin
earnest phoenix
sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

west raptor
#

probably need to clean and rebuild node_modules it looks like

quartz kindle
#

check if your modules are compatible with visual studio 2019

west raptor
#

@quartz kindle It says there's a corrupt file, I doubt it's that

#

there would be a different error it was a build tools problem

warm marsh
#

Anyone know where I can find how often a certain request to the API can be found?

earnest phoenix
#

ratelimits aren't static

#

follow the ratelimits returned in the request headers

#

chances are if you're using a lib it already handles it for you

warm marsh
#

But just in-case

earnest phoenix
#

again

#

ratelimits aren't static
follow the ratelimits returned in the request headers

blissful scaffold
#

If you really want to find the rate limits then check the headers

tiny tinsel
#

I need y'all help for sentences example: Drop at, Land at, Start at If you guys have suggestions It would be appreciated.

So far I have:

"Alright, start at: ", 
"Go to: ", 
"Let's the party begin at: ", 
"You have to drop at: ", 
"Drop at: ", 
"Please drop to: ", 
"Land to: ", 
"You have to land to: "
summer torrent
#

I dont understand

tiny tinsel
#

I need suggestions / sentences for my project.

#

That suggest users where to drop.

#

But having just "Drop at: x location" was boring.

abstract crow
#

Wait I put it in the ApplicationDbContextModelSnapshot.cs file

tiny tinsel
#

No.

#

That's your migration snapshot wait.

abstract crow
#

Yeah I messed up

tiny tinsel
#

Yeah.

#

That's your snapshots (Migrations history)

abstract crow
#
The entity type 'Assignment' requires a primary key to be defined. If you intended to use a keyless entity type call 'HasNoKey()'.
tiny tinsel
#

@abstract crow That's because your Assignment has no Id.

#

You can tell Entity framework to build your model with no Primary key (Id)

abstract crow
#

Should I provide an ID? My assignment is setup by the user and its only for them so I didn't think I needed them

#

Same with Teacher

tiny tinsel
#

You should.

abstract crow
#

And Classroom

#

Ok

tiny tinsel
#

Because Entity framework will do relationships for you.

abstract crow
#

But how do I assign an Id?

tiny tinsel
#

It gonna auto increment.

daring sand
#

do you want that table to have a PK auto increment? if so search for "EF attribute Primary Key"

abstract crow
#

Ah ok. So just public int Id { get; set; }

tiny tinsel
#

Yes.

abstract crow
#

Ok

#

Yay it worked!!!

tiny tinsel
#

Else if you really don't need key:

protected override void OnModelCreating(ModelBuilder modelBuilder)
   {
       modelBuilder.Entity<Assignment>().HasNoKey();
   }
#

You can override the method OnModelCreating and use ModelBuilder.

abstract crow
#

Ah gotcha. Imma just use the Ids for now since its recommended

tiny tinsel
#

It is always better. For relationships or If example one day you have a problem with Assignment. You can write a query and search it with It Id.

abstract crow
#

True

tiny tinsel
#

SELECT * from Assignments where ID = 1;

abstract crow
#

Also(sorry lol) I have another question... Now that I can put in data, I am not sure where to go about this now. I know I need to create a controller which will feed the data to the razor pages, but I'm not sure how I incorporate the SQL data in the controller

tiny tinsel
#

That's where I'd use Dependency Injection, Repositories, Interfaces

abstract crow
tiny tinsel
#

There is different way to do it.

abstract crow
#

Directly in the Razor page?

tiny tinsel
#

Well you could.

#

But the proper way is to create a Folder called Repositories by example.

#

And create a AssignmentRepository class.

#
public interface IAssignmentRepository
    {
        void Create();
        void Delete();
        void Update();
    }

    public class AssignmentRepository : IAssignmentRepository
    {
        void Create()
        {
            ...
        }
        void Delete()
        {
            ...
        }
        void Update()
        {
            ...
        }
    }
#

In your Startup.cs you would have to use something like <Something>.AddScoped<IAssigmentRepository, AssignmentRepository>();.

#

And in your Razor page It would look like:

  private IAssignmentRepository _assignments;
  public <Your Controller Name> (IAssigmentRepository assignmentRepository) {
     _assignments = assignmentRepository;
  }

  public Index() {
     return _assignments.GetById(1);
  }
#

Assuming you have GetById() in your AssignmentRepository. method.

#

That's the proper way to do it.

abstract crow
#

Mhm. I mean I hate to say it but it seems like a little bit too complicated for me rn. I also like the controllers because it just seems more organized for me

snow urchin
#

Right, would it be easy to make something like the following:

User: b!stt
Bot: Command not found, did you mean "stats"?

tiny tinsel
#

@abstract crow Didn't say to use it haha. It is the proper way to do it. But you could do it directly in the controller. It is fine.

abstract crow
#

Ah gotcha ๐Ÿ™‚

tiny tinsel
#

@snow urchin Yes.

#

@snow urchin Well no.

snow urchin
#

.

tiny tinsel
#

I don't know It is up to you.

#

Have you heard of the Levenshtein distance?

snow urchin
#

No

tiny tinsel
#

It is a string metric to measure the similarity between two strings.

#

There is probably libs that will do it for you.

#

@snow urchin What language you use?

snow urchin
#

Javascript - Discord.js

tiny tinsel
#

Are you willing to pay for a service or you wanna do it yourself?

snow urchin
#

I am not willing to pay

tiny tinsel
earnest phoenix
#

It's not hard to write your own function for it though

tiny tinsel
#

For string similitude?

#

I mean you could with Leveinstein Distance or with Contains, Includes, StartsWith, EndsWith, Regex etc..

sick cloud
#

is express broken for node 13?
TypeError: Cannot read property 'lazyrouter' of undefined

west raptor
#

@sick cloud possibly, did it just start happening when you upgraded?

sick cloud
#

@west raptor yeah, i think i got it though

#

its cus i'm using ES

#

like import and all

west raptor
#

Ah ok

sudden geyser
#

were you possibly using destruction methods

abstract crow
#

@tiny tinsel Apologies bud, I got another question for you. In the midst of all this I realized one thing. Each model(classroom, teacher, and assignment) are different for each student. When a student logs in, I want it to show only their stuff. That means that we may have duplicate entries of teachers in the database(which is fine) as 2 students may have the same teacher. The point of the site is that the student chooses everything and its only for them. How would I be able to filter out these results so I can have them just for the student? The student has an email, but I don't know how I can associate the email with each model..

glad charm
#

Well it's obviously a many to many relationship.
Say a student has an array of teacher_id's for each teacher for X class. And a Teacher has student_id's for each student in their class. Where do you think there will be dups?

abstract crow
#

The student_ids are going to be duplicated for the teachers and the teacher_ids for the students

glad charm
#

Are you using SQL?

abstract crow
#

Unless I add each and every teacher manually, then you select which teacher. Then I have to do that for classes which is impossible

#

Yes

glad charm
#

You can return only unique results if you want.

abstract crow
#

Right but how can I associate a user's teacher with that user

glad charm
#

I'm going to assume table names here
SELECT DISTINCT ARRAY(teacher_id) FROM student WHERE student.id = @someId

#

Kinda get the idea?

abstract crow
#

Not really. Lets say I want to list all teachers a student has. I need to associate the teachers with each student

glad charm
#

Right so above we just got the teacher id's for a specific student.

#

Using those id's we can get the teachers info if we so need.

tiny tinsel
quartz hill
#

I want to use Shard. But I have one that should be global hashmap. How can I synchronize it. Sometimes a place is deleted from the hashmap, sometimes it is added.

#

nodejs lang

#

I know how to create a shard. bot is currently working in a single shard. the problem starts when there are many. I have to share what should be global hashmap. Sometimes I need to delete some of them from every shards.

modest maple
#

You can't rlly

#

Unless you're running seperate processes they should see the same hashmap

#

But they're is no way to properly sync them because well the whole idea it's async

#

That's why global vars are not recomm amung other things

analog roost
#

UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "url" argument must be of type string. Received type undefined

#

?

#

so what did I do wrong this time

valid frigate
#

there is maybe an exception to the rules of no global variables and that's if the value will remain constant

#

a constant variable is pretty much no different than reading from a .json file only, so in a sense it's useful for database clients and discord clients

#

well actually not discord clients

#

your best bet is probably using something like redis, which is an in-memory database meant to handle that kind of stuff (such as command cooldown handlers and other things that must change often amongst multiple processes)

warm marsh
#

@analog roost read the error.

analog roost
#

alright

west spoke
#

i believe

#

thats how that would work

glacial mango
#

Can I send a message to a channel every time a new song is playing? I'm using Discord.js & ytdl-core

marble juniper
#

well if you have stored the text channel of where the user used the play command

#

you can upon the dispatcher ends

#

with .on('end')

#

end event

#

you can then send a message with the new song playing

#

to the channel

glacial mango
#

So? js dispatcher.on('end') { //code here }

marble juniper
#

kind of

#

wait

#

let me grab some code from my music bot

#

it uses ytdl-core too

glacial mango
marble juniper
#
dispatcher.on("end", () => {
       //code here
})
#

dispatcher is in this case your variable with the voice channel connection you are playing the song to

glacial mango
#

Thank you

half spear
#

Ok so weird random question: With bot cooldown messages, I noticed my bot got declined originally for having them, If i was to make it so a cooldown msg auto deletes itself after around 4 seconds would it be allowed, I ask since Ive seen bots like Tatsumaki get away with it doing that?

late hill
#

How did you implement these cooldown messages before

#

Because if someone uses a command and the bot replies with something along the lines of "Please wait x before doing this again", that should be completely fine..

gusty tartan
tiny tinsel
#

@gusty tartan What command do you use?

#

To install it.

gusty tartan
#

service mongod start

tiny tinsel
#

Did you try to start with sudo?

half spear
#

@late hill I think i used a embed msg with the same sort of message, Ill redo it with the format you put. Thanks.

golden condor
#

Does anyone have any alternatives to ytdl-core and YouTube API?

#

With a music bot

modest maple
#

lava link

golden condor
#

I've tried using lavalink but I can't get it working, ytdl and opus works best for me

#

It works quite well with high sound quality

gusty tartan
#

@tiny tinsel yeah i did start it with sudo

#

i can try again

#

Nope even with sudo it still throw that error

humble pendant
#

damn

jade briar
#

hello,
how do I get a new player role?
i try let role = NewMember.roles.filter(roled => !oldMember.roles.has(roled)).first()

#

ohhh

grizzled raven
#

hm

earnest phoenix
#

what the fuck lmao

#

oh ok

grizzled raven
#

whats the ratelimit for fetching messages?

slender thistle
#

Fetching messages doesn't have ratelimits apparently

#

It's up to you as a dev to ensure you don't send requests unnecessarily

grizzled raven
#

oh

#

huh

fluid sapphire
#

can someone help me?

#

This is a cmd for a privatemessage

if(message.content.startsWith(${prefix}dm)){
message.delete();
var user = message.mentions.users.first();
var text = message.content.split(' ').slice(2).join(' ');

if(!user) return message.channel.send("Du hast keinen Nutzer angegeben!");
if(!text) return message.channel.send("Du musst ja schon ne Nachricht angeben");
user.send(text)

}

grizzled raven
#

whats the problem

fluid sapphire
#

it dosn`t send the privatemessage

#

?

blissful scaffold
#

Looks like you only send a message when there is no user or no text

fluid sapphire
#

ok

#

but when I don`t write a user or text it send me the message for no user or no text

blissful scaffold
#

I was wrong, it looks ok to me

fluid sapphire
#

ok

#

I also mean it`s ok

#

I find the problem

earnest phoenix
glad charm
#

Why did you upload a txt and use a code block

topaz fjord
#

Too big

#

once a message goes over 2k discord sends it as a text file @glad charm

glad charm
#

Since when?

#

That must be recent.

topaz fjord
#

Since canary

glad charm
#

gg

modest maple
#

its been a thing for the last couple weeks

modest maple
#

DaTaBaSE iS LoCKeD

jade briar
#
function rang (item) {
       ranks.forEach(rank => {

  
     
        if(item == rank.position){ 
          console.log(rank.name)
         
           return rank.name
       }
       else return "net"
       })
    }
    console.log(rang(2))
#

why return undefined ?

earnest phoenix
#

you tell me

late hill
#

you can't return in a forEach

#

and even if you could

#

you'd still have an issue because you'd return on the first iteration

fluid sapphire
#

where can I host my discord bot for free (24/7)

glad charm
#

Google Cloud gives you a year free and I believe AWS also does if you can deal with that.

#

You can also host on your own PC or a RPi

fluid sapphire
#

yeah i haven`t an rpi but thanks for the first ๐Ÿ‘

uneven wyvern
#

how can i get home addresses and that stuff from a ip?

glad charm
#

What the

uneven wyvern
#

what wrong?

modest maple
#

ever heard of the term privacy xD

#

you can geo locate an ip

#

but that wont give you the exact adress most of the time

slender thistle
#

Dynamic IP ftw

modest maple
#

and will get blocked by any dns

uneven wyvern
#

well how would I geo locate a ip?

modest maple
#

why df do you want to

uneven wyvern
#

well, just wanna know how to

modest maple
#

best advise: dont

#

xD

#

not for bots

uneven wyvern
#

why? xD

slender thistle
#

That's not usually what you should know

modest maple
#

because people rather enjoy not having their addresses logged / shown on a digital platform

slender thistle
#

I'm fairly sure I personally wouldn't like to see my home address posted somewhere on the Internet just because I visited some fucking website

#

even if it was way off

modest maple
#

i wouldnt fucking want a bot that knows my address or even my ip

quartz kindle
#

how would a bot even obtain such information?

modest maple
#

ToS breaking ways

quartz kindle
#

anyhow ip geolocation requires a database of ips and addresses, there are some websites and companies that offer such services, such as maxmind

lofty hamlet
#

Hi for the revocation link token it is : https://discordapp.com/api/oauth2/token/revoke?access_token=TOKEN ?

bitter sundial
#

a lot of sites geolocate the country of a user via an IP

uneven wyvern
#

@bitter sundial well each of them gives you an different location

quartz kindle
#

because they all use different databases

modest maple
#

because DNS' exist

#

and vpns

bitter sundial
#

@lofty hamlet if Discord follows the RFC 7009 standard for Oauth 2.0 Token Revocation, it should be a POST request there with an urlencoded body (tho apparently query string parameters as you have shown are accepted by Discord API for whatever reason).
The parameter would be token with an optional parameter token_type_hint which would be set to access_token in your case.
You will also need your client id and secret.

#

example

POST /api/oauth2/token/revoke HTTP/1.1
Host: discordapp.com
Content-Type: application/x-www-form-urlencoded

token=aBcD123&client_id=987654321&client_secret=45uVW67Xyz
lofty hamlet
#

@bitter sundial this is token = and not access_token = ?

#

And i do put the client id and secret ok

#

message "405: Method Not Allowed"

wheat jolt
#

I want to make an android app. Android Studio lets me choose Kotlin or Java as coding language. Which is more similar to node.js?

glad charm
#

Uh, neither that I'm aware of

sterile minnow
#

idk

quartz kindle
#

android itself is based on java, so not much choice there

#

if you want to use node, you need to code an app that uses webview or something

#

there are a few compilers out there that can build js code to something android compatible

#

but its not an easy thing

lofty hamlet
#

@quartz kindle u can help me plz ?

wheat jolt
#

I don't want to use node.js

#

I want to use Kotlin or Java

#

but i don't know which

topaz fjord
#

kotlin

#

@vital lark amirite

earnest phoenix
#

i mean there are frameworks like xamarin but that's for c#

topaz fjord
#

which cry is this

slender thistle
#

The og

earnest phoenix
#

yee

topaz fjord
#

the og one

#

oh

#

what happened to the pfp

earnest phoenix
#

idk at this pointlol

topaz fjord
#

oh

earnest phoenix
#

anyways, i dont think node would perform well on arm anyways

blissful scaffold
#

RPi is arm and it runs ok on that

twin pendant
#

anyone good at reaction collectors?

var embed = new Discord.RichEmbed()
        .setTitle(pollTitle)
        .setDescription(desc)
        .setTimestamp()
        .setFooter(`initiated by ${message.author.username}`)
    let emb = await message.channel.send(embed)
    await emb.react('๐Ÿ…ฐ๏ธ');
    await emb.react('๐Ÿ…ฑ๏ธ');
    const reactions = await emb.awaitReactions(reaction => reaction.emoji.name=='๐Ÿ…ฐ' || reaction.emoji.name=='๐Ÿ…ฑ', {time:pollTimeout});
    console.log(reactions.get('๐Ÿ…ฐ').count);

this tells me that it cant read the property count of undefined

restive furnace
#

whats wrong rn?

twin pendant
#

even tho i react with ๐Ÿ…ฐ๏ธ

west raptor
#

that's a lot of awaits

twin pendant
#

yup, is that bad?

west raptor
#

not really

#

anyways, what's the issue

twin pendant
#

hm ok i just cant figure out why it wont work , i copied it exactly from a video

modest maple
#

theres ur issue

#

copy + paste = bad

twin pendant
#

i mean i edited it for my use

west raptor
#

outdated probably

twin pendant
#

maybe ill read the docs lmao

modest maple
#

yh

west raptor
#

are you on master or stable

twin pendant
#

uhhh

#

6.4.1

west raptor
#

6.4.1 d.js?

twin pendant
#

thats a problem...

#

yup

west raptor
#

how the fuck did you manage that

modest maple
#

you are like 6 versions behind

#

thats excluding updates

twin pendant
#

i made this bot ages ago and kept adding commands and making it better

modest maple
#

on 6.4!?

twin pendant
#

lemme see

#

was made on the 18th of march 2019

#

idk when 6.4 was released but i think i just did npm i discord.js when i created it

quartz kindle
#

1 year is not even that old

#

my bot is like 3 years old, and back then d.js was already on version 11

#

are you sure thats not your node.js version?

twin pendant
#

well i did npm -v discord.js

#

and it gave me 6.4.1

quartz kindle
#

that makes no sense lmao

modest maple
#

002_holy_fuck how df did that

#

how did you do that

twin pendant
#

genuinely dont know

modest maple
#

how did you not notice

#

that like everything

quartz kindle
#

there isnt even a version 6

modest maple
#

was diffrent

quartz kindle
#

anymore

modest maple
#

hes gone back in time

twin pendant
quartz kindle
#

show your package.json

#

oh wait

#

thats your npm version

#

lolololol

twin pendant
#

bruhh what

quartz kindle
#

you cant use npm -v on a package

twin pendant
#

dam

quartz kindle
#

either open your package.json or try npm view discord.js

twin pendant
#

ok thanks, it said im on 11.5.1

modest maple
#

thank jesus

twin pendant
#

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

earnest phoenix
amber fractal
#

changing the x and y

#

you set it to 25 25

#

200 200 is the width and height

earnest phoenix
#

go to the arguments press backspace and then your coords

#

@amber fractal i will try thx

amber fractal
#

well where are you trying to place it

earnest phoenix
#

in middle

amber fractal
#

Images in canvas draw from the top left so do you know how to center an image that draws from the top left?

earnest phoenix
#

no

slender thistle
#

max_width / 2, max_height / 2

#

:^)

quartz kindle
#

hint:
x = width / 2 - imageWidth / 2
y = height / 2 - imageHeight / 2

amber fractal
#

well yeah that mmLol

earnest phoenix
#

where should I write this?

amber fractal
#

Not exactly like that, but it's your x and y

quartz kindle
#

you should think how to apply this formula

#

copying and pasting exactly what i wrote will not work

#

do you know what are x and y?

modest maple
#

ur version is wrong?

west raptor
#

make sure intellij is looking at the correct sdk

valid frigate
#

lol you're on an outdated sdk probably

#

in your project structure you can change the sdk version because as far as i know intellij ultimate is dumb

half spear
#

Does anyone know how to convert all raw messages in a string into usernames, I have a bot command in discord.py 1.2.5 that takes a message to generate a image using it but the message contains things like !@12398719238712123980 instead of actual names. I tried using regrex but because I dont usually use it I dont know how to make this work with it.

modest maple
#

because its a mention and thats how discord sees mentions

slender thistle
#

That's how mentions work

modest maple
#

get the ID from the <! >

slender thistle
#

It's your client converting them into readable state

modest maple
#

and get user from that

half spear
#

ok i didnt need a explanation as to why...

#

not being rude

#

but just saying

modest maple
#

well you kinda need to know

half spear
#

i dont

#

I know how it works

modest maple
#

otherwise you aint gonna get anything we tell you

#

and clearly you dont

#

otherwise we wouldnt be here

#

xD

half spear
#

really...

#

Ive never done this sort of thing before

slender thistle
#

get the ID from the mention, get_user or fetch_user that ID, return the string

half spear
#

thats all

slender thistle
#

That's probably what should make sense

half spear
#

I just want to know how to turn a string like "blah blah !@8374389274" to something like "blah blah randomUser"

modest maple
#

that is how you do it

#

we are not gonna spoon feed you

slender thistle
#

string.replace, use regex

modest maple
slender thistle
#

connect those two together uwu

modest maple
#

get user ID from regex -> get user -> replace with user name

#

ez

half spear
#

yes "ez"

#

I dont know how regrex works since I dont usually use it at all

modest maple
#

learn it then

#

only way ur gonna do it

#

and regex takes like 10 mins to learn the basics todo what you need todo

slender thistle
#

me neither, let's suffer together trying to understand regex
or read the docs

half spear
#

I forgot about read the docs, thanks shivaco

modest maple
half spear
#

Im so used to StackOverflow that gives me tons of useless code

modest maple
#

beacuse you shouldnt copy and paste and use others code

#

when 90% of d.py stuff is outdated

slender thistle
#

SO for d.py is definitely out of the window

modest maple
#

d.py docs are easy to understand

#

regex slightly worse off

#

but plenty of basic tutorials on it

half spear
#

from what I know I can use a re.match to find terms

#

making those terms tho

#

thats the challenge

#

thanks for the help tho

modest maple
#

match returns a bool

#

use findall

half spear
#

ah ok

#

thanks

narrow kettle
#

hey guys, how do i make an int into char(ascii) in c?
for example i have the int 928, i want to make it into char[3] = '9', '2', '8';

slender thistle
#

owo what

narrow kettle
#

how can i make an int i have into ascii? i know how to do the oppisite but not an int into ascii

#

(in c)

slender thistle
#

Would this help?

narrow kettle
#

i cant use stuff like convetr.tochar or stuff like that

#

cuz like lets say my int is 4, i will do 4 + 44 which would be 48 which is '4' BUT how do i make that 48 into a char?

topaz fjord
#

Can you to itoa

narrow kettle
#

nope

topaz fjord
narrow kettle
#

not sprintf either

green kestrel
#

A networking guy walks into a bar with a bird in his shoulder. The bird keeps repeating "pieces of nine, pieces of nine". The bar tender asks what's up with your bird, shouldn't it be saying "pieces of eight"?. No says the networking guy, that's just a Parrotty error...

#

itoa(), @topaz fjord

modest maple
#

xD

quartz kindle
#

anyone else had a problem with randomly missing messages?

#

for example, i have a bot that sends a welcome message with instructions to enter the server, and when a person joins, i can see the bot's message, but sometimes the person who joined cant

#

even though they can see past messages, and they see all other messages in the channel, only their specific welcome message is missing from their chat

odd scroll
#

if the welcome message is sent in an embed they could have embeds disabled

#

if not, just blame discord and nothing you can do about it

quartz kindle
#

yeah, im blaming discord

#

they can see past welcome messages

#

let me show an example

#

this is what i see (notice the timestamps, they left and rejoined)

#

this is what they see (they sent me the screenshot)

#

the second welcome message is completely missing from their chat, and they're trying to solve the first welcome message

earnest phoenix
#

slow internet could be a reason, they're failing to catch up to the message events

#

for the bot the user is already in the guild but for the user, if they have slow internet, they might be a bit behind and still in a state of joining

#

and by the time the message event is sent out the client ignores it because the client still thinks the user is in the middle of joining

quartz kindle
#

well, he was sitting there for an hour, trying to solve the old captcha

#

then he was auto-kicked for failing to solve it

#

lmao

#

then he rejoined a third time, and it finally worked

earnest phoenix
#

the reason they see old messages is because of the rest request which isnt realtime

#

websocket is iffy though

quartz kindle
#

yeah im guessing for some reason the websocket failed, and then the client didnt send any fetch request because, well, there was nothing to update client side

#

but it kinda sucks because its not the first time that this happened with this bot

#

i've seen it happen a few times before

earnest phoenix
#

have you thought ab delaying the message for a few hundred ms? might help

quartz kindle
#

hmm good idea

mossy vine
#

can anyone explain to me why this returns Window when ran in a browser and global when ran in node?
Function('return (function() {}.constructor("return this")( ));')()

#

i think i understand it to the point of {}.constructor("return this")

west raptor
#

wtf is that code

#

where did you find it

mossy vine
#

obfuscated javascript

#

as to where i found it

west raptor
#

inb4 you wrote it

#

uh that's.. interesting

mossy vine
#

i didnt

west raptor
#

to me it just seems like it's calling several nested functions

mossy vine
#

it is

west raptor
#

so what are you confused about

mossy vine
#

i just dont understand wat {}.constructor("return this") does

#

well i mean

#

i know its just this

#

but idk why

west raptor
#

actually

#

i dont know

mossy vine
#

oh wait

#

its part of function

#

function() {}.constructor("return this")( )

west raptor
#

oh i see

#

yeah

earnest phoenix
#

prefix @left gale

#

Oh shoot my bad

#

didnt mean to ping you

late hill
#

All global variables and functions you create are added to the global namespace

#

which is "global" in node

#

and "window" in browsers

bitter sundial
modest maple
#

read the error

#

and dont say you have because if you did you would know the issue

#

Anyone by any chance know how / why Im occasionally getting my DB on a diffrent thread to the thread calling it raising an error

#

even tho in theory they should be the same

#

i think its if multiple threads get started

blissful scaffold
#

Maybe 2 threads try to connect with the DB at the same time and it causes an error?

modest maple
#

maybe

#

trouble shooting time

blissful scaffold
#

I added a read/write lock for every DB interaction,
multiple threads are allowed to read at the same time, but only 1 thread can write at a time

modest maple
#

i think it cuz as one thread finishes a new thread is immediately created not giving enough time for the async task to finish writing to db

dull terrace
#

Anyone know exactly how to get a bot to join a voice channel ?

#

In python

quartz kindle
#

have you checked the docs?

#

should be easy to find

dull terrace
#

Yes i tried several things but nothing conclusive

round tulip
#

@fierce thorn CodeBot should be fixed now.

dull terrace
#

Thx Tim

cursive kiln
#

this doesnt work whyy??? I tried so harddd to fix

fallen lion
#

const

#

not counst

dusky marsh
#

Also you need an arrow function operator not as assignment operator for the callback on the message event

#

There are a few errors with what you sent

#

I'm not gonna spoonfeed but the errors you get should be self-explanatory

limber plinth
#

Please hide your token

dusky marsh
#

^ was about to mention that as well haha

amber fractal
#

not only hide it

#

regenerate it

fallen lion
#

how can I read a varchar with jda and litesql? So that I have the varchar as a string

summer torrent
#

@cursive kiln regenerate your token

blissful scaffold
#

@modern sable maybe you need to remove a post that contains a token?

#

doesnt really matter I guess, it leaked already

modern sable
#

was a fake token

#

deleted it anyways

blissful scaffold
#

@fallen lion Are you trying to read it from the sqlite database or trying to put it in the database?

#

sqlite has no varchar datatype, it is probably saved as text

fallen lion
#

i try to read it

blissful scaffold
#

You can just read it from the database as a string

fallen lion
#

how do you mean?

blissful scaffold
#
PreparedStatement stat = connection.prepareStatement(SELECT_QUERY);
ResultSet rs = stat.executeQuery();
if (rs.next()) {
    String value = rs.getString(VALUE);
    // do something with it
}
// close it all or put it in a try block
fallen lion
#

okey

blissful scaffold
#

I guess you are using prepared statements

fallen lion
#

yes

sonic stratus
#

How can i use command handler?

fallen lion
#

@blissful scaffold what do you mean by "value"?

cursive kiln
#

Const Discord = require('discord.js')
Const client = require Discord.Client()

client.on(message, async msg = {
if(message.content = "info") {
Message.channel.send("Hi i am warrior the best bot that will give you everything you want")
})}

Client.login(Blah blah blah)
Is this correcter? Sorry im bad at english

#

It still dosent work

blissful scaffold
#

rs.getString(VALUE);
VALUE can either be an int (columnIndex) or String (columnLabel)

#

@fallen lion I see you are using Eclipse
Eclipse tells you exactly what it expects

earnest phoenix
#

@cursive kiln thats not how u make a function

#

Also message is undefined

fallen lion
#

@blissful scaffold I always get null

blissful scaffold
#

maybe that is what is stored in the database

fallen lion
#

i use it

#

it works

#

thank you โค๏ธ

dusky marsh
#

@cursive kiln arrow function as callback, not assignment. And that message is never gonna send, you aren't using the correct variable name for the message object in the func body

#

Mostly capitalization errors from here

cursive kiln
#

Whats callback

fallow quiver
#

So question, what's wrong with this code

if (message.content.startsWith(prefix + "ban")) {
        if (message.member.hasPermission("BAN_MEMBERS") || message.author.id == "509122806663872530") {
            var modBanning = message.author.username;
            var reason = message.content.slice(prefix.length + 4 + mention1.length);
            if(!message.guild.roles.find(mention1, 'Admin') && !message.author.id == "509122806663872530") {
                message.channel.send("Banned " + mention1 + "!");
                console.log("User: " + mention1.username + ", ID: " + mention1.id + ", was banned by: " + modBanning + ", Because: " + reason);
            }else {
                message.channel.send("That user cannot be banned via bot, try it manually");
                console.error(message.author.username + " tried to ban " + mention1 + " to no avail!");
            }
        }
    }

Specifically the if(!message.guild.roles.find(mention1, 'Admin'), it says, that the augument must be a string, but I cannot read the username of mention1

mention1 = message.mentions.first();

west raptor
#

.find(a, b) is deprecated

#

pass a function instead

prime cliff
#

Not checking if it has an arument in the first place, no checks if the bot has ban perms and silent ban command if the user does not have ban perms mkay

#

Also why are you mentioning the banned user when they get banned then their mention won't resolve for others LULW

west raptor
#

this code is just yikes tbh

fluid sapphire
#

can someone help me?

#
    let args = message.content.substring(PREFIX.length).split(" ");
    
    switch (args[0]) {
        case 'mute':
            var person  = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[1]));
            if(!person) return  message.reply("Ich kann die Person " + person + " nicht finden.")

            let mainrole = message.guild.roles.find(role => role.name === "normal");
            let role = message.guild.roles.find(role => role.name === "mute");
        

            if(!role) return message.reply("Die Rolle `mute` wurde nicht gefunden.")


            let time = args[2];
            if(!time){
                return message.reply("Du hast keine Zeit angegeben!");
            }

            person.removeRole(mainrole.id)
            person.addRole(role.id);

            message.channel.send(`@${person.user.tag} wurde fรผr ${ms(ms(time))} gemutet!`)

            setTimeout(function(){
            
                person.addRole(mainrole.id)
                person.removeRole(role.id);
                console.log(role.id)
                message.channel.send(`@${person.user.tag} ist nun unmutet.`)
            }, ms(time));
        }

#

whats wrogn there?

earnest phoenix
#

Let me see

#

I think its the part var person = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[1]));

#

you cant call on some one like that

fluid sapphire
#

ok

earnest phoenix
#

It would be something like this

#

const to = message.mentions.members.first() || message.guild.members.get(args[0]);

grizzled valley
#

getting the following error in my music bot : [tls @ 000001f5e079e400] Error in the pull function. {link of the song}

slender sleet
#

How you do to use the bot with de mention ?

earnest phoenix
#

-bots

gilded plankBOT
#

tickNo This user has no bots

modest maple
#

Don't use Luca here ty

earnest phoenix
#

nice | Okay, Sorry

gilded plankBOT
tough hull
#

Sry

modest maple
#

Smh

earnest phoenix
mossy vine
#

what are you trying to do

earnest phoenix
#

i want to connect my bot to database

mossy vine
#

is that the mongodb installation software or whatever

summer torrent
#

@earnest phoenix if you want to get a connection string, select "Connect Your Application"

earnest phoenix
summer torrent
earnest phoenix
#

2|atlanta | [2020-01-19 00:22:47.814]: ERROR Unable to connect to the Mongodb database. Error:MongoTimeoutError: Server selection timed out after 30000 ms getting this error

summer torrent
#

what is your mongoose version

earnest phoenix
#

"mongoose": "^5.7.13"

summer torrent
#

it is an older version

#

update

earnest phoenix
#

but whhen i put my frnd db url its works and when i put my it shows me that error

summer torrent
#

do you whitelisted your connection IP address?

glacial anchor
#

how to convert html to discord markdown?

#

or github md, doesnt matter

earnest phoenix
#

how to do that

glacial anchor
#

ive seen some packages but they dont work for me

glacial anchor
#

i tried it earlier

#

didnt work

#

but i'll try again

#

i have a multi-line html file

earnest phoenix
#

Ist grad jmd hier der Erfahrung hat? ich finde den irwie den Fehler im Code nicht..

glacial anchor
#

ok

mossy vine
#

@earnest phoenix post the error and the relevant code

glacial anchor
#

@summer torrent

uneven wyvern
#

@earnest phoenix U use the AtlantaBot Source lmao

#

@earnest phoenix Bei was brauchst du Hilfe?

summer torrent
#

do you get any error

earnest phoenix
#

i change the ip

glacial anchor
#

@summer torrent ok turndown worked, ty!!!

summer torrent
earnest phoenix
#

still same error

#

help me out

glad charm
#

No one has to help you man.

earnest phoenix
#

y

glad charm
#

Why? Cause you're not entitled to it.

earnest phoenix
#

:/

glad charm
#

My best guess is you didn't make a DB or you typo'd the DB name when trying to connect.

earnest phoenix
#

i just click on connect then connect to application then copy the url and paste in my bot config.js

#

and replace password to my mongodb password

summer torrent
#

no

#

do you created a database user?

earnest phoenix
#

yes

#

its created

summer torrent
earnest phoenix
summer torrent
#

and replace password to my mongodb password
@earnest phoenix password isn't a your mongodb password. It is a password of database user

earnest phoenix
#

means

#

the password of my mongodb login password no

#

i have to put that only

summer torrent
#

replace password (on connection string) with password of your database user

earnest phoenix
#

where i get that

summer torrent
#

You set it when creating the database user

earnest phoenix
#

ohk wait

#

still same error

#
  |       at TLSSocket.Readable.push (_stream_readable.js:214:10)
  |       at TLSWrap.onStreamRead (internal/stream_base_commons.js:186:                           23) {
  |     name: 'MongoNetworkError',
  |     [Symbol(mongoErrorContextSymbol)]: {}
  |   },
  |   [Symbol(mongoErrorContextSymbol)]: {}
  | }
  | MongoTimeoutError: Server selection timed out after 30000 ms
  |     at Timeout._onTimeout (/root/pikachu/node_modules/mongodb/lib/c                           ore/sdam/server_selection.js:308:9)
  |     at listOnTimeout (internal/timers.js:549:17)
  |     at processTimers (internal/timers.js:492:7) {
  |   name: 'MongoTimeoutError',
  |   reason: MongoError: Authentication failed.
#

getting this error in logs

#

@summer torrent

summer torrent
earnest phoenix
#

what happend

uneven wyvern
#

read the fucking error

#

Auth failed

earnest phoenix
#

i have putten proper password

uneven wyvern
#

Have you removed the <>?

earnest phoenix
#

yes

uneven wyvern
#

Ok.

#

Have you set the Network Access to public (0.0.0.0)?

earnest phoenix
#

yes

uneven wyvern
#

my advise, delete all commands and remove the mongoDB fully

#

I use Atlanta Bot Source also and I did it like that

#

Mongo sucks anyways

earnest phoenix
#

๐Ÿ˜ฆ

#

means i dlelete my mongodb acc

uneven wyvern
#

yeah, it's good but very complicated to understand

mossy vine
#

mongodb complicated?

#

thats funny

uneven wyvern
#

yes

#

Enmap best db ngl

marble juniper
#

#whitenames

uneven wyvern
#

stfu

earnest phoenix
#

:/

#

but when i use my frnd db its work fine

#

but when i put mine its sucks

uneven wyvern
#

is not so that I have 3 Discord Bots with over 6000 servers on my old Discord Account... @marble juniper

marble juniper
#

cool

#

do I care

#

if you want to argue this is not the place to go sorry

uneven wyvern
marble juniper
#

either stop your 3 year old responses or go to dms

earnest phoenix
#

/:

uneven wyvern
#

@earnest phoenix I wouldn't apply a bot with a known bot source.

earnest phoenix
#

means

uneven wyvern
#

delete the commands and make your own :D

earnest phoenix
#

y

marble juniper
#

because stealing is bad and you learn nothing from stealing it

#

if there is an error you won't even know why and where

#

try coding your own commands so you actually know what it does and you can then Improve on skills

#

At least try it

#

and I recommend using a command handler because it can get messy once your code gets longer and longer

uneven wyvern
#

^

earnest phoenix
#
let akce = db.startsWith(`akce_${message.guild.id}`, { sort: '.data'})

what can I use instead?

summer torrent
#

what do yo want to do?

#

leaderboard?

earnest phoenix
#

@summer torrent yes

summer torrent
#

is this quick.db?

earnest phoenix
#

yes

summer torrent
#

you can use sort() with db.fetch()

earnest phoenix
#

@summer torrent can you look dm?

modest maple
#

bruh damn u need to learn good var names

#

okay then

dull terrace
#

Why?

modest maple
#

because you're labelling a voice channel object as a server and that starts making life confusing

dull terrace
#

Yes, I made a mistake, it seems more logical to me but its still not working

@client.command()
async def connect(ctx):
    await ctx.author.voice.VoiceChannel.connect(timeout=60.00, reconnect=True)
modest maple
#

well i mean youre trying to connect to a user's DMs voice call

earnest phoenix
#

@ NMW03

0001 Can You Help Me Install top.gg Bot

#

<@&265158261945270273>
Can You Help Me Install top.gg Bot

modest maple
#

THIS IS NOT THE SITE TO MAKE BOTS

#

also dont @ website admins

unique nimbus
#

Don't pping Web Administrators

blissful scaffold
#

I dont even understand the question

#

Do you want to add a bot to your server, or do you want to make a bot?

dull terrace
#

And now ?

@client.command()
async def connect(ctx):
    channel = ctx.message.author.VoiceChannel
    await client.channel.connect(timeout=60.00, reconnect=True)
#

No, there are problem

modest maple
#

isnt it just VoicChanne not Voice.VoiceChannel

dull terrace
#

Its still not working

glacial mango
#

I am making a dashboard for my Discord bot. After the user is logged in I have the variables user & guilds, when I try to do

<% guilds.then(function(result) {
  console.log(result) 
}) %>```

It gives `{ message: '401: Unauthorized', code: 0 }`
How do I fix that?
mossy vine
#

what are the oauth scopes

glacial mango
#

https://discordapp.com/api/oauth2/authorize?client_id=${CLIENT_ID}&redirect_uri=${redirect}&response_type=code&scope=identify

earnest phoenix
#

did you exchange the code for an access token

glacial mango
#

What do you mean?

mossy vine
#

identify doesnt provide you the guilds

earnest phoenix
#

401 means wrong token

restive furnace
#

indentify&guilds into scooe

#

maybe

glacial mango
#

I changed it to https://discordapp.com/api/oauth2/authorize?client_id=${CLIENT_ID}&redirect_uri=${redirect}&response_type=code&scope=identify%20guilds
but still get the error

earnest phoenix
#

you have to exchange the code you get for an access token

glacial mango
#

A code you get from the user when it logs in?

earnest phoenix
#

yes

#

the code that's returned in the url when they get redirected

glacial mango
#

I console.log() that code, how do I use it to get the guilds?

earnest phoenix
#

read the fucking doc page

#

...

glacial mango
#

I don't understand how to do it ๐Ÿ˜

earnest phoenix
#

what part of it

glacial mango
#

I have the acces token when the user logs in, but I don't know how to use it to get their guilds

slender thistle
#

"everything"

earnest phoenix
#

iirc the endpoint should be GET /users/@me/guilds

#

check the docs for it

glacial mango
#

Mhm

#

I was using this

      async function getGuilds(serverid, token) {
        const response = await (await fetch(
          `https://discordapp.com/api/guilds/${serverid}`,
          {
            method: "GET",
            headers: {
              Authorization: `Bearer ${token}`
            }
          }
        )).json();
        return response;
      }```
earnest phoenix
#

Hey i have a problem with a bot of mine.
The bot always goes offline after a certain amount of time then I took another bot with token and it works.
How can I fix it?

warm marsh
#

Maybe an error?

sudden geyser
#

Does anything get logged in your console, like an error?

slender thistle
#

Anyone here who worked with Xamarin?

modest maple
#

anyone got any idea why occasionally the Database is being started on a diffrent thread and process to the rest of the code

#

alchemy confussles me somtimes

blissful scaffold
#

JS?
I think those async and await calls run on a different thread?
But I don't work with JS so I don't really know

modest maple
#

python

uneven wyvern
#

how can i console.log numbers from 1-1000?

modest maple
#

for loop

#

loop through n number of times printing n intervals

uneven wyvern
#

ok I've never for loops but let's see

#

ok wtf my keyboard just did

#
var points = new Array(10);
        var label = points.length;
        for (var i = 0; i < label; i++) {
            console.log(points[i]);
        }
}

run()```

logs undefined
summer torrent
slender thistle
#

Where did you put logs

quartz kindle
#

i mean, if you want to only print the numbers, you can simply do js for(i = 0; i < 1000; i++) { console.log(i) }

uneven wyvern
#

oh well that's the easiest way ig

grizzled valley
quartz kindle
#

your code was returning undefined because you created an array with 10 entries, those 10 entries are undefined by default

#

then you attempt to log each individual entry

modest maple
#

@grizzled valley you add a command for queue?

#

where play is

uneven wyvern
#

@quartz kindle Ok how would I loop trough an array of words?

quartz kindle
#
let array = ["word1","word2","word3"];

// using a regular "for" loop
for(let index = 0; index < array.length; index++) {
  console.log(array[index]) // or do anything else with it
}

// using a "for of" loop
for(let item of array) {
  console.log(item) // or do anything else with ir
}

// using a "for in" loop
for(let index in array) {
  console.log(array[index]) // or do anything else with it
}
#

a for loop is a basic loop present in most programming languages
for in and for of are shorcuts for looping specifically over indexes and values. additionally, a for in loop can loop over an object's keys

uneven wyvern
#

Thanks :D

small prairie
#

Can We "Publish" Messages Using Bot? d.js If It helps (Like Publish In Announcement channels)

earnest phoenix
#

nope

#

that endpoint is for users only

mossy vine
#

can you publish a message posted by a bot tho

dull terrace
#

I not found the solutuion for my bot join server voice channel ๐Ÿ˜

@client.command()
async def connect(ctx):
    await ctx.message.author.VoiceChannel.guild.connect(timeout=60.0, reconnect=True)
slender thistle
#

What are you expecting author.VoiceChannel to be

dull terrace
#

I want the bot to join the channel of the member who writes the command

small prairie
#

@mossy vine Yeah

quartz kindle
#

.guild.connect makes no sense

#

you cant connect to a guild

small prairie
#

Lol

quartz kindle
#

@dull terrace have you looked at the documentation? i found it in 1 min

dull terrace
#

Yes

#

x)

#

But I must not understand x)

topaz fjord
#

God damn tim

quartz kindle
slender thistle
#

idk if Tim is pissed or doesn't know how else to explain it

quartz kindle
topaz fjord
#

@slender thistle both

#

this is Tim in his natural habitat

quartz kindle
#

Lol

ruby talon
quartz kindle
#

give a man a fish, and he will eat for a day (and beg you for another fish every day)
teach a man how to fish, and he will eat for a life time (and leave you alone for the rest of his life)

ruby talon
#

:))

#

nom nom

topaz fjord
#

this is his habitat

ruby talon
#

JEEZ

#

thats a lot

topaz fjord
#

it's not

#

I have 69,117

quartz kindle
#

lmao

earnest phoenix
#

because you're able to generate millions of snowflakes within a second

ruby talon
#

Why is that @earnest phoenix ?

earnest phoenix
ruby talon
#

ty

modest maple
#

welp, just pushed the massive update

dull terrace
#

I am full of attempts, but nothing conclusive

modest maple
#

lets hope nothing burns

hoary elm
#

Quick question... My bot was declined for Returning NSFW content outside of a NSFW channel (I wasn't aware the images could be NSFW) but I was wondering if this is a good enough fix.

Sorry I deleted the message the first time LOL I attached the wrong image with it....

twilit rapids
#

Yeah that's fine

hoary elm
#

Awesome ๐Ÿ˜

modest maple
#

okay we're crashing and burning

#

shard 2 is not starting

#

discord why

ruby talon
#

bcs

#

discord is big bully

modest maple
#

the autosharding system is doing its job

#

but because the events r broken

#

having to use my own system

#

which mean

#

when autosharded system says "hey we dont need this shard cuz we're not at 2500 yet" the system doesnt finish booting

dull terrace
#

Tim why VoiceState ?

quartz kindle
#

its the only voice related thing that a member contains

grizzled raven
#

cry has only sent 1000 messages outside of this channel also, so i guess tim and cry own this channel zoomeyes

dull terrace
#

i don't need that for the bot to join the channel though?

quartz kindle
#

member contains VoiceState

visual zenith
#

Hi

quartz kindle
#

VoiceState contains VoiceChannel

ruby talon
#

Hello @visual zenith

dull terrace
#

Ok

visual zenith
#

@ruby talon nice pp ๐Ÿ˜‚

ruby talon
dull terrace
#

i still don't understand sorry ๐Ÿ˜ข

quartz kindle
#

sigh...

#

what is it that you dont understand?

modest maple
#

might be time to learn OOP with python

dull terrace
#

Yes, that's what I'm going to do

quartz kindle
#

go to message, and scroll down, you will see all the properties that a message object has. you know what is a property right?

#

for example OBJECT.property

#

message.author

#

author is a property of message

#

so in the docs, you see that author is listed as a property of message, that means you can do message.author in your code

#

but what does message.author give you? the docs tell you what it gives:

authorยถ
A Member that sent the message. If channel is a private channel or the user has the left the guild, then it is a User instead.

#

if the message came from a guild, it gives you a Member object

#

so that means, if the message came from a guild message.author is a Member

#

now click on Member in the docs, and you will see the list of properties a Member has

#

search for anything related to voice, and you will find this:

voice
Returns the memberโ€™s current voice state.

#

so voice is a property of Member and message.author is a member, if the message came from a guild

#

that means in your code, you can write message.author.voice

#

then in the docs, click on VoiceState, and you will see what properties a VoiceState object has

#

and so on

#

just continue through the docs that way

#

untill you find a voice channel, and until you find the connect function

dull terrace
#

Ok, I'll see, I hope I understand

#

thx

modest maple
#

jeuss so much stuff is breaking

dull terrace
#

When its channel, I can replace this per VoiceChannel?

#

I know I'm missing something because VS Code has to show me the options of .connect

glacial mango
#

I have an array of user guilds. How do I create a new array with guilds the user has permissions MANAGE_GUILDS. I know something with array.filter() but not exactly how to