#development

1 messages Β· Page 371 of 1

austere meadow
#

oh so you want to check the value of activeWin()?

neat falcon
#

the function returns this

Promise {
{ title: 'Node.js command prompt - node chrome.js',
id: 3483840,
owner:
{ name: 'cmd.exe',
processId: 13644,
path: 'C:\Windows\System32\cmd.exe' } } }

#

and it is title am looking to check

austere meadow
#

let test = activeWin()
test.title.includes("chrome") ?

neat falcon
#

thanks, will test

austere meadow
#

alright

neat falcon
#

what do i do with test.title.includes?

austere meadow
#

you can put that in an if statement

#

so if (test.title.includes(..)) doSomething()

austere meadow
#

so test is activeWin() right
and that returns a promise

neat falcon
#

yes

austere meadow
#

are you doing await activeWin()

neat falcon
#

no

austere meadow
#

do you need to await it or does it return the results anyways

neat falcon
#

it just returns the results

austere meadow
#

alright

#

can you try awaiting it?

neat falcon
#

lol, i've not really used async and await

austere meadow
#

okay thats fine

#

im gonna spoonfeed you a bit since its 3am and im a bit tired so pls no angery but heres the basic idea of what i mean

async function testForChrome() {
    let test = await activeWin()
    //from this point, assuming that test is an object that includes "title", we can access "title" which should be a string
    return test.title.includes("chrome"); //if it includes "chrome", return true, else return false
}
#

the reason your code wasn't working was because you need an async function to use await

neat falcon
#

okay

#

mm ok it seems to be working, but i can't get it to log anything to console by using js if (test.title.includes("Node")) { console.log(title); }

austere meadow
#

if thats the case then the if statement isnt getting triggered meaning that the title doesn't include "Node"

#

or something else is bad

neat falcon
#

hmm

austere meadow
#

well

#

title is undefined unless you've defined that elsewhere

#

needs to be test.title

#

and you should try console.logging that outside of the if statement

neat falcon
#

still returns nothing

austere meadow
#

can you give me your code?

neat falcon
#

sure

austere meadow
#

sorry if this is taking a while im just having a bit of trouble understanding what test is returning

neat falcon
#
const DiscordRPC = require("discord-rpc");
//DiscordRPC.register("412270730168762369");
//const rpc = new DiscordRPC.Client({ transport: "ipc" });

const activeWin = require('active-win');


function setActivity() {
    rpc.setActivity({
        details: "",
        state: "Google Chrome",
        largeImageKey: "chrome",
        largeImageText: "Chrome",
        instance: false
    });
}

//rpc.on("ready", () => {
    //console.log("RPC is ready!")
    //setActivity();
//});

//rpc.login("412270730168762369");

async function testForChrome() {
    let test = await activeWin()
    //from this point, assuming that test is an object that includes "title", we can access "title" which should be a string
    return test.title.includes("Node"); //if it includes "chrome", return true, else return false
    console.log(test.title);

}

testForChrome()

``` pls ignore messy code
austere meadow
#

okay

#

first of all

#

that console.log will never get triggered

#

since you are returning before it

drowsy falcon
#

kal

austere meadow
#

you should move it above the return

#

@neat falcon how'd you go?

neat falcon
#

it logs but it doesn't check if it is the right window

austere meadow
#

ok

#

can you console.log(testForChrome())?

#

it should return a boolean

grave mirage
#

how do i fix this?

#

events.js:188
throw err;
^

Error: Unhandled "error" event. ([object Object])

austere meadow
#

do you handle the error event in your bot.js file

inner jewel
#

x.on("error", console.log)

austere meadow
#

^

inner jewel
grave mirage
#

no

drowsy falcon
#

how can i get my bot uptime?

#

d.js

austere meadow
#

client.uptime

#

its in milliseconds

drowsy falcon
#

but like hours,minutes etc

#

some bots have it

languid dragon
#

google

#

node modules

uncut slate
#

preferrably not

inner jewel
#

you don't even need a module for that

#

it's basic math

drowsy falcon
#

i dunno how to use google

austere meadow
#

true

drowsy falcon
#

lmao

inner jewel
#

converting to JS should be easy

uncut slate
#

ewwwwwwwwwwww

earnest phoenix
#

WHY DO i smell java zoomeyes

drowsy falcon
#
  if (message.content === '-purge') {
message.channel.bulkDelete(100).then(() => {
  message.channel.send("Deleted 100 messages.").then(msg => msg.delete(3000));
}
});```
#

what is wrong OwO

inner jewel
#

@earnest phoenix idk i don't smell anything

neat falcon
#

@austere meadow i don't use discord rpc for it atm it just logs

earnest phoenix
#

.

drowsy falcon
#

how can i make vote command?

#

xd

drowsy falcon
#

?

rough pelican
#

but i could help

drowsy falcon
#

?

rough pelican
#

ehm

#

i could help with ur vote cmd if u need help

#

but i wont spoonfeed

drowsy falcon
#

ok

cerulean zinc
pale light
#

hm

elder rapids
#

US-Central

wicked tartan
#

is it possible to get a users roles by name and not id number in eris?

heady zinc
#

you need to have access to the guild roles

#

then just map the user roles with the data from the guild roles

wicked tartan
#

as in I'd need manage roles perms?

inner jewel
#

no

#

you can always see all of a guild's roles, channels, members, categories

#

regardless of permissions

trim plinth
#

How to post server count onto DBL? I tried looking in #312614469819826177 for a javascript one but for the discord.js one you need an API key and it doesn't list where to get the key

#

so it's kinda a dead end and I'm looking for alternatives

#

Β―_(ツ)_/Β―

inner jewel
#

go to your bot's page

#

click on edit

#

and scroll down

trim plinth
#

mk

fleet mason
#

how do i fix this

#

