#development

1 messages · Page 667 of 1

lost bramble
#

I watched this video on how to fix the issue and I couldn't figure out what was being asked

amber fractal
#

What os are you on

copper cradle
#

MacOS

lost bramble
#

mac os

opaque eagle
#

OS X

copper cradle
#

ok then

amber fractal
#

I figured it wasnt windows. Folders with forward slashes mmLol

copper cradle
#

microsoft thinks backwards

opaque eagle
#

also is that monokai pro? @lost bramble

lost bramble
#

well I use both, I'm just on my macbook rn because I'm away from my desktop

copper cradle
#

hmm

lost bramble
#

what the environment?

opaque eagle
#

the theme

copper cradle
#

still, change the owner of those folders

#

and then npm will have write access

lost bramble
#

oh, I forget. I think I downloaded one and changed some of the colors. I like the calming blue and dark vibes

opaque eagle
#

lol

lost bramble
#

for when times like this arise and I don't know how tf to fix something

copper cradle
#

you can use the chown command to change the owner of those folders

lost bramble
#

@fossil oxide Please help brother camnaz

copper cradle
#

that should fix your problem

lost bramble
#

what should??

copper cradle
#

changing the owner of those folders

lost bramble
#

how do I do that

copper cradle
#

/Users/cnazarko/.npm-packages/lib/node_modules/

#

sudo chown -R cnazarko /Users/cnazarko/.npm-packages/lib/node_modules/

opaque eagle
#

Also, .npm-packages isn't what npm uses by default... how did that happen lol

copper cradle
#

maybe he changed it?

opaque eagle
#

ahh, that's prob why this error happens lol

copper cradle
#

or maybe the magical goblin from my closet changed it idk

opaque eagle
#

when npm was first installed it should've configured permissions properly for its normal installation location

copper cradle
#

yes

lost bramble
#

alright, I inserted that line of code

#

hazah

#

added 1 package 1 from 1 distributor instead of error messages

copper cradle
#

send pic of the console

lost bramble
#

contributor*

copper cradle
#

now

#

npm i -g typescript

lost bramble
#

still giving me tsc unknown

copper cradle
#

hmm

#

did u run npm i -g typescript

lost bramble
#

yes

#

that says updated

copper cradle
#

bruh

lost bramble
#

do you want to screenshare?

copper cradle
#

yeah why not

lost bramble
#

alright, I'm going out to eat rn though xD

#

just got notified

copper cradle
#

b r u h

lost bramble
#

We can pick this up later if you're still active

copper cradle
#

yeah

#

but I can't talk

lost bramble
#

I'm just trying to get this damn bot up and functional so I can start learning more complicated stuff

#

yah that's ok

copper cradle
#

alright

lost bramble
#

I'll do the same thing on my windows computer and see what happens

copper cradle
#

ok

lost bramble
#

I may have fucked up something and downloaded uneccesary stuff that is causing problems. I may have to backtrack but we shall see

copper cradle
#

yeah

junior epoch
#

500 Internal server error, server lost?

#

how can i change that?

amber fractal
#

you cant

#

500 is server side

junior epoch
#

i cant edit my server

amber fractal
#

you cant do anything about it except report it to whoever made what you're trying to access

#

Yeah

#

it's a server error

#

on dbl's side

junior epoch
#

okay

cursive dagger
#

Usually gets auto fixed in about 5-10m

junior epoch
#

okay

#

every time i click submit it shows up...

amber fractal
#

yeah

#

it's a server error

#

You should contact the admins/mods

opal copper
#

who can help me plz i got a json variable with a - and i don't know how to use this variable

hushed berry
#

what

low wasp
#

@opal copper what language? if its javascript use json["i-am-value"] to get it

opal copper
#

oh ok thx that's what i needed

earnest phoenix
#

how can i display guild count on my bot's page?

mossy vine
copper cradle
#

how can I get something from a json file in python? (sry I'm new to python)

earnest phoenix
slender thistle
#

open it, use json module and then json.load the open file

bold wigeon
#

someone know python and can help me please?

#

i changed the location of the code and now the code cant import discord.py

#

please

earnest phoenix
#

My old bot can't stay up for more than a couple minutes. That's even worse than usual. One by one the shards are missing the heartbeat and disconnecting, am I the only one with issues right now?

earnest phoenix
#

On join message that includes support server link. Is that bad? Unsolicited advertising?

tight heath
#

yes

lusty dew
#

Okay, well I'm in a bit of a problem, using my friends server I have access to it when I go and start the bot using pm2 it will show as started but won't come online and when I do pm2 logs process and it will show up empty not even the console logged stuff in the ready event

#

Afraid I can't provide much more info

#

I get 0 errors

#

Funny thing is it went offline right after it got accepted into DBL

tight heath
#

can you copy the exact commands you use in pm2

#

and paste them here

lusty dew
#

pm2 start clap

#

pm2 logs clap

#

Those are the two

tight heath
#

Oh huh

#

Can you run pm2 logs --err --lines 100

lusty dew
#

@tight heath ye sorry here you go!

tight heath
#

huh

lusty dew
#

Told you it comes back completely empty

tight heath
#

are you sure pm2 start clap is configured correctly

lusty dew
#

Yea

#

It should be

#

It was working earlier before the bot got accepted

#

And after it got accepted into DBL it went offline

#

Nvm realized it could have been caused in other servers

hollow saddle
#

can you try pm2 list

hollow saddle
#

hmm odd since its online in the eyes of pm2

lusty dew
#

But it isn't online

#

Hmph

hollow saddle
#

very odd

tight heath
#

Restart it

#

Shroog

lusty dew
#

I tried that as well

#

I honestly don't know what's causing this and it's making me mad

trail dagger
#

regenerate your bot token at www.discord.app.com and paste in the new token in your code and try again

lusty dew
#

Okay

trail dagger
#

tell me if it worked

lusty dew
#

K

#

Didn't think about that tbh

#

Lol

tight heath
#

Should throw an error though

maiden mauve
#

hm, what's a good solution to bot can't send messages at all

#

obviously you can catch the error but

#

how do you let the owner know?

earnest phoenix
#

I have a problem , when i start the bot in my pc works command =stats http://prntscr.com/ooce1u but when i upload it on host it gives me only the error, what should i do?

Lightshot

Captured with Lightshot

#
    }).catch(err => {
        console.log(err);
        msg.channel.send(`0 Users with name > ${username} <, try again with another username`);
    })```
#

My command error

amber fractal
#

gonna need some more code

#

we dont know what's undefined

#

the username I presume?

earnest phoenix
#

all

#

When the bot is on the host

shy rose
#

your .catch isnt the part being called

#

its your bot reading some value which is undefined

earnest phoenix
#

when is in my pc it works

shy rose
#

hence we need the top part so we can check what the api replies and what your trying to read

earnest phoenix
#

ok

#
    {
        const args = msg.content.split(/ +/g);
        const username = args[1];
        const platform = args[2];
        const data = apex.user(username, platform).then(data => {
            // Stats
            let level = data.data.segments[0].stats.level.value;
            let hopa = data.data.segments[0].stats.kills.value;
            let avatar = data.data.platformInfo.avatarUrl;
            console.log(level,hopa)
            // RANKINGS
            let rank = data.data.segments[0].stats.rankScore.metadata.iconUrl;
            console.log(rank,avatar)
            // Wins
            const s2 = data.data.segments[0].stats.season2Wins;
            const s1 = data.data.segments[0].stats.seasonWins;
            msg.channel.send(`${s1}, ${s2}`)
            console.log(s2,s1);
            const url = 'https://trackercdn.com/cdn/apex.tracker.gg/ranks/';
            // RANKS EMBEDS
            ```
#

and down are more embeds

lusty dew
#

@trail dagger Idk if it worked

#

I can't seem to save the file

#

That holds my token

lusty dew
#

This is the error I get

#

But I just regenerated the token

#

