#development

1 messages · Page 478 of 1

lusty dew
#

How

#

Woldn't that make it only search that game?

quartz kindle
#

yes, but it gives you what you need

lusty dew
#

.

#

But

#

that is not what I want it to do.

#

I want it to do so when people do !steam Rust or !steam Gmod
It will request the game data from it and send it out in an embed

quartz kindle
#

and which part are you stuck with?

lusty dew
#

.

quartz kindle
#

the search gives you the game id

#

use the game id to do another request

lusty dew
#

request.get(https://store.steampowered.com/api/storesearch?cc=us&l=en&term=${game})

#
request.get(`https://store.steampowered.com/api/storesearch?cc=us&l=en&term=${game}`)
#

defining game

#

so whatever they type in

#

will go where ${game} is

quartz kindle
#

oh

#

i thought you had that already

#

just get it from the message

lusty dew
#

Ok

#

Atfer that

#

I should be able to do the rest

#

if not I will ask for help again

quartz kindle
#

alright

lusty dew
#
var game = gamemessage = args.join(" ").slice(22)
#

isnt this how you would define it though?

quartz kindle
#

that looks weird af

#

what is the content of args?

lusty dew
#

content?

#

Nvm

#

It didn't work

#

anyway

#

I am trying to figure out how to define game rn

#

lol

quartz kindle
#

what does args contain

#

what value does it represent

#

console.log(args)

lusty dew
#

Ok

#

It represents

#

what I say after activating the command

#

like

#

!steam Rust

#

it logs rust

sick cloud
#

so use args

lusty dew
#

I did.

sick cloud
#

or args[0]

quartz kindle
#

how does it log it? as "rust" or as ["rust"]?

lusty dew
#
[ 'rust' ]
quartz kindle
#

that means its an array

sick cloud
#

[0]

lusty dew
#

ok

quartz kindle
#

meaning you access it by its index

#

which is index 0 (first value)

#

so game = args[0]

lusty dew
#

[ 'rust' ]

#

still logs as that

quartz kindle
#

you're still console.logging args

#

you can remove the console.log

#

show the rest of the code

lusty dew
#

Ah ok

#

Well

#

ALl I have for now

#
const Discord = require("discord.js");
const request = require("node-superfetch");

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

    var game =  args[0]
    request.get(`https://store.steampowered.com/api/storesearch?cc=us&l=en&term=${game}`)

}

module.exports.help = {
    names: ["steam"]
}
#

Is this so far

#

I am trying to figure out how to request the data now that I have the game requested

quartz kindle
#

alright, now you have to wait for the request and receive a reply

lusty dew
#

Ok

quartz kindle
#

whats the node-superfetch example?

lusty dew
#

?*

quartz kindle
#

go to the node-superfech page

#

in npm

lusty dew
#
const request = require('node-superfetch');
 
try {
    const { body } = await request.get('https://registry.npmjs.com/node-fetch');
    console.log(body);
} catch (err) {
    console.error(err);
}
#

I need to do all that

#

lol

quartz kindle
#

not all

#

see what they did?

lusty dew
#

Yes

quartz kindle
#

the request is assigned to a variable

#

in a special way

lusty dew
#
const Discord = require("discord.js");
const request = require("node-superfetch");

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

    var game =  args[0]
    try{
        const { body } = await
        request.get(`https://store.steampowered.com/api/storesearch?cc=us&l=en&term=${game}`)
    } catch(err){
        console.log(err)
    }

}

module.exports.help = {
    names: ["steam"]
}
#

So like that?

quartz kindle
#

await and request in the same line

lusty dew
#

It is

#

idk why

#

it is like that

quartz kindle
#

then alright

#

at this point

#

body should contain the result of the search

lusty dew
#

ok

quartz kindle
#

you can console.log(body) right after

#

to confirm

lusty dew
#

Ok

#

tested it

#

got this back

quartz kindle
#

alright

#

thats a json response

lusty dew
#

Ok

#

Hmm

#

Could I make it narrow it down to one game?

quartz kindle
#

now you have to navigate it, and access the relevant part

lusty dew
#

instead of multiple?

#

Ah ok

quartz kindle
#

usually the first result is always the closest match

#

so you can stick with it

lusty dew
#

Yea

quartz kindle
#

now, how is this object structured? can you read it? how would you access what you need?

lusty dew
#

Hmmm

#

By defining each one?

#

like

#

price and stuff

#

I would have to define

#

price and platforms

#

for sure

quartz kindle
#

is the information contained there enough? or do you need more?

#

because there is another url with more details

lusty dew
#

Need more

#

I need more then what that gives me

quartz kindle
#

for example

#

check this link

lusty dew
#

Oh

#

lol

quartz kindle
#

this is what you have

#

and this is what you want

#

correct?

lusty dew
#

Yes

#

I want that

quartz kindle
#

so how do you get it? what do you need to access that information?

lusty dew
#

Ummmmmm

shrewd lark
#

/ayuda

lusty dew
#

It looks like a Json response

quartz kindle
lusty dew
#

He asked for help

#

lol

quartz kindle
#

yes, its json, but how do you get there?

lusty dew
#

Hmmm

shrewd lark
#

Quien me enseña hacer una bot de discord

lusty dew
#

I don't know

quartz kindle
#

@shrewd lark ahi se habla solo inglés. se qieres hablar español, hablas en #memes-and-media

#

@lusty dew what did you do right now, to make that appear on your screen?

#

the very basic action you did

lusty dew
#

AH

#

I logged it

#

but I requested

#

the info from that

quartz kindle
#