TypeError: Cannot read property 'has' of undefined
at Object.exports.run (C:\Users\sande\Desktop\mybot\commands\member.js:5:25)
at Client.client.on.message (C:\Users\sande\Desktop\mybot\mybot.js:28:17)
at emitOne (events.js:116:13)
at Client.emit (events.js:211:7)
at MessageCreateHandler.handle (C:\Users\sande\Desktop\mybot\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
at WebSocketPacketManager.handle (C:\Users\sande\Desktop\mybot\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:103:65)
at WebSocketConnection.onPacket (C:\Users\sande\Desktop\mybot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:330:35)
at WebSocketConnection.onMessage (C:\Users\sande\Desktop\mybot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:293:17)
at WebSocket.onMessage (C:\Users\sande\Desktop\mybot\node_modules\ws\lib\event-target.js:120:16)
at emitOne (events.js:116:13)

#
let guild = message.member.guild;
let Role = guild.roles.find('name', 'MEMBER');

if (message.member.role.has(Role.id)) {
    message.channel.send('You already have this role!');
    console.log('${message.author.username} already has a role')

}
  else{
    message.member.addRole(Role);
    message.channel.send('WooWho, You got a role!')
    console.log('${message.author.username} got a role')
  }
}
trim plinth
#

hmm

#

you never defined the role id

fleet mason
#

if i chage role.id to the MEMBER role id. would that work?

trim plinth
#

I don't think so

fleet mason
#

how do i define it?

#

would that work?

#

the number is the id of the role

quasi marsh
#

Does anybody have any experience with jQuery.post

#

I'm trying to post to my web server, but It doesn't get the data

#

I can CURL just fine

glass inlet
#

show code

fleet mason
#
let guild = message.member.guild;
let Role = guild.roles.find('name', 'Member');

if (message.member.Roleid === 36044994179078553) {
    message.channel.send('You already have this role!');
    console.log('${message.author.username} already has a role');

}
  else{
    message.member.addRole(Role);
    message.channel.send('WooWho, You got a role!');
    console.log('${message.author.username} got a role');
  }
}
quasi marsh
#
$.post(url, "{"user_id" : user_id, "server_id": server_id, "captcha": captcha}")
fleet mason
#

now it gives the role but just skips the first if and goes to else and always puts out Woohoo...

quasi marsh
#

var's have been defined above

#

@glass inlet

#

I think the issue is is that it's not sending valid JSON

glass inlet
#

uh

#

shouldn't there be + for string concat

quasi marsh
#

It's not about string concat

glass inlet
#

any errors in console?

#

define your data with a var and log it

drifting shell
#

Holy moly

#

New java lib

#

the day after I spent like 2 hours figuring out why my statistics submitting wans't working....

#

im sad but happy at the same time...lmfao

earnest phoenix
#

I have a question about this:

dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);

Do you have to add the 2nd and 3rd parameters or are they optional?

#

What lib?

#

JS

#

Yeah they're optional

#

thanks

floral stone
#

Could the js doc can be used onl the client side

#

I assume not

quasi marsh
#

@glass inlet Found the issue, it seems like Firefox is blocking the POST function because it's http, not https

#

"This request has been blocked; the content must be served over HTTPS."

earnest phoenix
#

Does dbl.getVotes(true) return a promise?

glass inlet
#

@quasi marsh ah of course. glad you got it fixed..

#

should have seen that at the console from the start tho

quasi marsh
#

Yeah I should have been looking at it πŸ‘€

deep parrot
#

Does any here know how to shard?

inner jewel
#

depends on the lib

earnest phoenix
deep parrot
#

Thanks πŸ˜„

earnest phoenix
#

np, use ?sharding on Discord.JS server to get the links above @deep parrot

deep parrot
#

@earnest phoenix thanks for the info πŸ˜„

earnest phoenix
hushed oyster
#

ModuleNotFoundError: No module named 'dblpy'

#

Installing collected packages: multidict, idna, yarl, async-timeout, chardet, idna-ssl, aiohttp, dblpy

#

kill me

drowsy yarrow
#

this is awkward

earnest phoenix
#

ah well i did
pip install dblpy
and i imported it, and now it's saying that there is no module named 'dblpy'

#

help

gleaming summit
#

@drowsy yarrow

#

What did you do?

#

@drowsy yarrow

drowsy yarrow
#

npm install dplapi.js --save

#

it installed but my bot died on startup and is vomiting errors

uncut slate
#

dplapi?

drowsy yarrow
#

O wait

#

nvm

#

Need to update my node its too outdated kek

modern kelp
#

dblapi

earnest phoenix
#
dbl.getVotes(true)
```for total votes.
#

But how can you get the daily votes?

gleaming summit
#

Can't get it

earnest phoenix
#

you can't?

errant bone
#

can anyone show me how to shard with JDA

#

I'm a little confused with it

gleaming summit
#

See the docs

errant bone
#

Link?

gleaming summit
bitter sundial
#

dbl.getVotes(true, 1)

errant bone
#

No not for the api on DBL endpoint

#

Just general JDA

bitter sundial
#

sorry the days part was like last minute change and didnt get documented

gleaming summit
#

πŸ€”

earnest phoenix
#

@bitter sundial thanks πŸ˜ƒ

deep parrot
#

Im getting a bad request when i try to post my servercount and shards,

upper pumice
#

Hello guys, Im needing someone to code somethings on my bot. My bot have the function of send a message of AFK-CHECK and who is not afk will reac to the message, and I want he do somethings more, this is : Who reac to the message will be movoed from channel, to Queue to Raid, and 50% of guys reac get a pm of the bot saying Group 1 and other 50% . I group 2. I can pay to who do this to me.

gleaming summit
#

Why are u gonna pay?

errant bone
#

Sorry to repeat my message, but does anyone have a good tutorial on how to shard with JDA?

inner jewel
#

@errant bone check the ShardManager interface

#

also read the github readme

gleaming summit
#

I think just learn and code ur-self is better

errant bone
#

@inner jewel Where on the github readme does it talk about sharding?

inner jewel
upper pumice
#

I cant learn now @gleaming summit , so I am paying someone to do this

errant bone
#

Oh

#

wow i'm stupid

#

Thank for your quick response

upper pumice
#

can some1 help?

ornate elm
#

Need help with mkaing bot

errant bone
#

Can you make your request a little more clear @upper pumice

#

Like lay out some bullet points

pale light
#

@ornate elm way too unspecific

gleaming summit
#

hey guys are gonna need help with making bot. I'll give a tutorial

#

And the docs is the right way to learn.

upper pumice
#

@errant bone what?

wicked tartan
#

He wants to be able to do 1. afk check. This part is done. and 2. move those who reacted to the message half to one room and half to another

gleaming summit
upper pumice
#

@wicked tartan Yes

#

He made this to me

drowsy yarrow
#

(node:7964) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: 401 Unauthorized

#

got this when doing dbl.postStats

gleaming summit
#

Change the token

deep parrot
#
    at _response.transport.finalizeRequest.call.then (/root/Bots/SiriBot/node_modules/snekfetch/src/index.js:195:23)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:160:7)
(node:21066) 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: 4)``` updating my servercount/shards error (dblapi.js)
gleaming summit
#