And copied and pasted it

trail dagger
#

and clicked save?

lusty dew
#

The thing was buggy

#

It finally saved properly

#

Okay no longer get that error

#

My friend added in some logs to see where the code stopped

#

But every console.log before and after the client ready event triggered

#

The logs inside the client ready event didn't

#

Here are some screenshots of the code

hollow saddle
#

You don't initiate the client as a variable

#

client = new Discord.Client({shardCount: 'auto'})

#

This line

#

It needs to be const client ...

lusty dew
#

Ok

#

@hollow saddle

#

I did that then I got this

earnest phoenix
#

lusty dew
#

?

earnest phoenix
#

Hi

hollow saddle
#

What's your updated code

lusty dew
#

Basically the same

#

Just with const

earnest phoenix
hollow saddle
#

Oh and follow the stacktrace

lusty dew
#

Doesn't make sense though

hollow saddle
#

The error came from db_game_functions.js

#

Show the code for that file

hollow saddle
#

Yeah you need to wrap that entire thing in a module.exports = (client) => { ... } function in order to use the require('./library/db_game_functions.js')(client) line in your clap.js file

lusty dew
#

Wait what

#

I thought it already was xD

hollow saddle
#

From the screenshot there, it's not

#

Oh wait

#

It is

#

omg I missed it

#

lmao

lusty dew
#

Yeee

hollow saddle
#

I see where the error is though

#

The line just above module.exports

#

You try to reference client without defining it, as the error stated

#

Move that line inside the module.exports function

#

let cdSeconds = client.settings.cdSeconds

#

move that ^

lusty dew
#

Ahhhh

#

Yeee

#

Thanks

hollow saddle
#

Yw

lusty dew
#
require('./library/db_game_functions.js')(client)
#

This should work no?

#
require('./library/db_functions.js')(client)
#

These two don't error

#

Just the db_game_functions one

hollow saddle
#

Probably some syntax error

#

Double check your parenthesis and such

lusty dew
#

In my functions file? @hollow saddle

#

Or my main file?

hollow saddle
#

Both

#

If you want to be thorough

lusty dew
#

Ok

#

I don't see anything wrong with either files huh

idle iron
#

Guys

#

I know

#

HTML

#

CSS

#

Python

#

Do those have anything to do with developing a bot?

west spoke
#

python

#

Html and css cannot be used

#

Neither are coding languages

idle iron
#

Yeah it seemed like python was what was being used

#

If this do that

west spoke
#

I use python in mine, mainly because image recognition

#

Ye if statements are easier

idle iron
#

Yeah definitely

#

That’s the way to go

west spoke
#

Yep

#

If you decide to use async branch, I have a github repo that ima be working on to provide things for that area that it doesnt have

#

Eg NSFW channel recognition, nitro boosts, etc.

idle iron
#

Ok

west spoke
#

If you need those, ask me

#

<3

idle iron
#

Sure

inner jewel
#

i'd recommend using rewrite for d.py

#

since it's the version you'll get more support

lusty dew
#

I still can't figure.this error out

#

require('./library/db_game_functions.js)(client)

#

It only errors on that one and not:

require('./library/db_functions.js')(client)
#

Which is before the game_func one

tardy viper
lusty dew
#

Okay nvm fixed that error but the bot still won't come online

tardy viper
#

I want to contract in one embed and replace true / false to Active / inactive
ping me for respond plz ;;

lusty dew
#

Damn no one can seem to help me oof

earnest phoenix
#

hi

lusty dew
#

Hi

earnest phoenix
#

Do you code bots?

#

Or are you presently coding a bot?

lusty dew
#

Presently trying to fix a bot 😂

earnest phoenix
#

Say I am a moderator of a server, but the admin has had his account terminated and we cannot add a new bot to the server but I have coded a bot.
Is there a way to invite a user to a server and get the bot to make use of that user's token and act as a bot under an account not claimed to be a bot?

amber fractal
#

Self bots will get your account terminated

#

and if the only admin/owner had his account terminated and no one else has access he can request ownership transfer I believe

valid frigate
#

you cant even connect to your own account anymore iirc

#

selfbots are impossible

amber fractal
#

Since when Thonk

earnest phoenix
#

I've seen it done 2 weeks ago someone raided the ice wall with a botnet of over 50 selfbots

valid frigate
#

discord used to be like "no we dont encourage selfbots but we still allow them for some reason" and now they're like "fuck it we'll ban any selfbot we see"

#

why do they still allow it to happen

earnest phoenix
#

OK what do I need to do?

valid frigate
#

uh

earnest phoenix
#

Shouldn't be an issue if it's just to display memes and apply roles

#

on one server

amber fractal
#

doesnt matter

lusty dew
#

You don't get it

amber fractal
#

it's still against tos

lusty dew
#

We won't help you make a self bot

valid frigate
#

the bot you're adding the server to is probably gone lol

#

since nobody has admin perms

lusty dew
#

Steven

#

Help me

#

Plz

#

😂

#

I'm in a bit of a situation

#

I am stumped

earnest phoenix
#

The bot I have coded is on my linux server.
The discord guild is alive and well with 32,000 members.
The old bot got taken down by the old botmaster because of drama etc.
The owner of the guild has been AWOL for a very very long time, we think the account got terminated a bunch of ours did a couple of months ago we haven't heard from him since.
We need a bot to manage roles and memes on the server and we can't add a bot to the server using conventional means.

lusty dew
#

Can't someone request ownership?

earnest phoenix
#

What's the procedure for requesting ownership?

lusty dew
#

Idk

#

I think it's a thing never done it tho

dusky marsh
#

¯_(ツ)_/¯

lusty dew
#

^

earnest phoenix
#

Can anyone help me to filter 10 strings to find something?

#

nodejs?

#

yes

#

Are the 10 strings in an array?

#

yes

#

i just wanna know what i do wrong in this line const wins2s = data.data.stats.filter(x=> x.key == "Season2Wins")[0]

#

what's the name of your array?

#

Season 2 Wins

#

I wouldn't do it that way

#

it's name: 'Season 2 Wins',

#

it's better to use the name for the filter?

#

I would do var wins2s = [];

tight heath
#

instead of filter()[0] why not do find()

earnest phoenix
#

then do wins2s = data.data.stats;

tight heath
#

@earnest phoenix consts can't be reassigned

#

That's the point of being a const

earnest phoenix
#

then do for (let i in win2s) {
if (win2s[i] == filter) {
DO SOMETHING
} else { DO SOMETHING DIFFERENT}
}

#

yeah sorry var

lusty dew
#

Var?

#

Just use let

earnest phoenix
#

let will work fine too

#

@tight heath with find() results undefined

#

so use indexOf instead it's a string

#

i will try @earnest phoenix command

#

you can also use contains or content

#

includes sorry

#

That's how I did a "link" detector

#

@earnest phoenix also you're calling an element of an array of somethign that isn't an array

tight heath
#

@earnest phoenix then you're querying wrong

#

What's the structure of an element in that array?

earnest phoenix
#

you can do that with console.log(data.data.stats)

heavy nymph
#

You have a generator meme api pls ? (Sorry, I speak french)

indigo geyser
#

@heavy nymph

lusty dew
#

I get these two errors

#

I have db defined so idk why it says I don't

#

And as for log_toggle I don't understand it

cursive dagger
#

Code?

lusty dew
#

That's for the db functions file

#

Which the log_toggle is also originating from

#

Though I have an idea of where log_toggle error is actually originating from

#

@cursive dagger there's my code UwU

tardy viper
#

No person can help me ?

quartz kindle
#

@tardy viper change all your promises to the await version and add fields to the embed with them

#

and only send one message at the end

tardy viper
#

Sorry i don't understand 😂

quartz kindle
#
// change this
asyncFunction(something).then(result => {
    embed.addField("title",result);
})

// to this
let result = await asyncFunction(something);
embed.addField("title",result);

#

so that you can do this ```js
let result1 = await asyncFunction1(something);
embed.addField("title1",result1);

let result2 = await asyncFunction2(something);
embed.addField("title2",result2);

let result3 = await asyncFunction3(something);
embed.addField("title3",result3);

channel.send(embed) //run all functions, add them to the embed and then send all at once

tardy viper
#

The problem is

#

The port tester isn(t equal

quartz kindle
#

it doesnt matter, you can test them differently after you get each result

#

whats important is that you get the result into the same scope, so that you can add them in sequence

#

if you use the .then() version, then you are creating a separate scope for each result, and wont be able to join them into a single embed

tardy viper
#

Just i could not use inUse more than one use

quartz kindle
#

you can, or rather, you dont need it

tardy viper
#

I want to use this

if (inUse = true) inUse = "Actif" 
  if (inUse = false) inUse = "Inactif"```
quartz kindle
#
//old
tcpPortUsed.check(80,'46.105.84.218').then(function(inUse){
    //use inUse here;
})

//new
let inUse = await tcpPortUsed.check(80,'46.105.84.218')
// do something with inUse;
inUse = await tcpPortUsed.check(27056,'46.105.84.218');
// do something with the next inUse
trail hinge
#

How tk use this bot to other chanel?

earnest phoenix
#

wat

#

can you rephrase that

tardy viper
#

@quartz kindle I am testing just when i want to start
ReferenceError: message is not defined

#

and when its channel ReferenceError: channel is not defined

quartz kindle
#

show your code

tardy viper
#

😂

#

i have added
channel.send(embed)
out of }