no, i mean the second link i showed you

lusty dew
#

Oh

quartz kindle
#

you clicked the link

#

and the page opened

lusty dew
#

I found it

#

Oh wait

#

yours

quartz kindle
#

meaning, how do you get all that information into your bot?

lusty dew
#

not mine

#

lel

#

Hmm

#

I have to make it request the data from it?

quartz kindle
#

exactly

#

what does the url need to give you what you want?

lusty dew
#

Um

#

the ID

#

of the game

quartz kindle
#

bingo

lusty dew
#

So

quartz kindle
#

where is the id of the game?

lusty dew
#

Um

#

that part

#

can't answer

#

I don't know lol

quartz kindle
#

you just logged it

lusty dew
#

oh

#

in bodfy

#

body

quartz kindle
#

see how it goes?

lusty dew
#

Yes

quartz kindle
#

first you search, then you get the id from the results, then you request again

#

so what do you need to do now?

lusty dew
#

Um

#

Wait

#

let me set that first part up real quick

#

if I can

quartz kindle
#

what you need to do now is to get the id

#

from the results

lusty dew
#

Yes

quartz kindle
#

can you do that?

lusty dew
#

I can try

#

so wait

#
const { body } = await request.get(`https://store.steampowered.com/api/storesearch?cc=us&l=en&term=${game}`)
#

I keep this

#

then get the ID from those results?

quartz kindle
#

yes

lusty dew
#

Ok

#

I can try and do that

#

Ok

#

I can't figure it out yet

#

lol

#

hm

#

I read this somewhere

#

I am not sure if it is for what I need

#

Nvm

bright spear
#

if you eval that code you should get the full response then you can try to find the id

lusty dew
#

I saw this

#

but

#
alert(json.parse[0].id)
#

I don't think it will work

#

eval?

#

What is eval

quartz kindle
#

i think the json is already parsed, else it would show up as a string in his logs

lusty dew
#

AH yes

#

Ah yes*

#

Ok

#

so

#

hmmm

#

Wait

#

would an alert work?

bright spear
#

uh

quartz kindle
#

no

bright spear
#

alert is for websites

lusty dew
#

Oh ok

quartz kindle
#

alert is for browsers

lusty dew
#

rip

bright spear
#

to get the id of the first result do body.items[0].id

quartz kindle
#

that is the answer yes

#

but do you know why?

bright spear
#

fyi an eval is a command most bots have, that runs code (make sure u restrict it to devs tho)

lusty dew
#

Ah ok

bright spear
#

and as tim said, do you know why that works? (body.items[0].id)

lusty dew
#

because

#

it is getting

#

the first item that pops up id

bright spear
#

yeah

#

its much easier when u see the full response lol

lusty dew
#

yea lol

bright spear
quartz kindle
#

he has it in his logs

bright spear
#

oh

lusty dew
#
const Discord = require("discord.js");
const request = require("node-superfetch");

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

    var game =  args[0]
    try{
        const { body } = await request.get(`https://store.steampowered.com/api/storesearch?cc=us&l=en&term=${game}`)
        console.log(body)
    } catch(err){
        console.log(err)
    }
    return body.items[0].id



}

module.exports.help = {
    names: ["steam"]
}
quartz kindle
#

but he doesnt understand the structure of the object that well

lusty dew
#

that is meh command now

quartz kindle
#

which is why im trying to explain

lusty dew
#

Yea

#

You are doing a good job ;p

#

I forgot

#

that I had to request it from the body

#

xD

quartz kindle
#

so basically body contains the entire object. and if you check your logs, you see that the object has two main properties: total and items

#

thats why you do body.items

lusty dew
#

Yea

#

Ah

#

I see

#

I didn't notice items

#

I only saw total at first

quartz kindle
#

then you see that items is an array

lusty dew
#

yea

quartz kindle
#

because it has [

lusty dew
#

so you do [0]

#

to get the first item

quartz kindle
#

exactly

lusty dew
#

then .id

#

to get it's id

quartz kindle
#

bingo

lusty dew
#

ok

quartz kindle
#

so you take all of this, and put it into a variable

#

var id = body.items[0].id

#

and do the next request with the id

lusty dew
#

ok

#

So wait

#

oof

#

didn't copy it all

#
    var id = body.items[0].id

    try{
        const { body } = await request.get(`https://store.steampowered.com/api/appdetails?appids=${id}`)
        console.log(body)
    } catch(err){
        console.log(err)
    }
#

so like that?

quartz kindle
#

yes, but

#

const can only be used once in the same scope

lusty dew
#

Ah

#

Ok

quartz kindle
#

so either change const to var

lusty dew
#

I changed it to var

quartz kindle
#

or change the second body to something else

lusty dew
#

Oh

#

Ok

#

well I just changed it to var

quartz kindle
#

alright

#

now your second console.log should get the response from the appdetails

lusty dew
#

No

#

Well

#

yes

#

but

#

it should

#
TypeError: Cannot read property 'items' of undefined
    at Object.module.exports.run (C:\Users\User\Desktop\LoverBot v3\commands\ste
am.js:14:19)
    at process._tickCallback (internal/process/next_tick.js:68:7)
#

but

quartz kindle
#

did you remove the first request?

lusty dew
#

?

#

No

quartz kindle
#

show full code

earnest phoenix
#

u cant access .items before you even mame a request lmfao captain_facepalm

lusty dew
#
const Discord = require("discord.js");
const request = require("node-superfetch");

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

    var game =  args[0]
    try{
        const { body } = await request.get(`https://store.steampowered.com/api/storesearch?cc=us&l=en&term=${game}`)
        console.log(body)
    } catch(err){
        console.log(err)
    }
    
    var id = body.items[0].id

    try{
        var { body } = await request.get(`https://store.steampowered.com/api/appdetails?appids=${id}`)
        console.log(body)
    } catch(err){
        console.log(err)
    }




}

