#development

1 messages · Page 841 of 1

earnest phoenix
crimson vapor
#

sklitl could you send a picture of your code

#

or send it in code blocks

earnest phoenix
#

or even better t e x t

#

use js codeblocks please

#

im crying

crimson vapor
#
js```
earnest phoenix
#

at the top and u need a new line

#

or else it wont work

wet iron
#

how do i set those colors on the code?

earnest phoenix
#

liek this

finite bough
earnest phoenix
#

u beat me

#

my pc is slow

finite bough
earnest phoenix
#

liek that

#

if u dont have a new line it wont work

#

like

wet iron
#
    
bot.on('messageReactionAdd', (reaction, user) => {

      let starmsg = message;
      let starembed = new Discord.MessageEmbed()
      .setAuthor(message.author.tag)
      .setColor("#FFFC00")
      .addField(":star:", starmsg)

      let limit = 4;
      if (reaction.emoji.name == '⭐' && reaction.count >= limit) bot.channels.cache.find(channel => channel.name === 'starboard').send();
#

ok

crimson vapor
#

ok to test, delete the if (reaction.emoji.name == ':star:' && reaction.count >= limit)

#

and try it

finite bough
#

my bot memory kinda went from 200 mb to 900mb

#

oof

earnest phoenix
#

what

#

did u do

crimson vapor
#

it should work on any reaction

earnest phoenix
#

what's your issue in the first place

#

the embed doesn't send?

#

i use a vps so i could just backup all my files except something named .cache

#

and reset my server

wet iron
#

it wont send

#

anything

earnest phoenix
#

what's your code, as of this very moment

crimson vapor
#

I will be honest, a lot of that seems to be a bit strange

#

ila rewrite is how I would do mine

vestal star
#

oof

#

wait..

wet iron
#
    bot.on('messageReactionAdd', (reaction, user) => {

      let starmsg = message;
      let starembed = new Discord.MessageEmbed()
      .setAuthor(message.author.tag)
      .setColor("#FFFC00")
      .addField(":star:", starmsg)

      let limit = 4;
      if (reaction.emoji.name == '⭐' && reaction.count >= limit) bot.channels.cache.find(channel => channel.name === 'starboard').send();
#

i use this

earnest phoenix
#

and you're saying it isn't sending anything

#

...because you aren't providing any arguments to send

wet iron
#

there were

#

for example

#

my embed

#

it didnt work

west raptor
#

what

wet iron
#

i tried even string

#

and it didnt work

earnest phoenix
#

i need to know the code you have right now

modest maple
wet iron
#
    let args = message.content.substring(PREFIX.length).split(" ");

    bot.on('messageReactionAdd', (reaction, user) => {

      let starmsg = message;
      let starembed = new Discord.MessageEmbed()
      .setAuthor(message.author.tag)
      .setColor("#FFFC00")
      .addField(":star:", starmsg)

      let limit = 4;
      if (reaction.emoji.name == '⭐' && reaction.count >= limit) bot.channels.cache.find(channel => channel.name === 'starboard').send(starembed);
earnest phoenix
#

also yes are you sure you're even sending it to the right channel

sudden geyser
#

do you have the messageReactionAdd event within the message event.

earnest phoenix
#

your code looks for the first channel named starboard out of all guilds, are you sure you're sending it to the right channel

wet iron
crimson vapor
#

gimme the id of that channel

wet iron
#

i tried with the id's

earnest phoenix
#

christ

#

this hurts

#

bye

wet iron
#

yes

crimson vapor
#

Lol

wet iron
#

i know

#

i want to die

crimson vapor
#

if its just for testing, I would hardcode an ID

earnest phoenix
#

but ur not giving us the stuff we need

#

or making it difficult lol

wet iron
#

aaaaaaaa

elder garnet
#

how do i make my bot save a sequelize variable?

#

in like a json or something

modest maple
#

sequelized in a json is just

#

i pray that its not a thing

crimson vapor
#

bruh

elder garnet
#

wot

crimson vapor
#

you know the way you set it, you would need 4 reacts for it to work

elder garnet
#

i've heared of a moudule called fs

#

module*

crimson vapor
#

fs is notorious for corrupting data

elder garnet
#

what i used was from the website was called discordjs-guide

crimson vapor
#

@wet iron ```js
bot.on('messageReactionAdd', (reaction, user) => {
if (reaction.emoji.name !== 'star') return;

let starmsg = message.content;
let channel = reaction.message.guild.channels.find(c => c.name == 'starboard');

let starEmbed = new Discord.MessageEmbed()
.setAuthor(message.author.tag)
.setColor("#FFFC00")
.addField(":star:", starmsg);

// let limit = 4;
let limit = 1;
if (channel && reaction.emoji.name == '⭐' && reaction.count >= limit)
bot.channels.cache.find(channel => channel.name === 'starboard').send(starEmbed);
});``` test this

wet iron
#

k

crimson vapor
#

yeah but fs is only for either small bots or for files that never get touched

#

because it loads the entire file into ram

elder garnet
#

oh

#

yeah i don't think heroku will work with fs lol

crimson vapor
#

most people use it for logs

elder garnet
#

ok

crimson vapor
#

because you can just append

#

Lol why the spoon reaction?

wet iron
#

no

#

it doesnt work

crimson vapor
#

alright idk then

wet iron
#

FOR FUCK SAKE IM GOING CRAZY

crimson vapor
#

try adding : and : to the star

finite bough
#

bruh

#

call me when u need me

crimson vapor
#

because I made name == star not :star:

elder garnet
#

will that work?

const fs = require('fs') //importing file save
var xpPath = 'file path to json here'
var xpRead = fs.readFileSync(xpPath);
var xpFile = JSON.parse(xpRead); //ready for use
var userId = message.author.id //user id here
if (!xpFile[userId]) { //this checks if data for the user has already been created
    xpFile[userId] = {xpp: 0, xppr: 0, currentRole: ""}; //if not, create it
    fs.writeFileSync(xpPath, JSON.stringify(xpFile, null, 2));
} else {
    //as an example, I will give the owner of the id 50 xp and the role "Awesome Role"
    var xppVar = Number(xpFile.xpp) + 50 //add 50 to their original xp
    var xpprVar = Number(xpFile.xppr)
    var roleToGive = "Awesome Role"
    xpFile[userId] = {xpp: xppVar, xppr: xpprVar, currentRole: roleToGive};
    fs.writeFileSync(xpPath, JSON.stringify(xpFile, null, 2));
    console.log(`Changed that player's xp to ${xppVar} and gave him the role ${roleToGive}`)

}

found it in stack overflow

finite bough
#

ew json db

earnest phoenix
#

ew json db

crimson vapor
#

ok so there are 3 or 4 things I would do differently, on top of not using fs

#

the first 3 statments can be combined in order to make one

#

also most people prefer to use let and const rather than var

elder garnet
#

"found it in stack overflow"

#

so

#

yh

wet iron
#

doesnt work @crimson vapor

#

i really want to die rn...

crimson vapor
#

I have not used reactions yet so idk sorry

wet iron
#

million

#

it works

#

@crimson vapor thanks

#

it worked

crimson vapor
#

what did you change?

wet iron
#

just had to add for

#
let channel = reaction.message.guild.find
#

it had to be

#

guild.cache.find

crimson vapor
#

oh you are on 11

#

or 12?

wet iron
#

v12

crimson vapor
#

ok I see what I did

wet iron
#

ok

#

now if

#

there is no channel

#

it will shit itself

#

and turn off

crimson vapor
#

yes because there is no channel, it returns

wet iron
#

ik

crimson vapor
#

wait no

wet iron
#

if there is no channel

#

it doesnt return

crimson vapor
#

it might say TypeError: cannot read property send of undefined

earnest phoenix
#

the most annoying error of all errors to existr

crimson vapor
#

no

earnest phoenix
#

besides module_not_found

crimson vapor
#

I hate the ones that dont show up

earnest phoenix
#

🤢

crimson vapor
#

module_not_found is because you are in the wrong dir

earnest phoenix
#

or

#

u didnt install it

#

in which case

#

u need to

#

again

low bolt
#

I need help for Sharding, when I start Shard correctly, bot says "Error: Shard 0's Client took too long to became ready". I'm trying in my VPS. But when I try in Glitch, bot works correctly.
I'm using Discord.js
My discord.js version is 11.6.3