Generate new token

#

And try again

#

I think the API server was down again

#
Error: 400 Bad Request
deep parrot
#

well already generate a new token

#

but we will see πŸ˜›

gleaming summit
#

πŸ˜›

deep parrot
#

Nope still the same error

gleaming summit
#

Login again

#

πŸ€”

deep parrot
#

Again?

gleaming summit
#

wait a sec

#
// Discord Bot List Patch
  const DBL = require("dblapi.js")
  const dbl = new DBL(process.env.dbl_token)
  setInterval(() => {
    dbl.postStats(client.guilds.size);
  }, 10000);
#

Can you show me the code?

deep parrot
#
const DBL = require("dblapi.js");
const dbl = new DBL('atoken');

client.on('ready', () => {
    setInterval(() => {
      dbl.postStats(client.guilds.size, client.shard.id, client.shard.total);
      console.log('DBL Stats updated!')
    }, 450000);
});
gleaming summit
#

Try without shard

bitter sundial
#

10000

#

why

#

no

#

dont

gleaming summit
#

Why

#

πŸ€”

deep parrot
#

makes the api lagg

#

:3

gleaming summit
#

:3

#

how about 10ms

bitter sundial
#

dont post every 10 seconds thats just dumb

inner jewel
#

if you have 11 shards

deep parrot
#

i have it on 7,5 minutes

inner jewel
#

that'd give a nice 1h ban

gleaming summit
#

I'll change it to 15sec

#

πŸ‘ŒπŸΌ

#

I love watching the results

deep parrot
#

btw with out shards worked

#

:/

#

but i want to post shards

gleaming summit
#

idk what's shards actually

#

lmao

#

;translate k shards

deep parrot
#

wrong chat

gleaming summit
#

.

#

k

pale light
#

mm what was that

deep parrot
#

a blank tag

#

lol

#

check bot-hell

pale light
#

nah

#

ik what it was

#

just why

deep parrot
#

wanted to ask something πŸ€”

gleaming summit
#

wait a sec

#

wt

#

srry to website team

#

really to srry

#

😭

fading breach
#

Is it good practice to send your list of commands in direct messages? (for the help command)

sick iron
#

It depends. You could. All kinda up to personal preference. If you plan the bot to be used on large discord’s then yes

fading breach
#

alright

pale light
#

dm help commands are annoying imo

fading breach
#

well you wouldn't exactly want

this
...
monstrosity```
in chat would you :^)
#

i guess that's where formatting comes in

pale light
#

thats where message embeds come through

#

waht

oak imp
#

Maybe a stupid question.. using discord.js, how would one simply grab all the roles a user/member has? Just looking for an array of their current roles.

languid dragon
#

i think you can get it using
member.roles

#

that'll return a collection

#

lemme check for u

oak imp
#

So, something like roles = member.roles

languid dragon
oak imp
#

ah mkay, so

roles = Array.from(member.roles());

#

maybe?

languid dragon
#

i dunno

#

depends on what you wanna do with the roles?

#

do you want to list them like

#
[1](Website Administrator)
[2](Special Bot)
[3](...)
#

that's just

message.member.roles.map(r => r.name)
oak imp
#

Just looking to put the role names in an array to be able to send them inn a massage actually

languid dragon
#

use message.member.roles.map(r => r.name)

frail kestrel
#

00f

oak imp
#

Okay, cool, that does the trick. Thank you ken!

languid dragon
#

no problemo

earnest phoenix
#

Im sorry

fleet mason
#
let guild = message.member.guild;
let Role = guild.roles.find('name', 'Member');

if (message.member.roleId === 36044994179078553) {
    message.channel.send('You already have this role!');
    console.log('${message.author.username} already has a role');

}
  else{
    message.member.addRole(Role);
    message.channel.send('WooHoo, You got a role!');
    console.log('${message.author.username} got a role');
  }
}
#

the first "if" wont work what did i do wrong/ how do i define roleid?

frail kestrel
#

ok so

#

ur saying

#

the message author's role id

#

no sense

#

whatsoever

gray turret
#

I think the number needs to be in β€œ β€œ

frail kestrel
#

no

#

actually

fleet mason
austere meadow
#

message.member.roleId isn't a thing

frail kestrel
#

o it isnt

#

heck

#

should consult the docs more lol

austere meadow
#

what are you trying to do?

frail kestrel
#

IDs are in quotes yah

austere meadow
#

^ that too

frail kestrel
#

numbers in (vanilla) js are without quotes tho

#

p sure

austere meadow
#

what version of d.js are you running @fleet mason

fleet mason
#

the newest

austere meadow
#

master?

#

or stable

fleet mason
#

stable

austere meadow
#

alright

#

do you want to grab the users highest role?

frail kestrel
#

if you want the exact version

#

I think you can do

#

npm ls discord.js

austere meadow
#

use message.member.highestRole

frail kestrel
#

on the terminal

#

o

#

yes

austere meadow
#

that returns a Role and you can use .id on that

fleet mason
#

i want it to see that if it has that role it will not give the person that role. but if he dosnt have that role i want to give him that role

austere meadow
#

trying to think if v11 has rolestore

#

message.member.roles.has("role id") i think

frail kestrel
#

yes

fleet mason
#
let guild = message.member.guild;
let Role = guild.roles.find('name', 'Member');

if(message.member.role.has("36044994179078553")) {
    message.channel.send('You already have this role!');
    console.log('${message.author.username} already has a role');
}
  else{
    message.member.addRole(Role);
    message.channel.send('WooHoo, You got a role!');
    console.log('${message.author.username} got a role');
  }
}
#

TypeError: Cannot read property 'has' of undefined
at Object.exports.run (C:\Users\sande\Desktop\mybot\commands\member.js:5:24)
at Client.client.on.message (C:\Users\sande\Desktop\mybot\mybot.js:28:17)
at emitOne (events.js:116:13)
at Client.emit (events.js:211:7)
at MessageCreateHandler.handle (C:\Users\sande\Desktop\mybot\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
at WebSocketPacketManager.handle (C:\Users\sande\Desktop\mybot\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:103:65)
at WebSocketConnection.onPacket (C:\Users\sande\Desktop\mybot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:330:35)
at WebSocketConnection.onMessage (C:\Users\sande\Desktop\mybot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:293:17)
at WebSocket.onMessage (C:\Users\sande\Desktop\mybot\node_modules\ws\lib\event-target.js:120:16)
at emitOne (events.js:116:13)

#

has didnt work

austere meadow
#

you've put role not roles

frail kestrel
#

rolesrolesroles

fleet mason
#

same as before

frail kestrel
#

oof

fleet mason
#

it wont understand that i have the role

#

and then it gives me the role again

austere meadow
#

are you sure you are doing it correctly

#

because .roles is a thing on stable

frail kestrel
fleet mason
#
    message.channel.send('You already have this role!');
    console.log('${message.author.username} already has a role');
}```
#