quartz kindle
#

what did you put there to show undefined?

tardy viper
#

juste added embed.addField("Status - PropHunt");

#

with no , "fffff"

quartz kindle
#

you have to add something to the field

#

.addField("title",contenthere)

tardy viper
#

Yesss ok

#

Just

#

how i can replace the true en the false

quartz kindle
#

if your inUse is either true or false

#

you can do inUse ? "active" : "not active"

#

which means if inUse is true, return "active", if its not true, then return "not active"

tardy viper
#

i have maked that

#

and not work 😂

#

@quartz kindle You was in mode this person is big noob

quartz kindle
#

return exits the function

#

so if you use return there, you're stopping and exiting the entire function

tardy viper
#

How i can do this ?

quartz kindle
#

also, = is assignment, not comparison

#

inUse = true, makes inUse become true, not check if its true

#
let inUse = await yourFunction();
embed.addField("title",inUse ? "active" : "not active")```
tardy viper
#

You leaved me a new use in Node js 😂

#

THANK

quartz kindle
#

👍

twilit rapids
#

big brain Tim

lusty dew
#

I keep getting that error and I don't know why

tardy viper
#

@quartz kindle Just how add emoji to this embed

#
    embed.addField("Activitée : ",inUse ? "Actif :actif:"  : "Inactif :inactif:");   ```
#

and not work

#

Nooo i have found sorry for the ping 😂

real helm
#

Hello

#

I like to start a web project

#

But i don't know where I start

#

Visual Studio Code or Glitch?

quartz kindle
#

what kind of web project? a website?

real helm
#

Yes

#

Glitch is editor and free host

quartz kindle
#

you can start a local project on your own computer, without a host

real helm
#

yes

#

And later send the project to glitch for free host?

quartz kindle
#

yes for example

real helm
#

mmm

#

Okay

#

Thanks bro ❤

tardy viper
#

@quartz kindle Just do you know how i can make the status embed refresh and create in a status channel automatic at the start of the bot ?

#

simply just edit embed to refresh all after 5 seconds

real helm
#

@tardy viper

#

Like log?

tardy viper
#

?

#

what ?

real helm
#

What do you need?

tardy viper
#

Refresh embed all 5 seconds

real helm
#

mmm

#

What embed?

tardy viper
#

embed of tcpPortUsed

quartz kindle
#

@tardy viper you can use setInterval and message.edit

tardy viper
#

Yess i know

#

just where

quartz kindle
#

probably in the ready event

tardy viper
quartz kindle
#

you want it to be on bot start, or on command used?

tardy viper
#

command used

quartz kindle
#

then after the command it used, it will keep refreshing?

tardy viper
#

yess

quartz kindle
#

you can do it like you are doing, but you need to rebuild your embed

real helm
#

What is the page that it gives you background css code

quartz kindle
#

also increase the timer to 5000 for 5 seconds

#

you can make a function to build the embed, and then use the function

tardy viper
#

i have tested the bot not refresh

quartz kindle
#
module.exports.run = async function () {
....
...
let newmessage = await message.channel.send(await build())
setInterval(async () => {
    newmessage.edit(await build())
},5000)

}

async function build() {
    build your embed here;
    return embed;
}```
real helm
#

What is the page that it gives you background css code?

trail dagger
#

in body it is
<body bgcolor: #eee;>

#

if i remember right

quartz kindle
#

@real helm what do you mean what is the page?

trail dagger
#

think he meant how to get background color

real helm
#

yes

#

Yes

#

like gradient background

#

And the page gives u the code

tardy viper
#

@quartz kindle I don't kow

real helm
#
body {
    background: #ee9ca7;  /* fallback for old browsers */
    background: -webkit-linear-gradient(to right, #ffdde1, #ee9ca7);  /* Chrome 10-25, Safari 5.1-6 */
    background: linear-gradient(to right, #ffdde1, #ee9ca7); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */

}
#

Like this

quartz kindle
#

like a css background generator? there are billions of them

#

just google "css background generator"

real helm
#

idk

#

thanks

tardy viper
#

@quartz kindle

const Discord = require("discord.js");
var tcpPortUsed = require('tcp-port-used');

module.exports.run = async (bot, message) => {
    
    if (message.author.bot) return undefined;
    const embed = new Discord.RichEmbed()

    const act = bot.emojis.find(emoji => emoji.name === "icone_actif");
    const ina = bot.emojis.find(emoji => emoji.name === "icone_inactif");
    embed.setColor("#ffffff")
    embed.setTitle("STATUS");
    let inUse = await tcpPortUsed.check(27015,'46.105.84.218')
    embed.addField("__________", 'Status - PropHunt'); 
    embed.addField("Activitée : ",inUse ? `Actif ${act}`  : `Inactif ${ina}`);   
    let inUse1 = await tcpPortUsed.check(27016,'46.105.84.218')
    embed.addField("__________", 'Status - DarkRP'); 
    embed.addField("Activitée : ",inUse1 ? `Actif ${act}`  : `Inactif ${ina}`);     
    let inUse2 = await tcpPortUsed.check(443,'46.105.84.218')
    embed.addField("__________", 'Site / Forum / Boutique'); 
    embed.addField("Activitée : ",inUse2 ? `Actif ${act}`  : `Inactif ${ina}`);      
    let inUse3 = await tcpPortUsed.check(90,'46.105.84.218')
    embed.addField("__________", 'Lien Boutique Discord'); 
    embed.addField("Activitée : ",inUse3 ? `Actif ${act}`  : `Inactif ${ina}`);       
    message.channel.send(embed)
}



module.exports.help = {
    name: "status"
  }```
quartz kindle
#

@tardy viper move the building of the embed to a separate function, so you dont need to repeat it

#

because you need to build the embed again, test all ports again

#

else you will edit the embed with the same embed

tardy viper
#

That

var tcpPortUsed = require('tcp-port-used');