earnest phoenix
#

kinda looks like copy n paste buck0

crimson vapor
#

thank you for showing a lot about what you are doing

low bolt
#

ye

crimson vapor
#

whats the stats of your VPS?

earnest phoenix
#

(who)

#

(ohimdumbokdontlistentome)

crimson vapor
#

lol

low bolt
#

SpeedTest or smh?

crimson vapor
#

no

#

the specs

#

like how many cores?

low bolt
#

@crimson vapor 3 core

#

i7

#

6gb ram

crimson vapor
#

ok so it should be able to run the bot

#

im not sure tbh

low bolt
#

Shard 0's Client took too long to became ready I'm getting this :/

crimson vapor
#

how many times have you tried to restart?

low bolt
#

Lots

crimson vapor
#

ok

#

im not sure then

low bolt
#

But when I try lots of, says error 429 too many requests x)

crimson vapor
#

Lol

#

you got rate limited

#

you just have to wait

low bolt
#

yea

#

and

#

why i'm getting bot is undefined error sometimes

#

this is the code.

#
const ayarlar = require('../ayarlar.json');
module.exports = async message => {
  let client = message.client;

  if (!message.guild || message.author.bot) return;
  
  const db = require('quick.db');
  let prefix = ayarlar.prefix

  if (!message.content.toLowerCase().startsWith(prefix)) return;

  const args = message.content.slice(prefix.length).trim().split(/ +/g);
  const command = args.shift().toLowerCase();
  const cmd = client.commands.get(command) || client.commands.get(client.aliases.get(command));
  if (cmd) cmd.run(client, message, args);
};```
#

events/message.js

crimson vapor
#

what line?

low bolt
#

if (!message.guild || message.author.bot) return;

#

message.author.bot

crimson vapor
#

whats your event handler look like?

low bolt
#

Here:

#
client.aliases = new Discord.Collection();
const init = async () => {
  await fs.readdir("./commands/", (err, files) => {
    if (err) console.log(err)
    console.log(`${moment().format("HH:mm:ss YYYY/MM/DD")} | ${files.length} komut yükleniyor.`)
    files.forEach((f, i) => {
      let pull = require(`./commands/${f}`);
      console.log(`${moment().format("HH:mm:ss YYYY/MM/DD")} | ${pull.config.name} adlı komut yüklendi.`)
      client.commands.set(pull.config.name, pull);  
      pull.config.aliases.forEach(alias => {
        client.aliases.set(alias, pull.config.name)
      });
    });
  });

  await fs.readdir('./events/', (err, files) => {
    if (err) console.error(err);
    console.log(`${moment().format("HH:mm:ss YYYY/MM/DD")} | ${files.length} olay yükleniyor.`);
    files.forEach(f => {
      const eventName = f.split(".")[0];
      const event = require(`./events/${f}`);
      client.on(eventName, event.bind(null, client));
      console.log(`${moment().format("HH:mm:ss YYYY/MM/DD")} | Yüklenen olay: ${eventName}.`);
    });
  });

client.login(ayarlar.token);
}

init()```
crimson vapor
#

Ight

#

ik your issue

#
const Discord = require("discord.js");
const ayarlar = require('../ayarlar.json');
module.exports = async (client, message) => {
  let client = message.client;

  if (!message.guild || message.author.bot) return;
  
  const db = require('quick.db');
  let prefix = ayarlar.prefix

  if (!message.content.toLowerCase().startsWith(prefix)) return;

  const args = message.content.slice(prefix.length).trim().split(/ +/g);
  const command = args.shift().toLowerCase();
  const cmd = client.commands.get(command) || client.commands.get(client.aliases.get(command));
  if (cmd) cmd.run(client, message, args);
};```
#

that should work

low bolt
#

What about shard error?

crimson vapor
#

im not sure

low bolt
#

if you do (client, message)

#

I need to delete let client = message.client;

crimson vapor
#

yes

low bolt
#
const Discord = require("discord.js");
const ayarlar = require('../ayarlar.json');
module.exports = async (client, message) => {
  let client = message.client;

  if (!message.guild || message.author.bot) return;
  
  const db = require('quick.db');
  let prefix = ayarlar.prefix

  if (!message.content.toLowerCase().startsWith(prefix)) return;

  const args = message.content.slice(prefix.length).trim().split(/ +/g);
  const command = args.shift().toLowerCase();
  const cmd = client.commands.get(command) || client.commands.get(client.aliases.get(command));
  if (cmd) cmd.run(client, message, args);
};```

@crimson vapor not works

#

when i use let client = message.client

crimson vapor
#

error?

low bolt
#

works

#

in test bot

#

error is

crimson vapor
#

ok

low bolt
#

author is undefined

#

message.author.bot

crimson vapor
#

idk then tbh

west herald
#

(message.author && message.author.bot)

earnest phoenix
#