just to make it do the others thing if its right

#

then else

#

thats how i learned to do the things

austere meadow
#

ah

#

message.member must be null

#

or incorrect

frail kestrel
#

eeeee

#

log message.member

#

and give us the output

#

:^)

austere meadow
#

use message.guild.fetchMember(message.author.id).roles.has()

#

actually dont

frail kestrel
#

o yes

austere meadow
#

wait

frail kestrel
#

o

austere meadow
#

one sec

fleet mason
#

?

austere meadow
#

lmfao void are you just saying yes to everything

frail kestrel
#

yes

austere meadow
#

fetchMember is a promise i believe

#

so

frail kestrel
#

yay kyle's on

#

oof wrong chat

austere meadow
#
message.guild.fetchMember(message.author.id).then(member => {
    if (member.roles.has(..)) //...
});
#

then you won't have the possibility of having message.member be null

fleet mason
#

like this?? ```exports.run = (client, message, args) => {
let guild = message.member.guild;
let Role = guild.roles.find('name', 'Member');

message.guild.fetchMember(message.author.id).then(member => {
if (member.roles.has("36044994179078553"))) { //...
message.channel.send('You already have this role!');
console.log('${message.author.username} already has a role');
}
else{
message.member.addRole(Role);
message.channel.send('WooHoo, You got a role!');
console.log('${message.author.username} got a role');
}
}
}```

austere meadow
#

yeah but your syntax is wrong

#

missing a }) in there

fleet mason
#

where

austere meadow
#

to close the fetchMember

#

well i cant show you where GWchadThonkery you have to add it in

fleet mason
#

do i want to close in the end or after the if

#

XD

austere meadow
#

after the else

#

after the if sorry

frail kestrel
#

yes

austere meadow
#

ok

fleet mason
#

ok

austere meadow
#

listen

#

void ur being spammy

frail kestrel
#

sorry

austere meadow
#

its all good

frail kestrel
#

where the fuck is my screenshot sharex

#

:(

fleet mason
#
let guild = message.member.guild;
let Role = guild.roles.find('name', 'Member');

message.guild.fetchMember(message.author.id).then(member => {
    if (member.roles.has("36044994179078553"))}); //...
    message.channel.send('You already have this role!');
    console.log('${message.author.username} already has a role');
}
  else{
    message.member.addRole(Role);
    message.channel.send('WooHoo, You got a role!');
    console.log('${message.author.username} got a role');
  }
}
frail kestrel
#

no

#

the circled bracket isn't closed

fleet mason
#

i closed it with the ))})

frail kestrel
#

where

fleet mason
#

``` if (member.roles.has("36044994179078553"))}); //...````

frail kestrel
#

nonononon

fleet mason
#
    if (member.roles.has("36044994179078553")); //...
    message.channel.send('You already have this role!');
    console.log('${message.author.username} already has a role');
})}```
#

now?

austere meadow
#

what in tarnation

frail kestrel
#

});

austere meadow
#

you've done it completely wrong

frail kestrel
#

oof

fleet mason
#

yea im so lost XD

earnest phoenix
#

What code editor do you use. It should show you what closed what and what connects to what.

austere meadow
#

^

frail kestrel
#

ye