module.exports.help = {
    names: ["steam"]
}
earnest phoenix
#

Body is out of scope

#

smh

#

do a let body = null; before the try catch

lusty dew
#

which one

#

lol

#

there is two

earnest phoenix
#

and then assign it the body from the request

#

both because the const body only lasts until the end of that block lmao

#

do u know what scope is? obvs not

lusty dew
#

Um no

earnest phoenix
#

it was rhetorical question lol

lusty dew
#

Ok

#

Well don't be a dick then

#

like damn

earnest phoenix
#

LMAO

#

lemme give you an example:

#
if(something) {
const x = 1
}
console.log(x) //x undefined

lusty dew
quartz kindle
#

basically your problem is that try creates a scope, meaning variables created inside it will only work inside it. you can either remove the try catch block, or put everything into only one block

earnest phoenix
#

no

#

he should put a let before the block

#

then assign it the body after he makes the request

lusty dew
#

How do you know I am a he?

#

-_-

earnest phoenix
#

because its the internet

#

and ur programming

#

statistical guess

lusty dew
#

That makes no fucking sense

#

but ok

quartz kindle
#

you dont need to declare the variable outside if you put everything into the same block

earnest phoenix
#

yeah but no need to be in 1 block

lusty dew
#

Can tim just help me....

earnest phoenix
#

js try catch performance grumble grumble

lusty dew
#

he was doing well

quartz kindle
#

better to be in one block then

#

2 requests in the same try catch

lusty dew
#

Ok

earnest phoenix
#
let body = null; 
try{ 
body = await request.get(`https://store.steampowered.com/api/appdetails?appids=${id}`).then(res => res.body);
console.log(body) 
} catch(err){ 
console.log(err) 
} 
``` not sure if thats correct for your request library
#

but worth a shot

#

nd the proper way

#

on mobile so the indentation might be scuffed sry

lusty dew
#

Well either way

#

body has already been defined

earnest phoenix
#

body is already defined because ur doing 2 requests and calling the response the same thing

#

just give it a diff name :p

lusty dew
#

Ok

#

well

#

That didn't work either

#

:/

quartz kindle
#

it looks nicer like this, but thats just mejs try{ var { body } = await request.get(`https://store.steampowered.com/api/storesearch?cc=us&l=en&term=${game}`); var id = body.items[0].id; { body } = await request.get(`https://store.steampowered.com/api/appdetails?appids=${id}`); console.log(body); } catch(err){ console.log(err) }

lusty dew
#

Ok

#

Yours worked Tim

#

Ok

#

next thing to do is

#

ummm

#

fuck

quartz kindle
#

find the information you need from the new body

lusty dew
#

Ah yes

#

Yea

quartz kindle
#

the same way you found it in the first body

lusty dew
#

Hmmmm

#

Yea

#

so

quartz kindle
#

read the object in your logs, and see how its structured

lusty dew
#

body.data[0].something

#

lol

#

I don't know what to put after that

#

let me look

quartz kindle
#

data is not an array

#

so no [0]

lusty dew
#

Oh ye

#

so just

#

body.data.pc_requirements?

#

would be one of them right?

#

and I can do that like

#

in the embed correct?

#

likew

quartz kindle
#

yes

#

check if data is indeed the first property

lusty dew
#

Ah ok

#

Oh

#

Data is the first property right?

#

by the looks of it, data is the first

quartz kindle
#

according to the url, it isnt

#

post your log

lusty dew
quartz kindle
lusty dew
#

Oh

#

the ID is

quartz kindle
#

first property is the id

lusty dew
#

Yea

#

then it is

#

Data

quartz kindle
#

yes

lusty dew
#

Ok

quartz kindle
#

so how would you get it?

lusty dew
#

I would do ermmm

#

Wait

#

let me think

#

while I have someoen spaming my DMs

#

Ok

#

back

#

so you would get it by

#

doing

#

Um

#

wait

#

why am I having trouble with this ugh

quartz kindle
#

because its a dynamic key

#

there is a specific way to access properties with dynamic keys

#

which coincidentally, its the same way you would access items in an array

lusty dew
#

oh

#

body isn't in an array is it?

quartz kindle
#

nope

lusty dew
#

Ok

earnest phoenix
#

its for like keys with spaces

#

stuff that cant be used as just .proeprty

lusty dew
#

proepty?

quartz kindle
#

property lol

lusty dew
#

Oh

#

lmfao

quartz kindle
#

like

#

you have object.key

#

right?

#

but if the key has spaces for example

#

object.key with spaces

#

doesnt work

#

the correct way is

#

object["key with spaces"]

lusty dew
#

Oh

#

so wait

#

Hmm

#

trying to understand that

#

I understand that

#

object.key with spaces is not correct

quartz kindle
#
object.key //works
object["key"] //works
object.key with spaces //doesnt work
object["key with spaces"] //works
object.variable //doesnt work
object[variable] //works```
lusty dew
#

Oh

#

so what you saying is

#

Oh nvm

#

what I was going to say was stupid

quartz kindle
#

basically the final answer is in the above block

lusty dew
#

ok

#

so

#

it would

#

be

#

body.object["key"].data?

#

or something

#

idk

quartz kindle
#

body is the object

lusty dew
#