node : The term 'node' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name,
or if a path was included, verify that the path is correct and try again.
At line:1 char:1

  • node run index.js
  •   + CategoryInfo          : ObjectNotFound: (node:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
    

@earnest phoenix

#

help

copper cradle
#

did you install node?

#

@earnest phoenix

#

also learn to read

#

if node wasn't found then check your node installation

#

but I'll guess you didn't even install it

earnest phoenix
#

ok i'll try

sudden geyser
#

restarting your computer or checking it's variable path would likely help

small prairie
#

get a non mentionable role from a message

#

d.js

heavy anchor
#

Anyone know what I’m doing wrong

msg.channel.send('Pong!').then(msg => {
  msg.edit('Pong! ' + (msg.createAt - msg.createdAt) + `ms`);
});```
#

It just returns this

earnest phoenix
#

error?

heavy anchor
earnest phoenix
#

you need to format it

#

you're using the wrong property and you shouldn't be doing that anyways

crimson vapor
#

so much about that is wrong tbh

earnest phoenix
#

either do it in an embed or format the string with ${}

#

subtracting createdAt timestamps isn't accurate - use Date.now() before and after sending the message and subtract that instead

crimson vapor
#

change the 2nd msg to m

earnest phoenix
#

Voidus, that's not the issue

#

it was for mine

#

lol

#

and it worked.

#

it isn't here.

#

it returned NaN

#

the issue is that they're using a nonexistant property

#

how?

#

createAt does not exist

#

fair

#

but still

crimson vapor
#

Date.now() - msg.createdAtTimestamp

earnest phoenix
#

it wont work

#

use Date.now() before and after sending the message and subtract that instead

#

in the way he is doing it

crimson vapor
#

or as cry said

#

before and after

earnest phoenix
#

using message timestamps isn't accurate

#

mhm

heavy anchor
#

So use date.now instead?

crimson vapor
#

Date.now()

#

if you dont do the function it wont work and the D must be capitalized

heavy anchor
#

OK thanks I’ll try that

#

And I’m a noob

#

That makes sense though

small prairie
#

How can i use regex with discord.js v11 to search a message for roles which arent mentionable

earnest phoenix
#

doesn't d.js already provide you with role mentions

#

in the message

crimson vapor
#

if a role isnt mentioned, you cannot use message.mentions.roles

#

you would have to do it a different way

small prairie
#

Read the message

#

i know i can use regex
But how

earnest phoenix
#

you don't need to

#

...?

crimson vapor
#

also you cant

small prairie
#

wut?

earnest phoenix
small prairie
#

oof

#

role is unmentionable

crimson vapor
#

a regex would be looking for a match, you can make a role with any name

earnest phoenix
small prairie
#

@crimson vapor ID mate

earnest phoenix
#

you're all being very wrong about this

small prairie
#

Why me?

earnest phoenix
#

you don't need regex - d.js does it for you

small prairie
#

if role isnt mentionable

#

no it doesnt

crimson vapor
#

he is saying by ID

earnest phoenix
#

million, mentions for roles are in a <@&id> format

crimson vapor
#

I know

small prairie
#

Yes

earnest phoenix
#

and yes it does

crimson vapor
#

but he is saying just an ID

small prairie
#

Nope just try it

crimson vapor
#

no <@&>

earnest phoenix
#

just the id king?

small prairie
#

Yes

#

from rehex

#

regex*

earnest phoenix
#

but you don't need regex

#

...

crimson vapor
#
let role = message.guild.roles.get(args[x]);
if(!role) return;```
small prairie
#

a'ight tell me any other way then

crimson vapor
#

this is what you want

earnest phoenix
#

just take the id straight out of the argument

small prairie
#

NO

#

Oof

#

its not a command

#

its a random message

crimson vapor
#

......

earnest phoenix
crimson vapor
#

-dotpost

earnest phoenix
#

what do you actually want to do

small prairie
#

which has a unmentionable role

#

see like

crimson vapor
#

you cant then

small prairie
#

some types
Hey Hows it goign <RoleMention>

#

And the role is unmentionable

earnest phoenix
#

what about it

crimson vapor
#

.......

#

are you okay

small prairie
#

i still want to get the role mention

cinder patio
#

Role mention like... <id> or just @RoleName

earnest phoenix
#

it's IN THE mentions property

crimson vapor
#

^

#

it shows up regardless

earnest phoenix
#

it doesn't matter if it's mentionable or not since it is a regex lookup

small prairie
#

not if the role isnt mentionable

earnest phoenix
#

jesus fucking christ

small prairie
#

just try it man

#

just try it

#

tell me then

crimson vapor
#

@dreamy jacinth Developers

#

<@&265125253443878912>

#

mention

#

see

heavy anchor
#

case "ping":
console.log(${msg.author.username} + ": " + msg.content);
msg.channel.send('Pong!').then(msg => {
msg.edit('Pong! ' + (Date.now() - msg.createdAtTimestamp) + ms);
});
console.log(bot.user.tag + ": " + "Pong!");
break;

#

it still says the same

earnest phoenix
#

why did you copy paste code

crimson vapor
#

put it in code blocks at least

#

ye

heavy anchor
#

idk how im a noob

earnest phoenix
#

i don't care, why did you copypaste code

crimson vapor
#

yes but matching a regex every message is inefficient and completely useless

#

instead just check if there are role mentions

#

ok so @heavy anchor you are using msg and msg

#

it wont work

heavy anchor
#

If you mean copied someone else code I didn’t

crimson vapor
#

you need to replace the msg in the .then to m or message or edit or something

#

tbh, I prefer using let x = await message.send()

#

looks cleaner

earnest phoenix
#

@small prairie , the docs state ```roles

Any roles that were mentioned Order as received from the API, not as they appear in the message content</

which is probably your issue, there's a prebuilt regex in the lib for role mentions (<https://discord.js.org/#/docs/main/v11/class/MessageMentions?scrollTo=s-ROLES_PATTERN>) so you can use it to get ids and then get the role object out of the guild allowing you to check if it's mentionable or not
crimson vapor
#

ig

heavy anchor
#

So like this?


case "ping":
         console.log(`${msg.author.username}` + ": " + msg.content);
         msg.channel.send('Pong!').then(m => {
            m.edit('Pong! ' + (Date.now() - msg.createdAtTimestamp) + `ms`);
         });
         console.log(bot.user.tag + ": " + "Pong!");
         break;

#

Sorry the codes a mess

crimson vapor
#

close

heavy anchor
#

It’s formatted in my document

crimson vapor
#

change the msg to m

heavy anchor
#

which one

crimson vapor
#

the one after Date.now()

heavy anchor
#

Ok thx

#
msg.channel.send('Pong!').then(m => {
            m.edit('Pong! ' + (Date.now() - m.createdAtTimestamp) + `ms`);
         });
earnest phoenix
#

i told u

#

format

#

:p

#

the most accurate would be

Date.now() in a variable
send message
  then
    edit with Date.now() - the Date in the variable
#

or

#
const time = Date.now() - m.createdAtTimtestamp
m.edit(`Pong! ${time}`)
#

might not be right

#

since i put it in a const

heavy anchor
#
var time = Date.now() - m.createdAtTimtestamp
m.edit(`Pong! ${time}`)
#

?

earnest phoenix
#

again using messge timestamps isn't accurate

heavy anchor
#

What better way is there to do it then?

heavy anchor
#

Ok I’ll stop bothering you thx

earnest phoenix
#

you expect me to spoonfeed you

#

which i won't do

#

i'm giving you a brain exercise to get your cogs going

heavy anchor
#

No I don’t

#

I appreciate it

tight plinth
#

I have some issues with ytdl, @discordjs/oups &/or ffmpeg-static : sometimes the music currently playing stops playing, sometimes it don't skip to next song when one is finished. I can't figure how it happens, as they are no error at all in the log.

#

Not song dependant, happens sometimes, sometimes not

earnest phoenix
#
  if (message.author.bot) return;
  if (message.content === "$rhelp") {
    message.channel.send(`
**Role Help Menu**

** $role all [Role Mention]  **
** $role bots [Role Mention] **
** $role humans [Role Mention]  **
   `);
  }
});
client.on("message", message =>
client.on("guildMemberAdd", member => {
  let id = member.user.id;
  let m = member.user;
  var embed = new Discord.RichEmbed()
    .setThumbnail(m.avatarURL)
    .setImage(
      ""
    )
    .addField(
      `:NW::NE::NL::NC::NO::NM::NE:`,
      `<@${id}>`
    )
    .setImage(message.guild.iconURL)
    .addField("Welcome To**", `**${member.guild.name}**`)
    .addField("Don't Forget To Follow DiscordTOS")
    .addField("Enjoy ")
  .setFooter("C-Bot By Mentux")
    .setColor("RANDOM");
  var channel = member.guild.channels.find("name", "Welcome"); //تعديل مهم اسم روم الولكم
  if (!channel) return;
  channel.send({ embed: embed });
});```
#

Someone Help?

#

It Say The Last Line Syntax Error

snow urchin
#

How would I do this, without getting "lastMessage" in the response?

tight plinth
#

@earnest phoenix channel.send(embed)

earnest phoenix
#

Ok

tight plinth
#

@snow urchin why would you do that

crimson vapor
#

you should just be able to add .lastMessage to it

earnest phoenix
#

Its Says The Last Line Is Wrong The });

#

how?

tight plinth
#

U forgot to close a ) or a }

#

Somewhere

earnest phoenix
#

I Did Close All

tight plinth
#

Well no

crimson vapor
#

yep

earnest phoenix
#

Check The Code

crimson vapor
#

I see

earnest phoenix
#

Everything Is Right

crimson vapor
#

your problem

#

add at ) before the ;

earnest phoenix
#

?

tight plinth
crimson vapor
#

I made it so simple for you

snow urchin
#

@tight plinth, cause when I send it over express, I get a circular structure error