fleet mason
#
    if (member.roles.has("36044994179078553")); //...
    message.channel.send('You already have this role!');
    console.log('${message.author.username} already has a role');
});```
austere meadow
#
exports.run = (client, message, args) => {
let guild = message.member.guild;
let Role = guild.roles.find('name', 'Member');

message.guild.fetchMember(message.author.id).then(member => {
    if (member.roles.has("36044994179078553"))}); //...
    message.channel.send('You already have this role!');
    console.log('${message.author.username} already has a role');
} else {
    message.member.addRole(Role);
    message.channel.send('WooHoo, You got a role!');
    console.log('${message.author.username} got a role');
  }
}); //here is the missing }) to connect fetchMember
}
frail kestrel
#

//...

#

lol

#

they kept ur comment blake

austere meadow
#

yeah uh

#

waitwhat you haven't done the if statement properly

#

you've removed the { from the if statement
if (member.roles.has("36044994179078553")) {

fleet mason
#

i thought i did that at the start with the }})} but did i miss the ;?

austere meadow
#

no no

frail kestrel
austere meadow
#

see my code i posted there

frail kestrel
#

me irl

austere meadow
#

thats where it was supposed to go

fleet mason
#

ok

#

SyntaxError: Unexpected token }
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:607:28)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Client.client.on.message (C:\Users\sande\Desktop\mybot\mybot.js:27:23)

#

im even more lost now

frail kestrel
#

show code

#

sh0w code

fleet mason
#
let guild = message.member.guild;
let Role = guild.roles.find('name', 'Member');

message.guild.fetchMember(message.author.id).then(member => {
    if (member.roles.has("36044994179078553"))}); //...
    message.channel.send('You already have this role!');
    console.log('${message.author.username} already has a role');
} else {
    message.member.addRole(Role);
    message.channel.send('WooHoo, You got a role!');
    console.log('${message.author.username} got a role');
  }
}); //here is the missing }) to connect fetchMember
}
frail kestrel
#

AAAAAAAAAAAAAAAAAAA

#

sadasdasd

fleet mason
#

?

frail kestrel
#

spoonfeed temptation 100

fleet mason
#

XD

earnest phoenix
#

spoon feeeed is bad

frail kestrel
#

I know

fleet mason
#

im so lost now. XD i normally learn from my mistakes if i know where to fix it XD. But now idk

frail kestrel
#

go back to it later, then

earnest phoenix
#

but now OwO comes to help

#

so wat is the problem with ur code @fleet mason

frail kestrel
#

doesn't know how to use if

fleet mason
#

it skips the if check role and just outputs it to false

frail kestrel
#

because ur code brok

fleet mason
#

i know how to use if but idk how to do it with roles

#

iv used if with people id

#

XD

azure yoke
#

Meaning you don't know how to use if/else

fading breach
#

the if statement is incorrect

frail kestrel
#

yes

#

Blake gave up

fading breach
#

the code won't trigger without a proper if statement

frail kestrel
#

I'm close to giving up too

#

yes

fading breach
#

why can't we spoonfeed

azure yoke
#

Because they won't learn.

frail kestrel
#

because they'll expect u to spoonfeed

#

ye

fading breach
#

temptation :(

fleet mason
#

it depends actually.

#

i learn from spoonfeed if i understand what i did wrong after i got the correction

frail kestrel
#

but you understand we won't spoonfeed you

fleet mason
#

yea ik

earnest phoenix
#
let modRole = message.guild.roles.find("name", "Mod"); //finds the role. . .
if(message.member.roles.has(modRole.id)) return; //doesnt do anything if they hv the role```
frail kestrel
#

no

#

actually wait

#

ok

fleet mason
#

yea

frail kestrel
#

I was finna say

#

.has only works on ids

#

but .id

#

so ok

fleet mason
#

and then i add the {} so the bot would do thingsd

frail kestrel
#

piss

earnest phoenix
#

wat kind of command are u makin?

frail kestrel
earnest phoenix
#

πŸ€” I am making a Spoon Feeding Bot

#

OwO

fleet mason
#

a command that makes it so that if the member already have a role it will tell them they have it. Else it will give them the role

fading breach
#

oh

earnest phoenix
#

why not trigger it when they join

azure yoke
#

Also I haven't used Discord.js in awhile but I'm pretty sure you don't have to fetch the member if it's in a guild

fading breach
#

is it not message.member

azure yoke
#

Last time I used D.js it was.

fleet mason
#

because i want to learn how to do different thinges. I iwll do that asweal @earnest phoenix

earnest phoenix
#
(check the docs to detect the msg author . .).addRole(muteMember.guild.roles.find("name", "Memed by Telk"));```
#

it shouldnt be dat hard to fill dat part πŸ€”

frail kestrel
#

@azure yoke message.member returned null for them

fading breach
#

documentation is your best friend

azure yoke
#

Is it a DM or in a guild?

frail kestrel
#

guild probably

earnest phoenix
#

Guild. . . it is for role 🀦

#

roles*

fading breach
#

you can't assign roles in DMs

frail kestrel
#

ye

azure yoke
#

I know, but the only time that should be null is if it's in a dm, unless D.js has changed significantly since I last used it (which it could have)

earnest phoenix
#

-waifu @earnest phoenix with @umbral hearth

#

xD

frail kestrel
#

o k

earnest phoenix
#

wat lang do u use now @azure yoke

azure yoke
#

js still, though I switched to eris because sharding with eris is easier

earnest phoenix
#

cool

fading breach
#

eris is imo the best js lib

#

although d.py rewrite is great overall

earnest phoenix
#

@fleet mason how is it?

fleet mason
#

idk

#

im so lost

#

XD

#

im at the planet jupiter now

earnest phoenix
#

i dont like spoon feeding

fleet mason
#

yea i understand

earnest phoenix
#

im living on mars

fleet mason
#

nice

azure yoke
#

calm down elon

earnest phoenix
#

jk. . .

fading breach
#

this is what i can provide

azure yoke
#

D.js won't spoonfeed either, though they'd know more.

earnest phoenix
#

ye

fading breach
#

hopefully it'll help you navigate around the lib more

azure yoke
#

Also, this isn't related to D.js, they'd probably just say "not lib related"

#

TCD would be better, if anything. Or MDN lol

earnest phoenix
fading breach
azure yoke
#

Yes it is

fading breach
#

oh they bought it

#

nice

azure yoke
fleet mason
#

ok so i tried to play a bit and got this code``` exports.run = (client, message, args) => {

if(message.member.roles.has("36044994179078553")) {
console.log(Yay, the author of the message has the role!);
} else {
console.log(Nope, noppers, nadda.);
}
}

#

the role.has(role id)

#

it wont work

#

i just goes to noep, noppers...

#

did i put in the role id wrong?

#

should i change it and make a memberId in my config?

#

and then have has(config.memberId)?

earnest phoenix
#

wat is the problem?

#

it just says with/without the role Nope, noppers, nadda.?

fleet mason
#

got it to work by making memberid in the config and then doing config.memberid

#

idk why it work it just worked XD

earnest phoenix
#

try to just use a variable

#

like var roleid = "memesarerllycool";

fleet mason
#

exports.run = (client, message, args) => {
let guild = message.member.guild;
let Role = guild.roles.find('name', 'Member');

if(message.member.roles.has(config.memberRole)) {
    message.channel.send('You already have this role!');
    console.log('${message.author.username} already has a role');

}
  else{
    message.member.addRole(Role);
    message.channel.send('WooHoo, You got a role!');
    console.log('${message.author.username} got a role');
  }
}
#