module.exports.run = async (bot, message) => {
    
    if (message.author.bot) return undefined;
    let newmessage = await message.channel.send(await build())
    setInterval(async () => {
        newmessage.edit(await build())
    },5000)
    
    }
    
    async function build() {
        const embed = new Discord.RichEmbed()
        const act = bot.emojis.find(emoji => emoji.name === "icone_actif");
        const ina = bot.emojis.find(emoji => emoji.name === "icone_inactif");
        embed.setColor("#ffffff")
        embed.setTitle("STATUS");
        let inUse = await tcpPortUsed.check(27015,'46.105.84.218')
        embed.addField("__________", 'Status - PropHunt'); 
        embed.addField("Activitée : ",inUse ? `Actif ${act}`  : `Inactif ${ina}`);   
        let inUse1 = await tcpPortUsed.check(27016,'46.105.84.218')
        embed.addField("__________", 'Status - DarkRP'); 
        embed.addField("Activitée : ",inUse1 ? `Actif ${act}`  : `Inactif ${ina}`);     
        let inUse2 = await tcpPortUsed.check(443,'46.105.84.218')
        embed.addField("__________", 'Site / Forum / Boutique'); 
        embed.addField("Activitée : ",inUse2 ? `Actif ${act}`  : `Inactif ${ina}`);      
        let inUse3 = await tcpPortUsed.check(90,'46.105.84.218')
        embed.addField("__________", 'Lien Boutique Discord'); 
        embed.addField("Activitée : ",inUse3 ? `Actif ${act}`  : `Inactif ${ina}`);  
        return embed;
    }

module.exports.help = {
    name: "status"
  }```
quartz kindle
#

yes, you can try that

tardy viper
#

error

#

bot is not defined

quartz kindle
#

dont create a new client instance, just pass the bot to build: await build(bot) async function build(bot)

#

your bot spams the embed?

#

like endlessly?

#

do you have other .on("message") events?

tardy viper
#

@quartz kindle just how add to the bot on ready

#
    setInterval(async () => {
        newmessage.edit(await build(bot))
    },5000)
    
    async function build(bot) {
        const act = bot.emojis.find(emoji => emoji.name === "actif");
        const ina = bot.emojis.find(emoji => emoji.name === "inactif");
        const embed = new Discord.RichEmbed()
        embed.setColor("#ffffff")
        embed.setTitle("STATUS");
        let inUse = await tcpPortUsed.check(27015,'46.105.84.218')
        embed.addField("__________", 'Status - PropHunt'); 
        embed.addField("Activitée : ",inUse ? `Actif ${act}`  : `Inactif ${ina}`);   
        let inUse1 = await tcpPortUsed.check(27016,'46.105.84.218')
        embed.addField("__________", 'Status - DarkRP'); 
        embed.addField("Activitée : ",inUse1 ? `Actif ${act}`  : `Inactif ${ina}`);     
        let inUse2 = await tcpPortUsed.check(443,'46.105.84.218')
        embed.addField("__________", 'Site / Forum / Boutique'); 
        embed.addField("Activitée : ",inUse2 ? `Actif ${act}`  : `Inactif ${ina}`);      
        let inUse3 = await tcpPortUsed.check(90,'46.105.84.218')
        embed.addField("__________", 'Lien Boutique Discord'); 
        embed.addField("Activitée : ",inUse3 ? `Actif ${act}`  : `Inactif ${ina}`);  
        return embed;
    }
});```
quartz kindle
#
bot.on("ready",async ()=>{
    setInterval(async () => {
    bot.channels.find(channelIDYouWant).send(await build(bot))
    // you also need to put your build function in the main file, or require it through a module
},5000)
})```
#

@woven sundial can you show the rest of your code?

tardy viper
#

@quartz kindle How edit

quartz kindle
#

@woven sundial btw you should not be running multiple bot.on("message") events lul

#

best is always to put all your commands in a single event

tardy viper
#
    setInterval(async () => {
    bot.channels.find("606619807810322655").send(await build(bot))
    let newmessage = await bot.channels.find("606619807810322655").send(await build(bot))
    setInterval(async () => {
        newmessage.edit(await build(bot))
    },5000)
    
    async function build(bot) {
        const act = bot.emojis.find(emoji => emoji.name === "actif");
        const ina = bot.emojis.find(emoji => emoji.name === "inactif");
        const embed = new Discord.RichEmbed()
        embed.setColor("#ffffff")
        embed.setTitle("STATUS");
        let inUse = await tcpPortUsed.check(27015,'46.105.84.218')
        embed.addField("__________", 'Status - PropHunt'); 
        embed.addField("Activitée : ",inUse ? `Actif ${act}`  : `Inactif ${ina}`);   
        let inUse1 = await tcpPortUsed.check(27016,'46.105.84.218')
        embed.addField("__________", 'Status - DarkRP'); 
        embed.addField("Activitée : ",inUse1 ? `Actif ${act}`  : `Inactif ${ina}`);     
        let inUse2 = await tcpPortUsed.check(443,'46.105.84.218')
        embed.addField("__________", 'Site / Forum / Boutique'); 
        embed.addField("Activitée : ",inUse2 ? `Actif ${act}`  : `Inactif ${ina}`);      
        let inUse3 = await tcpPortUsed.check(90,'46.105.84.218')
        embed.addField("__________", 'Lien Boutique Discord'); 
        embed.addField("Activitée : ",inUse3 ? `Actif ${act}`  : `Inactif ${ina}`);  
        return embed;
    }
},5000)
})```
quartz kindle
#

@tardy viper dont use 2 intervals

#

send the message first, then use the interval with a message edit

tardy viper
#

@quartz kindle ```bot.on("ready",async ()=>{
bot.channels.find("606619807810322655").send(await build(bot))
let newmessage = await bot.channels.find("606619807810322655").send(await build(bot))
setInterval(async () => {
newmessage.edit(await build(bot))
},5000)

async function build(bot) {
    const act = bot.emojis.find(emoji => emoji.name === "actif");
    const ina = bot.emojis.find(emoji => emoji.name === "inactif");
    const embed = new Discord.RichEmbed()
    embed.setColor("#ffffff")
    embed.setTitle("STATUS");
    let inUse = await tcpPortUsed.check(27015,'46.105.84.218')
    embed.addField("__________", 'Status - PropHunt'); 
    embed.addField("Activitée : ",inUse ? `Actif ${act}`  : `Inactif ${ina}`);   
    let inUse1 = await tcpPortUsed.check(27016,'46.105.84.218')
    embed.addField("__________", 'Status - DarkRP'); 
    embed.addField("Activitée : ",inUse1 ? `Actif ${act}`  : `Inactif ${ina}`);     
    let inUse2 = await tcpPortUsed.check(443,'46.105.84.218')
    embed.addField("__________", 'Site / Forum / Boutique'); 
    embed.addField("Activitée : ",inUse2 ? `Actif ${act}`  : `Inactif ${ina}`);      
    let inUse3 = await tcpPortUsed.check(90,'46.105.84.218')
    embed.addField("__________", 'Lien Boutique Discord'); 
    embed.addField("Activitée : ",inUse3 ? `Actif ${act}`  : `Inactif ${ina}`);  
    return embed;
}

})```

#

that make error

#

Error: Value must be specified.

#

i have added async (bot)

#

and channels is not a function

bold wigeon
#

someone with python knowledge can help me understand why the part of the code is not sending the msg

winged thorn
#

where is code

#

i do python

bold wigeon
#

may i pm it to you?

winged thorn
#

go ahead

stark beacon
#

anyone recommend any nodejs hosts that have high bandwidth allotments? My bot is blowing through our data cap it seems at home..

viral kayak
#
const prefixes = ["circ ", "c ", "c!"]
    for(const thisPrefix of prefixes) {
        if(msg.content.includes(thisPrefix)) prefix = thisPrefix;
    }
    if(!prefix) return;

why do prefixes with space just not work here

quartz kindle
#

@stark beacon galaxygate has unlimited traffic

#

its one of the favorites among many bot developers

stray garnet
#

@viral kayak thats the thing what i want to know aswell lol

tardy viper
#

@quartz kindle Problem

quartz kindle
#

@viral kayak try using startsWith instead of includes

tardy viper
#

The bot not sending on start

viral kayak
#

ok then

#

that works but then i can put like 50 spaces

tardy viper
#