crimson vapor
#
}));```
#

there

earnest phoenix
#

Thanks ❤️

tight plinth
#

@earnest phoenix it won't work

earnest phoenix
#

It Works

tight plinth
#

Why u have two client.on('message'

#

It's stupid

#

And useless

earnest phoenix
#

No Its oLD cODE

#

The First One

tight plinth
crimson vapor
#

LOL

#

LMFAO

#

I didnt see that

#

correct me if im wrong but it should be this ```js
client.on("message", message => {
if (message.author.bot) return;
if (message.content === "$rhelp") {
message.channel.send(`
Role Help Menu

** $role all [Role Mention] **
** $role bots [Role Mention] **
** $role humans [Role Mention] **
); } }); client.on("guildMemberAdd", member => { let id = member.user.id; let m = member.user; var embed = new Discord.RichEmbed() .setThumbnail(m.avatarURL) .setImage( "" ) .addField( :NW::NE::NL::NC::NO::NM::NE:, <@${id}> ) .setImage(member.guild.iconURL) .addField("Welcome To**",${member.guild.name}`)
.addField("Don't Forget To Follow DiscordTOS")
.addField("Enjoy ")
.setFooter("C-Bot By Mentux")
.setColor("RANDOM");
var channel = member.guild.channels.find("name", "Welcome"); //تعديل مهم اسم روم الولكم
if (!channel) return;
channel.send({ embed: embed });
});```

snow urchin
#
                var guild = client.guilds.get("551070196958363648");
                let mmembers = [];
                guild.members.forEach(m => {
                        mmembers.push({username: m.user.username, avatar: m.user.avatarURL})
                })
                res.json({
                    server: {
                        name: guild.name,
                        id: guild.id,
                        member_count: guild.memberCount,
                        boost_count: guild.premiumSubscriptionCount,
                        boost_level: guild.premiumTier,
                        boosters: guild.roles.get('585543799673978891').members.map(m => m.user),
                        members: mmembers
                    }

https://panelapi.boun.cc/v1/serverinfo?pretty

TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'User'
    |     property 'lastMessage' -> object with constructor 'Message'
    --- property 'author' closes the circle
    at JSON.stringify (<anonymous>)
heavy anchor
#
msg.channel.send('Pong!').then(m => {
var time = Date.now()
m.edit('Pong! ' + (Date.now() - time) + `ms`);
});
#

so i did this it reply 0ms

earnest phoenix
#

like <5000MS cooldown spam, is changing the bot's status <5000MS bannable or suspendable? I couldn't find any information.

crimson vapor
#

move var time = up

tight plinth
#

lastMessage = undefined @snow urchin

#

@earnest phoenixbannable

earnest phoenix
#

e

#

ok

heavy anchor
#

is that right?

late hill
#

What are you doing that you need it all converted to json

heavy anchor
#

i dont

late hill
#

^Callum

#

And no, your ping calculation isn't right

#

@heavy anchor You're sending a message, once that message has been sent, you grab the current time and edit the message to the current time minus the current time

#

If you understand what .then() does, you should be able to fix your logic flaw

earnest phoenix
#

whats the code for send with id

#
  if (message.content.startsWith(prefix + "issue")) {
    let messageArgs = message.content
      .split(" ")
      .slice(1)
      .join(" ");
    let messageReason = message.content
      .split(" ")
      .slice(2)
      .join(" ");
    if (!messageReason) return message.reply("**# Specify The Issue!**");
    let Rembed = new Discord.RichEmbed()
      .setTitle("`Issue!`")
      .setThumbnail(message.author.avatarURL)
      .addField("**# - Reason:**", messageReason, true)
      .addField("**# - Channel:**", message.channel, true)
      .addField("**# - Time:**", message.createdAt, true)
      .setFooter("If You Are Joking Around You Will Get BlackListed From Bot");
    message.channel.send(Rembed);
    message.channel
      .send("__Are you sure you want to send this to the Mentux??__")
      .then(msg => {
        msg.react("✅");
        msg
          .react("❌")
          .then(() => msg.react("❌"))
          .then(() => msg.react("✅"));
        let reaction1Filter = (reaction, user) =>
          reaction.emoji.name === "✅" && user.id === message.author.id;
        let reaction2Filter = (reaction, user) =>
          reaction.emoji.name === "❌" && user.id === message.author.id;

        let reaction1 = msg.createReactionCollector(reaction1Filter, {
          time: 12000
        });
        let reaction2 = msg.createReactionCollector(reaction2Filter, {
          time: 12000
        });
        reaction1.on("collect", r => {
          message.guild.owner.send(Rembed);
          message.reply("**# - Done! 🎇**");
        });
        reaction2.on("collect", r => {
          message.reply("**# - Canceled!**");
        });
      });
  }
});```
#

I Want It To Send To Me Not The Guild Owner

#

Like With Id

heavy anchor
#
put var time = Date.now() before then?
copper cradle
#

are you creating a message event for each command

#

@earnest phoenix

earnest phoenix
#

No When Someone Typr $issue He Fill His Issue And The Message Come To Me

#

On DM

copper cradle
#

that's not what I meant

#

where are you from

earnest phoenix
#

Egypt

pallid marsh
#

any1 can help me pick settings for ytdl and the discord.js music?
my music getting lagged and im trying to fix it.
i have 4gb ram and 4vcores vps
with 200mbit/sec download
and 25mbit/sec upload
my code is: let dispatcher = connection.play(ytdl(link, {filter: 'audioonly',quality: 'lowestaudio', highWaterMark: 1024 * 1024 * 10}),{ volume: 0.5, passes: 3 });
and its lagging. any idea why and how can i fix it?

tight plinth
#

Highwatermark

#

Set it to 600

pallid marsh
#

ok

#

ill try

copper cradle
#

why did you set it to lowest audio

pallid marsh
#

i thoguht itll fix the lags

copper cradle
#

that defeats the whole purpose of a music bot

tight plinth
#

It reduces the quality

pallid marsh
#

just for the try

#

itll not be like that

tight plinth
#

Filter audio only is great

#

Try adding format opus

pallid marsh
#

ok

#

to the ytdl options?

tight plinth
#

Ye

pallid marsh
#

or the .play

#

ok

#

ill try

#

its way better with the highwatermark

#

trying to bring back the highestaudio

#

format opus making it to lag i think

#

ye its lagging

#

it was better without it

tight plinth
#

Try things and look at the best settings for you

pallid marsh
#

ok

slate oyster
#

I finally got Eclipse Rich Presence to work correctly

restive furnace
#

Nice, BTW what command framework/handling you use, or you did one?

slate oyster
#

?
My Discord library is Discord4J
The commands are just simple interfaces
I've moved to using annotations for metadata

fierce path
fringe bane
#

That's pretty kewl. I saw that it has Machine Learning (at least in the post)

#

Did you train a neural network or using an api?

tight plinth
#

Is that ad

fierce path
#

@fringe bane I didn't train any NN for this, using a free API. But might start training own NN in the future for this, depends ofc 🙂

earnest phoenix
#

who help me with bot status command?

fringe bane
#

@tight plinth well he did just post a blog post and the source code, not the bot url itself so

#

I guess it's more of an example code of how to use this functionality

fierce path
#

There is no official/live bot of this version at the moment, so not an "ad" per se

fringe bane
#

I mean this functionality is awesome but IDK if I myself would use it because I only know how to code bots in Java and Elixir

tight plinth
#

Jm

#

Yea

fringe bane
#

Though it would be fun sometime in the future to use this

tight plinth
#

Not an ad by itself

fierce path
#

I use it personally when gaming with friends. But depending on the popularity I might turn it into an official bot

earnest phoenix
#

who help me with bot status command? My command is bugged.

fringe bane
#

Is it CPU-intensive? I can't read JS so I don't know how it works. Do you detect the voice and then store the base64 and sent it to the api, or live-streaming it to the api?

fierce path
#

no it's not cpu intensive

#

I run the whole thing on a 5$ droplet from digitalocean

fringe bane
#

Why not use heroku, you can start a bot for free 24/7 there

fierce path
#

the github install instructions are just copy & paste, I even have a dockerfile , so you dont need to do anything :p

crimson vapor
#

if it uses an API its probably needs more network than cpu

fierce path
#

@crimson vapor correct

fringe bane
#

How's the 'backend' of the bot to send the data to the api? Base64 encoding then sending chunks or a stream?

earnest phoenix
#

who help me with bot status command? My command si bugged.

fringe bane
#

I man, I'm just curious

fierce path
#

no encoding, just raw audio data converted to .wav & submitted to the api

#

api responds with text

copper cradle
#

woah

fringe bane
#

So 'caching' it and sending chunks?

fierce path
#

smthn like that

fringe bane
#

I plan to write bots in Elixir and there's a thing there that you can integrate parts of multiple Elixir apps in one big Elixir app

#

There's a webapp framework for it which has NodeJS a part of it so I might make a mix of Elixir and NodeJS

#

Because Elixir is BLAZINGLY fast, lightweight and safe for errors

crimson vapor
#

does the bot listen to the voice command then send a command based on that, because in the video it looks like it would respond to bots

earnest phoenix
#

who help me with bot status command? My command si bugged.

copper cradle
#

@fierce path woah, that's actually pretty cool

fierce path
#

@crimson vapor the bot handles both voice and text commands. Voice commands are parsed and if there's a match, it just replies with the text command for further execution; it's just a design thing

marble juniper
#
messages.forEach(msg => {
                    let user = client.users.cache.get(msg.user)
                    let member = message.guild.members.cache.get(user.id)
                    embed.addField(member.displayName, msg.content)
                })

I am trying to add a field for each user stored in my database but it doesn't seem to work
the msg.user property includes the id of the user
Error: TypeError: Cannot read property 'id' of undefined

#

The user and member should be in the cache

fringe bane
#

But like does the database have the ID in the table?

crimson vapor
#

a better way would be to create an api with the commands and what it should do because sending it as a message would probably allow bots to respond

copper cradle
#

get is used with ids

crimson vapor
#

but I could be confused

marble juniper
#

no its not lilke that

copper cradle
#

inside of the user definition

fierce path
#

@crimson vapor well yah, that would be the stricter cleaner way of doing it. I might refactor it later

#

@crimson vapor my initial code was to send commands from my bot to Groovy (the music bot) , but almost all other music bots dont accept messages from other bots

#

so I had to implement my own music player

fringe bane
#

ahahah @copper cradle will sudo rm -rf / destroy the system? Try it and see!

crimson vapor
#

yeah bots here get muted if they respond to other bots

fringe bane
#

You could as well add TTS to your bot

marble juniper
#
if (!snipes.has(message.channel.id)) snipes.set(message.channel.id, [])
snipes.push(message.channel.id, {
        user: message.author.id,
        message: message.content
    })

this is what I am storing in my database upon message deletion

fringe bane
#

so you can control it with voice but as well get the audio of a response

marble juniper
#

user is not the user object just the id

fringe bane
#

idk if there are free tts apis for JS (probably are)

fierce path
#

@fringe bane yah :):

