#development

1 messages · Page 488 of 1

inner jewel
#

probably

#

but i guess it'd be inefficient as hell

topaz fjord
#

Even if I try I'll have to do it on the lavalink side

inner jewel
#

lavalink doesn't support audio filters

#

so gl

#

you'd need to patch it to support them

earnest phoenix
#

anyone got a quick way to check if a string contains a number and only a number
isNumeric(args[1]) && Number.isInteger(parseInt(args[1]) ?

#

or can i just use one of them 🤔

#

args[1] is a string like '1' '2' or '3' etc but i want to make sure its a number and nothing but

#

parseInt will actually get number from first part of a string e.g. '123asdf' -> 123

#

oh really?

#

huh TIL

#

yea

#

"a number and notiing but" so no decimals?

earnest phoenix
#

for non-decimal you could use a simple regex like:

/^\d$/.test(args[1]) test for a single digit integer
/^\d+$/.test(args[1]) test for any digits integer

earnest phoenix
#

Can somebody tell me why

});

don’t work now?

#

lib is discord.js

#

having to write a library for bot

#

the lib file at least

#

Why is ) at }); an unexpected token if I need it to end a script?

#

send the full block of code

#

that is errorign it

#

ok

#

Any errors that cost the last }); to not work?

#

I can’t send it in cuz it’s too long. Imma google it myself

bitter sundial
#

you're probably missing some other bracket before that

#

check for missing } from if statements and whatnot

earnest phoenix
#

^

wicked summit
#

Can someone help me?

#

Idk whats wrong

#

If someone know how to fix it please mention me!

lament meteor
#

@wicked summit try re-downloading all the packages

wicked summit
#

Its fixed 😀

#

Just need to prune the modules

rocky vale
#

Why I get logged out?

earnest phoenix
#

wut

rustic axle
#

Gitch reeee

stone hatch
#

Is discord.js broken, cuz making a kick command is impossible.

knotty steeple
#

impossible or the fact that you cant code?

stone hatch
#

I asked the person who made a kick command using the exact same way I did it and has a bot named CBot that is used alot.

real ocean
#

does the bot have permission to kick?

stone hatch
#

Ye.

#

MANAGE_SERVER

earnest phoenix
#

Oh maybe you forgot something, to add to the script.

knotty steeple
#

thats not the permission to kick

#

its kick members

stone hatch
#

Tommie.

#

You made the script for me.

real ocean
stone hatch
#

You even tried it.

earnest phoenix
#

ye, but it is not working on your bot

stone hatch
#

ye.

#

lemme try this again.

rustic axle
#

The kick members permission needs to be set...

#

Manage server only can change the overview settings in the server settings

upper ember
#

How do I check if user is in a specific guild? (Discord.js)

real ocean
#

loop through the guild's members looking for the user

upper ember
#

How lol?

real ocean
#

guild.members is a collection of all the members in the guild indexed by id, just check if the user's index is defined

#

i haven't used discord.js but theres no reason that it shouldnt work

#

worst case you can convert guild.members into an array of keys and check each element, seeing if it's the users id

jagged plume
#

or you can use .has

#

iirc thats a thing

real ocean
#

actually ye

real ocean
#

out of curiosity, what do people use to store data for their bots? im using mongodb

ruby dust
#

mongodb isn't bad

#

I don't like SQLite but I'm using that anyway

#

and I don't want to rewrite my entire codebase just because I want to move to a different db system

real ocean
#

i'd never used mongo before i started doing discord bots, but using SQL in python just felt wrong to me

#

too structured

ruby dust
#

that's exactly what I'm using

#

well, SQLite at least is very staightforward

#

I don't have any problems with it other than the fact that it wasn't made to be used for something like "discord bots"

#

it's more for a single user thing

real ocean
#

ah right

shell blade
#

How do you check your bot's permissions in a guild with Discord.js?

quartz kindle
#

var permissions = bot.canHasPerms ? kthx : bye;

stone hatch
#

Guys, how can I fix this error for kick code?

#

Ima just leave this here and see tommorow if there is any help, I might just wait a bit cuz someone is typing.

gilded blaze
#

Include the parenthesis so JS knows you are calling the constructor

stone hatch
#

Huh?

#

Idk what you mean, me beginner.

#

For kickEmbed?

#

Put ()?

earnest phoenix
#

RichEmbed()

stone hatch
#

ok

gilded blaze
#

^

wanton walrus
#

Its a constructor

#

please please please lookup the basics of JS

#

please

earnest phoenix
#

^

wanton walrus
#

It'll help you so much in the long run

stone hatch
#

I am beginner, sorry if I was a nuisance.

#

ok

#

But thank you guys for the help.

#

It works now.

earnest phoenix
#

You actually need to lookup the info yourself

wanton walrus
#

It's understandable but you shouldn't work with a web application until you know the basics

earnest phoenix
#

whats a constructor 4Head

#

Like Google, Stack Overflow, MDN

wanton walrus
#

@earnest phoenix no u

stone hatch
#

Guys, it went online but it will not work.

#

This is what the command prompt says.

earnest phoenix
#

Look, if it says cannot read of undefined, then you need to look the layer before .first()

stone hatch
#

oh ok

earnest phoenix
#

Try to console it

stone hatch
#

i dont understand. rip me

earnest phoenix
#

Console.log

stone hatch
#

oh ok

barren brook
#

how do i make a taxi command for fortnite

earnest phoenix
#

i keep getting (npm ERR!) in cmd

quartz kindle
#

that means a module failed to install for some reason. it should say in the error why

whole plume
#

I could highkey use help setting up a currency system in my bot, dm me if you're willing to lend me some of your expertise.

quartz kindle
#

just post your questions here

earnest phoenix
#

error

#

node index.js isnt responding

whole plume
#

no errors or nothing

#

hm

quartz kindle
#

index.js doesnt have anything to keep it running

#

probably you didnt set up the discord event listener correctly

earnest phoenix
#

^

quartz kindle
#

show your index.js code

earnest phoenix
#
// Load up the discord.js library
const Discord = require("discord.js");

const client = new Discord.Client();

const config = require("./config.json");

client.on("ready", () => {

  console.log(`Bot has started, with ${client.users.size} users, in ${client.channels.size} channels of ${client.guilds.size} guilds.`);
 
  client.user.setActivity(`Serving ${client.guilds.size} servers`);
});

client.on("guildCreate", guild => {
  
  console.log(`New guild joined: ${guild.name} (id: ${guild.id}). This guild has ${guild.memberCount} members!`);
  client.user.setActivity(`Serving ${client.guilds.size} servers`);
});

client.on("guildDelete", guild => {

  console.log(`I have been removed from: ${guild.name} (id: ${guild.id})`);
  client.user.setActivity(`Serving ${client.guilds.size} servers`);
});


client.on("message", async message => {

  if(message.author.bot) return;

 
  if(message.content.indexOf(config.prefix) !== 0) return;

  const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
  const command = args.shift().toLowerCase();

  if(command === "kick") {

     if(!message.member.hasPermission("KICK_MEMBERS")) return errors.noPerms(message, "KICK_MEMBERS");

     let member = message.mentions.members.first() || message.guild.members.get(args[0]);
     if(!member)
       return message.reply("Please mention a valid member of this server");
     if(!member.kickable)
       return message.reply("I cannot kick this user! Do they have a higher role? Do I have kick permissions?");

     let reason = args.slice(1).join(' ');
     if(!reason) reason = "No reason provided";

     await member.kick(reason)
       .catch(error => message.reply(`Sorry ${message.author} I couldn't kick because of : ${error}`));
     message.reply(`${member.user.tag} has been kicked by ${message.author.tag} because: ${reason}`);

   }

});