OH

#

i am dumb

quartz kindle
#

keep trying, almost there

lusty dew
#

body.[0].data

#

wait

#

body[0].data?

quartz kindle
#

close, but no

lusty dew
#

Oh oof

quartz kindle
#

body doesnt have a property 0

lusty dew
#

Oh

quartz kindle
#

it has a property 252490

#

which is the game id

lusty dew
#

Yea

quartz kindle
#

which is stored in a variable

lusty dew
#

yea

#

so wait

#

was only the 0 wrong?

#

or was

#

body[0] just wrong in general

quartz kindle
#

only the 0 was wrong

lusty dew
#

Oh so

#

Ah i think i see

#

So would it be 1 instead

#

since the first property or whatever is the game ID

quartz kindle
#

no

lusty dew
#

sorry my mind not thinking straight

quartz kindle
#

objects dont have a concept of "first" or "second"

#

they are not ordered

#

object are indexed by keys

lusty dew
#

Oh

quartz kindle
#

you need to know the key, to access the content

#

the key is 252490

lusty dew
#

oh

quartz kindle
#

i need to go sleep, hurry up

lusty dew
#

Sorry

#

I don't know

#

I am rushing to do things

#

and multi-tasking

#

my mind isn't directly focused on just this

quartz kindle
#

then try again when you have more time

lusty dew
#

Hm

#

so the key is

#

the game ID

quartz kindle
#

yes

lusty dew
#

so data would be

#

wait

#

if there is a key

#

nvm

#

I will just

#

try again later

#

I was going to ask if ther are key's and value's

quartz kindle
#

the answer is here

#
object.key //works
object["key"] //works
object.key with spaces //doesnt work
object["key with spaces"] //works
object.variable //doesnt work
object[variable] //works```
lusty dew
#

ah

#

body["key"]

#

or

#

body["key with spaces"]

#

Or wait

#

it wouldn't be variable would it?

quartz kindle
#

you have game id stored in a variable

lusty dew
#

Ima say it is

#

body["key"]

quartz kindle
#

that is correct, but there is no key named "key" in the object

lusty dew
#

Oh

#

wait

quartz kindle
#

the key is named "252490"

lusty dew
#

body["data"]?

quartz kindle
#

nope

#

data comes after the key

lusty dew
#

Oh well

#

then idk

#

:/

#

I will just figure it out later

#

when my mind is more focused

quartz kindle
#

alright good luck

lusty dew
#

Thank you

quartz kindle
#

im tempted to just give it to you, but eh

lusty dew
#

oof

quartz kindle
#

you wont learn that way

#

or will you?

lusty dew
#

Well

#

if you explain

#

how you got that

#

I could possibly learn

quartz kindle
#

ok

#

so i'll give you 2 examples, both work, but only one is correct

lusty dew
#

Ok

quartz kindle
#

body["252490"].data
body[id].data

#

which one is correct?

lusty dew
#

body[id].data

quartz kindle
#

correct

#

why?

lusty dew
#

Cause

earnest phoenix
#

I need a bot idea.

🤔

lusty dew
#

then it would only be getting the data for that game

#

plus

#

we have ID defined

#

so the id will be taken

#

from whatever game the user searches

quartz kindle
#

very good

lusty dew
#

@earnest phoenix A bot about games

#

lol

quartz kindle
#

alright, so i hope you learned something

#

im off to sleep

lusty dew
#

K

earnest phoenix
#

@lusty dew wut games

lusty dew
#

goodnigght

sick cloud
#

@quartz kindle gn mmLol

quartz kindle
#

@_@

earnest phoenix
#

@quartz kindle gn 👌

lusty dew
#

Thank you Tim (Hopefully you will see this xD)

wintry quest
#

Am I able to DM someone about an issue I'm having? :D

idle mountain
#

Why not just post about it here? bingT

#

but you can DM me if you need to

wintry quest
#

blah I'll keep it here idk why I said that 😂

#

I'm having a "blonde" moment. It's whacking up that ${message.author} isn't defined, either it's {message} isn't defined, if I add message where it has exports.exec = function (msg, log) { then it yells and says author isn't defined.

#

I'm being real dumb atm

#

I swear

idle mountain
#

isn't is msg.author not message.author?

wintry quest
#

YES HAHAH

idle mountain
#

lol

wintry quest
#

I jsut did that

#

I did msg.id first

#

then realised

#

lmao

idle mountain
#

it happens to the best of us topKEK

wild tide
#

um

#

no

#

msg has been deprecated. Usually when you use msg it will pump out a warning into console that msg has been deprecated, and to use message instead.

knotty steeple
#

what

#

thats stupid

wild tide
#

So, message.author was correct. There was some error elsewhere when your author was undefined. It could be cause that author was defined incorrectly, or that author isn't a global variable, which would be why that line could not access the definition

knotty steeple
#

he defined msg not message

#

thats why it didnt work

wild tide
#

welp

#

that would also be why lmao

#

found some decent evidence of the deprecation

knotty steeple
#

wat

earnest phoenix
#

welp ? what mean this in english

knotty steeple
#

because they use message doesnt mean msg is depreciated GWfroggerSpongeWait

#

you can define it to what you want

earnest phoenix
#

cuz im learn english 😊

wild tide
#

I prefer message over msg anyway, it just looks tidier

plain condor
#

How can I make it so my JavaScript bot sends a message if it doesn't have the right permission?

steel drum
#

well

#

do something along the lines of

#

if (!message.guild.member(Bot.user).hasPermission("PERMISSION")) return message.channel.send("cant do that");

