#development

1 messages · Page 875 of 1

digital ibex
#

idk if that made sense uh, im getting this error when trying to connect to mongoose and uh

golden condor
#

@amber fractal is there a save function?

amber fractal
#

wym

#

When you insert to the db it saves

tired nimbus
#

In sqlite, how can I get all users who have a certain value?

#

I want to access each user individually

modest maple
#

use SELECT * FROM xyz WHERE <column to filter>=?

#

then can do fetchall

tired nimbus
#

wouldnt that return every single user at the same time

modest maple
#

it returns an iterator...

#

you can iterate over it

pallid marsh
#

hey how can i close all the shards if i want?

digital ibex
#

just

valid frigate
#

shut down your bot

digital ibex
#

client.disconnect()

#

or client.destroy()

valid frigate
#

and then restart it

crimson vapor
#

Is today DB day?

#

I read through and see it’s all about mongo and SQL

quartz kindle
#

why not? lets all worship how great database technology is

crimson vapor
#

lol

finite bough
#

my brain uses json db

crimson vapor
#

If you were to set your bot as an API so you can request data on guilds and db information (for a web interface), would you host 2 instances or just one doing the api and main functions?

digital ibex
#

does anyone know how i can fix this error when trying to connect to mongoose?

#

not the unhandled promise thing

small prairie
#

getaddrinfo EAI_AGAIN discordapp.com discordapp.com:443 at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)

#

Whats this?

#

d.js v 11.5

#

i mean error*

torpid valve
#

Can someone give me script to get all server invites that bot in? I can't find it and actually no idea how to create it

earnest phoenix
#

in

#

which

#

library

small prairie
#

there are a flaw there
1st Its not allowed

torpid valve
#

discord.js

small prairie
#

You cannot get invite with the server's permission

torpid valve
#

Forgot to say it

small prairie
#

i mean you arent supposed to do it

#

are you?

earnest phoenix
#

Can someone please Tell me how to make my bot leave any server that doesn't have a user that has manage server that has either one of the 2 roles in my server that are supposed to be able to Invite the Bot?

Using js

small prairie
#

Is it only me or this wasnt understandable

earnest phoenix
#

Like premium bote

#

Bots

#

That have roles that can invite the bot

#

And if the said user doesn't have the role

#

The bot leaves

small prairie
#

then get your server and then check the owner or whatever for a role

earnest phoenix
#

That's not what I mean

#

I wanna make my bot do that

small prairie
#

;-; wow

topaz sphinx
#

anyone here who got SQL brains?

earnest phoenix
#

Like unbelivaboat premium

topaz sphinx
#

it's rare to see those creatures these days

#

most people rely on JSUNreliable and SQSinglethread

severe zealot
#

Can anyone help me with bot commands

earnest phoenix
#

Explain the problem

#

We are all here to help

topaz sphinx
#

smash the kb and carry the vinegar

earnest phoenix
#

ELECTR0ZED#0001 knows sql I believe @Gofven#00021

severe zealot
#

@earnest phoenix its just im not good at commands and I would like to learn how to be good at making them

earnest phoenix
#

OOF failed ping

topaz sphinx
#

@earnest phoenix can ye summon him

earnest phoenix
#

Well go Dms

#

Uhh

#

@coarse dust

topaz sphinx
earnest phoenix
#

That counts as a cold ping ;w;

#

Can someone please Tell me how to make my bot leave any server that doesn't have a user that has manage server that has either one of the 2 roles in my server that are supposed to be able to Invite the Bot?

Using js

topaz sphinx
#

lots of if else statements

#

it's a specific case issue

lime hare
#

What will we use to show the total number of banned users?

#

exam : Server Owner ', msg.guild.owner

earnest phoenix
#

in which library

grizzled raven
#

what could you do to improve ram management

tired nimbus
#

sql.prepare("SELECT COUNT(*) FROM raid WHERE raid1 > 0");

Would this return the number of occurences where raid1 are greater than 0?
It returns not a number

grizzled raven
#

nevermind about my question

wise quartz
#

I'm trying to make a command that my bot users will use to report bugs they find on my bot. So the command will work like m!report-bug {title} {description} {attachment} how do i make the arguments be sentences not only 1 word for the title and description? (Python)

turbid bough
#

using quotes?

wise quartz
#

How?

turbid bough
#

m!report "here is a sentence" "here is another sentence"

wise quartz
#

Yeah but

#

I mean most people won't know how to use that

turbid bough
#

then give them an error

#

"too many arguments"

wise quartz
#

Ain't there like a way to split text by commas or?

turbid bough
#

yeah, but that wouldnt work if you were going to add a comma on your description or title

wise quartz
#

I mean your quotes idea ain't bad...

#

😂

#

Less work is my thing so

#

Ye thanks

turbid bough
#

Or, you can use a website to generate a command for you like how discord does

tired nimbus
#

sql.prepare("SELECT COUNT(*) FROM raid WHERE raid1 > 0");

Would this return the number of occurences where raid1 are greater than 0?
It returns not a number

#

even after having

#

Number( )

#

hmmmmm maybe

#

its because I have no ;

#

nope

turbid bough
#

works for me

#

the one you sent the code above

#

with the semicolon though

tired nimbus
#

still doesnt work

turbid bough
#

sql.prepare returns NaN?

tired nimbus
#

const usersin1 = sql.prepare("SELECT COUNT(*) FROM raid WHERE raid1 > 0");

#

Number(usersin1)

#

= NaN

turbid bough
#

but userin1 const returns what?

#

if Number(userin1) returns NaN that means you are probably not selecting the correct variable right?

tired nimbus
#

Im using the same variable

#

However

#

without Number()

#

it seems to be null

#

let me gather a few more tests

turbid bough
#

can you try querying directly from the database?

tired nimbus
#

Update: it seems without Number() it returns

#

[object Statement]

earnest phoenix
#

anyone out there proficient in TypeScript looking for some side-work? My current dev is having to take a break, and I've got a bot in over 2600 servers I'd like to continue having worked on haha

turbid bough
#

what do you usually do with database data when you are retrieving the whole row

#

btw, what language

tired nimbus
#

if im getting the whole row I just do row.column

#

node

turbid bough
#

try that

#

since you are still returning a table, not just a number

#

it would just be in array[0][0]

#

basically

#

what library are you using for database, since i cant find the function

topaz sphinx
#

thaun are you a rare SQL troll?

#

I need ur knowledge

turbid bough
#

??

topaz sphinx
#

i am trying to learn postgresql but I can't just do the harder part

turbid bough
#

what are the harder part?