client.login(config.token);```
quartz kindle
#

hmm weird

earnest phoenix
#

...?

quartz kindle
#

try removing everything and adding it back one at a time, to see if it works

#

example```js
const Discord = require("discord.js");
const client = new Discord.Client();
const config = require("./config.json");

console.log("test")```

#

see if "test" shows up

next wedge
#

What the problem with your ping?
.addField(`Pong!`, `Bot ping: **${Math.round(client.ping)}ms**, Your ping: **${Math.abs((new Date().getMilliseconds()/1000+new Date().getSeconds() - (dk.getMilliseconds()/1000+dk.getSeconds)))*1000+"ms"}** `)

#

?

quartz kindle
#

what is dk?

next wedge
#

var dk = new Date();

#

🤔

quartz kindle
#

what doesnt work? error or wrong ping?

next wedge
#

It say for your ping = NaN

#

bot ping works well

#

only your ping Not.

quartz kindle
#

dk.getSeconds is missing parenthesis

next wedge
#

Ok thx.

blazing gorge
#

My friend is currently making a bot

#

But

next wedge
#

🤔

blazing gorge
#

He doesn't know how to set it for 24/7

#

Can u help me?

#

He's not in the server yet

next wedge
#

Sorry mine isnt 24/7 so i cant help :(

blazing gorge
#

Who TF does this bot belong to

next wedge
#

but i eanna knoe that too

blazing gorge
#

-botinfo @lunar sentinel

gilded plankBOT
#
Bot info
ID

440511248371810315

Username

Gruppe Sechs Security

Discriminator

6488

Short Description

Gruppe Sechs Security; The bot that will solve all of your security problems... Automatically!

Library

discord.js

Prefix

g6! (Customizable)

Upvotes

173

Server Count

144 Servers

Owner(s)

@midnight widget

quartz kindle
#

again lmfao

#

i saw this bot before

#

his name is hillarious

#

anyway, to have a bot running 24/7, you need a computer running it 24/7

#

so either leave your computer always on, or put your bot in a VPS (virtual private server)

blazing gorge
#

Ikr

whole plume
#

or you could buy a raspberrypi or something similar for cheap and host it off that

quartz kindle
#

would a pi be cheaper than a vps considering power/internet costs?

whole plume
#

depends on who the host is

#

and if you pay for power and internet

#

its definitely less power comsumption than leaving your pc on all day

topaz fjord
#

Depends on how much power consumption and internet ur using

blazing gorge
#

O

topaz fjord
#

I would say a vps would be cheaper if you opt for the cheaper ones

blazing gorge
#

?

#

The bot keeps dming me

#

Oml

#

Hejebd

quartz kindle
#

a pi would be comparable to a cheap vps, since its hardware isnt that great. whats the avergae ram a pi runs on?

topaz fjord
#

512mb to 1 gig afaik

blazing gorge
#

Why does this bot keep dming me

whole plume
#

ive seen some with 2

topaz fjord
#

You can get a high end version for some more

whole plume
#

it all depends on which one you get

topaz fjord
#

Money

blazing gorge
#

Who owns @lunar sentinel

#

Who's the owner

whole plume
#

im opting in to get a $50 pi

blazing gorge
#

Pi?

whole plume
#

gonna host a bot off it

#

raspberrypi

blazing gorge
#

TF IS THIS BOT MRSSAGING ME

#

Tf

queen sentinel
#

you got screenshots?

#

oh oof

#

didn't scroll down xd

blazing gorge
#

Who owns that bot

#

Legit

topaz fjord
#

Jonny r u blind mmLol

blazing gorge
#

😂

queen sentinel
#

cus I'm Asian

topaz fjord
#

no

blazing gorge
#

Oof

topaz fjord
#

never implied shit

#

stop assuming

queen sentinel
#

that's anti-fax - amirite @fiery birch

#

anyway

blazing gorge
#

Anyone know a great website for new pple who want to learn java, python etc?

#

O
M
L

queen sentinel
#

I can't really do anything about that bot unless 2 more people tell me they're getting DMs too

topaz fjord
#

@blazing gorge block the bot

queen sentinel
#

^^^

blazing gorge
#

LOL

topaz fjord
#

Block the bot

blazing gorge
#

-botinfo @lunar sentinel

gilded plankBOT
#
Bot info
ID

440511248371810315

Username

Gruppe Sechs Security

Discriminator

6488

Short Description

Gruppe Sechs Security; The bot that will solve all of your security problems... Automatically!

Library

discord.js

Prefix

g6! (Customizable)

Upvotes

174

Server Count

146 Servers

Owner(s)

@midnight widget

blazing gorge
#

Djdbdbdbd

quartz kindle
#

i got a dm from him once, but that was like 2 months ago

blazing gorge
#

I swear

#

If it message me when I have DM off

topaz fjord
queen sentinel
#

^^^

blazing gorge
#

Omg

#

I will lose it 😂

#

Lol

#

I hate bots messaging me

#

My friend got s Russian bot

queen sentinel
quartz kindle
#

it says who the owner is, you can message the owner and complain xD

topaz fjord
#

jonny I'm literally doing your job

blazing gorge
#

IDK if it is

#

😂

queen sentinel
#

KIDS

topaz fjord
#

move to shitpost

queen sentinel
#

yea

#

that

topaz fjord
#

or mutes

blazing gorge
#

I have a question

#

TF is this Language

queen sentinel
#

Dude

blazing gorge
#

Sorry

queen sentinel
topaz fjord
queen sentinel
#

else I'll have to mute

blazing gorge
#

-botinfo @cenkenernetwork

gilded plankBOT
#

Please include a bot mention

blazing gorge
#

o

topaz fjord
blazing gorge
#

Oops

#

My b

ruby dust
#

how do you do a watching status in d.py nowadays?

#

I feel like this shit keeps changing

upper ember
#

this is the value

Rainbow Six Commands

%help (Give's you all the commands)
%ash (Show's you information about Operator Ash)
%thermite (Show's you information about Operator Thermite)
%fuze (Show's information about Operator fuze) 
%kapkan (Show's information about Operator Kapkan)
%ela (Show's information about Operator Ela)
%botinfo (Show's Information About The Bot)
%invite (Show's you a link to add the bot to you're server)

but on the bot page. it shows it like that

Rainbow Six Commands %help (Give's you all the commands) %ash (Show's you information about Operator Ash) %thermite (Show's you information about Operator Thermite) %fuze (Show's information about Operator fuze) %kapkan (Show's information about Operator Kapkan) %ela (Show's information about Operator Ela) %botinfo (Show's Information About The Bot) %invite (Show's you a link to add the bot to you're server)

any idea why?

#

btw ```html
<div class="container">
<div class="row">
<div class="card card-body">
<div class="mx-auto" style="width: 1100px;">
<h3 class="card-text">
<%- botinfo.desc -%>
</h3>
</div>
</div>
</div>
</div>

slender thistle
#

await client.change_presence(discord.Activity(type=discord.ActivityType.watching, name='blah blah')) @ruby dust

quartz kindle
#

html usually ignores line breaks

#

you have to either use manual line breaks <br>

ruby dust
#

yeah I realized that you have to use Activity for that now, cause I was using Game all the time

quartz kindle
#

or use elements with display:block like <p> or <div>

wide ruin
#

const { RichEmbed } = require('discord.js')