#

something along the lines of that

#

all the diff permissions are in the documentation

knotty steeple
#

you can just use msg.guild.me.hasPermission()

steel drum
#

or that

#

i didnt know

#

that existsed

plain condor
#

ty

lusty dew
#

would this be considered NSFW?

steel drum
#

Doubt it but still not smth I'd add

#

To my bot

lusty dew
#

Lol

#

It was just a funny thing

#

It is a Fun/Informative bot

ruby dust
#

"informative"

quartz kindle
#

Lol

rustic axle
#

Not as much nsfw but more shitpost bloblul

#

But yeah thanks for that idea

#

Oh yeah and how to make discord javascript library that looks like discord.js but has totally nothing to do with it

upper nymph
bright spear
#

@upper nymph post your server count to the api

#

what language are you using?

steel swallow
#

I have that too

#

I'm using discord.js

bright spear
upper nymph
#

jda

bright spear
steel swallow
#

Ty.

bright spear
#

yw

upper nymph
#

tq

rustic axle
#

But I am not using an api and it comes up as undefined

#

Hmmm

wide ruin
#
const Discord = require("discord.js");
module.exports.run = async (bot, config, message, args1) => {
    
    let reportschannel = bot.channels.get(486167748205084694)
  if(message.guild.name != "Discord Bot List") {
   reportschannel.send(" ") 
  }
  let user = message.author.id
  let requestEmbed = new Discord.RichEmbed()
  .setTitle("Request")
  .setColor(0x00ff00)
  .addField("Someone requested", args1, true);
  reportschannel.send(requestEmbed);
  
  
  
  let submit = new Discord.RichEmbed()
  .setTitle("Successful")
  .setColor(0x00ff00)
  .addField(`You requested`, args1, true);
  message.channel.send(submit);
  
}
    
module.exports.help = {
    name: "submit"
}```
#

the bot doesnt send anything

#

at Client.client.on (/app/server.js:153:31)

at emitOne (events.js:116:13)

at Client.emit (events.js:211:7)

at MessageCreateHandler.handle (/rbd/pnpm-volume/e833a0de-7dc5-4e4f-82a8-7de26ebb0fdd/node_modules/.registry.npmjs.org/discord.js/11.4.2/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)

at WebSocketPacketManager.handle (/rbd/pnpm-volume/e833a0de-7dc5-4e4f-82a8-7de26ebb0fdd/node_modules/.registry.npmjs.org/discord.js/11.4.2/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:103:65)

at WebSocketConnection.onPacket (/rbd/pnpm-volume/e833a0de-7dc5-4e4f-82a8-7de26ebb0fdd/node_modules/.registry.npmjs.org/discord.js/11.4.2/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:333:35)

at WebSocketConnection.onMessage (/rbd/pnpm-volume/e833a0de-7dc5-4e4f-82a8-7de26ebb0fdd/node_modules/.registry.npmjs.org/discord.js/11.4.2/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:296:17)

at WebSocket.onMessage (/rbd/pnpm-volume/e833a0de-7dc5-4e4f-82a8-7de26ebb0fdd/node_modules/.registry.npmjs.org/ws/4.1.0/node_modules/ws/lib/event-target.js:120:16)

at emitOne (events.js:116:13)

(node:10189) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)

(node:10189) [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.

steel drum
#

Try making the reports channel parameter a string

smoky spire
#

IDs are always strings in d.js

#

It’s also probably erroring on the sending of an empty message

topaz fjord
#

IDs have to be a string

#

Honestly man you should really learn the language

steel drum
#

it could be

#

an honest mistake

topaz fjord
#

I dont believe that

#

if you look at the past questions u will understand

earnest phoenix
#

HELLO

#
    if (message.content.match(/([A-Z0-9]|-|_){24}\.([A-Z0-9]|-|_){6}\.([A-Z0-9]|-|_){27}|mfa\.([A-Z0-9]|-|_){84}/gi)) {
        if(!message.guild.members.get(client.user.id).hasPermission('MANAGE_MESSAGES')) return message.channel.send('**I need Permission \`MANAGE_MESSAGE\`To delete Tokens**')
        message.delete();
        message.reply(`you sent your token! Do not worry you've deleted it`);
        return;
    }
                              if(message.channel.type === "dm"){
    if (message.content.match(/([A-Z0-9]|-|_){24}\.([A-Z0-9]|-|_){6}\.([A-Z0-9]|-|_){27}|mfa\.([A-Z0-9]|-|_){84}/gi)) {
        message.delete();
        message.reply(`you sent your token! Do not worry you've deleted it`);
        return;
    }
}
});
#

this code allowed ?

#

or my bot will be delete

#

-_-

#

this code if one sand token account or token bot masseg will be delete

hushed berry
#

@earnest phoenix you could improve that code a lot

earnest phoenix
#

improve like what ?

#

@hushed berry

#

i can make [ on and off ]

by reaction

wide ruin
#

does client.channels.size count voice channels in .js?

earnest phoenix
#

yas

wide ruin
#

thanks

#

how can i make the member count not count this server?

#

@earnest phoenix

earnest phoenix
#

hmm

#

wit im tar to arabic

wide ruin
#

?

earnest phoenix
#

im speak arabic

wide ruin
#

oh

spring ember
#

I know a bit of Arabic

wide ruin
#

can i still have help please

earnest phoenix
#

realy

wide ruin
#

yes

spring ember
#

yes

#

@wide ruin whatcha nees

#

need

earnest phoenix
#

@spring ember like what

spring ember
#

?

wide ruin
#