earnest phoenix
#
if (!member.guild.me.hasPermission("MANAGE_CHANNELS")) return;```

Cannot read property ‘hasPermission’ of undefined
#

why?!

topaz sphinx
#

@turbid bough can i yeet u into my dmz, Vinx theres discord servers dedicated to discordjs

#

and eris

turbid bough
#

guildmember does not have haspermission, but member has

tired nimbus
#

I cant seem to get a valid output

topaz sphinx
#

i wanna do something similar to this thaun

#
DO $$ 
DECLARE
    ratelimit     INTEGER := 42;
    reset_timeout timestamptz := NOW() - '1 hour'::interval;
BEGIN 
    IF reset_timeout >= NOW() THEN
        ratelimit := 45;
        reset_timeout := NOW() + '1 hour'::interval;
        RAISE NOTICE 'reset';
    ELSE
        IF ratelimit > 0 THEN
            ratelimit := SUM(ratelimit - 1);
            RAISE NOTICE 'decrement';
        ELSE
            RAISE NOTICE 'error';
        END IF;
    END IF;
END $$;
#

but ratelimit and reset_timeout is instead values from an user_id in a database

turbid bough
#

uh ive only dealt with sql for like not alot

topaz sphinx
#

i see konatacry

wanton nova
#

whats the minimum age to be a Verified Developer on discord?

turbid bough
#

13

wanton nova
#

alright

#

thank you

#

just need to find my passport lmao

turbid bough
#

@topaz sphinx are you just wanting the variables ratelimit and reset_timeout come from just the database, and thats it?

topaz sphinx
#

yes

#

the function is complete

#

almost but

#

if i get the variables linked to memory addresses

#

or something similiar

#

then im done

#

its PostgreSQL 11

turbid bough
#

looking it up you can get set a variable from a table using this as an example

SET @ModelID = (SELECT m.modelid 
                  FROM MODELS m
                 WHERE m.areaid = 'South Coast')
topaz sphinx
#

will changing that varaiable affect the table too

turbid bough
#

no, but that you can do with an another command

topaz sphinx
#

raise notice are useless comments that i use

#

what could i use in place of those

#

just regular updates

#

or

#

is there a better alternative

turbid bough
#

regular update should work fine

topaz sphinx
#

aight

#

ill go ahead and test them changes

#

thanks for your guidelines

tired nimbus
#

omg

#

what if it wasn't working because

#

i didn't add .run()

#

nvm Im dumb itsn ot

#

maybe .get()

turbid bough
#

what is the library you are using?

#

for sql

tired nimbus
#

better-sqlite3 on node.js

#

its still broken

turbid bough
#

db.transaction

tired nimbus
#

const usersin1 = sql.prepare("SELECT COUNT(*) FROM raid WHERE raid1 > 0").get().count;

#

now im getting undefined

turbid bough
#

nvm yeah you are missing run

#

ah nvm, it is get

#

im dumb cant read docs

wintry sonnet
tired nimbus
#

OMG FINALLY

wintry sonnet
#

Finally what?

turbid bough
#

he did it

tired nimbus
#

Id like to say that this thing is very stupid and the fact that I had to ask stackoverflow gives shame and doubt in my ability to use sqlite

summer torrent
#

check soundcloud docs

wintry sonnet
#

Soundcloud docs? Link?

summer torrent
wintry sonnet
#

Thx

tired nimbus
#

let stmt = sql.prepare("SELECT COUNT(*) count FROM raid WHERE raid1 > 0");
let row = stmt.get();
let usersin1 = row.count;

#

Why does this work but
const usersin2 = sql.prepare("SELECT COUNT(*) FROM raid WHERE raid2 > 0").get().count;
doesnt

amber fractal
#

does sql return promises?

#

wait that wouldn't do anything anyways

#

ignore me

#

idk sql

turbid bough
#

probably cause thats how the library works

topaz sphinx
#

i got it working

queen needle
#
if (message.content.startsWith("$ban")) {
 
    var member = message.mentions.members.first();
  
    member
      .ban()
      .then(member => {
        // Successmessage
        message.channel.send(
          ":wave: " +
            member.displayName +
            " has been successfully banned https://gfycat.com/playfulfittingcaribou :point_right: "
        );
      })
      .catch(() => {
        // Failmessage
        message.channel.send("Access Denied");
      });
  }
  
    if (message.content.startsWith(PREFIX + "elon")) {
    message.channel.send(
   "https://gfycat.com/thornyspotlessarrowworm :point_right: "
    )
  }

});```
topaz sphinx
#

but its soo ugly only its own mother could love it