module.exports.run = async (bot, message, args) => {
 args = (args[0] + 1)
 const success = new RichEmbed()
           .setTitle(`Cleared ${args[0]} messages!`)
           .setColor(0x00ff00);
 const successmax = new RichEmbed()
           .setTitle(`Cleared 100 messages, ${args[0]} `, "<= 100")
           .setColor(0x00ff00);
const min = new RichEmbed()
           .setTitle(`No messages cleared, ${args[0]} < 1 `, )
           .setColor(0x00ff00);
 if(!message.member.hasPermission("MANAGE_MESSAGES")) return message.reply("You don't have the required permission to use this command!");
  if(!message.content.includes("-")) {
    if(args[0] < 1) {
    message.delete()
    message.channel.send(min).then(msg => msg.delete(5000))
  } else if(args[0] > 100) {
    message.delete()
    message.channel.bulkDelete(100).then(message.channel.send(successmax).then(msg => msg.delete(5000)))
  } else {
    message.delete()
    message.channel.bulkDelete(args[0]).then(message.channel.send(success).then(msg => msg.delete(5000)))
  }} else message.channel.send(min)
}

module.exports.help = {
    name: "purge"
}
``` discord.js
#

This only works with 1 digit amounts

#

o/purge 1000 just does 1

earnest phoenix
#

you're setting args = (args[0] + 1) and then you're using it as args[0] again

wide ruin
#

So just use args?

#

@earnest phoenix

earnest phoenix
#

you can just do like args[0] = parseInt(args[0]) to convert the string parameter to an integer (rather than doing "" + 1) and then use args[0] (like you do), but also would be a good idea to make sure args[0] is an integer in the first place

quartz kindle
#

args[0] + 1 is wrong in the first place. if args[0] is a string, then the +1 will add a digit to the string

#

meaning purge 1 will become purge 11

earnest phoenix
#

yes

wide ruin
#

So parseInt(args[0])

quartz kindle
#

you dont need to do anything to args[0] tbh, i believe discord takes strings as well

earnest phoenix
#

its wise to do so tho since he already performs some numerical checks to args[0]

quartz kindle
#

and all arithmetic operators except + work as intended with strings

earnest phoenix
#

I just find it odd to do stuff to a supposed number while its a string, maybe its just me xD

quartz kindle
#

yeah its odd, but its not that complicated lmao

#

like, there are many performance comparisons about converting strings to numbers, and one of the most popular solutions surprisingly is simply string*1 lmao

earnest phoenix
wide ruin
#

So can I do amount = parseInt(args[0])

quartz kindle
#

yes

wide ruin
#

And can I just do amount = amount + 1

quartz kindle
#

there is also Number(string) if you dont need to round it

#

but why do you need the +1?

#

oh to delete the delete command

wide ruin
#

Yeah

earnest phoenix
#

module.exports.run = async (bot, message, args, admins) => {
  
  if(message.author.id !== admins) return;

  let sUser = message.mentions.users.first();
  
  if(err => console.log(err));
  
  message.channel.send(`<@${sUser.id}>`)
  message.channel.send(`<@${sUser.id}>`)
  message.channel.send(`<@${sUser.id}>`)
  message.channel.send(`<@${sUser.id}>`)
  message.channel.send(`<@${sUser.id}>`)
  message.channel.send(`<@${sUser.id}>`)
  message.channel.send(`<@${sUser.id}>`)
  message.channel.send(`<@${sUser.id}>`)
  message.channel.send(`<@${sUser.id}>`)
  message.channel.send(`<@${sUser.id}>`);

}

module.exports.help = {

  name: "spam"
  
}```
The console says it can’t send an empty message
quartz kindle
#

jesus why are you sending the same message so many times

earnest phoenix
#

Reasons

quartz kindle
#

spam commands are considered api abuse and against discord's tos

earnest phoenix
#

;-;

#

Deleted the command then...

quartz kindle
#

also your if is wrong

earnest phoenix
#

Wdym

quartz kindle
#

if(expression) {
//code
}

earnest phoenix
#

Oh

quartz kindle
#

also, where is that err coming from?

earnest phoenix
#

Looks to be undefined to me

wide ruin
#

Are unprefixed commands allowed on other servers?

#

By this I mean if somebody says @dawn lagoon, it says :angeryping:

topaz fjord
#

its not allowed in this server

wide ruin
#

Can bots react with :angeryping:

topaz fjord
#

they can

ruby dust
#

instead of asking if "allowed", think how those servers will react to that, many communities that will use your bot will treat it as some sort of spam that can not be toggled

wide ruin
#