i want the member count not count this one

spring ember
#

That is a bit problematic

wide ruin
#

why?

earnest phoenix
#

I know a bit of english

spring ember
#

The solution is to iterate over all the servers except this one and add all of the users to a set

earnest phoenix
#

wit

spring ember
#

sadly it is not scalable

earnest phoenix
#

he wont blockd one form server ?

spring ember
#

What

earnest phoenix
#

im vary bad in english

wide ruin
#

i just mean like client.users.size - client.guild.size(264445053596991498)

spring ember
#

@wide ruin what about you

#

You are in both servers

wide ruin
#

ik

spring ember
#

Like in this server and in another

wide ruin
#

but it just subtracts this servers count

spring ember
#

yes

wide ruin
#

how do i do that

spring ember
#

that is the problem

#

I gave you the only solution

earnest phoenix
spring ember
#

That is really nice

earnest phoenix
#

this my idea

#

😊

wide ruin
#

how do i get the member count of 264445053596991498

spring ember
#

I have this for music queue

earnest phoenix
#

yah

#

w

spring ember
#

@wide ruin client.guilds.get(id).size

earnest phoenix
wide ruin
#

thanks

earnest phoenix
#

if you need code call me 😊

#

amm

#

@spring ember

#

im forget ask you

#
    if (message.content.match(/([A-Z0-9]|-|_){24}\.([A-Z0-9]|-|_){6}\.([A-Z0-9]|-|_){27}|mfa\.([A-Z0-9]|-|_){84}/gi)) {
        if(!message.guild.members.get(client.user.id).hasPermission('MANAGE_MESSAGES')) return message.channel.send('**I need Permission \`MANAGE_MESSAGE\`To delete Tokens**')
        message.delete();
        message.reply(`you sent your token! Do not worry you've deleted it`);
        return;
    }
                              if(message.channel.type === "dm"){
    if (message.content.match(/([A-Z0-9]|-|_){24}\.([A-Z0-9]|-|_){6}\.([A-Z0-9]|-|_){27}|mfa\.([A-Z0-9]|-|_){84}/gi)) {
        message.delete();
        message.reply(`you sent your token! Do not worry you've deleted it`);
        return;
    }
}
});
#

allowed ?

deep tusk
#
@client.command(pass_context=True)
async def pest(ctx):
    server = ctx.message.server
    await client.create_channel(server, 'cool-channel', type=discord.ChannelType.text)
    await client.send_message(message.channel, "test")
#

Doesnt work, no errors.

#

yes

lofty abyss
#

hey how do i put a space in my description like this

Commands
!help >> Receive this help message!
!suggest >> Create a suggestion!
!invite >> Receive the invite links!
!reportbug >> Report a bug to the developers!
!approve >> Approve a suggestion!
!reject >> Reject a suggestion!
!setchannel >> Set the suggestion channel!
!setsubmitchannel >> Set the submit channel!
!setprefix >> Set the prefix!

loud salmon
#

if you are using markdown, then you need to put 2 enter spaces in between lines in the editor

lofty abyss
#

kk

#

but then it has that weird space

#

oofs

ruby dust
#

why does it have to yell each command's description?

barren brook
#

How do I do a invite command

#

Invite to a server

wide ruin
#

What's the .js code for if message is a DM?

barren brook
#

Idk

wide ruin
#

The point is that you help others

barren brook
#

Oh

wide ruin
#

But you didn't say your language

barren brook
#

Oh

knotty steeple
#

what

earnest phoenix
#

wut

knotty steeple
#

What's the .js code for if message is a DM?

#

wat

barren brook
#

How do I do a invite command in JS

wide ruin
#

I said .js in the message

knotty steeple
earnest phoenix
#

still

#

wat

topaz fjord
#

@wide ruin did you check the d.js docs first?

knotty steeple
#

probably not

smoky spire
#

@wide ruin check if message.channel.type is dm or if message.guild is null

wide ruin
#

How?

knotty steeple
#

he literally just said how

wide ruin
#

if(message.channel.type = dm) {

#

}

#

Does that work?

knotty steeple
#

no it doesnt

wide ruin
#

How will it?

knotty steeple
#

you are trying to declare something not check if something is equal to another thing

wide ruin
#

Ok

#

I'll check docs

knotty steeple
#

js docs*