this worked

earnest phoenix
#

wat is the **let Role = guild.roles.find('name', 'Member');
** for πŸ€”

#

u can also change the config.memberRole into Role.id

fleet mason
#

all that other shit people said i got wrong never worked XD

fading breach
#

yes that

#

you don't need the config

earnest phoenix
#

im making the dumbest bot ever

heady zinc
#

iirc addRole() can take an entire role object and use its ID in the background, but that's not the case for Collection.has() well as its a collection so you need to provide the key, and obviously the object isn't the key πŸ‘€

restive silo
#

^ has is a map method so d.js doesn't extend it utility, so you need to provide an ID there

fleet mason
#

ok i have a question why wont the console.log('${message.author.username} got a role'); work

#

${message.author.username} got a role

azure yoke
#

Use backticks

fleet mason
#

i want the username not the string

#

when i see other people do it it just works.

azure yoke
#

`` instead of ''

earnest phoenix
#

🀦 ``

#

or do

message.author.username + " got a role!!!!!!!! hype oMG OwO"```
azure yoke
#

Google is your friendβ„’

earnest phoenix
#

xD

fleet mason
#

ok but how do i use the string

#

because when i copy paste somethimes it workes

#

when i type it dosnt

azure yoke
#

Step one: don't copy and paste it

#

step two: use backticks

earnest phoenix
#

step 2: dont ask to be noops deef

fading breach
#

noops deef

#

clever

azure yoke
#

Step three: use Googleβ„’

fleet mason
#

i copy paste to test the code. and then make my own version XD

earnest phoenix
#

noops deef
goes like a train
and copy/paste are for losers
they will learn
nothing but sh*t

fading breach
#

haiku:
Please don't no-ops deef
It disrupts proper learning
And it really sucks

fleet mason
#

o

#

just got it to work

#

XD

earnest phoenix
#

ok

sweet portal
#

For the bot giving a welcome message to the user on each server would I have to do a json with the servers with their text channels? would you know informs if this is viable?

earnest phoenix
#

wat u mean?

sweet portal
earnest phoenix
#

thats python?

#

right?

#

javascript programmers this right?

 if(message.content.startsWith ("+kangtest")) {
    message.channel.send(`Testing message.`, {
    files: [
      "./imagens/imageone.gif"
      "./imagens/imagetwo.gif"
    ]
  })
 }
#

this is discord.js

#

no its c#

austere meadow
#

looks alright but i dont see the need for the space between startsWith and (

earnest phoenix
#

its javascript

#

not c#

austere meadow
#

actually

#

on the array

#

you are missing a comma

#

like erlite said

#

shoutout to my boy erlite

sweet portal
#

@earnest phoenix yeah is this python

earnest phoenix
#

Python is my weakness

sweet portal
#

only yours? haha I understand 1 bit of python because of my school, then I decided to do a project (yes my project is my bot.)

#

Sorry if my english is bad, I do not usually speak much english because ,I'm Brazilian.

frail kestrel
#

oof

#

wait this is developmen

polar stream
#

I need help

quiet bobcat
#

With?

polar stream
#

I tried making my bot right.

#

Then

#

Idk what this is

quiet bobcat
#

That's what you use to invite your bot to your server

polar stream
#

Like invite that bot to the server u want?

quiet bobcat
#

Yes

#

that link

#

is what you're supposed to use in there

polar stream
#

Not working..

quiet bobcat
#

?

polar stream
#

Wait.

#

Let me dm u the prob and see what’s happening.

quiet bobcat
#

ok

lethal sun
#

How to make a bot to like for example, DM an user when that user upvoted the bot?

heady zinc
#

it's not possible without checking on a regular interval

spring anchor
#

^

cerulean zinc
#

Should I really make a chat platform or should I make something else?

elder rapids
#

Do what you want

#

Don't doubt yourself if you want to make something cool

cerulean zinc
#

Yea you're right

slow elk
#

I would need some help with a command that assigns roles to the person using it. The addRole() attribute in discord.js, how exactly do we use that?

drowsy yarrow
#

I cant make http requests bc it says XMLHttpRequest is not defined wtf

#

what am I doing wrong

#
var xhr = new XMLHttpRequest();
xhr.open("GET", "https://discordbots.org/api/bots?limit=1&fields=id&search=id:264811613708746752", false);
xhr.send();
message.reply(xhr)
glossy sand
#

there is no XMLHttpRequest in node

#

you'll want some third-party request library

drowsy yarrow
#

fuck

quasi sandal
glossy sand
#

well, you can do that if you want

#

but there are better solutions in node lol

weary lily
#

which icon better?

drowsy yarrow
#

First

weary lily
#

yeah

elder rapids
#

First if it was colored maybe

#

Seems off

#

The exclamation also seems too small

weary lily
#

yeah

#

which exclemation mark color?

#

red yellow or black?

uncut slate
weary lily
#

site feedback?

#

no

#

general then?

quiet bobcat
glossy sand
upper pumice
#

what is the custom emoji code to add reactions

elder rapids
#

For emotes like Thonk ?

peak palm
#

with an id you just need to fetch the emoji (in discord.js)

elder rapids
#

replacing the stuff as needed

upper pumice
#

Wich stugg

#

If so it's <Thonk356771720863940608>

#

How

lethal sun
#

Someone, please tell me how to make a bot to DM an user when that user upvotes the bot.

#

please

gusty topaz
#

Poll the API

#

Every like minute

#

And detect changes

glossy sand
#

watch your ratelimits

gusty topaz
#

That's the only way

#

Tonkku, websocket Api when

#

No

glossy sand
#

...no?

gusty topaz
#

Since you poll every 1 minute

#

Fetch votes every fixed time period

#

And detect changes

upper pumice
#

How can I get the emoju Id?

lethal sun
#

This doesen't seem to work...
Code:

        db.get(`SELECT * FROM all WHERE ID = '${message.guild.id}'`, function(err, row) {

            if (!row) {
                db.run(`INSERT INTO all(ID) VALUES(?)`, [message.guild.id], function(err) {
                    console.log(`A row has been inserted with rowid ${this.lastID}`)
                    message.channel.send('lul')
                });
            }

            message.channel.send(row.laungage)
        });```