@quartz kindle Can you help me ?

viral kayak
tardy viper
#

And the error is same when its bot.channels.find(`606619807810322655`).send(await build(bot))

quartz kindle
#

@viral kayak you can also do prefixes.includes(content.split(" ")[0]) that matches prefixes without space, but works for messages with spaces

#

@tardy viper i'll get back to you shortly

tardy viper
#

Okai

quartz kindle
#

@tardy viper remove bot form the first line, you are replacing your entire client with nothing

#

async () not async (bot)

tardy viper
stark beacon
#

sent them an email with my Q's, thanks @quartz kindle

quartz kindle
#

they also have a discord server which is pretty active

tardy viper
#

@quartz kindle

    bot.channels.find(`606619807810322655`).send(await build(bot))
    let newmessage = await bot.channels.find("606619807810322655").send(await build(bot))
    setInterval(async () => {
        newmessage.edit(await build(bot))
    },5000)```
quartz kindle
#

@tardy viper also, dont use .find("prop","val") use .find(channel => channel.id === "yourID") but anyway if you're using IDs, dont use .find at all, just use .get("yourID")

viral kayak
#

ok uh

#

where do i put that

stray garnet
#

@quartz kindle can u help me aswell?

quartz kindle
#

@stray garnet your code makes no sense, what is message.c?

tardy viper
#

@quartz kindle BIIIIIIIIIIIIIG thank

quartz kindle
#

@viral kayak if you send a message like !pr something, you can do ```js
prefixes = ["!pr","!34","!a"];
if(prefixes.includes(message.content.split(" ")[0]))

#

that will always check if the beginning of the message UNTIL THE FIRST SPACE, includes one of the prefixes

viral kayak
#

so i dont need the for then

quartz kindle
#

nope

tardy viper
#

@quartz kindle Just latest help how i can add system of bot CLear channel after reboot

quartz kindle
#

explain

trail dagger
pale marsh
#

Check your css and see where it might be breaking

#

Or maybe those white lines are just in the image itself

trail dagger
#

nothing with css and the image, idk why that would happen

slender thistle
#

Those white lines are CSS most likely

pallid zinc
#
       const voiceChannel = message.member.voiceChannel;
       if (!voiceChannel) {
message.channel.send(':x: **I\'m sorry but you need to be in a voice channel to play music.**')
  } else { voiceChannel.join() 
      
      try {
        var video = await youtube.getVideo(url);
      } catch (error) {
        try {
          var videos = await youtube.searchVideos(searchString, 1);
          var video = await youtube.getVideoByID(videos[0].id);
        } catch (err) {
          console.error(err);
          return message.channel.send(':x: **I could not obtain any search results.**');
        }
        return handleVideo(video, message, voiceChannel);
      }}
      break;```
#

its not playing anythink

earnest phoenix
#

guys i need an api wrapper

#

which is the official

tardy viper
#

How i can make status web in node js

quartz kindle
#

@trail dagger its a box-shadow on .bot-image

trail dagger
#
  box-shadow: none;
} ```
#

??

tardy viper
#
const app = express();
var tcpPortUsed = require('tcp-port-used');








const server = app.listen(94, () => {
    console.log(`Express running → PORT ${server.address().port}`);
  });

  setInterval(async () => {


app.get('/', function (req, res) {

 let inUse = tcpPortUsed.check(27015,'46.105.84.218')
 let inUse1 = tcpPortUsed.check(27016,'46.105.84.218')
 let inUse2 = tcpPortUsed.check(443,'46.105.84.218')
 let inUse3 = tcpPortUsed.check(90,'46.105.84.218')


res.send(`Serveur PropHunt ${inUse ? `Actif`  : `Inactif`}Serveur DarkRP ${inUse ? `Actif`  : `Inactif`}Site / Forum / Boutique ${inUse ? `Actif`  : `Inactif`}Lien Boutique discord ${inUse ? `Actif`  : `Inactif`}`);

}, function(err) {
    console.error('Error on check:', err.message);
});



},5000)```
#

How i can make web with express @quartz kindle did you know ? 😂

real helm
#

I like to do a generator in html

quartz kindle
#

@tardy viper you just did it lol

tardy viper
#

?

#

I know how create html

#

just

#

i don't know how use the

 let inUse1 = tcpPortUsed.check(27016,'46.105.84.218')
 let inUse2 = tcpPortUsed.check(443,'46.105.84.218')
 let inUse3 = tcpPortUsed.check(90,'46.105.84.218')```
#

in the html

abstract crow
#

With script tags

#

Use <script> code </script>

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

lusty dew
#

Using an embed you can use .setImage()

low wasp
sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

low wasp
#

Ah

warm marsh
#

.setImage()

sage bobcat
#

One message removed from a suspended account.

low wasp
#

Then it would be either .attachFile, .setThumbnail, or .setImage

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

warm marsh
#

As a file itself?

#

Plus a separate embed

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

warm marsh
#

Ok

low wasp
#

@sage bobcat use .attachFile then

warm marsh
#

new Discord.Attachment("url", "name.jpg");

sage bobcat
#

One message removed from a suspended account.

warm marsh
#

then in the send bit send(Embed, attachment)

#

Oh, Actually depends what version of d.js you're on.

#

For me it's MessageAttachment()

sage bobcat
#

One message removed from a suspended account.

halcyon nymph
#

Question for the newest version of discord.py, is there a way to delete roles, I know their is a way to create roles, but i don't know about deleting them

warm marsh
#

setFile doesn't exist.

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

low wasp
#

is that the correct path?

#

did u forget a \ between UnderCordImages and Flowey

tardy viper
#

How my bot can clear channel at is start ?

#

clear a specific channel *)

real helm
#

Hello

#

How I do a copy button in HTML

#

using id

halcyon nymph
#

@real helm you use java script

var copyText = document.getElementById("myInput");
  copyText.select();
  document.execCommand("copy");
  alert("Copied the text: " + copyText.value);

From w3schools website

real helm
#

it works?

halcyon nymph
#

Idk, I just googled it

real helm
#

How I put it in a button

halcyon nymph
#

<button id= “myInput”></button>

#

I assume

real helm
#

o yes

#

true

sage bobcat
#

One message removed from a suspended account.

real helm
#
<button id=“myInput” onclick="copy()">Copiar</button>
     <script>
     function copy(){ 
    
      var copyText = document.getElementById("myInput");
     copyText.select();
     document.execCommand("copy");
     alert("Copied the text: " + copyText.value);
     }
   </script>
#

@halcyon nymph like this?

halcyon nymph
#

Idk, my html is god awful so I wouldn’t know sorry, I’d recommend using w3schools though, that really helps me with my markdown

real helm
#

mm okay

tardy viper
#

Can you say me how i can set all in false

#

when the inuse5 is false ?

#

i have maked it

#
     if (inUse5 = false) {
           (inUse = false)
            (inUse1 = false)
            (inUse2 = false)
            (inUse3 = false)
            (inUse4 = false)
        }```
#

and not work

halcyon nymph
#

Is that JavaScript @tardy viper

tardy viper
#

Js

#

yess

halcyon nymph
#

You might want ; at the end of your declarations

tardy viper
#

not work

halcyon nymph
#

The brackets are also unnecessary if you’re declaring them

tardy viper
#

its if five is false ALL go false

halcyon nymph
#

Oh

#

You want ===

#

Instead of just =

tardy viper
#

what change ,

halcyon nymph
#

in the if statement

#

1 = sign is for declaring variables

#

3 = signs is comparing two variables

tardy viper
#

i make it if (inUse5 === false) { (inUse = false); (inUse1 = false); (inUse2 = false); (inUse3 = false); (inUse4 = false); } ?

halcyon nymph
#

Yeah, see if that works

tardy viper
#

not work

#

no error

halcyon nymph
#

You also don’t need the brackets

#

Around Inuse 1 through 4

tardy viper
#
            (inUse = false);
             (inUse1 = false);
             (inUse2 = false);
             (inUse3 = false);
             (inUse4 = false);```