tulip snow
#
Uncaught Exception:  TypeError: Cannot read property 'send' of null```
#
// This event executes when a new member joins a server. Let's welcome them!

const Discord = require('discord.js');

module.exports = (client, member) => {
    // Load the guild's settings
    if (member.user.id === client.user.id) return;
    const guildSettings = client.settings.get(member.guild.id);

    const welcomeMessage = guildSettings.welcomeMessage.replace('{{user}}', member.user.tag);

    // Send the welcome message to the default server channel. Not ideal,
    // there's a place for more configs here.
    if (guildSettings.welcomeEnabled === 'true') {
        if (member.guild.channels.find('name', guildSettings.welcomeChannel)) {
            member.guild.channels.find('name', guildSettings.welcomeChannel).send(welcomeMessage).catch((e) => client.log('log', `Unable to send message to welcomeChannel (${guildSettings.welcomeChannel}) on ${member.guild.name} (${member.guild.id}): \n ${e}`, 'Error'));
        }
        //return console.log(`Unable to send welcome message to guild: '${member.guild}' (${member.guild.id}) as the channel '${guildSettings.welcomeChannel}' does not exist`);
    }


    const logWelcome = new Discord.RichEmbed()
        .setColor('GREEN')
        .setTitle('New Member')
        .addField('User tag', member.user.tag)
        .addField('User ID', member.user.id);

    if (guildSettings.logNewMember === 'true') {
        member.guild.channels.find('name', guildSettings.modLogChannel).send({ embed: logWelcome }).catch((e) => client.log('log', `Unable to send message to modLogChannel (${guildSettings.modLogChannel}) on ${member.guild.name} (${member.guild.id}): \n ${e}`, 'Error'));
    }
};
#

Its at this line

#
        member.guild.channels.find('name', guildSettings.modLogChannel).send({ embed: logWelcome }).catch((e) => client.log('log', `Unable to send message to modLogChannel (${guildSettings.modLogChannel}) on ${member.guild.name} (${member.guild.id}): \n ${e}`, 'Error'));
smoky spire
#

It can’t find the channel

rustic axle
#

it is either declared in a section where message, guild or channels is not defined in any case, it is declared in an external function, or it needs to be fed one of those 3 things mentioned above

brave pewter
#

Any one know a great place to start learning to make discord bots

knotty steeple
#

depends on what language

#

certain languages have libraries that maybe have guides

brave pewter
#

What is the easiest

knotty steeple
#

so you just want to make a discord bot

#

and you dont even know a language

slim heart
#

How would i add a reaction to the latest message in a channel, so like im trying to make it so in my ticket channel if i just say no, itll add a reaction to the ticket message in that channel

tulip snow
#
TypeError: Cannot read property 'run' of undefined
slim heart
#

First of all nice selfbot, second, i mean the part of getting the message that was sent in the first place

tulip snow
#

Wdym selfbot?

slim heart
tulip snow
#

Thats a message lol

slim heart
#

whatever

#

anyways

west raptor
#

That's not Selfbot

slim heart
#

Im just trying to figure out how i would do it to the latest message because you're just using message as the object

#

how would i get the latest message

west raptor
#

also

#

what lib?

slim heart
#

ik but it looks like an eval response

#

js

west raptor
#

lib

slim heart
#

discord.js

#

soz

west raptor
#

its ok

#

well

#

to get another user's besides the author's last message it would be js let user = (this.)client.users.get('id') // you can also get it by .find // then user.lastMessage for the author it would be js (message).author.lastMessage i havent done lastMessage much but it works i think

#

if thats what you are asking

slim heart
#

not the users last message but the channels last message

west raptor
#

ohh

slim heart
#

okay so basiclly ill try and explain what im trying to do

#

So i have a censor bot and i have a ticket command where people can report words etc. So one that I do to keep track of whats happened is to add reactions to the messages with yes no or and o for something else, dont worry. so in order to make it easier im trying to make it so i can send "no" in the channel and itll add the reactions on its own

tulip snow
#

Do u mean like

let m = message.channel.send("Whatever")
m.react(':ok_hand:')
``` or whatever the thingy is
slim heart
#

no

#

Its already a sent message

west raptor
#

you'd need to await that message @tulip snow

#

also

#

one sec

tulip snow
#

Its just a example lmao

west raptor
#

still

slim heart
#

aSyNc

#

Cuz one thing ik that a property of a channel is lastMessage but the thing is that when i send "no" thatll be the latest message and im not trying to add the reaction to that im trying to add it to the message before it

smoky spire
#

Is the message before yours a command that you want to react to?

slim heart
#

yea

smoky spire
#

In that case, message.react() would react to the command message

#

Because the message object would be the command message

slim heart
#

I want it to do the message before the command message

smoky spire
#

Then why’d you say yes to it being the command message

slim heart
#

I thought u said the message before the command emssage

eager wasp
#