Like if(message.content.includes("@BagelBot#3472") { message.react(:angeryping: }

#

Would that work in js?

topaz fjord
#

not how reactions work

wide ruin
#

I used the emoji id

topaz fjord
wide ruin
#

<: angeryping:490231147658215424>

#

That's what I used

#

But can they react with emojis from servers?

topaz fjord
#

yes

#

bots can use emojis from any server

#

that they are in

wide ruin
#

Right

#

So from that link, it uses message.guild

#

Wouldn't that just look in that server?

topaz fjord
#

yes

smoky spire
#

It's an example you can change it

wide ruin
#

How can I make it for its emoji server?

topaz fjord
#

you can use <Client>.guilds.filter() to get the guild with the emoji

wide ruin
#

I don't fully understand filter

topaz fjord
#

u can use .get() also

smoky spire
#

Just use get() on client.emojis

topaz fjord
#

.get take an id

#

that works too

wide ruin
#

let emoji server =client.guilds.filter("bagelbot emojis")

#

Would that work?

smoky spire
#

Very much no

wide ruin
#

Oh

#

See I don't understand

topaz fjord
#

you can also use client.emojis.get('id') like Keenser said

smoky spire
#

If you have the id of the emoji, you don't need to find a guild

wide ruin
#

<: angeryping:490231147658215424>

topaz fjord
#

ok

wide ruin
#

How would I use it then

smoky spire
#

client.emojis.get("490231147658215424")

topaz fjord
#

const hfweafgdbuqjhn = client.emojis.get('490231147658215424')

wide ruin
#

const angeryping = client.emojis.get('490231147658215424')

smoky spire
#

Yes

wide ruin
#

message.react(angeryping)

smoky spire
#

Yes

topaz fjord
#

yes

wide ruin
#

Thanks

topaz fjord
#

you do know you can try it before writing it piece by piece and asking us if its right

wide ruin
#

how do you use .mentions

#

I have if(message.mentions()) {

#

What goes inside () @topaz fjord?

smoky spire
#

Mentions Isn't a method

topaz fjord
#

also not how you use .mentions()

smoky spire
#

Please look at the docs before asking

topaz fjord
wide ruin
#

No, I don't know what to put inside the ()

smoky spire
#

There are no ()

wide ruin
#

So what to I use for of mentions bot

#

If*

#

if(message.mentions() ) {
message.react(angeryping)
}

topaz fjord
#

not how you use it

ruby dust
#

do you even know what .mentions even does?

topaz fjord
#

look at the docs

wide ruin
#

But what do I put after .mentions

#

I don't know which one

ruby dust
#

oh god

topaz fjord
wide ruin
#

I'm also amused after seeing message.nonce

ruby dust
#

oh yeah, I've been willing to ask what is nonce even is

wide ruin
topaz fjord
wide ruin
#

This is nonce

topaz fjord
#

random string used for checking that the message was delievered

wide ruin
#

So why nonce

ruby dust
#

yeah well I don't really get that one, or how it can be useful to me ¯_(ツ)_/¯

wide ruin
#

This better?

#

@topaz fjord

topaz fjord
#

.user isnt a property for .mentions

wide ruin
#

I thought it said it was

topaz fjord
wide ruin
topaz fjord
#

you typed .user

wide ruin
#

Oh

#

.users

topaz fjord
#

and also .id() isnt a thing for a collection

wide ruin
#

Oh

#

So just remove .id?

topaz fjord
#

no

night imp
#

It is a property not method

#

so you need to compare it

wide ruin
#

What do I put instead

topaz fjord
#

.get('id')

wide ruin
#

if(message.mentions.users.get('476609928023244801'))

#

This?

topaz fjord
#

yes

wide ruin
#

Ok thanks

topaz fjord
#

literally idk how many times we can tell you to read the docs

wide ruin
#

I would count

#

Too high

#

I only have 10 bits

topaz fjord
#

then why dont you just read them

wide ruin
#

Well I do, but sometimes I don't get it

topaz fjord
#

then google is a friend

wide ruin
#

Nothing

#
const angeryping = client.emojis.get('490231147658215424')
const token = process.env.TOKEN;
const dbl = require("dblposter")
const DBLPoster = new dbl(`Yep, this is something I shouldn't share`, client);
DBLPoster.bind();
const fs = require('fs');
const commands = {}
fs.readdirSync('./commands/').forEach(file => {
    commands[file.substring(0, file.length - 3)] = require('./commands/' + file);
})

const prefix = "o/";
client.on('message', async (message) => {
  if(message.mentions.users.get('476609928023244801')) {
    message.react(angeryping)
  }```
topaz fjord
#

log angeryping to see if it exists

wide ruin
#

Looking at the logs, it doesn't

west raptor
#

undefined?

wide ruin
#

Can you check, it's very long

#

Please

west raptor
#

Ok

#

Emoji must be a string or emoji/reactionemoji

earnest phoenix
#

It makes me mad that you load commands synchronously reee

#

With node.js, of all things

knotty steeple
#

pls

steel heath
#

how do you check if anyone from @everyone have the permission to see channel mmLol

earnest phoenix
#

library?

#

in d.js you could probably do something like channel.permissionsFor(guild.defaultRole).hasPermission("VIEW_CHANNEL")

wide ruin
#

In d.js, what is nonce for?

#

"a random number or string used for checking message delivery"

#

What does that even mean

steel heath
#

@earnest phoenix ty d.js yes

inner jewel
#

loading stuff synchronously isn't bad

#

when done properly

#

no issue with loading command ssynchronously

#

they're needed for the bot to work anyway

knotty steeple
#

natan super cool coding guy

west raptor
#

^

earnest phoenix
#

@inner jewel You don't get it lol

#

Node.js was built around asynchronous operations

#

using synchronous I/O really isn't the Node way

inner jewel
#

then why is that function a thing?

#

there's nothing wrong with that usage

#

the process won't be doing anything besides the bot

#

no issues with waiting for commands to load before proceeding

earnest phoenix
#

synchronous methods are made for times when asynchronous I/O isn't optimal

#

this situation does not fit that case

#

anyone know how to fix this with my stats command

(node:11416) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'size' of undefined
west raptor
#

what are you trying to get the size of

earnest phoenix
#

channels and roles in a server

west raptor
#

code?

earnest phoenix
#
Channels: ``" + `${message.guild.channels.size}` + "`` \nUsers: ``" + `${message.guild.users.size}` + "``\nRoles: ``" + `${message.guild.roles.size}` + "``
west raptor
#

guild doesnt have the property users iirc

earnest phoenix
#

how can i make it work then

ruby dust
#

guilds have members, not users

inner jewel
#

members

earnest phoenix
#

ok

west raptor
#

^^

earnest phoenix
#

module.exports.run = async (bot, message, args) => {

  let mUser = message.guild.member(message.mentions.users.first() || message.author);
  
  let uEmbed = new Discord.RichEmbed()
  .setTitle(`User information for ${mUser.tag}`)
  .setDescription(`Account created on ${mUser.createdAt}`)
  .setAuthor(`Requested by ${message.author.tag}`)
  .addField('User ID: ', mUser.id, true)
  
  message.channel.send(uEmbed);

}

module.exports.help = {

  name: "user"
  
}``` This outputs mUser as undefined
#

???

bright spear
#

message.guild.member(message.mentions.users.first() || message.author);

#

the frick

#

message.guild.member isnt a thing

earnest phoenix
topaz fjord
#

it is

#

@bright spear

earnest phoenix
#

Even if i were to remove it, it would output the same

#

I tried that

bright spear
#

oh oof

#

its in the old version

#

but you can just use message.mentions.members.first() || message.member

west raptor
#

member doesnt have the property tag

earnest phoenix
#

It outputs the exact same thing

west raptor
#

it would be member.user.tag

topaz fjord
#

it shouldnt

earnest phoenix
#

Fixed

bright spear
#

wait

#

you dont even need a member

#

everything you need is on the user object

earnest phoenix
#

user.tag

#

member = user

#

basicaly right?>

bright spear
#

no

topaz fjord
#

nope

earnest phoenix
#

NO?

bright spear
#

member and user are different

earnest phoenix
#

I need to refresh my d.js

bright spear
#

member = a user in a guild, has information about that user relating to the guild

#

user = a discord user in general, not related to guilds

earnest phoenix
#

So member is about users in general and user is a specific user?

topaz fjord
#

user is the specific user on discord

#

member represents the specific user in a guild

earnest phoenix
#

Ohhh ok

west raptor
#

if you want to get user properties from a member it would be <member>.user

slim heart
#

What is wrong with this?

            let argo = arg[i]
                for (z = 0; z < words.length; z++) {
                    let word = new RegExp (words[z], 'gi')
                    if(argo.match(word)) {
                    const array = arrays[words[z].toLowerCase()]
                        for (b = 0; b < array.length; b++) {
                            let sio = new RegExp (array[b], 'gi') 
                            if(argo.match(sio)) break;
                            stopped();
                            break;
                        }
                }
            }
                }```
knotty steeple
#

idk

#

you say

slim heart
#

it works the first part but when b comes into play it doesnt do

knotty steeple
#

those indents 👀

slim heart
#

shush

#

i need quick help lol

knotty steeple
#

well idk whats happening there so i cant help :<

earnest phoenix
#

we need some context and also contents of words / arrays

#

that code alone out of the blue really hard for anyone to tell what's wrong

quartz kindle
#

if the b part doesnt work, probably array is getting an empty/undefined array

slim heart
#

its some problem with the for

#

I asked in TCD and i ended up with this code

            let argo = arg[i]
                for (z = 0; z < words.length; z++) {
                    let word = new RegExp (words[z], 'gi')
                    if(argo.match(word)) {
                    const array = arrays[words[z].toLowerCase()]
                        for (b = 0; b < array.length; b++) {
                            let sio = new RegExp (array[b], 'gi') 
                            if(argo.match(sio)) break;
                            stopped();
                            if(isstop) break;
                        }
                }
            }
                }```
#

and still, it doesnt seem to give sio a match on the argo EXCEPT on the first part of array

#

so is it something like for keeps definitions of things and you overwrite

real ocean
#

what is arrays?

quartz kindle
#

maybe tell us what you're trying to do

#

perhaps you dont need triple nested for loops nor regexes

#

for example, if you want to see if argo matches a word in the words array, you can use indexOf or includes instead

slim heart
#

Im trying to search the array array, (which is based on the word sent) and itll go thru everything and if it matches it stops the loop

earnest phoenix
#

just finished my rewrite transitioning all my data storage and such to mongodb :D

#

happy times

#

now time to work on web ui 😢

quartz kindle
#

if you post an example of what arg, words and arrays contain, it will be much easier to help

slim heart
#

const words = swears.var

        const arrays = byp
#

var byp = new SelfReloadJSON('./byp.json');

#

const swears = new SelfReloadJSON("./swears.json")

#

it doesnt do you much good

#

but here

quartz kindle
#

i mean

#

the actual contents

#

like what you see if you do console.log(arg)

#

doesnt need to be everything, specially if is a big array

slim heart
#

const arg = RemoveAccents(message.content.replace(/[.]/g, '').replace(/\u200b/g, '')).slice().trim().split(/ +/g)

#

thats arg

#

that byp.json

#

thats swears.json

quartz kindle
#

so basically arg is all the worlds of a message

#

arrays is an object

slim heart
#

yes

#

yes

quartz kindle
#

words is an array of they keys to arrays

slim heart
#

so words is the matched phrase in arg and then used as word as a key to arrays

quartz kindle
#

hmm

#

how are the arrays in byp.json different from swears.json?

slim heart
#

check your dms

quartz kindle
#

because they will already match a swear

#

what else do they need to match?

slim heart
#

swears contains all the words then byp contains all the words as keys and used to find the responsible array for bypasses

quartz kindle
#

but like

#

you get a word from message, you see if it exists in the swears array, if it exists you see if the same word exists in the bypasses?

#

can the same word be both a swear and a bypass?

slim heart
#

idk, but it works how it is im just switching from forEach to for and its all just oof

quartz kindle
#

if i understood correctly, you want to see if the rest of the message contains a bypass if a swear is found?

slim heart
#

yes exactly and i achieved this before by using this horrible mess

quartz kindle
#

because what the code is doing right now makes no sense, you're matching a key and then matching the same key again to the content of the key

#

it will only ever work if your byp.json is something like {"swear":["swear"]}

#

the same swear for both key and value

slim heart
#

It works obviously because it works fine in the old version, but its just not working how it is which the only difference is it uses for instead of foreach

#
arg.forEach(arg => {
            words.forEach(words => {
                let word = new RegExp (words, 'gi')
                if(arg.match(word)) {
                  const array = arrays[words.toLowerCase()]
                    if(array[0]) { 
                    let sio1 = new RegExp (array[0], 'gi') 
                    if(arg.match(sio1)) return; 
                    }
                        ^ repeated a shit ton
#

thats the old version

#

So, whats happening is im matching the content to an array of words, and depending on which word is picked up as a match, it uses that word as a key to find the array in byp.json that corresponds to the word

quartz kindle
#

yes that part makes sense

#

but what are you doing to that array then?

slim heart
#

im seeing if the argument also matches any of whats in the array and if it does it returns

#

its to stop mishaps like the bot picks up "ass" but then one of the words in the array in byp.json is "assum" so if someone types "assume" its not censored

#

but its individual, so say like "fuck" one of the words in its array is "fuch" but if you type "assumefuck" it'll do a check for "ass" which will return negative because it contains "assum" and continue, then it finds "fuck" and it doesnt find anything in the array because its not there so then it continues and runs the censor function etc.

#

if that makes sense?

quartz kindle
#

hmm i see

zealous veldt
#

couldn't you have something like?

{
"words":[
"fuck": {"ignore":["..."]}
]
}```?
slim heart
#

probably, but im not in need of changing that whole system

#

it works how its supposed to but i really would just liked to switch to for statements

zealous veldt
#

my idea would work well with for statements

slim heart
#

it'd probably work the same- its just array with keys

#

its the same concept and output just a different organization

zealous veldt
#

yeah, it would be a lot better if you stored the bypassers with the word they override so that they don't screw with other things

slim heart
#

well still the problem im having here, whatever it is would sitll be present

#

because its a problem with for or the match or something im not even sure

#

thats the worst part i have no clue what's wrong with this:

for (b = 0; b < array.length; b++) {
                            let sio = []
                            sio = new RegExp (array[b], 'gi') 
                            if(argo.match(sio)) return;
                            stopped();
                            if(isstop) break;
//My indents are the best dont make fun of me
                        }```
zealous veldt
#

have you tried to removing the RegEx for normal .includes(...)?

#

to make sure its not a RegEx problem

slim heart
#

i need the match tags idk

quartz kindle
#

i would do something like this if i had to use that structure

for(var a = 0, l = arg.length; a < l; a++) {
    for(var a2 = 0, l2 = words.length; a2 < l2; a2++) {
        if(arg[a].match(words[a2])) {
            for(var a3 = 0, l3 = arrays[words[a2]].length; a3 < l3; a3++) {
                if(arg[a].match(arrays[words[a2]][a3])) { break; }
            }
        }
    }
}```
slim heart
#

It couldnt be a problem with regex

#

aaaand that still doesnt work @quartz kindle

quartz kindle
#

well i said "something like this", not "copy and paste this"

slim heart
#

Ik i made my changes to it

quartz kindle
#

i mean, what i usually do to debug problems like this is to just put a bunch of console.log() in relevant places

#

see if all the values are the expected ones

slim heart
#

yeah so ONE REALLY weird thing

#

i did that right

zealous veldt
#

or if you're me, use console.debug for no reason lmao

quartz kindle
#

lmao

slim heart
#

and when i cursed and told it to console.log sio, and it only sent the first part of the array (array[0])

#

so like if i typed wass, which is the first part of the array
(

"ass": ["wass", etc.........

)
and only the first one and it would actually break and not censor like its supposed to

quartz kindle
#

the problem is that the code flow is kinda weird, like first check if true, then check again if false, and change true to false if so

zealous veldt
#

yeah

quartz kindle
#

so you can for example, add a variable in the second for, like var matched = true; and then the third for will say matched = false, if an ignore is found

#

and then after the third for, evaluate matched and censor if true

slim heart
#

I see what you're tryna say

#

ok i was thinking, what if i just drop the other for statements and keep them foreach and just change the 3rd to for

#

because the 3rd always changes if i add a bunch of bypasses to one of the array in byp.json

quartz kindle
#
for(var a = 0, l = arg.length; a < l; a++) {
    for(var a2 = 0, l2 = words.length; a2 < l2; a2++) {
        if(arg[a].match(words[a2])) {
            var matched = true;
            for(var a3 = 0, l3 = arrays[words[a2]].length; a3 < l3; a3++) {
                if(arg[a].match(arrays[words[a2]][a3])) {
                    matched = false;
                    break;
                }
            }
            if(matched) { censor(); return; }
        }
    }
}```
slim heart
#

so id like it to loop based on how many times its actually there

#

(still the same problem btw)

quartz kindle
#

then idk, console.log everything

slim heart
#

i did i told u what happened

#

idk im too tired for this

quartz kindle
#

try again later

slim heart
#

Ill just drop it its not like necessary

zealous veldt
#

For the time being, you probably could find an API that will evaluate messages for swearing

quartz kindle
#

i cant count the amount of times i solved programming problems by going to sleep and waking up with an answer

#

lmao

slim heart
#

I like to keep things hand programmed

#

Well, it might happen

#

Imma just shleep

#

gn guys

quartz kindle
#

cya

sick cloud
#

anyone able to help with this?

TypeError [REQ_RESOURCE_TYPE]: The resource must be a string, Buffer or a valid file stream.
bright spear
#

@sick cloud looks like ur trying to use something thats not a string, buffer, or valid file stream GWchadThinkeyes

sick cloud
#

i am tho

#

@bright spear i'm making a MessageAttachement with a buffer and trying to send it

#
const { body } = await get(` a   u r l   o w o  /overlays/discord`)
.set('Authorization', auth_key)
.query({ avatar: user.user.displayAvatarURL({ format: 'png', size: 512 }), house: 'bravery' });

if (!body || !body.data) return msg.reply(`I was unable to generate that image for you right now, sorry.`);

return msg.channel.send(`Image generated, here you go!`, { files: [new MessageAttachment(body.data, 'bravery_avatar.png')] });
bright spear
#

if you console.log body.data is it a buffer?

sick cloud
#

yep

#

an array of numbers

#

like

#

89, 78, etc

#

lots of them too

bright spear
#

it says <Buffer ?

sick cloud
#

no, its an array angeryBOYE

bright spear
#

then... its not a buffer?

sick cloud
#

well, it said it was on the docs

#

buffer array

bright spear
#

oh try Buffer.from(body.data)

sick cloud
#

oh

#

i'll try it

#

oh yay, that worked

#

thanks

bright spear
#

yw

#

now gimme the site

sick cloud
#

its the idiotic api

last marten
#

I was looking in the testing channels and i saw an embed without the color bar

#

is it an embed?

#

and how do you do that

gilded blaze
#

It's an embed, but the color is set to the background color for Discord chat. If you were to turn on light theme you would see it.
Look at https://discordapp.com/branding for the colors Discord uses.

last marten
#

oh i see it now

#

thanks

stone hatch
#

Someone please help me, I am making this kick command, but when I run the command prompt, it just looks normal with only saying it goes online, but when I try the command, it does not work. Can someone tell me what is going on?

sick cloud
#

any errors

stone hatch
#

nope

#

look in command prompt.

#

nothing

#

nothing at all

#

but if i do run it

#

i think error comes out

#

look at the top when i first ran it

sick cloud
#

where did you define kMember

#

fyi, in order to kick you need KICK_MEMBERS not manage messages

stone hatch
#

oh

#

hold on

#

lemme show you

#

Like this?

sick cloud
#

no

#

where have you defined kMember i asked

stone hatch
#

i didnt

sick cloud
#

ie. where did you do const kMember = ... or whatever

#

then theres your issue lmfao

stone hatch
#

oh

sick cloud
#

your trying to use something that doesn't exist

stone hatch
#

but can u teach me how to get the code?

#

idk how

sick cloud
#

no

stone hatch
#

i just beginner

sick cloud
#

you should learn instead of using example code

stone hatch
#

not like spood feed me, but in steps.

sick cloud
#

steps === spoonfeeding still

stone hatch
#

oh ok

sick cloud
#

google exists, the discord.js docs exist, use them.

stone hatch
#

ok

#

idk what i should look at

#

const or let

earnest phoenix
#

@rapid marsh

if your bot is in said server you could use an eval. for example in Discord.JS:

bot.guilds.find('name', SERVER_NAME).channels.find('name', CHANNEL_NAME).createInvite({maxUses:1}).then(invite => msg.say(invite.code));

(example code, adjust for your bot etc etc)

rapid marsh
#

Yes that’s what I was trying to ask

#

I hope it works

#

So In the eval cmd where do I put the server name?

earnest phoenix
#

there are some caveats

  • discordJS master uses different .find syntax
  • You may need to get your bot (client) differently
  • you may need to return the invite code differently, for example msg.channel.send(invite.code)
#

at SERVER_NAME ofc 😮

#

but again, this only applies to DiscordJS. If you don't use that then you'll have to read your lib's own docs

rapid marsh
#

I figured that out a min ago lol

#

I use discord JS

earnest phoenix
#

you could also make a fresh new command and just make it check if you are using it so no one else can if you like that more. At the end of the day eval is the same as writing the regular code

rapid marsh
#

Ok thanks for the help

#

Is it against TOS to break into server ?

earnest phoenix
#

afaik, no. They did add y our bot after all...

rapid marsh
#

Kk

#

My bots the lockdown bot it’s been in this server before and it’s my first day back after being banned for who knows how long close to two years I’ve been banned

earnest phoenix
#

tbh I did "invade" other servers that way in the past. I log all my bot errors to a channel on my server and sometimes the server owners never reply to DM's so I have no other option if I want to fix a consistently occurring error '_>'

#

like when a server forgot to change my prefix and everytime they used some commands in Mee6 my bot threw an error fp

rapid marsh
#

Yeah my bot does that and people don’t join our support server to fix it they just kick the bot cause they too stupid to get it set up in the first place

earnest phoenix
#

we need an expanding intellect meme for this convo right here ^

rapid marsh
#

Yeah

earnest phoenix
#

-> fixing the bug

-> using bot to create invite in their server without their auth, joining and asking what they did

rapid marsh
#

Lol true

#

That’s what I’m about to do

#

I hope it works

earnest phoenix
#

u should not do that

#

if user doesnt do a command, bot shouldnt do anything

#

especially making invites to other peoples server

#

that's not the thing tho...

#

or rather

#

I don't know exactly what bjbrown's issue is but for me it was they were using a command for my bot but that was also a command on another bot and the syntax was only right for the other one

rapid marsh
#

If this is gonna end up getting me banned cause it’s put down as API abuse I’m not gonna do this

earnest phoenix
#

i think it was !warn as command

rapid marsh
#

Problem is with my bot it doesn’t work until you do l! create

earnest phoenix
#

i.e. my bot has has !warn user points reason and mee6 has like !warn user reason something or other. They are both commands but the argument syntax differs.

rapid marsh
#

I put a space between that so it wouldn’t create channel

earnest phoenix
#

well I would firsst try to get the owner to invite you @rapid marsh

#

if you cant DM them yourself try to add friend them or DM them with your bot and tell them to add friend you

rapid marsh
#

Yeah cause that cmd didn’t even work

#

How do I dm them with my bot

earnest phoenix
#

again the same concept, find the guild object. A guild object has the Owner object which is a User

rapid marsh
#

Can I send a message in their server ?

#

With my bot

earnest phoenix
#

Guild.owner.send('text_here');

#

How you get the Guild part is up to you really coz I don't know your code :v

frigid bone
#

guild.owner.send works too

earnest phoenix
#

oh ye true i forgot GuildMember.send() is a thing

earnest phoenix
#

Can somebody tell me how can I make my bot randomly select a message and send it ?

quartz kindle
#

make an array of possible answers and chose a random one using Math.random()

earnest phoenix
#

@earnest phoenix Do you understand what Tim means? If not, I could elaborate.

#

So..

let replies = [“hello”, “hola”]
let result = Math.random(replies)

like that?

#

Erm... No.

quartz kindle
#

almost

earnest phoenix
#

Then how?

quartz kindle
#

but Math.random() returns a random number between 0 and 1

earnest phoenix
#

^

quartz kindle
#

so you have to adapt it into returning something valid for the array

#

for an array of 2 items, all you need to do is round it into an integer

#

for more than 2 items you need to multiply it by the amount of items and then round it into an integer

earnest phoenix
#
let result = Math.floor((Math.random() * result.length));
quartz kindle
#

you dont need libraries

#

yes, but i would use Math.round() instead of Math.floor()

earnest phoenix
#

True.

#

Math.random() exists for that

#

Highy recommend against using an extra module for this

#

So uh... how should I change the code in order to make it work?

#

I use it because it saves loads of time when using a random number in 50 commands.

quartz kindle
#

you select an item from an array like this

#

array[number]

#

math.floor gives you the item number

earnest phoenix
#

so... what should I type in the result line?

#

SunOG it would be even easier to have an actual ping command rather than preset ones.

#

Wait is there an actual ping command?

#

🤔

quartz kindle
#

partially yes lmao

earnest phoenix
#

How can I use it?

quartz kindle
#

client.ping = average websocket latency

topaz fjord
#

lmao

earnest phoenix
#

oh

quartz kindle
#

as for message roundtrip, you have to use new Date() minus message.timestamp

earnest phoenix
#

Thanks for telling me that

#

👋 bye

quartz kindle
#

you thought everyone did random pings like that? lmao

earnest phoenix
#

@quartz kindle isn't there an actual thing for ping... Date minus message.timestamp can be inaccurate.

quartz kindle
#

there is client.ping, but its the websocket heartbeat, not the message roundtrip

topaz fjord
#

There isn't one for message round trip

earnest phoenix
#

True

#

Im making a phone bot

#

So i can call people from discord

#

Lol

topaz fjord
#

expensive

earnest phoenix
#

I mean

#

It's either that or I could make a dominos bot

#

!order regular

#

👍

#

Good thing we have a dominos module

fresh kernel
#

genius

earnest phoenix
#

@topaz fjord i could get a number for $1/mo

topaz fjord
#

but some apis charge for calls

earnest phoenix
#

Meh

#

@topaz fjord i got it for free my dude

shell blade
#

Is anyone familiar with the An Idiot's Guide API and know how to get a key?

quartz kindle
#

what key?

quartz kindle
#

cant find it anywhere, ask in their discord server

shell blade
#

Okay.

upper ember
quartz kindle
#

try whitespace: pre-wrap

#

or word-break: break-all

#

or overflow-wrap: break-word

olive lantern
#

Anyone here good with Lavaplayer? I'm trying to figure out how to use the Youtube Search function but nothing I found was really helpful
I'm using the JDA btw

limpid cosmos
west raptor
#

lib/lang?

#

@limpid cosmos

#

.-.

limpid cosmos
#

for having servers

#

like thet

#

*that

west raptor
#

i just asked

#

what lang

limpid cosmos
#

oh srry

#

JS

west raptor
#

js api ^

limpid cosmos
#

okay 😉

#

ty

west raptor
#

np

next wedge
#

hy

earnest phoenix
#

post to their API POGGERS

signal saffron
#
se which was not handled with .catch(). (rejection id: 8)
(node:17704) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions
    at item.request.gen.end (/rbd/pnpm-volume/1c20d6ad-77cf-4a2d-a304-cf5bd0cca464/node_modules/.registry.npmjs.org/discord.js/11.4.2/node_modules/discord.js/src/client/rest/RequestHandlers/S
equential.js:79:15)
    at then (/rbd/pnpm-volume/1c20d6ad-77cf-4a2d-a304-cf5bd0cca464/node_modules/.registry.npmjs.org/discord.js/11.4.2/node_modules/discord.js/node_modules/snekfetch/src/index.js:215:21)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
(node:17704) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promi
se which was not handled with .catch(). (rejection id: 10)
(node:17704) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions
    at item.request.gen.end (/rbd/pnpm-volume/1c20d6ad-77cf-4a2d-a304-cf5bd0cca464/node_modules/.registry.npmjs.org/discord.js/11.4.2/node_modules/discord.js/src/client/rest/RequestHandlers/S
equential.js:79:15)
    at then (/rbd/pnpm-volume/1c20d6ad-77cf-4a2d-a304-cf5bd0cca464/node_modules/.registry.npmjs.org/discord.js/11.4.2/node_modules/discord.js/node_modules/snekfetch/src/index.js:215:21)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
(node:17704) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promi
se which was not handled with .catch(). (rejection id: 12)```** what is this?**
earnest phoenix
#

Looks to me a like an unhandled promise rejection warning

#

happens by throwing inside an async function without a catch block or a rejected promise that u didnt .catch()

#

And caused by doing something that you didnt have permissions for

signal saffron
#

I understand, I'm learning everything through this place, thanks

earnest phoenix
#

to avoid errors such as that, you should implement an if statement or check if your bot has permissions before doing a certain action which will require such permissions.

inner jewel
#

@olive lantern use ytsearch:query

#

after adding the source manager

olive lantern
#

Alright

#

thanks

inner jewel
#

manager.loadItem("ytsearch: memes", handler)

lean minnow
#
lastResult = eval(code);
    message.channel.send("**Result:** \n${util.inspect(lastResult, { depth: 0 })}");
catch(err) {
    message.channel.send(`Error while evaluating: ${err}`);
};
#

anything wrong here?

wet kite
#
 message.channel.send(`**Result:** \n${util.inspect(lastResult, { depth: 0 })}`);``` you was using " not `
lean minnow
#

oh

#

thx

earnest phoenix
#

Can't tell u mmLol

#

@earnest phoenix

#

(Its actually free)

#

tell meee

#

😦

earnest phoenix
#

Just lookup NodeJS Outbound Call API

#

@earnest phoenix

#

thx

#
(node:6996) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of undefined

anyone able to help

sullen path
#

read the error

olive lantern
#

I think I'm too stupid to get how ytsearch works on lavaplayer

earnest phoenix
#

@sullen path im new to coding, i dont know how to fix it

const Discord = require('discord.js'),
           db = require('quick.db');

exports.run = async (client, tools, message, args) => {


  const status = new db.table('AFKs');


  let afk = await status.fetch(message.author.id);


  const embed = new Discord.MessageEmbed()
    .setColor(0xffffff)

  if (!testafk) {
    embed.setFooter('You are now AFK.');

    status.set(`${message.author.id}`, args.join(' ') || `Sorry, ${message.author.username} is AFK.`);
  } else {
    embed.setFooter('You are no longer AFK.');

    status.delete(`${message.author.id}`);
  }


  message.channel.send(embed);

}

thats the code

sullen path
#

status.fetch(message.author.id); either message or author is undefined

#

I don't do js, can't be sure

frigid bone
#

author is

sullen path
#

ah k

#

that makes sense

frigid bone
#

Check wherever you're calling this function

#

You're probably passing the wrong thing

earnest phoenix
#

look at the code i sent, do you see any thing that could be wrong?

frigid bone
#

No, I don't see anything wrong there, so it's more likely that you're invoking the function you posted with bad parameters, in case I missed something

earnest phoenix
#

well, it only gives the error when i go to use it, and, it doesnt come up with errors on vsc

frigid bone
#

Check if the third argument you're passing is the message object you need

#

Well, it's JavaScript, you won't get many warnings

earnest phoenix
#

i tried using the command after restarting the bot, it gave no errors but didnt do anything

real shore
#

Hello children

#

How do I blacklist this server from broadcast?

sullen path
#

if the guild id is 264445053596991498 skip

real shore
sullen path
#

that if cascade

real shore
#

😂

sullen path
#

if(found === 0 && guild.id != 264445053596991498)

#

🤷

frigid bone
#

First of all, that's some horrible indentation

#

Secondly, why are you using map

real shore
#

First of all, its from stack overflow

sullen path
#

third, why copy-paste from stackoverflow

real shore
#

Secondly, it wasnt originally my code anyway, its my friends

#

👌

frigid bone
#

Friend's code from SO? hmm

real shore
#

Third, pls help

#

Ok

#

we are doing live share

#

🤔

frigid bone
#

You can filter a Collection, such as guilds using the filter method to only include some items

#

In your case, that would be client.guilds.filter(g => guild.id !== enter id here).map(..., if you want to hardcode it

#

Filter takes a function as its argument and returns an array of the items on the collection it was invoken on, which the said function returned true on

#

In the example I provided, all items except the one whose id is equal to the given id will pass

#

Keep it in mind, since you might want to filter more guilds in ifferent ways using this in the future

#

Also, map is used for creating a new array of modified items, you shouldn't use it if you just want to iterate through a collection

#

use tap instead

#

discord.js' Collection class has lots of other similar methods, which you should check https://discord.js.org/#/docs/main/stable/class/Collection

earnest phoenix
#

const Discord = require('discord.js'); const client = new Discord.Client(); client.on("ready", async => { setInterval(function(){ client.channels.find('id', '435814918651117579').setName("♡Δ");}, 500); client.channels.find('id', '435814918651117579').setName("♡ΔN");}, 500); client.channels.find('id', '435814918651117579').setName("♡ΔNI");}, 500); client.channels.find('id', '435814918651117579').setName("♡ΔNIM");}, 500); client.channels.find('id', '435814918651117579').setName("♡ΔNIMΞ");}, 500); client.channels.find('id', '435814918651117579').setName("♡ΔNIMΞ Ꮆ");}, 500); client.channels.find('id', '435814918651117579').setName("♡ΔNIMΞ ᎶΔ");}, 500); client.channels.find('id', '435814918651117579').setName("♡ΔNIMΞ ᎶΔM");}, 500); client.channels.find('id', '435814918651117579').setName("♡ΔNIMΞ ᎶΔMΞ");}, 500); client.channels.find('id', '435814918651117579').setName("♡ΔNIMΞ ᎶΔMΞR");}, 500); client.channels.find('id', '435814918651117579').setName("♡ΔNIMΞ ᎶΔMΞRs");}, 500); client.channels.find('id', '435814918651117579').setName("♡ΔNIMΞ ᎶΔMΞRs♡");}, 500);