queen needle
#
if(message.member.guild.me.hasPermission('ADMINISTRATOR')```
#

how could i add that if statement to thar command

earnest phoenix
#

by adding it

topaz sphinx
#

@turbid bough 1 to 10 how good is my solution

#
DO $$ 
DECLARE
    ratelimit INTEGER := (SELECT image FROM users.ratelimits WHERE user_id = 2);
    reset_timeout timestamptz := (SELECT image_refresh FROM users.ratelimits WHERE user_id = 2);
BEGIN
    IF reset_timeout <= NOW() THEN
        UPDATE users.ratelimits
        SET image_refresh = NOW() + '1 hour'::interval,
            image = 45
            WHERE user_id = 2;
        RAISE NOTICE 'reset';
        
    ELSE
        IF ratelimit > 0 THEN
            UPDATE users.ratelimits
            SET image = image - 1
            WHERE user_id = 2;
            RAISE NOTICE 'decrement';
            
        ELSIF ratelimit <= 0 THEN
            RAISE NOTICE 'out of credits';
            
        ELSE
            INSERT INTO users.ratelimits(user_id) VALUES (2);
            RAISE NOTICE 'error';
            
        END IF;
    END IF;
END $$;
turbid bough
#

does it work?

topaz sphinx
#

yeah

#

flawlessly

queen needle
#

yeah but where would i add it

turbid bough
#

add it right after the first if statement

queen needle
#
f (message.content.startsWith("$ban")) {
 if(message.member.guild.me.hasPermission('ADMINISTRATOR') 
    var member = message.mentions.members.first();
  
    member
      .ban()
      .then(member => {
        // Successmessage
        message.channel.send(
          ":wave: " +
            member.displayName +
            " has been successfully banned https://gfycat.com/playfulfittingcaribou :point_right: "
        );
      })
      .catch(() => {
        // Failmessage
        message.channel.send("Access Denied");
      });
  }
#

right thwre

earnest phoenix
#

hello

queen needle
#

if i add it there i get an error

#

unexpected token var

earnest phoenix
#

add curly braces

#

learn how scoping works

turbid bough
#

probably beacuse you forgot curly braces yeah

earnest phoenix
#

you're missing fundamental knowledge lol

queen needle
#

i fixed it lol

tired nimbus
#

How can I do something like this:

      bot.users.get(user).send("THE CORRUPT HAS APPEARED! YOU FAILED TO DEFEATH THE CORRUPTED!")
      let usera = await getScore.get(user)
      usera.raid1 = 0
      setScore.run(usera)
    })```
#

I want to access each user who has a certain value

queen needle
#
client.on("message", message => {
   if (message.content.startsWith("$ban")) {
 if(message.member.guild.me.hasPermission('ADMINISTRATOR') {
    var member = message.mentions.members.first();
  
    member
      .ban()
      .then(member => {
        // Successmessage
        message.channel.send(
          ":wave: " +
            member.displayName +
            " has been successfully banned https://gfycat.com/playfulfittingcaribou :point_right: "
        );
      })
      .catch(() => {
        // Failmessage
        message.channel.send("Access Denied");
      });
  }
}
})```
#

if i addcurly brackets like that it doesnt work

turbid bough
#

i think your code needs organizing

queen needle
#

formatting?

earnest phoenix
#

reread your code

#

you aren't closing your if statement

#

you have a syntax error

queen needle
#

oh okay

earnest phoenix
#

how tf do you not know how to use an if statement

queen needle
#

im an idiot i was missing a )

tired nimbus
#

I want to get each user who has a specific value in their row and access each of them. I want something like Js sql.prepare("SELECT * FROM raid WHERE raid1 > 0 AND NOT id='685337576810610734'").run().forEach(async (user) => { bot.users.get(user).send("THE CORRUPT HAS APPEARED! YOU FAILED TO DEFEATH THE CORRUPTED!") let usera = await getScore.get(user) usera.raid1 = 0 setScore.run(usera) })
But for it to actually go through each user who has raid1 > 0. Im trying to iterate through the array as its output but I have no idea how to start this out.
Node.js

sand ginkgo
clear wraith
#

Hey, I have a question... when I type a command for my bot... Why does it send the same thing multiple times in the command?

#

Ill get a screenshot

queen needle
#
if (message.content.startsWith(PREFIX + "roll")) {
    message.channel.send({
      embed: {
        color: 3447003,
        title: "cinnamon roll"
      },

      fields: [
        {
          name: "Here is a cinnamon roll",
          value: "https://gfycat.com/defiantgrimydodo"
        }
      ]
    });
  }
});```
earnest phoenix
#

you have multiple command handlers, @clear wraith

queen needle
#

why doesnt that embed work

earnest phoenix
#

learn how js works

queen needle
#

that embed only sends the title

amber fractal
#

fields should be in embed probably

clear wraith
#

What do i do?? I try to fix it... But i end up doing nothing..

#

what do i remove

queen needle
#
if (message.content.startsWith(PREFIX + "roll")) {
    message.channel.send({
      embed: {
        color: 3447003,
        title: "cinnamon roll",
         fields: [
        {
          name: "Here is a cinnamon roll",
          value: "https://gfycat.com/defiantgrimydodo"
        }
      ]
      }

     
    });
  }```
#

like that

amber fractal
clear wraith
#

mine is like this...

lyric mountain
#

Why are you deleting the message twice?

clear wraith
#

Ooo.. lemme fix that

queen needle
#

now the command doesnt work at all

#
    message.channel.send({
      embed: {
        color: 3447003,
        title: "cinnamon roll",
         fields: [
        {
          name: "Here is a cinnamon roll",
          value: "https://gfycat.com/defiantgrimydodo"
        }
      ]
      }

     
    });
  }```
#

oh yeah

#

wait what?

lyric mountain
#

Forget about that, just noticed that you built the embed inside the send function

unreal cliff
#

is the message just not showing up?

clear wraith
#

when i type c!psinfo the command works. It just sends it multiple times in a row

earnest phoenix
#

Hello

#

Can you help me.?.

clear wraith
#

The message shows up, yes. I just don't know why its sending the command multiple times

earnest phoenix
#

I need money, please, my mother is in surgery, the date she left us alone, you donate at least 1 euro

west spoke
#

Bruh

west raptor
#

no

#

go away thanks

west spoke
#

@earnest phoenix begone, human

unreal cliff
#

@mods

west spoke
#

dont you dare

#

ping mods over this

weak parrot
#

@earnest phoenix Not the place for this type of stuff

unreal cliff
#

wasn't going to

west spoke
#

I may have a fear of mod pings

queen needle
#

yeah the message just doesnt show up

west raptor
#

timo thats a fat ban

unreal cliff
#

hmmm

#

is the command line showing an error

lyric mountain
#

Probably it's a duplicated handler

clear wraith
#
const Discord = require("discord.js");

exports.run = async (bot, message, args, config) => {
  let user = message.mentions.members.first() || message.author;

  let money = await db.fetch(`money_${user.id}`);
  if (money === null) money = 0;
  var fs = require("fs");

  fs.readFile("./e/cmds.json", "utf8", function(err, contents) {
    var c = JSON.parse(contents);
    if (c.economy === "0") {
      message.channel.send();
    } else {
      cc();
    }
  });
  function cc() {
    const embed = new Discord.RichEmbed()
      .setColor("BLUE")
      .setTimestamp()
      .setDescription(`${user}, has $${money}`);

    message.channel.send(embed);
    name: "balance";
  }
};
#

Why does this command not work when i type c!balance?

turbid bough
#

i only see one string mention of "balance"

lyric mountain
#

Because you're not checking for c!balance anywhere in that code

earnest phoenix
#

we're not wizards, we can't know why because you don't provide your codebase and what you're doing

#

use debugging tools available to you to find the root of the problem

lyric mountain
clear wraith
#

Ok

turbid bough
#

or gist

wanton nova
#

is sending your ID to discord for bot verification even trustworthy?

frozen dagger
#

@dull oriole @sour stream

sour stream
#

@frozen dagger yeah?

frozen dagger
#

my bot name is blackfire

#

:d

sour stream
#

xD

#

@dull oriole

frozen dagger
#

@dull oriole

#

😄

sour stream
#

🙃

wanton nova
#

is there a primal reason for discord to know your identification to verify your bot?

#

cause it seems very stupid

#

why not just verify via phone number or something

sour stream
#

who knows 🤷‍♂️

robust moth
copper cradle
#

no

#

message.guild.me.voiceConnection.channel.id

earnest phoenix
#

glitch + light theme 😩

topaz fjord
#

gitch in the first place

grizzled raven
#

how did you incorrect yourself

topaz fjord
#

shut

earnest phoenix
#

yes im a big hypocrite

calm shore
#
  let prefixes = JSON.parse(fs.readFileSync("./prefixes.json", "utf8"));

  if(!prefixes[message.guild.id]) {
      prefixes[message.guild.id] = {
        prefixes: botconfig.prefix
      }
  }

  let prefix = prefixes[message.guild.id].prefixes;``
`
How do i set this as a constant for everysingle ${prefix} in my Main js file
lyric mountain
#

is sending your ID to discord for bot verification even trustworthy?
@wanton nova an ID alone is harmless

#

Ah, nevermind, I see what you mean

wanton nova
#

yeah...

#

im under 16 so i dont have a drivers lisence

#

*license

#

so cant send that...

#

hopefully they fix soon...

lyric mountain
#

Well, the id has you photo, so it's not like someone can impersonate you

wanton nova
#

yeah but still

#

its sensitive information

#

this isn't a legal document

#

this is a discord bot

lyric mountain
#

You don't even have private data anymore, privacy has gone to space in a long time ago

wanton nova
#

ah

tired nimbus
#

I want to get each user who has a specific value in their row and access each of them. I want something like Js sql.prepare("SELECT * FROM raid WHERE raid1 > 0 AND NOT id='685337576810610734'").run().forEach(async (user) => { bot.users.get(user).send("THE CORRUPT HAS APPEARED! YOU FAILED TO DEFEATH THE CORRUPTED!") let usera = await getScore.get(user) usera.raid1 = 0 setScore.run(usera) })
But for it to actually go through each user who has raid1 > 0. Im trying to iterate through the array as its output but I have no idea how to start this out.
Node.js

How do I Select all users with raid1> 0 and then access it?

lyric mountain
#

pretty sure for comparison you can use != or <>

#

instead of NOT

tired nimbus
#

I dont think sqlite supports that

calm shore
#
  let prefixes = JSON.parse(fs.readFileSync("./prefixes.json", "utf8"));

  if(!prefixes[message.guild.id]) {
      prefixes[message.guild.id] = {
        prefixes: botconfig.prefix
      }
  }

  let prefix = prefixes[message.guild.id].prefixes;``
`
How do i set this as a constant for everysingle ${prefix} in my Main js file
clear wraith
#

How can i verify my Discord bot? Does anyone know?

tired nimbus
#

for what

calm shore
#

get the required amt of servers

tired nimbus
#

official discord bot developer?

clear wraith
#

Yeah

tired nimbus
#

get 75+ servers using your bot

#

then go to the dev portal

clear wraith
#

Ok

calm shore
#

100*

tired nimbus
#

go to that bot and enter your information

#

Stripe accepts different verification methods

#

like passport, driver's license, but all vary on country

clear wraith
#

Ok, Thanks!!

digital ibex
#

@calm shore try not using a json as a db

calm shore
#

thats not the problem

#

bruh

#

smh

digital ibex
#

lol

#

a json file will break but go ahead if u really want to, just use a db which isn't a json

#

but, ur choice

ember atlas
#

If you aren’t gonna help don’t say anything at all. A user’s DB is up to them and based off personal preference.

digital ibex
#

ok

calm shore
#

Ive been using json for a year

#

no problems

#

that isnt the problem nor is what i was asking for

clear wraith
#

what did i do wrong

#

im confused

earnest phoenix
#

can i see user?

#

where did you define user

clear wraith
#

ill copy the code

earnest phoenix
#

how would I get the total memory free to mb from os.freemem()?

#

I'm on discord.js

clear wraith
#

let targetuser = await db.fetch(`money_${user.id}`); // fetch mentioned users balance @earnest phoenix. what did i do wrong?

earnest phoenix
#

is user defined?

clear wraith
#

how do i define the user??

earnest phoenix
#

um...

#

let user = client.users.fetch(id);

#

or message.mentions.users.first();

clear wraith
#

would i but that at the end of the code, or infront of the code

earnest phoenix
#

in front ofc

#

dude, learn basic programming before doing those kind of shit

clear wraith
#

lol

#

ok

warm marsh
#

Also, you must be coping and pasting because otherwise you'd have the required variables.

clear wraith
#

I have no one to copy from. so how am i copying??

warm marsh
#

You have the internet to copy from.

clear wraith
#

No

#

i didn't do that

icy crane
#

ok den

earnest phoenix
#

Does anyone know if it is possible to make a dashboard for my bot on bubble.io? (ping me when read.)

lyric mountain
#

@earnest phoenix probably

#

As long as you can connect to your bot's database you're able to do it

earnest phoenix
#

Alright, thanks.

abstract spruce
#

if somone can help me put my bot online join testing #1

#

or DM me

ruby talon
#

@abstract spruce depends.
You'll have to be more specific.

#

Has anyone used Kite?

grizzled raven
#

any reason why a client wont connect to discord?

small prairie
#

Wrong token?
Api Down?

#

Also whats the rror coming

pallid marsh
#

um hey i have a music command that was perfectly working until now... and now the music isnt playing.. the dispatcher seems to be ok and everything but the music still not playing... any idea of how can i fix it?
thats the code i use: let dispatcher = connection.play(ytdl(link, {filter: 'audioonly',quality: 'highestaudio', highWaterMark: 600}),{ volume: 0.5, passes: 3 });

warm marsh
#

Did you change any code before this happened?

pallid marsh
#

nop

#

tried to play music from a file and it worked

#

its the ytdl apparently

#

but why does this happen

warm marsh
#

No idea

golden condor
#

@pallid marsh your code looks fine

#

Is there any errors?

pallid marsh
#

no

#

tried to reboot the vps

#

tried to restart the bot

#

and still nothing

queen needle
#
if(message.content.startsWith(PREFIX + "embed")){
     message.channel.send({
      embed: {
        color: 15158332,
        titls: "Continue:",
        fields: [
          {
            name: "!continue bob",
            value:
              "You choose bob !continue bob to continue the adventure or do !cancel to choose nick"
          }
        ]
      }
     })
  }```
#

does anyone know why that embed doesnt work

sudden geyser
#

titls should be title

#

What doesn't work about the embed

queen needle
#

nothing sends

sudden geyser
#

What is PREFIX? Did you run the command properly? Are you getting an error?

queen needle
#

PREFIX is ^ and i did ^embed and it sent no message and no

sudden geyser
#

Try logging PREFIX and see if it's truly only ^. It may also be where it's in your code.

queen needle
#

well my other commands work

#

and they use the same PREFIX + 'h' for example

earnest phoenix
#

@sudden geyser i tested his bot with him but no matter what... It doesn't send embeds

sudden geyser
#

Well could you show the source code for whereever that code is in your file

earnest phoenix
#

We also tried the <discordrequiredname>.MessageEmbed()
And that also didn't work lmao

queen needle
#

it has to be glitch because i use glitch for me=y bot sadly and i tried it on a test bot f=with visual studio and it worked

sudden geyser
#

well that may depend on your version but can you send the source code

queen needle
#

like all the code in that file

#

if i downgrad the verison to 11.5.1 it works

sudden geyser
#

just in the scope of your message listener as I assume it's there

#

or the whole file if you prefer (as an attachment)

queen needle
#

can i just send a pastebin link?

#

and i got it to work but had to dwongrade

sudden geyser
#

yeah sure

queen needle
#

its a 407 line file

sudden geyser
#

don't publicly display your token MisuFacepalm

#

reset your bot token

queen needle
#

im an idoit

sudden geyser
#

why do you have two bot instances

queen needle
#

wdym

#

an just changed my token

sudden geyser
queen needle
#

idk

copper cradle
#

@queen needle why do you have 2 instances of it????

pale vessel
#

i d k

queen needle
#

dont question my dumbness

pale vessel
#

this is the result of copy pasting code

ruby talon
#

A question, is it allowed for my bot to say closest match to a command? eg:

user: !inform
bot: Hey user, did you mean `!info`?
queen needle
#

um

ruby talon
#

A question, is it allowed for my bot to say closest match to a command? eg:

user: !inform
bot: Hey user, did you mean `!info`?

@coral trellis do you know this :3

sudden geyser
#

it's so messy I have a hard time finding what's wrong except for the fact you're using the same token for two different client instances with its own event listeners.

coral trellis
#

It's allowed but we mute those type of bots here

ruby talon
#

I don't want the bot to get muted x)
Would it still get muted if it only does it if it starts with a mention?

pale vessel
#

seems like it's an alias

#

if it starts with a mention, sure

ruby talon
#

@pale vessel lol, I'm way to lazy to manually create all those aliases.
I would like to hear that from a mod. ^^

pale vessel
#

look, a mod already said it

#

but if it starts with the bot's mention, it's fine

ruby talon
#

Still, I would like to hear that from a mod.

pale vessel
#

okay

ruby talon
#

I don't want the bot to get muted x)
Would it still get muted if it only does it if it starts with a mention?
@coral trellis, sorry for ping again.
But could you please answer this?

coral trellis
#

It will get muted because it's essentially unknown command messages.

ruby talon
#

Ait, then I won't do it.
Thanks for clearing that up. :)
@pale vessel This is the reason why I wanted to hear it from a mod. 😉 Don't go spreading info if you're not sure of it m8

pale vessel
#

well it's a mention and it won't reply to every unknown command messages, just some so that's why i said send it was fine. well i guess not

wanton nova
#

sooo im kinda new to html, and was about to submit my HTML into the designated space for my bot...

#

and i was wondering

#

is it commented off?

pale vessel
#

did you know that you can use markdown?

wanton nova
#

yeah yeah

#

i just wanted to try html

pale vessel
#

it could be. look for <!-- in the code

wanton nova
#

doesnt seem to be any <!-- anywhere...

pale vessel
#

so it's not commented out

wanton nova
#

i'll try submitting and see what happens

pale vessel
#

don't do that

ruby talon
#

@wanton nova if its surounded by <!-- and --> its comment.
Don't always go off the color.

pale vessel
#

preview it

wanton nova
#

ah yeah

#

forgot thats a feature

#

oh wait

#

you can't preview it if you are just submitting the bot i think

#

cause i dont see the button

pale vessel
#

it's okay

#

you can submit it and edit it

#

it'll take a while until a mod review your bot

wanton nova
#

i tried submitting

#

it says "invalid token"

pale vessel
#

try it again

#

or the token you provided was invalid

wanton nova
#

alright

#

it works

#

just need to fix some formatting

#

thank you!

#

also is there a limit to the amount of images?

pale vessel
#

no

wanton nova
#

hmmm

#

one of my links seems to be dead

#

even though it leads to an image

pale vessel
#

then yes

#

lol

#

try removing one image and see if that one works

#

big brain

wanton nova
#

yep

#

there is indeed a limit

#

10 image limit

earnest phoenix
#

So i have a userinfo command that works completely fine but the field that shows the game or custom status are working too but when you mention a user or use their user id to look at their user info... If the user has a custom status and custom status is only an emoji and not a text...
It shows null... How can i make show the emojis too?

true ravine
#

What lib are you using?

earnest phoenix
#

Discord.js 12.1.1 lol

tight plinth
#

look at the log

#

reloading the command does absolutely nothing

pale vessel
#

restart bot

tight plinth
#

I tried

#

same result

#

over and over again

golden condor
#

@tight plinth serverQueue is undefined so two options. Either you have misdefined queue or the server doesn't have a queue

tight plinth
#

no no no

#

thats not the problem

golden condor
#

Have you defined serverQueue twice?

pale vessel
#

where even is "delete"?

#

i can't see it

tight plinth
#

it was the 59th line before

golden condor
#

That's a message

tight plinth
#

(m is supposed to be a message here)

#

and it is

golden condor
#

It's needs await

pale vessel
#

but it's not a property

#

no

golden condor
#

Const m = await message.channel.send

tight plinth
pale vessel
#

did you put delete instead of delete()?

tight plinth
#

no

#

the code works locally

golden condor
#

Why you doing if(m)

pale vessel
#

if m exists?

#

bruh

golden condor
#

Yeah but it would send anyways

pale vessel
#

no

#

it can be deleted

#

it's going to be an unknown message error or something

tight plinth
#
if (m)``` I tried this to "solve" my problem, but it doesnt solve it wtf
golden condor
#

Try logging m

#

See if it exists

tight plinth
#

I cant

pale vessel
#

well then

golden condor
#

Like when you make m log it

tight plinth
#

this dumbshit wont uncache the file, even after restart

pale vessel
#

what the hell is going on

tight plinth
#

¯_(ツ)_/¯

golden condor
#

delete the cache then

#

Eval it

tight plinth
#

trying last restart before going crazy

golden condor
#

I know that feeling

tight plinth
#

oh wait

#

it seems to work now

golden condor
#

Ok

small prairie
#

cant we add buffer in image in setimage?

#

messageEmbed

#

d.js

pale vessel
#

make it an attachment first

small prairie
#

new attachment?

robust moth
#

How can I retrieve store info in queue ????

mossy vine
#

that is way too wague

robust moth
#

Like

Details : hhhh
URL : hhhhj```
earnest phoenix
#
        if re.match("^(?:(?:1[0-2])|(?:0?[1-9])):[0-5][0-9][AP]M$", time): #12h
            minute = int(time.split(":")[1][0:2])
            hour = int(time.split(":")[0])
            am_pm = time.split(":")[1][2:] == "PM"
            if hour == 12:
                hour = 12 if am_pm else 0
            else:
                if am_pm: hour += 12
        elif re.match("^(?:(?:2[0-3])|(?:[01]?[0-9])):[0-5][0-9]$", time):  #24h
            hour = int(time.split(":")[0])
            minute = int(time.split(":")[1])
        else:
            e = discord.Embed()
            e.colour = discord.Colour.red()
            e.title = "Invalid Time"
            e.description = f"{time} is an invalid time. Times must be in 12-hour " \
                            f"`12:00PM` or 24-hour `14:00` formats."
            await ctx.send(embed=e)
            return
        dt = datetime.datetime.combine(datetime.datetime.now().date(), datetime.time(hour, minute, 0), stz)
        await ctx.send(str(stz) + " " + str(ftz) + "\n" +
                       f"{hour} {minute}")
        await ctx.send(dt.astimezone(ftz).strftime("%c") + "\n" +
                       dt.strftime("%c") + "\n" +
                       datetime.datetime.now().strftime("%c"))
#

the important part

#

ftz is the timezone to convert to, 1st arg, hour and minute become the time to convert, and stz is the timezone to convert from (3rd arg)

#

i'm converting the string to a time correctly, combining it with a data correctly, but the timezone change just doesnt work

cerulean pebble
#

If i sharding bot so heroku will divide my ram right ?

#

i use free host to host a 1500+ servers bot

earnest phoenix
#

you're using heroku

#

to host a bot

#

that's in 1.5k servers????

turbid bough
#

So, i have an issue with node.js where request.url is undefined..

#

im not sure what exactly the code you want me to send, but its basically

#

app.use('/login', loginRouter);

#
router.get('/', function(req, res, next) {
  const queryObject = url.parse(req.url,true).query;
  res.send(queryObject);
});```
cerulean pebble
#

@earnest phoenix actually 1640

earnest phoenix
#

w h y

cerulean pebble
#

my bot always max ram in 100 mins

earnest phoenix
#

you can literally

#

rent a vps

#

for the price of a cheeseburger

cerulean pebble
#

@earnest phoenix anwser my ques 🙂

earnest phoenix
#

i have no clue.

cerulean pebble
#

i will be the women in the world host 10 000 + servers bot in free host

earnest phoenix
#

thats a terrible idea.

cerulean pebble
#

i know

turbid bough
#

ok now this is even weirder, where the webserver is giving me error that the url is not defined, yet the debugger differ

cerulean pebble
#

@turbid bough ?

turbid bough
#

ah nvm, its probably cause req.url only returns a query

#

and then url.parse returns undefined

#

/?code=sumcome is what req.url is returning

#

that wont be parsable

cerulean pebble
#

need clue

turbid bough
#

im originally trying to get a query

#

ok nvm

#

im dumb lol

#

i never imported url.

#

i was like "why is url undefined????"

#

boom, it works now

#

now i need to know how to safely store the login code

finite bough
#

@cerulean pebble yes it will

#

if you are using heroku and ur bot is in 1000+ servers

#

try not using shards

cerulean pebble
#

hmmm

#

i will pass 2500 soon

finite bough
#

as the memory usage can go high and ur shards are just gonna crash

#

resulting ur bot to die

cerulean pebble
#

oke

#

so 2 shards

finite bough
#

try it if you want

true ravine
#

Any idea why the top.gg widget takes a second or so longer to appear on my website than the rest of the site?

#

Is it a problem my end or is it their end?

cerulean pebble
#

@true ravine ?

true ravine
#

Does it load slower for everyone or is it me?

mossy vine
#

yeah they always load slower

true ravine
#

Oh okay thank you

#

I assume it's because it's an svg that it has to download rather than an image?

mossy vine
#

¯_(ツ)_/¯

#

no fuckin clue

true ravine
#

Idk quite how it works lol

mossy vine
#

all i know is that it loads slower

true ravine
#

Yeah thanks anyway tho lol

turbid bough
#

should user access token be stored in cookies?

pale vessel
#

no

cerulean pebble
#

crashh

#

this happn when you use free host

#

CPU 200% ?

#

in 10 mins

#

it's impossible

earnest phoenix
#

get a vps or upgrade lol

cerulean pebble
#

@earnest phoenix i am poor girl

#

no money

earnest phoenix
#

set up patreon

#

whats your bot even

true ravine
#

If you have a card you can get 1 year of AWS which is a single xeon core and 1gb of ram - ik it's not a big improvement but it might tie you over till you can get something good

earnest phoenix
#

^

finite bough
#

maam

true ravine
#

Makes sense

finite bough
#

do no shard

earnest phoenix
#
if(collected.first().content == randomnumber) return message.channel.send(yesembed).then(coins.add(`${message.guild.id}.${message.author.id}`, parseInt(betdouble)))```
#

Im not able to add coins because thats in the .then(collection part

cinder patio
#

then accepts a function

#

wrap the code inside the then in a function

earnest phoenix
#

can you give an example?

cinder patio
#
  ...code here
}```
earnest phoenix
#

oh

#

thank you!

#

its working

cerulean pebble
#

@finite bough if i do not shard

#

my bot can not in 2500 + servers

finite bough
#

u dont have enough ram maam

#

u 1st dont have enough ram to handle ur bot itself

cerulean pebble
#

@finite bough poor girl without money 😦

finite bough
#

dont shard

cerulean pebble
#

@finite bough i am near 2500

finite bough
#

optimise ur project

cinder patio
#

don't cache things you won't need

high bough
#
 Profile.findOne({
        channelID: message.channel.id
      }, (err, res5) => {
        if(err) console.log(err);

        if(!res5){
          const newDoc5 = new Channel({
            guildID: message.guild.id,
            channelID: message.channel.id
          })
          return newDoc5.save().catch(err => console.log(err));
        } else {
            if (res5.useallowed === "false") return
        }
    })
```Guys, how do i async this?
#

I'm using mongoose

cinder patio
#

Promisify the function or put the rest of your code in the callback

high bough
#

English please

#

Whatls promisify?

cinder patio
#

It does what you want, but you have to do that for every mongoose function

high bough
#

I see, thanks.

cinder patio
#

The easier option would be to put the rest of the code inside the callback (the function you provide after your query)

high bough
#

How's that?

cinder patio
#

how's what?

high bough
#

Putting the code in callback

cinder patio
#

You just put the code that needs res5 inside the function

high bough
#

Example please?

small prairie
#

Convert buffer to message attachment to use in message embed

#

d.js v 12

cinder patio
#

I mean you've done it already in the code you gave

someFunction({}, (result) => { // This function is the callback
   // You can use result here, put all the code that uses result here
});
// You cannot use result here
high bough
#

Oh, okay thanks

cinder patio
#

@small prairie Use the MessageAttachment constructor

small prairie
#

It doesnt seem to work

#

(node:14514) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body

high bough
#
someFunction({}, async (result) => { // This function is the callback
   // You can use result here, put all the code that uses result here
});
// You cannot use result here
#

Would this work?

small prairie
#

Yes i know its buffer as if i send its in normal message its sent

cinder patio
#

Legendary, which function are you using to set it to the embed

#

yes Kayui that will work

high bough
#

Thanks

small prairie
#

.setImage

cinder patio
#

Try with attachFiles, setImage only accepts a string

#

.attachFiles([theAttachmentYouCreated]);

small prairie
#

That sends a file before the message

#

@cinder patio

cinder patio
#

That's the only way to add it afaik

earnest phoenix
#

im guessing this is djs

earnest phoenix
#

how can i reset a quick.db database for a server?

#

oh lmao i just did it

tight plinth
#

just delete json.sqlite mmlol

earnest phoenix
#

i just checked it again and it didnt work

#

and wdym

tight plinth
#

delete the db file

#

🙂

earnest phoenix
#

and how
there is no delete option i see

tight plinth
#

copy ur db file locally & edit it using a sqlite db editor

earnest phoenix
#

idk how

#

are we talking about the same thing?
quick.db?

lyric mountain
#

Right click -> delete file

earnest phoenix
#

...

west spoke
#

I mean it works you just need to remake it

earnest phoenix
#

i have no idea how to change the sqlite file

#

can i get an example?

west spoke
#

Nspoonfeed spoonfeeding

#

google

earnest phoenix
#

lmao

#

i never even used it

#

nvm

pine aspen
#

Hey, how can i do to check if the computer is connected to the internet?

#

@west spoke any forks available then?

west spoke
#

...........

#

what?

pale vessel
#

spoon-feeding
fork-feeding

yikes.

pine aspen
#

🤣

#
        const ifConnected = window.navigator.onLine
        if(ifConnected = true) {
            connected = true
        } else {
            connected = false
        }
#

Shouldn't this work?

pale vessel
#

onLine?

pine aspen
#

I'm not sure.

mossy vine
#

yeah that seems correct

pine aspen
#

I've been looking.

#

Ok

#

I'm just checking my code

#

😛

mossy vine
#

you dont need the connected variable tho

#

you can just use window.navigator.onLine

pine aspen
#

(node:31313) UnhandledPromiseRejectionWarning: ReferenceError: window is not defined

#

Ok.

mossy vine
#

you are not running this in a browser are you

pine aspen
#

Nope.

mossy vine
#

thats why there is no window

pine aspen
#

I'm trying to check for an internet connection while checking the token.

mossy vine
pine aspen
#

Ah.

#

Ok

#

@mossy vine, how could i get this function to return a true?

#
    connected: function() {
        require('dns').resolve('www.google.com', function(err) {
            if (err) {
               connected = false
            } else {
               connected = true
            }
        })
    }
pale vessel
#

what are you doing

pine aspen
#

Trying to get a true value

#

or false

#

depending if the device is connected to the internet

pale vessel
#

return false

pine aspen
#
bot.login(_token).catch(err => {
    if (utils.connected() === true) {
        error('Token provided is invalid! Please run node configure.js to change it!')
    } else {
        error('You seem to be offline!')
    }
})
#

Ok.

#

I'm trying to do this ^^

mossy vine
#

uhm

#

if you are offline you are not going to get a connection anyways

#

and login will reject with a different error if token is wrong

west spoke
#

^

earnest phoenix
#

Is anyone else having issues with visual studio code right now? The program says I have zero problems with the code and I am connected to WiFi. When I type “node .” Into the terminal it doesn’t even come up with an error. It just does nothing

#

I’ve tried updating visual studio code and it’s not worked

pine aspen
#

Nope

#

works fine.

pallid marsh
#

when i add the bot discord sais i have 1590 servers but when i open my bot my shards sais 2135? some1 knows how can i fix it?

earnest phoenix
#

Even restarting my laptop too

sacred mountain
#

The prefix for my bot doesn’t work

#

For any of my bots

royal herald
#

hm whats wrong with it

sacred mountain
#

It responds to any prefix

royal herald
#

?

pale vessel
#

fix it then

sacred mountain
#

It’s meant to be cc!

#

But it responds to anything

royal herald
#

what lib do you use

sacred mountain
#

?

royal herald
#

or.. just paste fragment of your code where you check prefix

pale vessel
#

show code

earnest phoenix
#

Do you use discord.js/Eris or what? @sacred mountain

sacred mountain
#

Discord.js

royal herald
#

so it is node.js

earnest phoenix
#

Can i see your bot prefix code

#

@sacred mountain ?

sacred mountain
#

K

#

One sec

royal herald
#

lets say message is your message content so you need to check if message.startsWith(prefix), where prefix is your prefix string

sacred mountain
#

So first near the start I hav:

pale vessel
#

it's message.content

sacred mountain
#

const PREFIX = 'cc!';

#

Then that sort of stuff

pale vessel
#

that's not

#

-...

#

omg bye

sacred mountain
#

What

earnest phoenix
#

Uhh

sacred mountain
#

What did i do

royal herald
#

on start of this on message event code

#

just check if(message.content.startsWith(PREFIX))

earnest phoenix
#

is he trying to make a prefix?

royal herald
#

and if not return

sacred mountain
#

let args = msg.content.substring(PREFIX.length).split(" ")

switch(args[0]){
#

Why doesn’t that work

royal herald
#

args[0] is your command name

sacred mountain
#

Yh

royal herald
#

not actually arg

earnest phoenix
#

its part of the prefix

pale vessel
#

do command = shift

sacred mountain
earnest phoenix
#

!commandname

sacred mountain
#

Look

earnest phoenix
#

Just do:
if(!message.content.startsWith(PREFIX)) return;

#

^

sacred mountain
#

Ok

pale vessel
#

after that, do command = args.shift() and switch(command) {}

#

so now args[0] is the actual args

sacred mountain
#

Oh

#

K

earnest phoenix
#

How can i replace info on json.sqlite?
i use quick.db for database and i want to make a reset all coins command

#

@sacred mountain also have this in your code too:
if (message.author.bot) return;
For it to not respond to bots or itself

sacred mountain
#

Oh

#

Would I put that within each command

pale vessel
#

no

#

just the first line inside the message event

lean swan
#

Error 520 how can i fix it?

#

I got it when bot has run for a long time

earnest phoenix
#

is it just saying error 520?

lean swan
#

yep

mossy vine
#

5xx means its discord shitting itself

lean swan
#

and a lot of error

earnest phoenix
#

lmao

lean swan
#

It make my bot down for random time

#

Is it possible to fix?

earnest phoenix
#

How long your bot been running in the background? @lean swan

lean swan
#

9 days

sacred mountain
#

@pale vessel the bot doesn’t work at all now

earnest phoenix
#

Show code?

lean swan
#

erh

sacred mountain
#

Someone help

pale vessel
#

it's const command

#

and switch(command)

earnest phoenix
#

const / let or var

sacred mountain
#

Wait why didn’t I do const for command

pale vessel
#

¯\_(ツ)_/¯

earnest phoenix
#

Lol

sacred mountain
#

I just left it blank 🤣

#

I’m so dumb

earnest phoenix
#

Hmm

sacred mountain
#

Lemme try now

blazing portal
#

You are using substring AND shift

sacred mountain
#

Yh

pale vessel
#

he split it afterwards chill

sacred mountain
#

It doesn’t work

#

It responds to its prefix now

#

But any other prefix with 2 characters then !

#

Anyone know how to fix it?

pale vessel
#

show code

sacred mountain
coarse topaz
#

the best method 👏

sacred mountain
#

Does anyone know how to fix it

royal herald
#

Salty

pale vessel
#

you didn't add if (!msg.content.startsWith(prefix)) return;

sacred mountain
#

Where

royal herald
#

as we said before

#

on start of on message function

sacred mountain
#

Yh but where

earnest phoenix
#

Uhh

royal herald
#

on start

#

1st line

sacred mountain
#

Where

royal herald
#

of this

#

function

earnest phoenix
#

Under the message event

sacred mountain
#

Oh

coarse topaz
#

up to the msg.reply line

sacred mountain
#

Wait what

pale vessel
#

not really

#

above let args

#

there you go

sacred mountain
#

Oh

coarse topaz
#

oh

sacred mountain
#

What just under it?

pale vessel
#

?

coarse topaz
#

True, you're right

pale vessel
#

above.

earnest phoenix
#

Under
bot.on('message', message => {

sacred mountain
#

Oh

#

Why

royal herald
#

think

pale vessel
#

why not?

#

yes, think

earnest phoenix
#

Thinking skills has been increased to 100

sacred mountain
earnest phoenix
#

Yes

sacred mountain
#

So now that will work?

earnest phoenix
#

Try it and SEE

royal herald
#

I think you need to learn some JS basics

sacred mountain
#

Dude

royal herald
#

Did I say something wrong?

pale vessel
blazing portal
#

You want to return when the message does NOT start with the prefix

earnest phoenix
#

And that's the correct way

pale vessel
#

it's !

#

my bad.

earnest phoenix
#

Lmao

sacred mountain
#

What

pale vessel
#

if (!msg

#

add a !

sacred mountain
#

Oh

royal herald
#

oh

sacred mountain
#

Then that will work?

royal herald
#

yes

#

try and see

earnest phoenix
#

=>
if (!msg.content.startsWith(PREFIX)) return;

sacred mountain
#

Why return if it does

earnest phoenix
#

How can i replace info on json.sqlite?
i use quick.db for database and i want to make a reset all coins command

sacred mountain
#

Should it be if it doesn’t

earnest phoenix
#

! makes it so if it doesnt

sacred mountain
#

Oh

earnest phoenix
#

@sacred mountain if the message's content doesn't start with it's prefix it returns nothing

#

^

sacred mountain
#

YESSS

#

👍👍

royal herald
#

msg.content.startsWith(PREFIX) returns boolean

earnest phoenix
#

Ayy

royal herald
#

true or false

earnest phoenix
#

Hmm

pale vessel
#

adding ! makes it return if that bool is false

royal herald
#

! makes true from false and false from true

#

so when message content starts with prefix it returns true and ! makes false so it does not return and go further

earnest phoenix
#

I asked this before but nobody responsded:
So i have a userinfo command that works completely fine but the field that shows the game or custom status are working too but when you mention a user or use their user id to look at their user info... If the user has a custom status and custom status is only an emoji and not a text...
It shows null... How can i make show the emojis too?
(Still wondering how to do it...)

royal herald
#

maybe nobody knows

earnest phoenix
#

Lol

viscid wave
#

halo

#

yorosikuna

lucid pasture
#

yo so does anyone know how to make the bot send nsfw in an only nsfw chat? (javascript)

prime cliff
#

Just check if the channel is nsfw toggled

lucid pasture
#

yea but how would i do that

prime cliff
#

Read the lib docs for channel

high bough
#
  client.shard.broadcastEval('this.channels.cache.get("696570986811621406")')
  .then(channelw => channelw.send(`Bot ${client.user.tag} Online! There are ${totalMembers} users and/or bots online. ${client.user.tag} is connected to these guilds: \n ${client.guilds.cache
         .map(g => g.name)
         .join(", ")}`).catch(err => console.log(err)))
  client.shard.user.setStatus("online");
  client.shard.user.setActivity(`${clientactivityset}`);
```I'm trying to shard my bot, what did i miss?
#

It won't work, no error codes

prime cliff
lucid pasture
#

thx

earnest phoenix
#

@lucid pasture

return message.channel.send("This is not an nsfw channel");
}```
lucid pasture
#

ight ight thanks guys

earnest phoenix
#

Kk...

high bough
#

.

lucid pasture
#

@earnest phoenix thx chief works like a charm

earnest phoenix
#

Np

pallid marsh
#

hey, any ytdl-core alternative? cuz ytdl seem to not work for me

#

at all

cinder patio
#

What's the optimal way of getting a random element from an array, where every value has a certain chance to be returned?
Currently I first get a random value from the array and then check if it will be returned or not:

while (res.length !== amount) {
 if (!arr.length) break;
 const eventIndex = Math.floor(Math.random() * arr.length);
 const eventValue = arr[eventIndex];
 if (Math.random() < eventValue.odds) {
    ...
 }
}

But is that truly depending on the chance of the variable? eventIndex can be the same value twice, so the chance kinda doubles if you get what I mean, also any other way of doing this without a while loop slonk

earnest phoenix
#
const _ = require('lodash')

const randomElement = array => array[_.random(0, array.length)]

const exampleArray = [23, 351, 213, 521, 4123]
console.log(randomElement(exampleArray))
amber fractal
#

Why

#

That doesn't even answer their question, it just adds an unneeded module

earnest phoenix
#

Sorry if I couldn't understand

#

I think he asked What's the optimal way of getting a random element from an array, where every value has a certain chance to be returned?

amber fractal
#

Adding a module doesn't make it optimal

cinder patio
#

Yeah every value has a different chance of being returned, so your solution won't work as there's an equal chance for every value

amber fractal
#

They want weighted chance

earnest phoenix
#

I read half my bad. @cinder patio can you explain more?

cinder patio
#

For example: [{odds: 0.5}, {odds: 0.7}, {odds: 0.2}]. The first value has a 50% chance of being returned, the second has 30% and so on...

#

yeah weighted chance exactly

amber fractal
coarse topaz
#

Hey guys! I wanted to get a bit of help in my code...
There's a role, and I already got the amount of how many members have that role...
Now, would like to get the half of the members that are in that role... How could I get it?

(Ping when answering to my doubt, please) - Thanks! ^^

earnest phoenix
#

@cinder patio solved?

cinder patio
#

I prefer not using any external packages

oak cliff
#

@coarse topaz you mean you want to divide it by two?

coarse topaz
#

Yep

#

And if possible, be able to add + 1

#

the half + 1, i mean

oak cliff
#

${(object.size/2) +1} ?

coarse topaz
#

ooohh okay... let me try 🙂

oak cliff
#

i think that should work

amber fractal
#

@cinder patio you can dig through the source code, it has no dependencies

#

But adding the code would basically be the same as indtalling a module with no dependencies

earnest phoenix
#

can someone help?

coarse topaz
#

oh man, that worked, @oak cliff Thanks for your help!!
Could you help me in something else? x)

oak cliff
#

i can try to :)

earnest phoenix
#

let guild = bot.guilds.cache.get(`675254454139748352`) const channel999 = guild.channel.cache.get(`694189734146211901`) channel999.send({ embed: embed }) });

coarse topaz
#

-ask2ask @earnest phoenix

gilded plankBOT
#

@earnest phoenix

Don't ask to ask.
Just ask your question, it wastes time if you say "i need help" or "can someone help me?" instead of just saying what the problem is. Save your time and other people's time and just ask the question.

Please read https://dontasktoask.com/ for an explanation on why this is an issue.

earnest phoenix
#

ok

coarse topaz
#

😉

#

i can try to :)
@oak cliff Ok, give mi a min :p

oak cliff
#

ur fine

earnest phoenix
#

?

oak cliff
#

@earnest phoenix what seems to be the issue with your code?

earnest phoenix
#

i check all the ids

#

and was good

#

channel id and guild id

coarse topaz
earnest phoenix
#

paste code

cinder patio
#

It needs to be inside a template literal