Console Output:
```TypeError: Cannot read property 'laungage' of undefined```
SQLite Studio Columns:
https://my-bot.dabs-on.me/DDDuycQfb.png
#

sqlite3 is the package

#

discord.js

upper pumice
#

Guys , how can I get the Emoji ID?

lethal sun
#

\:emoji:

#

ez

sweet portal
#

@upper pumice in node or python?

elder rapids
#

or... send the emote => right click => copy id

lethal sun
#

that doesent work for me

#

the copy thing

#

for me it copies the message id

gusty topaz
#

Inspect element

elder rapids
#

prob does tbh

gusty topaz
#

Go to emoji source image

elder rapids
#

Copy link for the emote works though

gusty topaz
#

And it should contain the id somewhere

#

In the url

#

Oh

#

Right

elder rapids
#

or just copy link lol

#

Why make that so complicated

fathom pebble
#

or just escape the emote lol

gusty topaz
#

Wait really?

elder rapids
#

I mean yeah but who wants to do that

gusty topaz
#

:mmLol:

elder rapids
#

That's lame

#

You fail

gusty topaz
#

I escaped mmLol but didn't get id

#

Maybe since I was on mobile

elder rapids
#

Mobile can't escape

lethal sun
#

escape mmLol

#

hmm

elder rapids
#

I just did

upper pumice
#

<:Spooky boi:407324790202957825>

#

Ok this is the emoji and the ip

#

And now How can I get the raw to me put on codes ?

#

@elder rapids How Can I get the raw emoji to put on my codes now?

elder rapids
#

That is the raw?

upper pumice
#

Idk to get the raw to put on codes to reac

#

@elder rapids Help?

wispy axle
#

@upper pumice what lib are u using?

#

How do i make my bot edit their own message (i tried message.edit)

modern kelp
#

\mmLol

upper pumice
#

Its the block

#

nothing

modern kelp
#

@wispy axle fetch the most recent message as soon as you send the message then edit that

#

@upper pumice the raw thing is <:Spooky boi:407324790202957825>

upper pumice
#

Not a ''pic'' , I need to put code <:Spooky boi:407324790202957825>?

#

Ok, I made

wispy axle
#

does anyone know how to fix it? ReferenceError: client is not defined

potent lily
#

If you want to fix it you need to learn how to code first ...

#

client is you're bot object

#

Check if you call it client

#

if you call it bot you can't call client

wispy axle
#

k whatever i deleted the api latency, but when i tried it again it shows : DiscordAPIError: Cannot edit a message authored by another user

potent lily
#

You are editing you're own message or someone else one ?

wispy axle
#

the bot message

potent lily
#

Can you show us ?

wispy axle
potent lily
#

You edit message

#

...

#

messageis the message who call the command

wispy axle
#

m?

potent lily
#

Yep

wispy axle
#

"m.edit"?

potent lily
#

m is your bot message πŸ˜ƒ

wispy axle
#

Oh

potent lily
#

So yep m.edit ^^

#

That's okay just ask us if you don't know what to do exacly with something

#

Some of us love helping and everyone started somewhere ^^

wispy axle
#

K its working thx for the help!

potent lily
#

No problem ^^

#

If you need help you can ping me

wispy axle
#

Okay

gleaming summit
#

Anyone can help me...?

potent lily
#

For ?

gleaming summit
#

enmap

#

not the code

#

npm i enmap-level

#

This isn't working for me