#

is this righ me

#

first time use

#

js

sullen path
#

use the right code block kthx

ruby dust
#

why do I have a bad feeling about what you are up to

frigid bone
#

There are several issues with your code

sullen path
#

that's called API abuse

earnest phoenix
#
const client = new Discord.Client();
client.on("ready", async  => {
setInterval(function(){
client.channels.find('id', '435814918651117579').setName("♡Δ");}, 500);
client.channels.find('id', '435814918651117579').setName("♡ΔN");}, 500);
client.channels.find('id', '435814918651117579').setName("♡ΔNI");}, 500);
client.channels.find('id', '435814918651117579').setName("♡ΔNIM");}, 500);
client.channels.find('id', '435814918651117579').setName("♡ΔNIMΞ");}, 500);
client.channels.find('id', '435814918651117579').setName("♡ΔNIMΞ Ꮆ");}, 500);
client.channels.find('id', '435814918651117579').setName("♡ΔNIMΞ ᎶΔ");}, 500);
client.channels.find('id', '435814918651117579').setName("♡ΔNIMΞ ᎶΔM");}, 500);
client.channels.find('id', '435814918651117579').setName("♡ΔNIMΞ ᎶΔMΞ");}, 500);
client.channels.find('id', '435814918651117579').setName("♡ΔNIMΞ ᎶΔMΞR");}, 500);
client.channels.find('id', '435814918651117579').setName("♡ΔNIMΞ ᎶΔMΞRs");}, 500);
client.channels.find('id', '435814918651117579').setName("♡ΔNIMΞ ᎶΔMΞRs♡");}, 500);```
#

@frigid bone tell me

#

i never used js

#

before

#

so

sullen path
#

learn js

#

problem solved

earnest phoenix
#

i'm

frigid bone
#

first off, your arrow function syntax is wrong on the third line, it should be ...async () => ..., if there are no parameters passed

sullen path
#

or use lib for a language you already know

earnest phoenix
#

well js is lighter to run

ruby dust
#

idk, sam is usually running into RAM overuse problems

#

¯_(ツ)_/¯

earnest phoenix
#

i need help with shards

#
      throw new TypeError('The shardCount option must be a number.');
      ^

TypeError: The shardCount option must be a number.
sullen path
#

I'm the one running 8 java bots on a single-core host 🤷

earnest phoenix
#

see

#

that what me talking about

frigid bone
#

also, everything after line 3 is just plain terrible and wrong

sullen path
#

anyways

ruby dust
#

in how many servers you bot is in? @earnest phoenix

sullen path
#

why are you changing the channel name every 500 ms?

earnest phoenix
#

@ruby dust Not That Much, i just want to have it prepared for the future

ruby dust
#

don't worry about sharding until you'll get to at least 1500 servers

frigid bone
#

If you have any programming knowledge, you should know that something is broken when you have more closing curly braces than opening ones...

ruby dust
#

then ask again

earnest phoenix
#

true

#
const client = new Discord.Client();
client.on("ready", async  => {
setInterval(function(){
client.channels.find('id', '435814918651117579').setName("♡A");
client.channels.find('id', '435814918651117579').setName("♡An");
client.channels.find('id', '435814918651117579').setName("♡Anime");
client.channels.find('id', '435814918651117579').setName("♡Anime G");
client.channels.find('id', '435814918651117579').setName("♡Anime Ga");
client.channels.find('id', '435814918651117579').setName("♡Anime Gam");
client.channels.find('id', '435814918651117579').setName("♡Anime Game");
client.channels.find('id', '435814918651117579').setName("♡Anime Gamer");
client.channels.find('id', '435814918651117579').setName("♡Anime Gamers♡");}, 10500);```
#