marble juniper
#

so I don't understand why it can't get the user

fringe bane
#

Honestly I don't like JavaScript, like the code itself looks like a cluster when reading

#

Or rather the default syntax of JS

#

I'm gonna use the snippet Link provided

#
if (!snipes.has(message.channel.id)) snipes.set(message.channel.id, [])
snipes.push(message.channel.id, {
    user: message.author.id,
    message: message.content
})
if (!snipes.has(message.channel.id)) snipes.set(message.channel.id, [])
snipes.push
(
    message.channel.id,
    {
        user: message.author.id,
        message: message.content
    }
)
#

Like for me the second one is easier to debug and stuff

earnest phoenix
#

who help me with bot status command? My command si bugged.

fringe bane
#

Which language did you code your bot in?

#

Also the framework

earnest phoenix
#

discord.js

fringe bane
#

But for syntax overall in languages (I've done C-like and non-C-like languages), #1 is the Elixir (kinda Ruby) syntax:

  @doc """
  Creates a random embed
  """
  def create_random_pic_embed(message) do
    %Nostrum.Struct.Embed{}
    |> put_title("Some title!")
    |> put_description("Some description!")
    |> put_image("link-to-image")
    |> put_color(7000)
  end
fierce path
#

looks a bit like python

#

I know almost all languages except ruby and the like

#

I actually prefer JS for many things

fringe bane
#

I've tried python but didn't like it

earnest phoenix
#

who help me with bot status command? My command si bugged.

fierce path
#

@earnest phoenix maybe try debugging manually ?

copper cradle
#

python is nice

#

try lua

#

the syntax is pretty similar to elixir

fringe bane
#

Like JS is okay because it's popular, but like performance-wise isn't the best I guess

copper cradle
#

and it's single threaded

earnest phoenix
#

@fierce path my comamnd send server -2 and users -3 and my bot is in 650 servers

copper cradle
#

so

fringe bane
#

I might try lua because I have a couple of microcontrollers

#

which are lua-compatible

copper cradle
#

nice

#

I don't like lua at all

fringe bane
#

Elixir is/isn't single threaded

copper cradle
#

I hate those langs where u don't use {}

fringe bane
#

Like you write it as if it's single threaded

copper cradle
#

feels weird to me

fringe bane
#

I had the same feeling but like elixir is

copper cradle
#

well I mean I just watched a video about elixir

fringe bane
#

instead of { you use do and instead of } you use end

#

Ah

copper cradle
#

and I like the fact you can call functions without ()

#

ofc if you pass in an arg

#

else then u need those ()

fringe bane
#

If you don't pass an arg, it will give warnings btw

copper cradle
#

😔

warm marsh
#

Is it better to have dark mode by default or an option to switch and use light mode by default?

fringe bane
#

Dark mode lmao

copper cradle
#

whatever you like

#

but dark mode

#

light == gay # True

scenic kelp
#

either way you should have the option to switch

fringe bane
#

What if someone opens your page at 3am

scenic kelp
#

why is your monitor at full brightness come 3am

gritty patio
#

Does anyone sell Google Play Gift Cards?

scenic kelp
#

No

#

Go away

fringe bane
#

I mean most apps are darkmode, even if the light is not 100% your eyes are like used to a dimmer color

#

like it's okay to be lightmode if your app has some dark parts

#

but if it's like 80% white and other bright colors, try dark mode by default

warm marsh
#

It's neutral colours fairly washed out.

#

They become slightly more vibrant when in dark mode.

fringe bane
#

could you send me a screenshot?

#

I mean idk how it looks like

#

send it in the dms if you want

warm marsh
#

Sure give me a second.

#

It's also very barebones as I just started.

fringe bane
#

dw, my webpages are 90% html barebone ahahahaha

#

Because I don't know frontend at all

copper cradle
#

discord should add a solarized theme tbh

fringe bane
#

Eh I just use betterdiscord for themes

copper cradle
#

client mods

#

that's agains the ToS

warm marsh
#

Will have to give me a second, Cloudflare likes caching everything.

fringe bane
#

against the ToS is anything with using the apis and revealing stuff which shouldn't be

#

I think just css edits are okay

copper cradle
#

they also state that client mods are agains the ToS

#

I remember being a custodian in dfeedback and a lot of ppl were getting reported due to client mods, also #memes-and-media

warm marsh
#

@fringe bane as I said barebones and doubt the hover color will stay. It's just there as an indicator of website primary colour.

#

Same for light.

slate oyster
#

I don't feel to much like working on my translation or reminder commands right now
Let's check out this new library I added to gradle
Will also have to write MemberCase, which I have procrastinated on

sudden geyser
#

okay

small prairie
#
TypeError: fields.flat is not a function
    at Function.normalizeFields (/rbd/pnpm-volume/13dc7619-49b0-4cc3-8e07-6aae909afd7f/node_modules/.registry.npmjs.org/discord.js/12.0.2/node_modules/discord.js/src/structures/MessageEmbed.js:436:8)
    at MessageEmbed.setup (/rbd/pnpm-volume/13dc7619-49b0-4cc3-8e07-6aae909afd7f/node_modules/.registry.npmjs.org/discord.js/12.0.2/node_modules/discord.js/src/structures/MessageEmbed.js:70:91)
    at new MessageEmbed (/rbd/pnpm-volume/13dc7619-49b0-4cc3-8e07-6aae909afd7f/node_modules/.registry.npmjs.org/discord.js/12.0.2/node_modules/discord.js/src/structures/MessageEmbed.js:11:10)
    at embedLikes.map.e (/rbd/pnpm-volume/13dc7619-49b0-4cc3-8e07-6aae909afd7f/node_modules/.registry.npmjs.org/discord.js/12.0.2/node_modules/discord.js/src/structures/APIMessage.js:164:40)
    at Array.map (<anonymous>)
    at APIMessage.resolveData (/rbd/pnpm-volume/13dc7619-49b0-4cc3-8e07-6aae909afd7f/node_modules/.registry.npmjs.org/discord.js/12.0.2/node_modules/discord.js/src/structures/APIMessage.js:164:31)
    at TextChannel.send (/rbd/pnpm-volume/13dc7619-49b0-4cc3-8e07-6aae909afd7f/node_modules/.registry.npmjs.org/discord.js/12.0.2/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:141:62)```
#

d.js v12

#

never used that fields.flat

crimson vapor
#

well yeah

#

its new in d.js 12

marble juniper
#

you need to update the node version

crimson vapor
#

update node

marble juniper
#

( Node.js 12.0.0 or newer )

earnest phoenix
#

is message.guild.roles.some's args the role's ID or the roles name? if not the rolename how would i find .some with the rolename?

digital ibex
#

Hi

earnest phoenix
#

hey

digital ibex
#

show with commas as something like: 1,5664 or something like that?

crimson vapor
#

well

#

actually im not sure

sullen patrol
#

What is the value client.users.cache.size returns?

karmic viper
#
 dbl.getStats("456204863320227861").then(stats => {
    console.log('DBL ye gerekli verileri girdim.') 
 });``` I Don't Understand , What İs The Problem?
#
at Object.<anonymous> (/app/index.js:2297:8)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
(node:8688) 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: 3)
(node:8688) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
crimson vapor
#

try catching it

amber delta
#

is there a limit for getting member list?

karmic viper
#

no