All folder of my bot is on "Read only" pls help me !
(I'm using debian)

#

(Send me a private message)

severe socket
#

sudo chmod -R 755 folder
assuming your are using the account that is the owner of the folder

lusty dew
#

How do you install canvas

#

cause

#

what the NPM thing is telling me

#

is not working

west raptor
#

any error?

#

when

#

installing

lusty dew
#

Yes

#

Ofc

#

I dont have it now

#

Plus

#

Computer made a bunch of beeping sounds

#

when trying to install it

wide flicker
#

I'm in the process of learning python.. could someone help me with a project I'm practicing with?

west raptor
#

whats the issue?

wide flicker
#

is_hungry = input("Are you hungry?: ")
is_happy = input("Are you happy?: ")
if is_hungry and not(is_happy):
print("You are hangry")
elif is_hungry and is_happy:
print("You must not be waiting on food like me.")
elif not(is_hungry) and not(is_happy):
print("If you ate you would probably be happy")

lusty dew
#

.

#

Ok

#

What da problem

#

lol

west raptor
#

code block plz

wide flicker
#

It's not changing even if the input changes from true to false

lusty dew
#
is_hungry = input("Are you hungry?: ")
is_happy = input("Are you happy?: ")
if is_hungry and not(is_happy):
    print("You are hangry")
elif is_hungry and is_happy:
    print("You must not be waiting on food like me.")
elif not(is_hungry) and not(is_happy):
    print("If you ate you would probably be happy")
#

There

west raptor
#
```py
code```
lusty dew
#

lol

#

Ye

wide flicker
#

Idk how to do that yet..

west raptor
#

re

lusty dew
#

Um

#

He/she

#

just showed you how

#

XD

west raptor
#

he

lusty dew
#

He

#

That is why I said

#

He/she

#

-_-

west raptor
#

ik

#

lol

lusty dew
#

Foite me

#

xd

west raptor
#

nou

lusty dew
#

Omg

#

No

#

That

#

MeME

#

needs

#

to DIE

#

Anyway

#

What is your problem @wide flicker

#

I know a tad bit of Py

#

it is

#

`

#

//py code //

#

oof

bright spear
#

```py
code```

wide flicker
#

It didnt work... but if I put true or false the answer never changes.

lusty dew
#

YE

knotty steeple
#

```py

code

```

lusty dew
#

Ok

#

Yes

#

They are smarter then me

#

xD

wide flicker
#

Only if I change it to is_hungry= True.. can I not have the input change it?

knotty steeple
#

im pretty sure not isnt a function

wide flicker
#

Sorry my pc died

#

But it works if I do is_hungry = True instead of asking for the input by doing is_hungry = input("Are you hungry?: ")

#

Not is a function I beleive. It works if I dont use input at least

knotty steeple
#

not isnt a function

wide flicker
#

I'm not sure but it works with if statements at least without wanting to use user input

#

My main question is, if the user inputs true or false as their answer will it not change is_hungry to it. Ex. They put true for they are hungry.. will that not make is_hungry = True?

west raptor
#

How would I grab a token from a json file in py?
im new to py development even though i started on a bot in py a long time ago but forgot how to get a token from a json file

knotty steeple
#

first you import json

#

then you load a json file

#

with

#

json.load()

#

but use the open function for the file

#

so

#

json.load(open("./file.json"))

west raptor
#

then what?

knotty steeple
#

you can define this as whatever you want

#

so if you defined it as jsonthing

#

to get something do jsonthing["athing"]

#

you get it?

west raptor
#

yea

#

thanks

knotty steeple
#

btw

#

you dont need to pip install it

west raptor
#

i know

wide flicker
#

So for my question... will the user input not change the True or False value of is_hungry?

quartz kindle
#

i dont know python, but its possible that the value returned by "input" is not a boolean

lusty dew
#

Ayyyy Tim wassup my buddy, thank you for your help last night ❤

quartz kindle
#

meaning, if you type true, python will interpret it as "true" (text/string) not true (true/false boolean)

#

i could be wrong tho, idk how python is typed

wide flicker
#

Ahhh I see

wanton zenith
#

I'm having trouble with trying to add bold and underlines to my bot description. Is __**something**__ not correct?

knotty steeple
#

it is Thonk

quartz kindle
#

something

#

should be correct

wanton zenith
#

It's not showing up 😦

west raptor
#

it doesnt show in my bot description as well

quartz kindle
#

in the website?

wanton zenith
#

Yeah

knotty steeple
#

btw its True @quartz kindle mmLol

quartz kindle
#

py booleans require capitals?

#

good to know xd

#

not that i'll ever use python

wide flicker
#

Ok so is there a function to change true/false boolean?

knotty steeple
#

yea they do for whatever reason tim

quartz kindle
#

change true to false, and vice versa?

#

or change something into a boolean?

wide flicker
#

Yea but by what a user inputs so the answer can be changed accordingly

quartz kindle
#

i think you have to directly compare the input to a predefined value

#

if input == "true" return True

#

or something like that

wide flicker
#

Ok awesome I didnt even think of that type of solution

lusty dew
#

ever since I installed canvas my bot hasn't been starting up properly

wide flicker
#

I think that should work

quartz kindle
#

whats the error?

lusty dew
#

Tim wassup

#

It no error

#

it is just not loading up

#

it is stuck on the command file that requires canvas

#

it won't load that one

quartz kindle
#

did it install properly?

lusty dew
#

ye

quartz kindle
#

because canvas requires some libs to be installed on the machine

lusty dew
#

Yea

#

I did

#

I downloaded

#

this thing called

#

GTK

#

and then some other thing it required

earnest phoenix
#

How can I throw an error on a variable statement in nodejs?

quartz kindle
#

it mainly requires cairo

#

throw "error text" i believe

lusty dew
#

cario

#

Anyway

#

It loaded now

#

but

#
{ run: [AsyncFunction], help: { names: [ 'glitch', 'gl' ] } }
TypeError: loadImage is not a function
    at Object.module.exports.run (C:\Users\User\Desktop\LoverBot v3\commands\gli
tch.js:14:19)
    at process._tickCallback (internal/process/next_tick.js:68:7)
#

I don't understand this

#

I read the docs

#

the way I used

#

loadImage

#

is correct

#

At least from my understanding of the docs it is

quartz kindle
#

show the file glitch.js

knotty steeple
#

its uh

#

throw Error("thing")

#

iirc

#

that should work

lusty dew
knotty steeple
#

wait ur thing works too xd

quartz kindle
#
throw 'Error2'; // generates an exception with a string value
throw 42;       // generates an exception with the value 42
throw true;     // generates an exception with the value true
throw new Error('Required');  // generates an error object with the message of Required```
lusty dew
#

Oh and Tim

#

The Steam command works

#

I had to mess around with it for a few

#

but I finally got it to work :3

quartz kindle
#

nice

#

which version of canvas are you using? 1.6 or 2?

lusty dew
#

How do I check

quartz kindle
#

it should say in your package.json file

lusty dew
#

version
1.6.11

#

Ah yea

#

Sorry

#

xD I forgot package.json has all that

quartz kindle
#

you're using the docs for version 2

lusty dew
#

OH

#

Damn

quartz kindle
#

version 1.6 doesnt have loadImage

lusty dew
#

Welp

#

That explains it

quartz kindle
#

for 1.6 use these examples

lusty dew
#

Yea

#
const canvas = createCanvas(data.width, data.height);
#

so wait

#

this won't work?

#

Ah nvm