this seems to work

#

but there is one issue

sullen path
#

API abuse

earnest phoenix
#

yes

sullen path
#

that's the issue

earnest phoenix
#

i want to send messages after that amount of time

frigid bone
#

Try to put all those channel name strings into an array and only use one setTimeinterval function to iterate through said array and change the name every couple of miliseconds, until it reaches the last element

ruby dust
#

ik how much everyone wants to do these little animations, but the api abuse is what we all have in common that limits us from doing it ¯_(ツ)_/¯

frigid bone
#

and yes, that's API abuse and can get you banned

earnest phoenix
#

get me banned

#

hell no i'm not going to risk that

#

then

#

forget the code

frigid bone
#

I mean the library you're using will most likely deal with ratelimits, but that doesn't mean there won't be any consequences

quasi marsh
#

I'm trying to make an animation to fade out some text on a site, replace the text and then fade it back in with the new stuff in place

#

I can make it fade out, but once I change the text it just jumps back to full opacity

#

Got something

#

Thanks for the help all

earnest phoenix
#

i am having an issue with the music part of my bot, it says
I could not join the voice channel: Error: FFMPEG not found
but ffmpeg is installed

real shore
#

you need to make an envirment variable %PATH% to it

#

and you need to restart your IDE

#

thats what I did

earnest phoenix
#