#
const DBL = require("dblapi.js");
const dbl = new DBL(client.ayarlar.dbltoken, client);




client.on('ready', () => {
   setInterval(() => {
        dbl.postStats(client.guilds.size);
  }, 1800);
   });

  dbl.getStats("693551232635240558").then(stats => {
    console.log('DBL ye gerekli verileri girdim.') //{"server_count":2,"shards":[]}
 });

client.login('')```
amber delta
#

hmm

#

weird

karmic viper
#
dbl.getStats("693551232635240558").then(stats => {
#

ı don understand

amber delta
#

my member count is 35k, but the bot creates just 14k user files

karmic viper
#

dbl.getstats ? id ?

zenith terrace
#

@amber delta there is

amber delta
#

how do I get the full member list then?

modest maple
#

also

#

14k

amber delta
#

if it's possible

modest maple
#

fucking files!?

zenith terrace
#

Lol

#

CF8 calm

#

xD

amber delta
#

yeah lol

#

doesn't really matter does it?

zenith terrace
#

Nah but can trigger some people

earnest phoenix
#

this kids is why you use a database

amber delta
#

it's created in like 6 seconds

#

i'm too lazy

#

geez

earnest phoenix
amber delta
#

i mean it works

earnest phoenix
#

To answer your question though it's probably caching

#

hasn't gotten all users yet

amber delta
#

everytime i restart it, it adds some of them yeah

#

wait no

#

i'm retarded

golden condor
#

With ytdl

#

Should I use thi

#

const dispatcher = serverQueue.connection.play(ytdl(song.url, {filter: 'audioonly', quality: 'highestaudio', highWaterMark: 1<<25 }))

#

Or how else do I make high quality?

amber delta
#

i can't load all of them at once

#

because it takes too much memory

golden condor
#

In client options

#

disable fetchAllMembers

earnest phoenix
#

@golden condor If you are trying to download the music I would recommend downloading it as an mp4 then converting it to an mp3 from youtube

golden condor
#

No

#

I am tryna play

#

A song

earnest phoenix
#

Then you get the compressed instant stream garbage youtube sends

#

enjoy

slow steeple
#

Hello.
I would like to know if it is possible to get a channel ID by his name

earnest phoenix
#

you want to get the last channel name a user posted in?

#

"his name" is throwing me off

slow steeple
#

No, I want to send a message in any channel

earnest phoenix
#

you want to just grab a random channel? Well in d.js channels are stored in a modifiable object

#

so you could Array.from(the object) and select randomly

slow steeple
#

Not a random one, I want to grab a specific channel

earnest phoenix
heavy anchor
slow steeple
#

lmao

earnest phoenix
#
if(message.guild.roles.some("muterole")==false){

is this valid

slow steeple
#

My english not that good I guess

earnest phoenix
#

its returning fn is not a function as a TypeError

#

"fn" is not a function? Then I don't think that code snippet is the issue

golden condor
#
if (url.match(/^https?:\/\/(www.youtube.com|youtube.com)\/playlist(.*)$/)) {
            const playlist = await ytpl(url);
            const videos = await playlist.items;
      const embed = new Discord.MessageEmbed()
      .setTitle("Playlist Added to Queue")
      .setDescription(`${playlist.title} has been added to the queue. It has ${videos.length} songs`)
       .setColor("#00aaff")
      msg.channel.send(embed);
            for (const video of Object.values(videos)) {
const result = await yts(video.title)
var video2 = result[0] 
            return handleVideo(video2, msg, voiceChannel, true); // eslint-disable-line no-await-in-loop
            } ``` What is wrong with this 
ytpl = ytpl 
yts = yt-search
earnest phoenix
#

^

#

im using d.js v11

#

just message.guild.channels.find()

slow steeple
#

Thanks ! 😄

amber delta
#

wait member list doesn't count bots right? @zenith terrace

zenith terrace
#

@amber delta wym

amber delta
#

if member list retrieves bots too

zenith terrace
#

No, there is 2 different codes for bots and members

amber delta
#

oh now it makes sense

#

thanks ❤️

zenith terrace
#

Np

wheat jolt
#
async function DownloadChunkFile(manifest, file, progress) {
    var fileUrls = GetFileURLs(manifest, file);
    var filename = file.Filename.split('/').pop();
    var fd = fs.openSync('./paks/' + filename, 'a');
    for (var i=0; i < fileUrls.length; i++) {
        var buf = false;
        var chunkPath = './chunks/' + fileUrls[i].hash + '_' + fileUrls[i].guid + '.chunk';
        if (fs.existsSync(chunkPath)) {
            buf = fs.readFileSync(chunkPath);
        } else {
            var req = await fetch(fileUrls[i].url, {
                method: 'GET',
                headers: {
                    'Accept-Encoding': 'br, gzip, deflate',
                }
            });
            var buf = await req.buffer();
            fs.writeFileSync(chunkPath, buf);
        }
        progress(i, fileUrls.length);
        var resBuf = ParseChunkHeader(buf, fileUrls[i]);
        fs.writeSync(fd, resBuf);
    }
    fs.closeSync(fd);
    return filename;
}

is there something that I can do to make this function "faster" ?

rapid geyser
#

Hello, I have been wondering for some time but I do not find the solution, you know how to transform permissions of this type:
104189632

On permissions of this type:
"MANAGE_GUILD", "ADMINISTRATOR",
I would absolutely like to know if the user has permission MANAGE_GUILD, on a bot panel

slate oyster
#

Guys I'ma force

slate oyster
#

I haven't forced yet

earnest phoenix
#

@rapid geyser check if the bit of those perms is set to one

rapid geyser
#

Ok

earnest phoenix
#

perms_int & 0x00000008 > 0 would be a check for ADMINISTRATOR

rapid geyser
#

Ok, thank you

elder pike
#

Hi

candid granite
#

Who’s bot gets discord users information? Like usernames, tags etc.

zenith terrace
#

Userinfo?

candid granite
#

Yeah sure

slate oyster
#

It's not evem the initial commit

#

78 files changed though

small prairie
#

message.author.dmChannel

#

Is null

#

d.js

#

v11

zenith terrace
#

What you trying to do

small prairie
#

create a messagecollector of dm

#

with dm i mean

zenith terrace
#

Oh

sudden geyser
#

The DM channel is likely not cached. Fetch it.

small prairie
#

nevermind

slow steeple
#

Hey again, how do I get the category name of a channel ?

#

(d.js last v)

prime cliff
slow steeple
#

Thank you

earnest phoenix
#

How Do I Make A Premium System

#

Like Is It Possible

#

It's pretty easy if you know how to implement it

#

Do You Have Any Guid

#

nope

#

unless you code in java

#

javacord

#

nope

#

ahhhh anyone else

quartz kindle
#

there are a billion ways to do something like that

#

you need to be more specific

crimson shuttle
#

There are problems with this dblapi.js

#

When it installs it says "too many request"

#

How can I solve it?

digital ibex
#

c!stast

#

wrong chat

#

worry

prime cliff
#

@crimson shuttle too many requests means you're spamming the api

crimson shuttle
#

But it happens when I turn on the bot

#

No commands are executed yet

robust moth
hollow granite
#

Was the command sent in a DM?

#

because it says the guild is undefined

earnest phoenix
#

Anyone have a dashboard guid

#

And how do I make after a certain time the bot leaves the server

restive furnace
#

you didnt even tell the language

earnest phoenix
#

discord.js

restive furnace
#

so js and library is d.js, so just do setTimeout bruh

hollow granite
#

is there an example of a command which would tell me the shards that are online and offline?

restive furnace
#

@hollow granite what lib and lang

hollow granite
#

discord js

obtuse wind
#

I have a question
about function :: toLowerCase()

Discord.js | Node.js | npm | using Atom.io to program dadada... Windows 10

how would I make my command reader, "toLowerCase" so that any/all commands can be used with messed up spelling like hElp heLP etc

restive furnace
#

add toLowerCase

#

@hollow granite client#broadcastEval, and if some shard doesnt respond, its offline/paused

obtuse wind
#

in the command itself or in one of those lines tho excuse spelling lol

earnest phoenix
#

how do i asynchronously make a directory if it doesn't exist?
is there a way to make fs.appendFile also create folders if they don't exist like it does with files?

restive furnace
#