#
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! leveldown@1.7.2 install: `prebuild-install || node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the leveldown@1.7.2 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Attribute\AppData\Roaming\npm-cache\_logs\2018-02-12T20_03_30_446Z-debug.log
#

Any idea?

potent lily
#

idk npm and js so someone else gonna help you

#

Good luck πŸ˜‰

gleaming summit
#

πŸ˜‰

gusty topaz
#

Ehm

#

Do you have a C compiler?

gleaming summit
#

Nope.

gusty topaz
#

That is kinda required for native modules to work

#

I believe you need windows sdk

gleaming summit
#

But

#

I am using heroku

gusty topaz
#

You don't upload node modules

#

Right?

gleaming summit
#

Any solutions with packages?

#

πŸ€”

#

I can upload it but

gusty topaz
#

Don't

gleaming summit
#

so many files

gusty topaz
#

Heroku will build it themselves for Linux

gleaming summit
#

yes

gusty topaz
#

Based on dependencies

gleaming summit
#

right

gusty topaz
#

But for it to run on your computer

#

You need windows SDK

gleaming summit
#

SDK?

gusty topaz
#

Ehm

#

Hold on

gleaming summit
#

k

potent lily
#

Source developpment kit

gleaming summit
#

oh. I didn't know that.

#

I used SDK manytimes but

#

I didn't know

#

lmao

gusty topaz
#

question

gleaming summit
#

to me?

gusty topaz
#

yes

#

can you take the log

#

remove personal info

#

and put it on hastebin/pastebin

#

then DM me the link?

gleaming summit
#

I don't have any personal info

#

Bot is opensrc

gusty topaz
#

the log

gleaming summit
#

executing again

#

wait a sec

gusty topaz
#

C:\Users\Attribute\AppData\Roaming\npm-cache\_logs\2018-02-12T20_03_30_446Z-debug.log

gleaming summit
#

k

gusty topaz
#

okay

#

what you need to do

#

run cmd as admin

gleaming summit
gusty topaz
#

and run npm install -g windows-build-tools

#

running as admin is important

gleaming summit
#

k

#

I am using powershell

#

then

#

no prob?

gusty topaz
#

as long

#

as npm install -g windows-build-tools

gleaming summit
#

Installing

gusty topaz
#

gets executed as admin

#

you can run anything

#

it may take some time

gleaming summit
#

πŸ€”

#

Almost done

#

I'll tell you when done

#

@gusty topaz Wait a sec

gusty topaz
#

yes

gleaming summit
#

This is not installing Visual Studio on my PC, is it?

gusty topaz
#

visual c++

#

this is what you need on windows to compile C++

#

lol

gleaming summit
#

Is the required space too large?

gusty topaz
#

you can cancel and test on linux virtual machine

#

but this is what it requires

#

on windows

#

and I don't know, I personally don't use windows

gleaming summit
#

πŸ€”

gusty topaz
#

I am a linux user

gleaming summit
#

oh..

gusty topaz
#

but I told you what I know from my experience

#

because I used to use windows

gleaming summit
#

Its ok

gusty topaz
#

and this is what I had to go through

#

to build native modules

#

Β―_(ツ)_/Β―

gleaming summit
#

oh

#

done

gusty topaz
#

πŸ‘Œ

gleaming summit
#

My laptop is hot

#

littlebit

gusty topaz
#

hmmm

gleaming summit
#

It's ok. I bought my laptop in 2017-10

#

hm

#

There is some yello colored words.

gusty topaz
#

yellow = warnings not errors

gleaming summit
#

I think its done

gusty topaz
#

yes

#

it installed successfully

gleaming summit
#

Thank you~

gusty topaz
#

yw

gleaming summit
#

However, this error did not occur in the past.

gusty topaz
#

you most likely never dealt with native modules

#

native modules have code written in C/C++

gleaming summit
#

oh

gusty topaz
#

and it needs to be compiled for your computer

#

(which in this case runs windows and needs a windows specific compiler)

#

I would guess all modules you installed earlier were just js-only modules

#

so node knew how to run them out-of-the-box

gleaming summit
#

ooooo

#

Much thanks~ Myself

#

NOT MYSELF

gusty topaz
#

this sounds awkward, just call me Rph

gleaming summit
#

πŸ†’

gusty topaz
gleaming summit
#

lol

#

I am gonna try

#

πŸ€”

oak juniper
#

Hi, does anyone know how to change an environmental variable? thanks

gleaming summit
#

wut?

#

process.env.VAR

#

?

oak juniper
#

well I am trying to add login with discord using express to a site and for the login to work I need to insert the USER_ID and USER_TOKEN

gleaming summit
#

πŸ€” and?

oak juniper
#

CLIENT_ID & CLIENT_SECRET

gleaming summit
#

changing var

#

changing var means

#

like

oak juniper
#

so I have looked and I need to change the environemntal variable

gleaming summit
#

password change?

oak juniper
#
const CLIENT_ID = process.env.CLIENT_ID;
const CLIENT_SECRET = process.env.CLIENT_SECRET;
gleaming summit
#

πŸ€”

#

Where it storaged?

oak juniper
#

idk they are apparently Environmental Variables

#

and I need to change them in the OS

gusty topaz
#

no

#

you put them in .ENV file

#

and use a module called dotenv

#

to load them

#

then you add .ENV to gitignore

#

so you dont commit it

gleaming summit
#

Are you windows or linux

oak juniper
#

linux

#

I am setting this up on my VPS

gleaming summit
#

Open the terminal

#
sudo su
#
env ENVNAME=VALUE
#

I think this will help you

oak juniper
#

Ok thank you

gleaming summit
#

Delete it with flag -u

oak juniper
#

right i will try thank you

cerulean zinc
#

what would be good to make using web sockets?

uncut slate
#

A chat app

cerulean zinc
#

Kek I'll keep working on it

wispy axle
#

wot lib are u using m9 @drowsy yarrow

drowsy yarrow
#

d.js

wispy axle
#

oh

#

wait hold on

drowsy yarrow
#

no thats not what I need

#

Im getting bot statistics from the DBL API

#

and I get this shit for avatar "avatar":"7055c85e548db7d7000724e6d1518888"

#

its the avatar hash I need to figure out how to convert that to a avatar url

trim plinth
#

how to get a format in a rich embed like this using the discord.js rich embed builder method zoomeyes

pale light
#

inline fields

trim plinth
#

ok

drowsy yarrow
#

This isnt a hash

pale light
#

@drowsy yarrow so this is my avatarURL:

https://cdn.discordapp.com/avatars/291620336078684170/18226bcdcdf99ec321ea7ac3e35953f7.png?size=2048

and the basic structure is:

https://cdn.discordapp.com/avatars/<user Id>/<avatar hash>.png?size=2048
slow elk
#

But my question still stands.. How do we use the addRole() attribute to the message author?

#

For example, when someone uses !kbs game Minecraft, the bot will give the Minecrafter role to that user. How am I able to accomplish this?

#

discord.js btw

unique star
#

<Message>.member

#

is a thing

#

@slow elk

slow elk
#

just the message.member? Hmmmm

unique star
#

whatever you definded message as

#

ye

#

and you can call member functions on that

#

<Message>.member is the author as member object

slow elk
#

Okay. I'll try that. Thanks

earnest phoenix
#

@drowsy yarrow of it starts with a_ it's a gif

rough pelican
#

how come

#

i failed so horribly

#
<html>
<body>
<style>
body {
background-color: #2C2F33;
}
  
.bot-name {
color: #FFFFFF;
}
</style>
</body>
</html>
#

this isnt turning the bot name white

#

.-.

#

even though bot-name is the name of the class

vital lark
rough pelican
#

xD

unique star
#

iirc you need to !important the username

rough pelican
#

wym?

#

@unique star, where u talking to meh?

#

xD

#

sorry for the ping

#

:3

unique star
#

color: <hex> !important

#

makes the change only overrideable by other important flags

#

and I believe username had one

#

so you need to use one aswell for it to take affect

rough pelican
#

so like this

#
p {
color: #7289DA; !important
}
unique star
#

ye

rough pelican
#

k πŸ˜„

unique star
#

well

#

no

#

the ;

#

after important

rough pelican
#

oh ok

#

πŸ˜„

hushed oyster
#

i think botname is an id

#

nevermind

rough pelican
#

ty

pale light
#

same

rough pelican
#

lars D

#

bot-name is the class

#
<span class ="bot-name">Infinite</span>
#

how come this still

#

isnt making the background white for the buttons :/

#
.botpagebutton {
background-color: #FFFFFF !important;
}
hushed oyster
#

try indenting background-color

rough pelican
#

still nope

#

:/

hushed oyster
#

wait

#

.botpagebutton

#

is that a class

rough pelican
#

yes

#

and the names of the buttons