im noob, how do i do the first one

#

@real shore

real shore
#

What oS?

earnest phoenix
#

i use windows
and my bot is javascript

real shore
#

OK

#

In your search bar

#

Type Enviroment Variables

earnest phoenix
#

wait, i know what u mean

real shore
#

and it should say "Edit the system enviroment variables"

#

yeah

earnest phoenix
#

ye, i know that, but i want it so i can use the ffmpeg thats in modules folder, so i when i upload my bot to its hosting site, it will run off that

real shore
#

┬─┬ ノ( ゜-゜ノ)

#

¯_(ツ)_/¯

#

It should just run

#

if you install it with --save

#

im not sure

earnest phoenix
#

i did that

#

lol, i might have fixed it

#

gotta test

#

yup, fixed

#

i used npm i ffmpeg-binaries ffmpeg

real shore
#

noice

earnest phoenix
#

Where

#

i can find

#

the weebhook

#

password?

knotty steeple
#

what

#

is

#

a weebhook

earnest phoenix
#

webhook

knotty steeple
#

what webhook

earnest phoenix
#

off

west raptor
#

What

earnest phoenix
#

Where
i can find
the webhook
password?

knotty steeple
#

what webhook tho

inner jewel
#

you define it

warped ruin
#

Weebhook blobcatthink

prime cliff
#

Ur a weeb

wide ruin
#

Is there a free place to code discord.js, and collaborate with others?

knotty steeple
#

glitch mmLol

wide ruin
#

Well yeah

#

The bot had too many requests and shut down

#

Glitch couldn't handle all the commands

#

So we need a better site

#

Any*

#

And recommendations?

earnest phoenix
#

It is memory leak that we are dealing with

#

We could try heroku if i knew how to use it 🤔

knotty steeple
#

u know

#

github exists

rustic axle
#

Heroku is easy

#

all you fucking do is git commit and git push all fucking day

wide ruin
#

Can we just copy all the glitch code over?

#

Will it work done?

#

Fine*

rustic axle
#

Yes

#

save the glitch code and push the folder to heroku