@obtuse wind before the command set, that set the name

cinder patio
#

@earnest phoenix

obtuse wind
#

oh ok thanks freestyle

gritty frost
#
if (data.lyrics.length > 2048) return msg.edit('Lyrics were too long.');

TypeError: Cannot read property 'length' of undefined

#

Why

#

help me

finite bough
#

log out data.lyrics

#

console log I mean

gritty frost
#

ok

frail ocean
#

Basically data.lyrics exist or it could exist (and if so) send what the log of it was here.

finite bough
#

^

earnest phoenix
#

hey guys, got a bit of a djs error hope you can help Ill paste my code below
The error is: SOMETIMES the check mark reaction will work and execute the code however 90% of the time it doesn't. Reacting to the X ALWAYS works and executes it's code. I've been trying to figure this out for hours hence how my code is now formatted, I needed to dissect it because it's giving me a headache...
https://sourceb.in/f2b6039408

copper cradle
#

and the error is?

earnest phoenix
#

none

#

no error

#

apart from the fact it is just inconsistent

#

Works, doesnt work, doesnt work ...

copper cradle
#

that's odd

earnest phoenix
#

very

copper cradle
#

I'm on my phone rn

earnest phoenix
#

it works perfectly with my other commands

#

and it's really bugging me

copper cradle
#

so I can't actually help

earnest phoenix
#

ah all good

#

photo for reference

slim heart
#

as in it's sometimes not picking up the reaction?

frail ocean
#

Let me have a look a sec.

slim heart
#

@earnest phoenix

earnest phoenix
#

sorry yeah sometimes it works

#

however 90% of the time it doesnt execute the reaction code

#

the X however, works perfectly fine

frail ocean
#

Does it print anything in the console?

tight plinth
slim heart
#

are you adding the reaction before the second one goes?

tight plinth
#

:ban:

earnest phoenix
#

nothing...

#

I've used the same code I have used for all my reaction collection commands

slim heart
#

before the second one is added by the bot*

earnest phoenix
#

they all work perfectly apart from this

slim heart
#

and if you unreact and rereact does it work

earnest phoenix
#

no

frail ocean
#

Personally I would of done both reaction collectors in one, rather than 2 separate ones as it's easier to debug.

earnest phoenix
#

I really though, don't see anything I've done incorrectly

slim heart
#

it's been done poorly but shouldn't be creating an issue

earnest phoenix
#

the formatting?

frail ocean
#

Inside of the reaction collector for the tick, can you do console.log("here") and try and see if it logs?

earnest phoenix
#

yeah one moment

slim heart
#

mostly everything lol but it's alr

frail ocean
#

So then run the command and see if it gets there.

earnest phoenix
#

okay

#

so I added one in the tick as well as the X

frail ocean
#

Does it log or not?

earnest phoenix
#

first time I did the tick, worked perfect (didnt console log however), I started the command again and reacted with the tick, nothing. I reacted with the X and it logged that.

frail ocean
#

Did you save the code?

earnest phoenix
#

yes

#

it logged the X reaction one

frail ocean
#

If so, it's your reaction collector then and not anything else.

slim heart
#

if you wait a few extra seconds after both reactions are added does it start working consistently?

frail ocean
#

^

slim heart
#

still feel like it's a timing issue here

earnest phoenix
#

nope

slim heart
#

have you- tried it

earnest phoenix
#

just tried it and didn't work after approx. 5 secs

frail ocean
#

Yeah or I'm thinking it could be just getting confused about the 2 different reaction collectors at the same time, where it typically wants it to be in 1.

slim heart
#

yeah well try and do that 28r, do the reactions properly,
create the collector before you even add the reactions and you can just switch() the emoji and do actions based on them

frail ocean
#

Shouldn't make a difference but occasionally it does in some scenarios.

earnest phoenix
#

reason, I did it like this is because I don't understand how to do it all conjoined and have been told to make sure I know what my code does to ensure I can debug etc.

#

however I guess I don't know this way as much as I thought?

slim heart
#

well you'll never understand new code if you don't make new code

earnest phoenix
#

yeah that's the thing haha I got 0 idea how to do it

slim heart
#

it's not too different and it's pretty simple to do if you already have the knowledge you've demonstrated

frail ocean
#

This one is rather simple (I'll about to share the key bits), and you should be able to read it.

earnest phoenix
#

alright, will do my best.

frail ocean
#
for(const e of ["emjoji1", "emoji2"]) await message.react(e); //This reacts on the message in the correct order.

var validEmojis = ["emoji1", "emoji2"]; //This puts it into an easy array to fetch later.

const filter = (reaction, user) => {return (validEmojis.includes(reaction.emoji) && !user.bot);}; //You can add more parameters here, this just checks it is a valid emoji and the user who reacted isn't a bot, you may want it to ensure that it is the same author however.

message.awaitReactions(filter, {max: 1, time: TIME, errors: ["time"]}).then(async collected => { //This is the reaction collector getting the filter, the max is 1 and you need to fill in the max time allowed.

message.clearReactions() //Clears all the reactions after it was got.

if(collected.first().emoji === emoji1){
//If it was emoji one.
} else if(collected.first().emoji ===emoji2){
//The code for emoji2.
} else {
console.log("Error- no valid emoji found somehow"); //This should never run, if it allw works.
}
});```

This uses exactly what you had but just rearranged.
#

See if you can finish and complete it, @earnest phoenix

earnest phoenix
#

oh alright lemme give it a go, thanks.

slim heart
#

@frail ocean btw i suggest adding the collector before adding the reactions as sometimes people will press a reaction before a second or however many there are, are added, they're unlikely to wait until they're all added before adding it

frail ocean
#

@slim heart its unlikely and this is easier to understand in chronological order. Typically if your bot is on a suitable connection the reactions are added quickly, and I've done testing and people would unreact and rereact.

#

But yeah 28er can swap it around if it's vital.

slim heart
#

well especially when things like this in a game where you're likely to get rate limited no matter how good the connection there's no avoiding it and better practice

frail ocean
#

Mhm.

earnest phoenix
#
0|index    |     at WebSocket.emit (events.js:198:13)
0|index    |     at Receiver.receiverOnMessage (/root/bharatbot/node_modules/ws/lib/websocket.js:789:20)
0|index    |     at Receiver.emit (events.js:198:13)
0|index    | TypeError: command.run is not a function
0|index    |     at Client.client.on (/root/bharatbot/index.js:144:24)
0|index    |     at Client.emit (events.js:203:15)
0|index    |     at MessageCreateHandler.handle (/root/bharatbot/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
0|index    |     at WebSocketPacketManager.handle (/root/bharatbot/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:108:65)
0|index    |     at WebSocketConnection.onPacket (/root/bharatbot/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:336:35)
0|index    |     at WebSocketConnection.onMessage (/root/bharatbot/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:299:17)
0|index    |     at WebSocket.onMessage (/root/bharatbot/node_modules/ws/lib/event-target.js:120:16)
0|index    |     at WebSocket.emit (events.js:198:13)
0|index    |     at Receiver.receiverOnMessage (/root/bharatbot/node_modules/ws/lib/websocket.js:789:20)
0|index    |     at Receiver.emit (events.js:198:13)```
#

@frail ocean I got an unhandled promise rejection error

frail ocean
#

@earnest phoenix add a catch in then, and read the error.

earnest phoenix
#

I suddenly encountered such a problem

golden condor
#

Hello all, I am having issues with playlist handling in d.js using the packages ytpl and yt-search
Playing a song on it's own works fine, just playlists don't. The code and error message can be found below. Thanks in advance!
js if (url.match(/^https?:\/\/(www.youtube.com|youtube.com)\/playlist(.*)$/)) { const playlist = await ytpl(url); const videos = await playlist.items; const embed = new Discord.MessageEmbed() .setTitle("Playlist Added to Queue") .setDescription(`${playlist.title} has been added to the queue. It has ${videos.length} songs`) .setColor("#00aaff") msg.channel.send(embed); for (const video of Object.values(videos)) { const result = await yts(video.title) var video2 = result[0] return /* I have also tried await*/ handleVideo(video2, msg, voiceChannel, true); }

(node:6632) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'videoId' of undefined
    at handleVideo (C:\Users\t\Documents\app\commands\play.js:73:15)
    at Object.run (C:\Users\t\Documents\app\commands\play.js:42:11)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:6632) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 6)```
#

This is the song handler which also works fine with singular songsjs const song = { id: video.videoId, title: video.title, url: `https://www.youtube.com/watch?v=${video.videoId}`, author: video.author.name, request: msg.author, thumbnail: video.thumbnail, duration: video.duration.timestamp };