#

that ?

halcyon nymph
#

No

#

Hold up I’ll do it

#
            var inUse = false;
             So on for the rest
            
         }```
sage bobcat
#

One message removed from a suspended account.

tardy viper
#

@halcyon nymph Just its to change the variable to false

#

and the problem is the code create a new var

halcyon nymph
#

Oh

tardy viper
#
        const act = bot.emojis.find(emoji => emoji.name === "actif");
        const ina = bot.emojis.find(emoji => emoji.name === "inactif");
        const embed = new Discord.RichEmbed()
        embed.setColor("#ffffff")
        embed.setTitle("STATUS");
        let inUse = await tcpPortUsed.check(27015,'46.105.84.218')
        embed.addField("__________", 'Status - PropHunt'); 
        embed.addField("Activité : ",inUse ? `Actif ${act}`  : `Inactif ${ina}`);   
        embed.addField("Heure de redémarrage: ", `6H du matin`);
        let inUse1 = await tcpPortUsed.check(27016,'46.105.84.218')
        embed.addField("__________", 'Status - DarkRP'); 
        embed.addField("Activité : ",inUse1 ? `Actif ${act}`  : `Inactif ${ina}`);     
        embed.addField("Heure de redémarrage: ", `7H du matin`);  
        let inUse2 = await tcpPortUsed.check(443,'46.105.84.218')
        embed.addField("__________", 'Site / Forum / Boutique'); 
        embed.addField("Activité : ",inUse2 ? `Actif ${act}`  : `Inactif ${ina}`);      
        let inUse3 = await tcpPortUsed.check(90,'46.105.84.218')
        embed.addField("__________", 'Lien Boutique Discord'); 
        embed.addField("Activité : ",inUse3 ? `Actif ${act}`  : `Inactif ${ina}`);  
        let inUse4 = await tcpPortUsed.check(94,'46.105.84.218')
        embed.addField("__________", 'Status WEB'); 
        embed.addField("Activité : ",inUse4 ? `Actif ${act}`  : `Inactif ${ina}`);  
        let inUse5 = await tcpPortUsed.check(443,'46.105.84.218')
        embed.addField("__________", 'Status VPS'); 
        embed.addField("Activité : ", inUse5 ? `Actif ${act}`  : `Inactif ${ina}`); 
             if (inUse5 === false) {
                var inUse = false;
                var inUse1 = false;
                var inUse2 = false;
                var inUse3 = false;
                var inUse4 = false;  
             }
        return embed;
    }
})```
halcyon nymph
#

If you’ve already defined it you don’t need var

#

@tardy viper idk what to tell you, I’ve literally written out the code in console and it works for me

tardy viper
#

They are problem

#

Work at 25%

#

if inUse5 is true error Cannot send an empty message

#

i have repare the problem

grizzled canyon
#

Hello, I'm looking for a tool that updates my bot without having to restart the .py app

#

Like nodemon in NodeJS

amber fractal
#

pm2 works for everything

#

you can use that and enable watch

#

I use pm2 to run my minecraft server mmLol

wooden plover
#

Agreed, pm2 is really good

winged thorn
#

What's pm2

valid frigate
#

bruh

#

process manager

inner jewel
#

i use systemd

valid frigate
#

if you know what forever is it's similar

winged thorn
#

Oh

#

I see

valid frigate
#

lots of people here use it yeah

cerulean zinc
#

Just looking for an opinion, would having the bot directly render images be better or having a stand alone server for rendering images be better?

earnest phoenix
#

if you have the money and resources, you'd usually have something that is not monolithic

peak quail
#

why this is creating a txt channel not a voice channel ?

await message.guild.createChannel(`User ${member} vom voice entfernt`, ["voice"]);
earnest phoenix
#

because you're passing it an invalid argument for the type

#

you're passing it an array

#

pass it ChannelData instead, e.g { type: whatever }

tardy viper
#

How i can make an automatic clear channel on start of bot ?

earnest phoenix
#

elaborate

tardy viper
#

That not saying me how

earnest phoenix
#

what

valid frigate
#

you want to delete an entire channel when your bot starts?

tardy viper
#

To automatic clear specific channel on boot of bot

#

just clear message

#

delete channel is my problem 😂

valid frigate
#

what lib

tardy viper
#

JS

earnest phoenix
#

yes but which library

tardy viper
#

?

earnest phoenix
#

js is a language

valid frigate
tardy viper
#

E^pic

#

😂

#

Easyyest 😂

#

Why i have not maked that the first time 😂

#

bot.channels.get("607930498055929876").bulkDelete(50)

valid frigate
#

uh

tardy viper
#

That work 😂

valid frigate
#

you're welcome mmulu

tardy viper
#

Thank 😃

cold canyon
#

Does anyone know a good hosting service that is free other than Heroku and Glitch

hushed berry
#

there isnt much/any overlap between good and free 🤷

#

you get what you pay for

cold canyon
#

I found PythonAnywhere but I have to pay

earnest phoenix
#

there are no good free hostings

#

there never will be

#

either selfhost or buy an actual vps

#

services like google cloud and aws offer free 1 year trials

#

you can also grab the github student pack if you have an edu email that gives you $50 on digitalocean

#

and $100 on azure

cold canyon
#

I'll use pythonanywhere

#

And get a custom plan

#

With 4 terminals

#

3 for my bots and 1 for packages

broken shale
#

why 4 terminals when you need one

still rampart
#

Curious if anyone know off top of head.
For new EmbedBuilder().setTitle(null, "imageLink")

How small will the image be in the header? Will it resemble the standard setImage?
Im basically trying to setImage above the description.

#

I would test but im kinda lazy tbh

broken shale
#

You can't set an image above the description in d.js iirc

still rampart
#

This is Java api

broken shale
#

then can't speak for that

still rampart
#

I'll throw together a test then, thanks for response.

broken shale
#

np

#

Rare JDA user

#

;o

still rampart
#

I grew up in the Minecraft plugin scene, work as a java dev for work. not very familiar with js.

#

Java C# SQL LUA not muhc of a web guy

earnest phoenix
#

you can't alter how anything displays on end user's screen, that includes the ordering of embed contents

still rampart
#

Ah. Seems it turns the Title into a link, instead of displaying an image. Kind disappointing.

#

Maybe I can cheese it, let's see.

#

Nope, ah well.

broken shale
#

Thats the same with d.js

#

Links don't get resolved in titles

copper cradle
#

you can, however, add an image to seTitle

late hill
#

This has nothing to do with your library

copper cradle
#

it'll look like a really small circle

late hill
#

If you can't do a certain embed thing within your library it simply means your library didn't fully implement everything

#

Embeds will always display the same no matter what library you're using

soft cove
#

Any suggestions for a good vps?

#

(that is able to run multiple bots)

late hill
#

digitalocean

#

It's expensive compared to others

#

But has good customer support/reliability

soft cove
#

Ok

soft cove
#

If I'm going to use a vps what should determine how many cores i get?

west spoke
#

pricing

soft cove
#

but should how many bots im going to be hosting have an affect on that

#

im going to be hosting 5 bots, but 3 of those bots would only be in 3 or less server

copper cradle
#

I mean

#

I guess

wise blaze
#

What wrong with that

            role = discord.utils.get(member.guild.roles,name='Bronzo')
            await member.add_roles(role)
west spoke
#

You need a member

#

Eg message.author

wise blaze
#

Eg?

west spoke
#

"For example" essentially

wise blaze
#

ah okey

sonic peak
#

well getting listed here helped me find a bug in discord.js

#

does anyone know why this is happening when I try to fetch the guild owner?
source code is js let owner = await client.fetchUser(msg.guild.owner);
and the error is a promise rejection from d.js js (node:1) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of undefined LemmeSmash-bot | at Object.User (/app/node_modules/discord.js/src/util/Constants.js:109:16) LemmeSmash-bot | at RESTMethods.getUser (/app/node_modules/discord.js/src/client/rest/RESTMethods.js:402:51) LemmeSmash-bot | at Client.fetchUser (/app/node_modules/discord.js/src/client/Client.js:319:30) LemmeSmash-bot | at Object.ensurePermissions (/app/bot/utils.js:66:38) LemmeSmash-bot | at processTicksAndRejections (internal/process/task_queues.js:89:5) LemmeSmash-bot | at async /app/bot/proxy.js:17:14 LemmeSmash-bot | (node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)

#

seems like its from this part of d.js according to the error

const Endpoints = exports.Endpoints = {
  User: userID => {
    if (userID.id) userID = userID.id;
    const base = `/users/${userID}`;
    return {
      toString: () => base,
      channels: `${base}/channels`,
      profile: `${base}/profile`,
      relationships: `${base}/relationships`,
      settings: `${base}/settings`,
      Relationship: uID => `${base}/relationships/${uID}`,
      Guild: guildID => ({
        toString: () => `${base}/guilds/${guildID}`,
        settings: `${base}/guilds/${guildID}/settings`,
      }),
      Note: id => `${base}/notes/${id}`,
      Mentions: (limit, roles, everyone, guildID) =>
        `${base}/mentions?limit=${limit}&roles=${roles}&everyone=${everyone}${guildID ? `&guild_id=${guildID}` : ''}`,
      Avatar: (root, hash) => {
        if (userID === '1') return hash;
        return Endpoints.CDN(root).Avatar(userID, hash);
      },
    };
  }```
#

specifically js if (userID.id) userID = userID.id;

#

because for some reason the argument passed to the function is undefined

earnest phoenix
#

have you thought of that maybe you're passing an undefined object

sonic peak
#

I'm not passing anything, that's discord.js source code

maiden mauve
#

hmm... someone wanna educate me on forEach and async?

sonic peak
#

msg.guild.owner does exist

maiden mauve
#

when written like that

#

newHex(); does full console log iteration

#

then console.log line does full iteration

#

when I remove the "await" in the middle

#

they interchange as expected

earnest phoenix
#

docs say it can be nullable

#

probably means the owner is uncached

sonic peak
#

shit when I query it manually it's returned fine

#

hmm

#

thanks for your help!

dusk hawk
#

H

earnest phoenix
#

to get the owner in cache simply call fetchMember(guild.ownerID) on a guild

sonic peak
#

oh fbdhdf yeah I was doing that thank you!

#

re: async functions as above, that just wraps it in a promise and it resolves when the thing is finished doing stuff

maiden mauve
#

am I doing something wrong with the syntax inside?

sonic peak
#

what's your expected behaviour?

#

I just gotta build a picture of what's supposed to happen and what's actually happening

maiden mauve
#

the outputs are behaving normally

#

but

#

with an await separating them

#

it iterates them completely separate

sonic peak
#

oh so you want them iterated as newHex() and immediately after, the console.log line?

maiden mauve
#

correct, the await is in there because it's ideally checking to make sure the hex doesn't exist in db

sonic peak
#

because if you await the call it will do only that call first and then when it's finihed, move on to the next part

#

maybe a do-while loop might help

maiden mauve
#

i just used forEach for simplicity but it seems to have unexpected behavior

sonic peak
#

yeah it's weird like that if you wanna do fancy things with it

maiden mauve
#

ive never heard of an iteration command doing each line separately

#

"do line 1 100 items, do line 2 100 times, etc"

sonic peak
#

js is async by default so it does weird things

#

hmm,

maiden mauve
#

it appears to work when i move the await

#

basically the idea was to assign random hex codes to a new property in the database

#

and if one repeated, get a new one

#

this would moved to "new account" when assigning the code

sonic peak
#

ohhh

#

yeah I implemented the same thing when checking for collisions in randomly generated IDs

#

I used a do-while loop as well

maiden mauve
#

I use player tags for players to attack each other

#

but many people complain

#

so I was going to assign people a 3-digit Hex

#

so instead of ?Attack @maiden mauve you could do ?attack #3FC

sonic peak
#

ahh i see yeah all the pings would get annoying

maiden mauve
#

and having a predictable order seemed boring

#

000 , 001 , 002 etc

#

16^3 = 4096

sonic peak
#

i'd do something like js do { textHex = netHex(); compare = await players.dbcallthing(); console.log("yourstuff"); } while (compare)

maiden mauve
#

yeah d/w simplifies the structure a little bit

sonic peak
#

that way it generates one first, and if its taken, it goes into the loop

maiden mauve
#

then at end of loop, assignment and save should work fine

sonic peak
#

yeah, tho I always recommend catching db query errors and handling them somehow

maiden mauve
#

I've never had a query error

sonic peak
#

neither have I but I like to be prepared

maiden mauve
#

lol

#

honestly who knows right db could go down

sonic peak
#

in C# I use HashSets to avoid duplicate entries

#

but idk if that's a thing in JS

#

damn

maiden mauve
#

db.findOne( { property } );

broken shale
#

^ if a db

maiden mauve
#

should immediately resolve it

#

im not sure what HashSets does

broken shale
#

But you'd have to filter it out in js

sonic peak
#

oh a HashSet is like... an Object but without values

maiden mauve
#

any check for duplication would have to iterate right?

sonic peak
#

HashSet is actually a type, it handles all that for you without having to have an iterator

#

instead of an array you could use a HashSet but not in mongo, I'm pretty sure it doesn't have those

maiden mauve
#

🤷

#

mongo iterates 1000 awaits in under 1 second so

sonic peak
#

yeah it's pretty fast

maiden mauve
#

iteration NomParty

broken shale
#

xd

sonic peak
#

I'd probably just stick with do-while

#

vfvfgvfhh

maiden mauve
#

yeah hopefully it doesn't get angry again

#

thanks

broken shale
#

What lang

maiden mauve
#

pizza time

#

🍕

sonic peak
#

lmao enjoy

#

also the lang is js

broken shale
#

cheeseburgers > pizza

#

Can't resist tbh

sonic peak
#

what about cheeseburger pizza

west spoke
#

why are we spamming emotes

broken shale
#

Not spam

#

Reactions

west spoke
#

it's still annoying.

I'm guessing you were the one who first added them to those messages?

split holly
#

j

west spoke
#

Wha--

sonic peak
#

it's not that annoying discombobulated

#

also I am a fool can someone help me with discord.js...
when I try to get the guild owner using guiildObjectHere.fetchMember(idHere) it returns a rejected promise saying Error: Invalid or uncached id provided.

#

I'm not sure how to get a member object that's uncached...

valid frigate
#
  1. just use guild.members.fetch() if you know the user is cached (aka your bot has seen it before)
  2. you're not providing a valid member id
sonic peak
#

it's definitely not cached, also the snowflake is returned from messageObject.guild.ownerID

#

which for this guild is apparently 107568785157795840

#

so like

#

it is valid

#

that's what's got me

#

unless this guild in particular is just discombobulated like that, because it's working in every other guild ever

#

I ended up just writing a function to do this and it's working bvhfbhg

valid frigate
#

something tells me maybe you were passing an invalid id if you made it into a function and it worked

#

but gj

sonic peak
#

yeah I probably was passing something invalid

#

I'll figure it out and yeet the function becuase I'm pretty sure it's just me fucking up vfvggfvbhf

jaunty stump
#

Ok, So. I have my bot made..now I am just struggling with having a couple commands only to be used by one person or can only be used if said person has a specific role

I think, if message.author.id == "USER_ID_HERE": will work but I don't know where to put it in (picture attached)

help would be nice if anyone isn't to busy helping other people with more advanced issues. Yes it's Python

sonic peak
#

thanks for your help!

valid frigate
#

np

sonic peak
#

@ Ori with that structure you're better off defining a function that checks the user ID and returns a bool or something

#

then just inserting it wherever you need that checked and bail if false is returned

valid frigate
#

something that can fetch the users roles and return a boolean

jaunty stump
#

hmm

sonic peak
#

does python have a switch statement?

jaunty stump
#

This is the first time I have made a bot in python so I am not sure

sonic peak
#

fair, either way conditionals do the job

#

is it every command after / that is only for a certain user?

jaunty stump
#

only 2 commands

#

not all of them

sonic peak
#

In that case I'd define a function that checks the message author's id against your chosen ID and/or checks user roles and returns a boolean

#

if they don't have permission or the user ID doesn't match, false is returned

#

and if you insert if ensure_permissions_func == false: return right below if command.startswith() you shuold be good

#

(that's pseudocode because I'm rusty with python vbbfvbhg)

jaunty stump
#

I will give that a try

sonic peak
#

it's half done I'm literally writing it right now vbfh

earnest phoenix
#

@sonic peak try
let owner = client.guild.find(g => g.id === msg.guild.id).members.find(m => m.id === msg.guild.ownerID);

sonic peak
#

thanks!

#

I'll save that

earnest phoenix
#

that will return a user, not a guildmember

#

There's shit you can do to a guildmember you can't do to a user

sonic peak
#

fair, I literally only need it to DM them

earnest phoenix
#

Some discords have had their owners deleted and you'll get a bot crash so you need either a catch error or an if (owner != null) {}

#

you get the idea

sonic peak
#

yeah I am catching

#

but for some reason it's not actually catching???

#
owner.send(`I'm missing the following permissions in **${msg.guild.name}**:\n\`• ${missing.join("\n• ")}\``).catch(async () =>```
#

that should like

#

catch... right?

sudden geyser
#

Maybe because it's async?

#

actually not sure, mind that

earnest phoenix
#

await client.fetchUser(msg.guild.ownerID)
.catch(console.error);

sonic peak
#

but that's inside the catch bit

earnest phoenix
#

Also word of warning, if you get the bot to send a message to someone who has blocked the bot, the bot will crash

#

so you need another .catch(console.error) on the message send

sonic peak
#

that's what I mean, I am

#

that's what that snippet is

#

but it's not actually catching

#

I get unhandled promise rejections

sudden geyser
#

Is the error message Cannot send message to this user

sonic peak
earnest phoenix
#

So go back earlier in the code and do a console log systematically on every step until you find something that's undefined or null and you'll find your glitch

sonic peak
#

I get missing permissions, which is because the owner has blocked it (we're testing)

#

I know where it is because I already did that

earnest phoenix
#

That's missing permissions so change the guild's permisisons or the room permissions and make sure your bot has manage channel enabled

sonic peak
#

it's definitely the send

earnest phoenix
#

or send message enabled

#

the bot will have it's own role

#

the room will have it's own rules

sonic peak
#

no no I'm doing this for testing, I definitely want the bot to handle not haivng permissions properly

weary zodiac
#

if it has its permissions

earnest phoenix
#

Those sorts of error messages don't usually crash bots

sonic peak
#

I'm trying to not give it permissions

weary zodiac
#

most errors dont crash bots

sonic peak
#

unhandled promise rejections will in future

#

but why aren't my promise rejections being caught when I literally use .catch()

earnest phoenix
#

sending a message to a user who has blocked the bot WILL crash the bot if you don't have a .catch

sonic peak
#

I literally am using .catch()

weary zodiac
#

no it doesnt

sonic peak
#

unhandled promise rejections will crash node

#

or they will in future

#

since they're deprecated

sudden geyser
#

It might be throwing somewhere else, or it could be inside the catch block. We don't know, but if you couldn't send to the user, it would reject with Cannot send message to this user.

sonic peak
#

Oh right

earnest phoenix
sonic peak
#

So somehow it's missing a permissions to do... nothing?

earnest phoenix
#

I'm telling you I had this guy block the dm on this server I run a bot on with over 5,000 members and I spent hours trying to figure out the problem, take my advice or leave it

#

The code will run up until the failed dm then it will do no more

#

if you have a catch, it will carry on further

sonic peak
#

I did, what I'm saying is I already took your advice

earnest phoenix
#

Cool

#

Embeds really make your bot's messages look professional, agreed

sonic peak
#

I already have the bot posting stack traces to a channel I configure in my server

earnest phoenix
#

That's something I can't do, got any good code on stack tracing?

sonic peak
#

I wrote a function for it

earnest phoenix
#

care to share?

sonic peak
#

fuck it broke markdown lmao

#

son of a bitch

earnest phoenix
#

e.stack!? that's it? I'm going to have to toy with that

sonic peak
#

lmao yeah every error object has a stack property

#

also I run a bot in > 6000 guilds but its in C# and I handle errors right

#

but js... that thing scares me

earnest phoenix
#

Woah I've only got a bot running in 2 guilds

weary zodiac
#

add it to this server and make ot 3

sonic peak
earnest phoenix
#

I could but it's kind of custom built for a server and I doubt you would use it as a moderator bot that assigns containment roles on trolls

sonic peak
#

troll => secure().contain().protect(troll);

#

heck the SCP emoji I had is gone :C

earnest phoenix
#

Like the bot has 143 role emojis in a database

#

and you click one of the emojis the bot adds/removes that role

#

but it's got a role limiter function

#

so we have categories, so with the mystery conspiracies roles we have a limit of 20 maximum roles of that type

#

And the bot sends you a message if you choose the role or remove the role

west spoke
#

Yagpdb has that

earnest phoenix
#

Similar to Yagpdb, but we wanted our own in house bot because someone's found an exploit to it and we wanted control of our own server

#

also yag didn't have a way to limit the number of roles of certain categories

sonic peak
#

Valid

earnest phoenix
#

coding our own bot seemed the right way to go

#

also vortex only had one containment role, we wanted 4

sonic peak
#

also my promise catch code is working in all my tests but just not in this server lmao

earnest phoenix
#

A big question I get asked is someone on the server keeps disconnecting us randomly in voice calls and I tried raw packet sniffing, the packet only says that user is now in a null voice channel, I couldn't figure out a way to find out who was doing it.

sonic peak
#

oof

earnest phoenix
#

That's what I got from the packet sniffer

#

It will tell you which user got disconnected but not who issued the diconnect command

#

There's like 50 moderators on the server and everybody is pointing fingers at each other

sonic peak
#

oh jeez

#

Good luck with that Sweats

earnest phoenix
#

I did a lot of digging, the voice chats they have their own gateway

sonic peak
#

wh.. so you can't do it without http yeeting a request to that?

#

or you mean ws gateway?

earnest phoenix
#

Sorry I'm a bit of an old timer, i'm not used to your kids language I don't really get the whole yeet thing.

sonic peak
#

vfvgfhg fair I'm not exactly young at 24, but still

earnest phoenix
#

That's young, trust me

sonic peak
#

thanks i actually needed to hear that bfvvbhd

#

anyway what I mean is, do you have to actually make a request to the separate gateway?

earnest phoenix
#

Well discord 12 now has a separate voice API,
The linux server I have to host my bot on can only really do discord 11.5 unless you recode the node modules

#

when a bot joins a vc it establishes a connection to the voice gateway

#

so unless the bot is in the voicechat at the same time I don't think there's a way to know

#

So a bot not in vc won't be able to intercept voice packet data for instance

#

And even then the voice packets are encrypted

#

I had ideas to do a voice to text, text to algorithm, algorithm to text, text to speech bot similar to Siri at one point.

#

But yeah voice chat bots are a whole can of worms in of themselves

sonic peak
#

oh man

#

that sounds complex

#

Oh man @earnest phoenix thanks for your advice btw I hope pings are ok bvbfdvh

#

I found the issue, it's uh, I was a complete fool

#

Imma need to code in a statically typed language for a bit to calm my nerves lmao

maiden mauve