earnest phoenix
#

@frail ocean dont mean to bother you, I know you've probably been helping people all day :/

cinder patio
#

Is it normal for chrome to send more than 1 GET request to the server? PM2 is telling me that when someone goes to the home page the req/min gets increased by 0.3-0.4 (which I think means 3-4 requests a sec)

#

I don't make any requests to the server client-side in the homepage

tight plinth
#

@golden condor I already got this problem, I can explain you how to solve it.

golden condor
#

Yes please

tight plinth
#

so

#

ytdl and ytpl handles videos differently

golden condor
#

Yeah

tight plinth
#

so they dont have the same proprieties

golden condor
#

I am feeding the videos in what I use to handle videos

#
const result = await yts(video.title)
var video2 = result[0] ```
with this
#

I use yt-search to handle songs

tight plinth
#

wats dt

golden condor
#

yts = yt-search

slender thistle
#

@cinder patio Network tab in dev console and see where the browser is sending requests

tight plinth
golden condor
#

What about it

tight plinth
#

try to log a somg from a playlist first to see how they are handled

golden condor
#

Ok

#

console.log(video)

cinder patio
#

Already checked, only one request to the server. I am not sure if the JS/css files that the HTML file imports also count

golden condor
#

Didn't log anythin

earnest phoenix
tight plinth
#

@golden condor js { 11:28:44 AM worker.1 | id: 'QtW_mlJuSBU', 11:28:44 AM worker.1 | url: 'https://www.youtube.com/watch?v=QtW_mlJuSBU&list=PLrR0UWVc3H19qjOsZ864Dw-KlrGPU7l7F&index=2&t=0s', 11:28:44 AM worker.1 | url_simple: 'https://www.youtube.com/watch?v=QtW_mlJuSBU', 11:28:44 AM worker.1 | title: "Nightcore - Don't Say That - (Lyrics)", 11:28:44 AM worker.1 | thumbnail: 'https://i.ytimg.com/vi/QtW_mlJuSBU/hqdefault.jpg', 11:28:44 AM worker.1 | duration: '3:04', 11:28:44 AM worker.1 | author: { 11:28:44 AM worker.1 | name: 'Syrex', 11:28:44 AM worker.1 | ref: 'https://www.youtube.com/channel/UCeZje_7vr6CPK9vPQDfV3WA' 11:28:44 AM worker.1 | } 11:28:44 AM worker.1 | }

#

this is how video are in a playlist

golden condor
#

So

#

Should the song object

#

Have || in it

tight plinth
#

no

golden condor
#

const song ={
id: video.videoId || video.id

#

?

tight plinth
#

        const song = {
          id: video.id || video.video_id,
          title: video.title,
          url: video.video_url || "https://www.youtube.com/watch?v=" + video.id,
          duration: `${minute}:${seconds}`,
          author: {
id: message.author.id,
username: message.author.username
}
        }
        if (video.thumbnail) {song.thumbnail = video.thumbnail}
        if (video.author) {song.artist = video.author.name}
        if (video.duration) {song.duration = video.duration}
        if (video.player_response) {
            let vid = video.player_response.videoDetails
            if (vid.isLiveContent) song.duration = 'Live'
            song.thumbnail = vid.thumbnail.thumbnails[vid.thumbnail.thumbnails.length-1].url
            song.artist = vid.author.name
            }

            if (video.server_response) {
                let vid = video.server_response.videoDetails
        
                song.artist = vid.author.name
                }
        ```
#

this is how personally I do

golden condor
#

I found my issue

#

I think

#

nope never mind

tight plinth
#

it tooks me several entire days of work to solve this issue, and I dont want you to feel this pain

golden condor
#

Thx

tight plinth
#

^^

earnest phoenix
golden condor
#

Should it be this

#

for (const video of Object.values(videos)) { await handleVideo(video, msg, voiceChannel, true); // eslint-disable-line no-await-in-loop
}

tight plinth
#

personally I do for (const video of videos)

#

lemme check

#

nope

golden condor
#

@tight plinth is this right?

#

const song = {
id: video.id || video.videoId,
title: video.title,
url: video.url || https://www.youtube.com/watch?v=${video.videoId},
author: video.author.name,
request: msg.author,
thumbnail: video.thumbnail,
duration: video.duration || video.duration.timestamp
};

tight plinth
#

try it and see

#

but

#

I dont recomment ptuuing the entire msg.author as request

#

it takes ram

golden condor
#

Ok

#

Would this work

#

msg.author.toString()

#

That's what I need

tight plinth
#
 if (message.author.id !== message.guild.ownerID || message.author.id !== client.config.ownerID) return message.channel.send('Only the server owner can change my prefix!');
            ```I'm a bit confused, I want the server owner AND/OR me (if I am the server owner) to be able to change my bot prefix. How to do that?
#

@golden condor hell no

#

just id should be enough

#

or tag

#

or both

golden condor
#

Why wouldn't .toString work

tight plinth
#

coz msg.author is an object

golden condor
#

It just worked

tight plinth
#

lol

finite bough
#

any errors?

#

.map('lu')

tight plinth
#

no

#

just some ytdl_is_dumb errors

finite bough
#

does it say the text if the msg.author is not the owner?

tight plinth
#

idk

finite bough
#

try it lmao

tight plinth
#

can u test in #commands plz (pichu prefix set prefix)

finite bough
#

are u using json db?

tight plinth
#

quick.db

finite bough
#

ah

tight plinth
finite bough
#

here it does not?

tight plinth
finite bough
#

in ur private server

#

u r the owner

#

so

tight plinth
#

owner detection works

finite bough
#

idk if this is a bad method but try using else

#

else if

tight plinth
#

I just want the dev to bypass server owner perms

#

ok

#

@woven sundial invite.inviter doesnt exist

cunning glen
tight plinth
#

whats ur host kyra

cunning glen
#

vps

#

linux

tight plinth
#

try using sudo npm i integer

barren swallow
#

@tight plinth check client owner id first

finite bough
#

lumap try using else if

golden condor
#

@tight plinth I am going insane

finite bough
#

lel

cunning glen
atomic quarry
#

And I don't know how to make a bot using noblox

cunning glen
finite bough
#

@atomic quarry what are u trying to do

atomic quarry
#

Make a Discord bot with noblox

cunning glen
#

an irritating module :/

tight plinth
#

and now retry

finite bough
#

is noblox a module?

atomic quarry
#

....

cunning glen
#

@tight plinth

tight plinth
#

sudo?

cunning glen
#

no

#

💩

tight plinth
#

oof

finite bough
#

@atomic quarry yes noblox is a module

tight plinth
#

wait a sec

cunning glen
#

@tight plinth terminal

tight plinth
#
if (false || true) return 1``` returns 1?
finite bough
#

btw lumap

#

u should allow everyone with admin perms to edit the bot prefix

tight plinth
#

k

#

if Im right its ```js
if (message.member.permissions.has("ADMINISTRATOR"))

finite bough
#

12v?

tight plinth
#

v12

#

ye

finite bough
#

try it

#

i think its hasPermission

#
.hasPermission(permission, { checkAdmin = true, checkOwner = true } = {}) { 
``` can also work ig
tight plinth
#

wait a second

#

server owner have admin by default

#

so it works fine in my private server

tight plinth
#

splitted the prefix command in 2 commands : one for the users, one for me

finite bough
#

if u could have just did

#

if(message..... ownerid
else if .... lumap

tight plinth
#

I tried, it didnt work

#

well splitting the command works

#

thanks for help

narrow kettle
#

[python] so im suppose to get a text file, which contains numbers from 1 to n(not in the right order) but is missing one number, i need to find what is the number that is missing and also add it to the file, i dont even know where to start

earnest phoenix
#

easiest way is just to sort it and find the gap 😛

narrow kettle
#

how do i find the gap tho? just go over it with a for loop and check when the number im currently on is +2 than the number before

slender thistle
#

Is the step a constant?

narrow kettle
#

after i sort it, yes