#development

1 messages · Page 935 of 1

digital ibex
#

i'm filtering every guild members roles to see it it includes the mod roles, and if it does, sort them into order and map by their mention

quartz kindle
#

still wrong

digital ibex
#

wdym?

#

what else can i do then, i've tried like loads of other stuff and this one seems to work

quartz kindle
#

you cannot use .includes(array), thats why you use .some in combination with .includes
also, dont map and sort inside the filter function, its not actually doing anything, just adding work to your cpu for no reason

#

you said you have 2 arrays, what arrays are those? is the first array your guild.mod.roles? what is the second one?

digital ibex
#

the guilds roles

#

message.channel.guild.roles

quartz kindle
#

why do you need that array?

digital ibex
#

to get guild.mod.roles from it

#

and if it does

quartz kindle
#

how are you getting the guild.mod.roles from it?

digital ibex
#

then get the members which has the roles?

#

wdym?

quartz kindle
#

how do you define guild.mod.roles?

#

do you search for roles that have admin permissions? or do you manually define them beforehand?

digital ibex
#

guild is the guild in the db, and mod is a property of it

quartz kindle
#

ok so guild.mod.roles is an array of pre-defined role ids, correct?

#

so you dont need to get guild.roles

digital ibex
#

no, i do ```js
const g = require('guild model');
const guild = await g.findOne({ 'guild.id': message.channel.guild.id }).lean();

guild.mod.roles /* returns an array */

#

oh

#

yea

#

it is

quartz kindle
#

whatever happened to the code i told you about yesterday and before yesterday?

torn nebula
#

guild model is that npm package?

quartz kindle
#

members.filter(member => member.roles.some(role => guild.mod.roles.includes(role)))

digital ibex
#

i couldn't get it to work correctly, idk y, me being me

quartz kindle
#

lets break it down

#

members is your guild.members from discord.js, its a collection of GuildMember objects (these are full member objects)

#

when you do members.filter() you give it a function that must return either true or false, if it returns false, that members is skipped, if it returns true, that member is kept. the final result is a new collection with only GuildMembers that passed the filter

digital ibex
#

i'm using eris, not d.js lol

quartz kindle
#

now filter function executes once for every single member, to determine if this member passes the filter or not

#

eris uses collections

digital ibex
#

wh

#

yeah

#

but guild.mod.roles isn't a collection

quartz kindle
#

no, its role ids

#

but you'll see why you dont need anything else

#

.filter(member => do something with member and return true or false)

#

so here we use member.roles.some()

#

why?

#

member.roles is an array of role IDs in eris

digital ibex
#

.filter(member => do something with member and return true or false) returns an array, a collection

quartz kindle
#

and .some() iterates over an array, and returns true or false if a condition is met

#

collection.filter() returns a new collection

#

as i said above

#

but member.roles is not a collection, its an array

#

so when you do member.roles.some() you're gonna check each role of this member against a condition, and if the condition passes, it returns true and if it returns true this member has passed the filter

#

so roles.some(role => here is a role id. we want to check if this id exists in guild.mod.roles)

#

so we use guild.mod.roles.includes(role)

digital ibex
#

ok, so would i do, ```js
let role = message.channel.guild.members.filter(member => member.roles.some(role => guild.mod.roles.includes(role))).map((e) => e.roles);
guild.mod.roles.includes(role)

#

wait

#

idfk

#

so confused

mystic copper
#

i need help. bot widget on my website shows undefined instead of servers amount (sry for bad english)

quartz kindle
#

this is a collection of members that have one of the roles

#

now what do you want to do with those members?

digital ibex
#

map them?

quartz kindle
#

map them to what? what do you want out of them?

digital ibex
#

their roles

quartz kindle
#

why do you want their roles?

digital ibex
#

to check if their roles include that, then say that persons a mod

quartz kindle
#

you already checked

digital ibex
#

if it does

earnest phoenix
#

this is ok?

let rol = member.guild.roles.filter(x => x.name === 'Muted').sort((a, b) => a.position - b.position).first();
member.roles.includes(rol)
digital ibex
#

yeah, but when i map((e) => e.roles)

#

it returns all the guilds roles

quartz kindle
#

but why do you want to map them into their roles?

#

you already have a collection of members who are mods, you already know if they are mods or not

earnest phoenix
#

is for, "The mentioned is already muted"

digital ibex
#

OH

#
let role = message.channel.guild.members.filter(member => member.roles.some(role => guild.mod.roles.includes(role))).map((e) => e.mention);
quartz kindle
#

yes, that will map them into their mentions and give you an array of mentions of mods

#

so you understand what the code is doing? for each member, check each of its roles, and for each of its roles check if the role is a mod role

#

if mod.roles includes the role, the role is a mod role, and if one of the roles is a mod role .some() returns true, and if .some() returns true, the member passes the .filter()

turbid bough
#

I was wondering, if you use __dirname on a parent, and the child who inherits the class, will it get the child's directory, or the parent's?

quartz kindle
#

@earnest phoenix that is redundant, unless you have multiple Muted roles

#

if you only have one Muted role, just do let muted = member.roles.find(x => x.name === "Muted")

digital ibex
#

ah, thanks tim

#

had to just test a few things and now it works, ty

quartz kindle
#

👍

earnest phoenix
#
let rol = member.roles.find(x => x.name === "Muted")
member.roles.includes(rol)```
? @quartz kindle
#

?

quartz kindle
#

no, remove everything else

#

you dont need to check if it includes either

earnest phoenix
#

already?

#

or

#

if( member.roles.find(x => x.name === "Muted"))

quartz kindle
#

yes you can do that

earnest phoenix
#

ok ty

#

and with the .sort?

#

x.name.includes christmasthink

quartz kindle
#

no need to sort

earnest phoenix
#

but i can?

quartz kindle
#

why?

#

.find() only returns 1 result

#

sorting 1 result does nothing

earnest phoenix
#

ok

#

if( member.roles.find(x => x.name === "Muted"))
@earnest phoenix this work with the event memberGuildRemove?

quartz kindle
#

if the member is cached, yes it should work

earnest phoenix
#

ok

#

ty

iron scroll
hardy vector
royal portal
#

how do i make a bot leave a specific guild?

digital ibex
#

<client>.guilds.get('id').leave()

royal portal
#

can I add that in the ready event?

digital ibex
#

wdym?

clever garnet
royal portal
#

where would I add that

#

oh I see

quartz kindle
#

@iron scroll how are you loading your commands?

iron scroll
quartz kindle
#

@hardy vector which line?

limber flume
#

bruh

quartz kindle
#

@iron scroll you are not setting the aliases

hardy vector
earnest phoenix
#

@quartz kindle need yall help

clever garnet
#

can someone help me

earnest phoenix
#
    const filter = m => m.author.id === message.author.id;
    let embed = new Discord.RichEmbed()
        .setColor(color.purple_light)
        .setTitle("Question here")
        .addField("Answer A: ", "Some text")
        .addField("Answer B: ", "Some text")
        .addField("Answer C: ", "Some text")
        .addField("Answer D: ", "Some text")
    message.channel.send("hello", embed)
    message.channel.awaitMessages(filter, {max:1, time: 10000, errors: ['time']}).then(collected => {
        console.log(collected.first())
    }).catch(err => {
        console.log(err);
    });

When i console.log() it says undifined

clever garnet
#

whats undefined

#

what is undefined

#

and what library u using

earnest phoenix
#

ahm . . .

quartz kindle
#

@clever garnet .includes(whitelist) not .includes.whitelist

earnest phoenix
#

d.js

clever garnet
#

ok

quartz kindle
#

also, its the other way arround

clever garnet
#

?

earnest phoenix
#

me ?

quartz kindle
#

whitelist.includes(id) not id.includes(whitelist)

earnest phoenix
#

oh

clever garnet
#

so why did you say .includes(whitelist)

quartz kindle
#

because you were using .includes.something

#

which is invalid

#

so first i said how to use the includes function properly

hardy vector
quartz kindle
#

then i noticed your order was incorrect

clever garnet
#

k testing rn

quartz kindle
#

@earnest phoenix collected.first() returns undefined? what version of djs?

earnest phoenix
#

v11

quartz kindle
#

v11 uses maxMatches

#

not max

#

afaik

earnest phoenix
#

omfg

#

thx you btw

clever garnet
#

@quartz kindle theres a new error

TypeError: Cannot read property 'includes' of undefined

earnest phoenix
#

Has anyone else noticed the glitch where a different member will be pinged on a very rare occasion

clever garnet
#

i thought they fixed that

earnest phoenix
#

Apparently not

#

Dank memer, my bot, and multiple others have been having that problem lately, I've noticed

#

At first I thought it was something I screwed up, but then dank memer did it

quartz kindle
#

@clever garnet what did you write?

clever garnet
#

if(message.author.whitelistforannounce.includes(id)){
message.delete();
announcementwebhook.send(embedforaccept);
}

if(!message.author.id.includes(whitelistforannounce)){
message.channel.send(embedforfail)
}

quartz kindle
#

@hardy vector sorry, cant find anything wrong. console.log m.author and message.author in your filter, you might be getting something weird from somewhere

#

@clever garnet you still have id.includes()

#

and you're still doing it wrong

clever garnet
#

ok

hardy vector
#

oh ok

quartz kindle
#

whitelist.includes(id)
what is whitelist and where does whitelist come from? whitelist is the array you defined: whitelistforannounce
what is id and where does id come from? id is the id that you get from message.author.id

clever garnet
#

whitelist

#

i never defined whitelust

#

i never even said anything about whitelist

quartz kindle
#

read what i said

clever garnet
#

i use whitelistforannounce thats the command

#

oh

#

so what do i do

earnest phoenix
clever garnet
#

not the right channel

quartz kindle
#

if if id is message.author.id
and whitelist is whitelistforannounce
then whitelist.includes(id) is xxxxxxxxxx

#

find the xxxxxxx

earnest phoenix
quartz kindle
#

wtf

earnest phoenix
#

Define your config.js at the beginning of your file, and change whitelist to whatever your arrays name is

clever garnet
#

?

quartz kindle
#

that answer is out of context

earnest phoenix
#

Hes trying to confirm that the author ID is contained inside the whitelist correct?

quartz kindle
#

yes, but dont tell him to rewrite his entire code into your preferred style, give him an answer that fits his current code

#

while trying not to spoonfeed

earnest phoenix
#
     let rol = member.roles.find(x => x.name === "Muted")
       member.addRole(rol)

why this dont work?

#

Ye, I was recommending that because if he ever wants to reuse the whitelist, then he can use it anywhere, unless hes doing a index only bot

#
(node:1369) UnhandledPromiseRejectionWarning: TypeError: Supplied parameter was neither a Role nor a Snowflake.
#

Have you defined member?

#

member is for guildMemberAdd

#

is member.user.addRole(rol) ?

torn nebula
#

member works if that in inside guildMemberadd event

earnest phoenix
#

i know

#
client.on('guildMemberAdd', async (member) => {
      if (member.user.bot) return;
     let count = await entrada.obtener(member.guild.id);
  if(!count) return;
     let rol = member.roles.find(x => x.name === "Muted")
#

You need the role search inside the guild, not the members roles

#

member.guild.roles.find(x => x.name="Muted") ?

torn nebula
#

will work

earnest phoenix
#

Ye, if you want to find a role, unless the member has it already it will return false

clever garnet
#

@earnest phoenix yeah i want to be able to reuse the whitelist

earnest phoenix
#

Are you making a bot with separated command files?

clever garnet
#

no

earnest phoenix
#

So one that it is all housed inside index.js?

clever garnet
#

yes

earnest phoenix
#

Ok

clever garnet
#

after im done then ill make a command handler

earnest phoenix
#

You can just define whitelist inside the index if you dont plan on extending it to the command handler

clever garnet
#

it doesnt work

#

its undefined for some reason

earnest phoenix
#

How do you have whitelist defined?

clever garnet
#

wdym

earnest phoenix
#

Do you have the whitelist contained inside an array?

#

So,

"Value 1",
"Value 2"
],
clever garnet
#

yeah like

const whitelistpeoplexd = [id1, id2, id3]

like that

earnest phoenix
#

Ok, do you have the ids quoted?

clever garnet
#

ill do that

quartz kindle
#

you need to define the whitelist outside of your event handles, for example at the top of your index file

#

that way it can be accessed by all events

silent berry
#

hey, im attemting to get a global chat into my bot but when anyone types in it, it repeats. i do have bot protection on

quartz kindle
#

if you define it inside an event, it will only exist inside that event

clever garnet
#

thats what im doing

#

k testing

#

TypeError: Cannot read property 'includes' of undefined

#

lemme find the line

#

TypeError: Cannot read property 'includes' of undefined

heres the code in that line
if(message.author.whitelistpeoplexd.includes(id)){

earnest phoenix
#

Oh

clever garnet
#

testing

earnest phoenix
#

You can't use message.author.includes(), that will result in a TypeError every time, you need to make the arrayName.includes()

silent berry
#

why am i getting this error

(node:106) UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Message
at /home/container/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:85:15
at /home/container/node_modules/snekfetch/src/index.js:215:21
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:106) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:106) [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.
#

discord.js v11.5.1

torn nebula
#

empty message iirc

earnest phoenix
#

But unless we know the event that caused it we can't help, sorry

clever garnet
#

i forgot the ! in the second part so it gave me the error and the sucsess embed lol alr imma test it now

silent berry
#

im trying to run a global chat

torn nebula
#

global chat ? wdym?

silent berry
#

chat accross servers

earnest phoenix
#

Is it an opt in?

silent berry
#

yeah

clever garnet
#

uhhhh

silent berry
#

they make the channel and it runs then

#

if named correctly

clever garnet
#

@earnest phoenix

    message.delete();
    announcementwebhook.send(embedforaccept);
  }

  if(!whitelistpeoplexd.includes(message.author.id)){
    message.channel.send(embedforfail)
  }```

it gives me the error message but it still works
silent berry
#

but its spamming the msg

#

my friend is trying to help

torn nebula
#

find channel and fetch messages in it

earnest phoenix
#

What are you trying to do with this?

clever garnet
#

me?

earnest phoenix
#

Ye

clever garnet
#

i have an announce command and it will send a webhook in an announcement channel this is just for a spefific server

earnest phoenix
#

Ah

#

Send me an invite to your testing server please, I want to see what youre doing when the error message pops up

clever garnet
#

i dont have a testing server i just test it in a private channel that i made

earnest phoenix
#

Ah

digital ibex
#

what r u doin 4 it 2 error?

clever garnet
#

?

#

theres no error

earnest phoenix
#

Try moving the if(! Above the success, and put a return in front of message.channel.send

digital ibex
#

what are you doing for it to error?

#

or ^^

clever garnet
#

theres no error

#

ok

#

wdym by infront

#

?

#

above bottom left or right

earnest phoenix
#

if(!whitelistpeoplexd.includes(message.author.id)){
return message.channel.send(embedforfail);
}

if(whitelistpeoplexd.includes(message.author.id)){
message.delete();
announcementwebhook.send(embedforaccept);
}

clever garnet
#

ok

#

testing

#

no difference

#

theres no difference

earnest phoenix
#

Can you send a screenshot of the channel you're testing in?

clever garnet
#

it sends the announcement in a different channel

earnest phoenix
#

Kk

clever garnet
#

its a bot for a cafe

#

on roblox

#

it still sends tho

earnest phoenix
#

Ah

clever garnet
#

i could change the webhook to the testing channel for a moment if u like

earnest phoenix
#

Are you the only person In the whitelist array?

clever garnet
#

no theres multiple i added the hrs to the whitelist

earnest phoenix
#

Ok

#

I've got to go to work, sorry

clever garnet
#

ok

earnest phoenix
#

@quartz kindle Are you able to help him, I can't help rn, got to go into work

quartz kindle
#

show your full code

clever garnet
#

for the event or the entire code

quartz kindle
#

for the event

clever garnet
#

//announcement

bot.on('message', message=>{
const announcementwebhook = new Discord.WebhookClient('712005281327874179', 'LF1cIM5EYNwqk04qa0aUXozEFSeg3s2o6stGlNEb9RHwrOAAdKoaiBraTiVvUWkv5dWx');
const announcementwebhooktext = message.content.split(" ").slice(1).join(" ");
const embedforaccept = new Discord.MessageEmbed().setDescription(announcementwebhooktext).setFooter(Sent from ${message.author.username})
const embedforfail = new Discord.MessageEmbed().setTitle('Missing permissions').setColor('#F04947').setDescription('You are not on the whitelist to execute this command.').setFooter('If you think you should be on the whitelits DM Qu1ckIy#5965')
let args = message.content.substring(PREFIX.length).split(" ");
switch (args[0]){
case 'announcement':

    if(!whitelistpeoplexd.includes(message.author.id)){
        return message.channel.send(embedforfail);
      }
    
    if(whitelistpeoplexd.includes(message.author.id)){
        message.delete();
        announcementwebhook.send(embedforaccept);
      }

}})

earnest phoenix
#

You can use ```

clever garnet
#

oh good idea

#

bot.on('message', message=>{
    const announcementwebhook = new Discord.WebhookClient('712005281327874179', 'LF1cIM5EYNwqk04qa0aUXozEFSeg3s2o6stGlNEb9RHwrOAAdKoaiBraTiVvUWkv5dWx');
    const announcementwebhooktext = message.content.split(" ").slice(1).join(" ");
    const embedforaccept = new Discord.MessageEmbed().setDescription(announcementwebhooktext).setFooter(`Sent from ${message.author.username}`)
    const embedforfail = new Discord.MessageEmbed().setTitle('Missing permissions').setColor('#F04947').setDescription('You are not on the whitelist to execute this command.').setFooter('If you think you should be on the whitelits DM Qu1ckIy#5965')
    let args = message.content.substring(PREFIX.length).split(" ");
    switch (args[0]){
      case 'announcement':


        if(!whitelistpeoplexd.includes(message.author.id)){
            return message.channel.send(embedforfail);
          }
        
        if(whitelistpeoplexd.includes(message.author.id)){
            message.delete();
            announcementwebhook.send(embedforaccept);
          }



}})
balmy knoll
quartz kindle
#

so you said that it still sends the webhook even if it fails?

clever garnet
#

nonon

#

if it succeeds it will send the webhook and the fail message

quartz kindle
#

i dont see how that could happen, but why dont you start with reorganizing your code in a way that makes more sense

#

first of all, check the command

clever garnet
#

this is how i normally do it

#

check the command?
wdym

quartz kindle
#

prioritize the correct things to improve performance and efficiency

#

for example

#
if(message.author.bot) return
let args = message.content.slice(prefix.length).split(" ");
if(args[0] === "announcement") {
  if(whitelist.includes(message.author.id)) {
    let webhook = new Discord.WebhookClient(...)
    let embed = new MessageEmbed()
    webhook.send(embed)
  }
}
dawn pagoda
stuck furnace
#

How do i program a music bot? @-@

quartz kindle
#

because the way your code is now, you are creating new webhook clients, and new embeds on every single message

#

because you create first and check later

#

thats a huge waste of cpu

#

you should always check the conditions first, and only create if all conditions are right

stuck furnace
#

???

quartz kindle
#

do you have any experience with programming?

#

or any experience at bot making?

clever garnet
#

wwho

quartz kindle
#

jake

stuck furnace
#

@-@

#

im new @-@

#

and i need some advice @-@

quartz kindle
#

so you have no experience with programming? never programmed in your life?

stuck furnace
#

no

clever garnet
#

search it up on yt i suggest watching the starter thing by codelyon to start understanding then read the docs

quartz kindle
#

so you should start by learning a programming language

#

for example, javascript, python, c#, java

stuck furnace
#

@-@

quartz kindle
#

pick one of those, and look into online courses and guides

stuck furnace
#

okay

#

thanks

quartz kindle
#

you need to know basic programming before starting a bot

stuck furnace
#

im still confused but okay.....

earnest phoenix
#

:music: Mixer

#

hmm

digital ibex
#

thats an emote

#

not a role lol

earnest phoenix
#

ik that

#

you can have emotes in your role names

#

but i dont think you can have custom emojis

quartz kindle
#

not afaik

earnest phoenix
#

wot

limber flume
#

bruh

balmy knoll
#

If possible, how can I do this with my music bot? Please, help me. [discord.js]

earnest phoenix
#

deafan your bot?

#

1s cooldown

#

channel settings

halcyon ember
#

how do i specify port for the vote listener

#

just 0.0.0.0:port or what

earnest phoenix
#

yes that

#

i want 1s not 5s

balmy knoll
#

deafan your bot?
@earnest phoenix I meant to make sure that when it connects to a voice channel, my bot has mutated audio input.

dawn pagoda
earnest phoenix
#

@earnest phoenix

#

in the data object you pass you can pick however many seconds you want

#

@balmy knoll so you want to mute the bot when it joins the voice channel?

#
message.channel.setRateLimitPerUser(1000)
  .then(algo => console.log("spanish here xd"))
  .catch(console.error);

@earnest phoenix

balmy knoll
#

@earnest phoenix I'm not sure how to explain it to you, but maybe this command (.setSelfDeaf(deaf)) is the one for me. Isn't it?

quartz kindle
#

@dawn pagoda because the original overrides it

#

this is the original

earnest phoenix
#

Tim

#

@balmy knoll defeaning the bot wont really do anything..

quartz kindle
#

well, it will show the icon, which i guess is what he wants

earnest phoenix
#

oh btw I wanted to delete a role if the bot left a server

#

but i got this error DiscordAPIError: Missing Access

magic jackal
#

What is the full error dump?

#

Lemme check

quartz kindle
#

you want to delete a role when your bot leaves a server?

earnest phoenix
#

ye

quartz kindle
#

in the server it leaves?

earnest phoenix
#

yes...

#

well no i sound stupid

quartz kindle
#

but if you leave the server, how are you gonna delete the role?

earnest phoenix
quartz kindle
#

lmao

magic jackal
#

You cant do that in theory.

earnest phoenix
#

tim is too smart

dawn pagoda
#

@quartz kindle thx u

halcyon ember
#

how do i make my bot like slice a mention off

#

like i have a command like $inv <args> @user but doing .content.slice includes the user mention

earnest phoenix
#

have you tried just taking the user as a first argument

halcyon ember
#

oh

#

but after that how do i make it crop off the mention

earnest phoenix
balmy knoll
#

@quartz kindle @earnest phoenix TypeError: client.setSelfDeaf is not a function Why do i get this error?

earnest phoenix
#

oh

quartz kindle
#

@balmy knoll what did you wrote?

earnest phoenix
#

you said you wrote the function right?

balmy knoll
#

client.setSelfDeaf(); this is supposed to self-defean the bot?

coral stirrup
#

wrong context i think, client does not include setSelfDeaf

balmy knoll
#

voice.setSelfDeaf(true) when the bot joins a voice channel ?

earnest phoenix
#

well there is

coral stirrup
#

if voice represents your voicestate then yeah

earnest phoenix
balmy knoll
#

Ok i try

coral stirrup
#

@earnest phoenix i said client does not includes setSelfDeaf, we were not talking about voicestate

earnest phoenix
#

i never said it was from client lol

coral stirrup
#

so why did you send it in here saying "well there is"?

earnest phoenix
#

there is a function that can self deafan

#

thats what i was trying the say....

coral stirrup
#

yeah but that was never out of question

balmy knoll
#

All works thanks

coral stirrup
#

np

slender thistle
#

In CSS, why does justify-content: center get ignored if I use flex-direction: column; in a flexbox?

coral stirrup
#

maybe no free space? i dont have any code in front of me

quartz kindle
#

do you want to center vertically or horizontally?

slender thistle
#

Horizontally

#

I want columns to be in the center of the page, if that's what you mean

quartz kindle
#

use align-items instead

#

justify-content applies to the main axis, when you use column, the main axis becomes vertical instead of horizontal

#

which causes justify-content to apply vertical centering instead

slender thistle
#

Oh

quartz kindle
#

align-items works on the cross-axis, vertical if row, horizontal if column

slender thistle
#

Huh, that's tricky 😄

#

Yep, it worked. Thanks KyoukoThumbUp

quartz kindle
#

took me a while to understand that too

heavy marsh
#

What is .splashURL()
The invite image?

#

this one?

earnest phoenix
#

yes

#

can bots set users status?

#

like the custom status

#

no

#

bots can have activity

#

but they can't have custom status

#

if you're asking if bots can set someone else's status

#

also no

#

ok

#

get the channel

#

send the message

#

browse the docs to see an example

#

get doesn't take a prop name

#

just the id

#

since it's a collection and you're getting by key

slender wagon
#

is there a better way to get to work a music bot without google api key?

earnest phoenix
#

use something that scrapes youtube

#

e.g. youtube-dl

#

not like the actual string "id"

#

just the numeric id

#

i keep forgetting js has 53bit ints and it's infuriating

pure lion
#

Is there a way to log the server name in the console (for some reason console.log(msg.guild.name) doesn't work)

earnest phoenix
#

depends on if you are doing it on guildCreate event

#

or a message event

sudden geyser
#

.cache.get() takes a string.

earnest phoenix
#

shouldnt it be fetch?

sudden geyser
#

and are you sure the channel will always exist

digital ibex
#

hi, with d.py, how can i get the clients uptime?

#

i've checked the docs but idk if i'm missing it or

slender thistle
#

it's a thing you implement yourself

digital ibex
#

oh

#

how would i do that?

slender thistle
#

Right after creating the client/bot object, create a property uptime (or whatever you want), value of which will be the either timestamp or datetime object

digital ibex
#

ah, ok. ty!

earnest phoenix
clear wraith
#

Someone asked me what they can do to fix an API Error...

earnest phoenix
#

let unbanMember = i know this is a nooby question but how would i get a bannedMember's id?

#

i've tried fetching but random errors like 404

#

i just want an alternative

hardy vector
#

does anyone know if digital ocean has student deals

earnest phoenix
#

github has a student pack

#

for digital ocean

#

promo codes

hardy vector
#

woah github student pack gives you everything

#

amazing

earnest phoenix
#

ikr

hardy vector
#

im going to apply for it but im going to ask my teacher first before i apply bc they require you to submit your school schedule or ID

torn nebula
earnest phoenix
#

i just submitted my school email and got accepted almost instantly

still merlin
#

What is a config.json file used for in d.js

modest maple
#

configs

still merlin
#

ok ty

modest maple
#

You get alot of free shit with Github student tho i doubt many use most of it

#

I dont use any of the hosting stuff but i make use of the free git kraken pro, sql stuff and some others

split hazel
#

and quite a few ask for a credit card

#

i dont wanna put my credit card into sites even if it says it will charge nothing thank you

earnest phoenix
#

uh

#

when you use student credits, they don't?

astral yoke
#

whats a good cooldown time in miliseconds

earnest phoenix
#

what

still merlin
#

Can home educators get student passes on github (asking for a friend)

earnest phoenix
#

no

#

you need to be enrolled in an official school and only students are eligible for the pack

still merlin
#

ok

earnest phoenix
astral yoke
#

for having a command cooldown you use timeout

#

mines 750 and its like it dosent exist

still merlin
#

is there a pass for uni students and home eders

earnest phoenix
#

go look at their site

hoary elm
#

for having a command cooldown you use timeout
@astral yoke cause 750 is pretty much nothing in MS 1000 = 1s

astral yoke
#

ooo

#

ima do 1000 then

earnest phoenix
#

there is no "good cooldown"

#

it all depends on your command influx, what you're doing in the command etc

true ravine
#

If an error is occuring within a module (meaning my catch block doesn't catch anything) how should I handle it?

hoary elm
#

^

earnest phoenix
#

there are too many variables for there to be a "good cooldown"

quartz kindle
#

@true ravine how are you using this module? does it return a promise?

true ravine
#

Yeah it does

quartz kindle
#

how are you catching the promise?

true ravine
#
imgdim = sizeOf('test.png').then(dimensions => {
console.log(dimensions.width)
console.log(dimensions.height)
if(dimensions.width<1){
    reject(err);
  }else{
    resolve(true)
  }
}).catch(err=>{
  reject(err)
})
clear wraith
#
    at RequestHandler.execute (/rbd/pnpm-volume/0edd064e-b617-4b7c-bbcb-437d7187c37d/node_modules/.registry.npmjs.org/discord.js/12.2.0/node_modules/discord.js/src/rest/RequestHandler.js:170:25)
    at processTicksAndRejections (internal/process/task_queues.js:88:5)
(node:3346) 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:3346) [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.```
earnest phoenix
#

docs say nothing

#

yt tutorial is outdated
version for rewrite was never uploaded to youtube

quartz kindle
#

@true ravine is that code inside another promise?

true ravine
#

Yeah it is

quartz kindle
#

show the full promise

slender thistle
#

Was there ever an official tutorial for ytdl in Python, though?

true ravine
#
async function downloadImage(url) {  
    return new Promise((resolve, reject) => {
        const writer = fs.createWriteStream("test.png");

        axios(url,{responseType: 'stream'}).then(response => {            
            response.data.pipe(writer);
            let error = null;
            writer.on('error', err => {
                error = err;
                writer.close();
                reject(err);
            });
            writer.on('close', () => {
                if (!error) {
                    imgdim = sizeOf('test.png').then(dimensions => {
                        console.log(dimensions.width)
                        console.log(dimensions.height)
                        if(dimensions.width<1){
                            reject(err);
                        }else{
                            resolve(true)
                        }
                    }).catch(err=>{
                        reject(err)
                    })
                }
            });
        });
    });
}
quartz kindle
#

and where does the error happen? in sizeOf() ?

true ravine
#

Yeah, and it says unhandled promise rejection there

quartz kindle
#

and how are you using downloadImage()? do you catch it as well?

true ravine
#

No I'm just awaiting it

still merlin
#

anyone know why the code

client.on("message", (message) => {
  let args = message.content.substring(prefix.length).split(" ");
  switch (args[0]) {
    case "uptime":
      message.channel.send("I have been online for") + client.uptime + "!";

      break;
  }
});

comes out as:

true ravine
#

You have some stray brackets

odd swan
#

hey so anyone here who knows python?

still merlin
#

where are the stray brackets?

odd swan
quartz kindle
#

@true ravine you're defining imgdim as a global variable?

true ravine
#

Would that affect it?

quartz kindle
#

your code could be done in a better way, but other than that it looks fine. if the promise rejects, you need to catch the rejection in downloadImage()

steel drum
#

the error stack doesn't even mention the line that invoked this error

quartz kindle
#

so either try{ await downloadImage() } catch() {}
or await downloadImage().catch(() => {})

true ravine
#

Oh okay thank you

#

I was trying to reduce callback hell as much as possible because I need to collect the result of multiple of that function run in a loop

quartz kindle
#

if you want to reduce it further, you can use async/await in sizeOf

#

also, no need for the function to be async, since you're returning a promise, which makes the returned value a promise by default. just make the promise itself async

odd swan
#

anyways ill just share my problem

true ravine
#

Oh okay thanks ^

odd swan
#

im trying to page a help class

hoary elm
#

anyone have any idea what this error is caused by? ERROR: DiscordAPIError: Missing Access

https://discordapp.com/developers/docs/topics/opcodes-and-status-codes doesn't provide much information about this but i could be blind
@steel drum bot is most likely missing access to the channel it is trying to send messages to that's usually what's wrong when I get this error

Discord Developer Portal

Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.

odd swan
#

but i always get the error that 'channel has no bot attribute'

#
        ctx = self.get_destination()
        embed = discord.Embed(title='The Abilities of Jarvis the Bot', colour=0x0000ff)
        description = self.context.bot.description
        embed.set_thumbnail(url='https://cdn.discordapp.com/attachments/706546902446899250/712095658324262922/4mgj2eykdi.png')
        if description:
            embed.description = description
        for cog, commands in mapping.items():
            name = '**__Miscellaneous__**' if cog is None else f'**__{cog.qualified_name}__**'
            filtered = await self.filter_commands(commands, sort=True)
            if filtered:
                value = ' | '.join(c.name for c in commands)
                if cog and cog.description:
                    value = '{0}\n{1}'.format(cog.description, value)
                embed.add_field(name=name, value=value, inline=False)

        await ctx.send(embed=embed)```
#

heres one example

#

i dont have the paging part in this

earnest phoenix
#

@hoary elm can you show us the code?

hoary elm
#

@earnest phoenix wrong tag

#

Not my error

steel drum
#

@hoary elm i have my bot explicitly ignore channels that it doesn't have SEND_MESSAGES in but ill test it around further, thanks!

quartz kindle
#

you can also use async/await in axios

earnest phoenix
#

oh lol misread, sorry GWowoHehe

hoary elm
#

Lol all good

silent berry
#
helium.on("message", async(msg) => {
    let chatmoderators = ['539195184357965833', '550170362248429568', '437019658374348801', '641795527444529152']
   if (msg.author.bot)return;
   if(msg.channel.name !== 'helium-global-chat')return;
   msg.delete()
   

   let e = new Discord.RichEmbed()
            .setTitle("Helium Global Chat")
            .setAuthor(msg.guild.name, msg.guild.iconURL)
            .addField("Message content", msg.content)
            .setColor("RANDOM")
            .setThumbnail(msg.author.avatarURL)
            .setTimestamp()
            .setFooter(`Helium Global Chat System || SECURITY | Guild id: ${msg.guild.id} | msg author id: ${msg.author.id} | code by Airbus A350-1000#0001. thanks to him, this bot will have a functioning global chat.`);

            if(chatmoderators.includes(msg.author.id)){
                e.addField("Sent By", `🛠️ Chat Moderator | **__${msg.author.tag}__**`)
            }else{
                e.addField("Sent By", `**__${msg.author.tag}__**`)
            }
        await Promise.all(helium.channels.filter(c => c.name === 'helium-global-chat').map(c => c.send(e)))

        await Promise.all(helium.channels.filter(c => c.name === 'helium-global-chat').map(c => c.setTopic(`Last message is sent by <@${msg.author.id}>`)))


        gcauthor = msg.author.tag
        gcauthorid = msg.author.id
        gccontent = msg.content
        
        


})
#

error is

(node:194) UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Message
at /home/container/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:85:15
at /home/container/node_modules/snekfetch/src/index.js:215:21
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:194) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:194) [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.
#

discord.js v11.5.1

earnest phoenix
#

did you read error message?

odd swan
#

ok nvm i fixed my problem

#

turns out i needed to use self.context

wheat jolt
#

@silent berry i don't think that error throws because of that event

rare mist
#

Hi im trying to set a custom background to my top.gg bot page
but this in css its not working

body {
  background-image: "blob:https://imgur.com/f57af399-73d7-4b01-8b2d-1ff93b346691" !important;
}```
but if i replace the image with a color it works fine
```css
body {
  background-color: #102030 !important;
}```
silent berry
#

@wheat jolt that error only comes up when typed in global chat

wheat jolt
#

that url isn't good

silent berry
#

then it repeats the said msg over and over

earnest phoenix
#

blobs aren't actually urls

wheat jolt
#

^

#

you need an image

rare mist
wheat jolt
#

url()

quartz kindle
#

thats not how you use background-image

wheat jolt
#

^

rare mist
#

Nice it works, thaks a lot guys!!

wheat jolt
#

np

hardy vector
#

holy shit github developer pack gives you so much

#

aws credit, azure, digital ocean

#

damn

#

courses

#

and more

#

im applying

sudden geyser
#

The only thing I have from the pack are the IDEs from JetBrains

hardy vector
#

dude use everything else lol

sudden geyser
#

too much work

wheat jolt
#

student dev pack?

hardy vector
#

yes for github

#

you get a lot of free stuff

wheat jolt
#

then yes

hardy vector
#

like a lot

wheat jolt
#

no shit

sick cloud
#

i used the domains, nothing else is really great for me

steel drum
#

github studetn pack is great

earnest phoenix
sudden geyser
#

what does not work about it

earnest phoenix
#

i try searching for stuff to tell me how to do it in the rewrite and its really stupid

#

text is too tiny, literally no mic and has a download that you have to pay for to get the code

#

really stupid shit

#

then you don't know how to do research which is a you problem ™️

slender thistle
#

Why are you searching on YT

queen needle
#

im trying to get make a snipe command js client.snipes = new Map() client.snipes.set(message.channel.id,{ content: message.content, author: message.author, }) if(message.content.startsWith(prefix + 'snipe')){ const msg = client.snipes.get(message.channel.id) if(!msg) return message.reply('No recently deleted messages') message.channel.send( new Discord.MessageEmbed() .setAuthor(`Message deleted by ${msg.author.tag}`, msg.author.displayAvatarURL()) .setDescription(msg.content) ) } it should grab the last deleted message but it grabs the last message not the last deleted message

sudden geyser
#

are you declaring that in your message create event

queen needle
#

wdym

earnest phoenix
#

so basically, I'm trying to get my stop command to end my queue, but when I stop It, I get "serverQueue.connection.dispatcher.destroy is not a function"

#

the code is serverQueue.songs = []; serverQueue.connection.dispatcher.destroy('Stop Command Used') const successfullystopped = new Discord.MessageEmbed() .setColor('#58eb34') .setTitle('![sc3](https://cdn.discordapp.com/emojis/705486500602576997.webp?size=128 "sc3") Successfully Stopped and left Voice Channel') return message.channel.send(successfullystopped) } }

#

V12?

#

yes

#

and serverQueue is defined as queue.get(message.guild.id)

#

@slender thistle not searching on yt google is just a shitty company with a shitty search engine

slender thistle
queen needle
#

anyone think they could help me with my snipe command

odd swan
#

cause i need some help with it

mossy vine
#

just post your question

earnest phoenix
#

and he never posted his question.

slender thistle
#

I mean it's the only reliable source in terms of being up-to-date

odd swan
#

ah right

#

sorry

#

anyways i was going to ask how to add two pages to the same class

#

i.e:

#
    async def format_page(self, menu, page, list2):
        embed = discord.Embed(title='Example', colour=0x7f03f1, description=page)
        embed.add_field(name=''.join(value for value in list2), value='​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​', inline=False)
        return embed```
#

im sure you understand what i mean

fiery stream
#

Unable to import 'alpha.exceptions'pylint(import-error) why is it giving me this random error lol

lime cypress
#

gb!help

#

gb!clear 5

#

gb!help moderation

#

:C

#

@vestal spindle

fiery stream
#
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x00000164073EE040>``` guys help
#

@lime cypress i dont think u can execute commands here

#

lol

lime cypress
#

ik

#

i figured that out lol

fiery stream
#

k cool

#

is gigabot your bot?

lime cypress
#

ye

fiery stream
#

nice py or js

lime cypress
#

js

fiery stream
#

nice

lime cypress
#

ye

#

im working on another bot rn

#

a givgeaway bot

fiery stream
#

so am i

#

no giveaway bot tho

#

not*

earnest phoenix
#
(node:30904) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). 
To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 33)
(node:30904) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message``` anyone know why i keep getting this
turbid bough
#

.then() or await

earnest phoenix
#

i honestly wish it could show me where the error is occuring

steel drum
#

@earnest phoenix the bottom says DiscordAPIError: Cannot send an empty message

earnest phoenix
#

i see that

turbid bough
#

or, it says there is a problem, but not where

earnest phoenix
#

literally spamming my terminal

sudden geyser
#

I mean it can with some flags but you may be passing an empty string or object without the correct key/values

fiery stream
#

hey

#

ctx = await super().get_context(message, cls=cls)

#

i get error with get context

#

anyone got idea why?

sudden geyser
#

what's the error

fiery stream
#
 File "c:\Users\Jassm\Desktop\Alpha\alpha\client.py", line 87, in get_context
    ctx = await super().get_context(message, cls=cls)
  File "C:\Python38\lib\site-packages\discord\ext\commands\bot.py", line 865, in get_context
    raise TypeError("Iterable command_prefix or list returned from get_prefix must "
TypeError: Iterable command_prefix or list returned from get_prefix must contain only strings, not dict```
#

so okay i got rid of super()

#

and now i get this error

#
    ctx = await get_context(message, cls=cls)
NameError: name 'get_context' is not defined```
#

@sudden geyser ??

eternal gazelle
#

How long does it even take bot verifing?

astral yoke
#

for what

#

like this server or like discord

cold ivy
#

my bot crashes everytime my computer goes to sleep

fiery stream
#

obviously it wwould

cold ivy
#

says something about networking

#

is there a way to stop that without preventing the computer from sleeping?

amber fractal
#

because when your computer sleeps its network turns off

fiery stream
#

usually when computer goes to sleep majority of stuf gets closed

#

to prevent battery drain

eternal gazelle
#

@astral yoke like bot

sudden geyser
#

Are you using your computer as the actual host or just for local development.

fiery stream
#

me?

sudden geyser
#

no

eternal gazelle
#

Me?

fiery stream
#

and kino u got answer for my situation thing

sudden geyser
#

NameError: name 'get_context' is not defined
This is self-explanatory. get_context is not a variable. I also don't know what super() refers to as in what it's an instance of + I have little knowledge on Python.

fiery stream
#

oh k ig ill figure it out myself

halcyon ember
#

say i have a number like 13221323912838 how do i crop 9 digits off the end of that?

hardy vector
sudden geyser
#

@hardy vector was the command used in a guild.

hardy vector
#

a server?

#

yes

viral spade
#

When i receive a shard's ready event discord.js, can i assume that all guilds (not the members, only the guild list) has been cached completely?

earnest phoenix
#

I get an error when I transfer the files in Glitch to VDS. How can I transfer the modules?

serene night
#

sup guys, i'm working with sequelize and i keep getting this error:```
UnhandledPromiseRejectionWarning: Error: WHERE parameter "user_id" has invalid "undefined" value
at SQLiteQueryGenerator.whereItemQuery (/Users/daydream/Developer/ava/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2184:13)
at /Users/daydream/Developer/ava/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2173:25
at Array.forEach (<anonymous>)
at SQLiteQueryGenerator.whereItemsQuery (/Users/daydream/Developer/ava/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2171:35)
at SQLiteQueryGenerator.getWhereConditions (/Users/daydream/Developer/ava/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2583:19)
at SQLiteQueryGenerator.selectQuery (/Users/daydream/Developer/ava/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1315:28)
at QueryInterface.select (/Users/daydream/Developer/ava/node_modules/sequelize/lib/query-interface.js:1122:27)
at /Users/daydream/Developer/ava/node_modules/sequelize/lib/model.js:1757:34...

#

just for context, this is the code that is having the actual issue: ```js
const target = msg.mentions.members.first() || msg.member
const user = await Users.findOne({ where: { user_id: target.id } }).catch(err => { console.error(chalk.red("[Ava][Error]"), err)})
const items = await user.getItems()

halcyon ember
#

how to get ping in discordjs v12 they removed client.ping

serene night
#

msg.guild.shard.ping?

halcyon ember
#

oh

earnest phoenix
#

help

#

will literally paypal someone $5 if they help in getting my bot back up lool

eternal gazelle
sudden geyser
eternal gazelle
#

okay ty

smoky spire
#

@halcyon ember client.ws.ping

halcyon ember
#

oh

viral spade
#

When i receive a shard's ready event discord.js, can i assume that all guilds have been cached at least so far, that they appear in the guilds.cache collection? How about guildmembers?

smoky spire
#

Members are never all cached at startup unless you specify so in the client options

#

But afaik guilds are always cached

viral spade
#

thx

#

i kno how to broadcast info from the manager to the shards. can i also send info from the shard to the manager, without using something external like ipc?

smoky spire
#

Wdym send info

fiery stream
#

anyone experienced with pymongo?

#

or maybe redis

#

for python

odd swan
#

hey so just one question about dpy

#

in a help class, how do i have the help command be guild only

#

i tried using guild_only in command_attrs, but i couldnt get it to work

fiery stream
#

use elif

#

or else if

turbid flint
#

br e um bando de macaco

viral spade
#

@smoky spire So i can redirect db queries to the manager, who holds a connection pool. So i dont have to close clonnections all the time / keep a connection per shard

smoky spire
#

@viral spade

odd swan
#

nvm i just set up an is instance

viral spade
#

isnt that again manager-> shard direction? i need shard -> manager

#

@smoky spire

smoky spire
viral spade
#

maybe. but with this, how can i trigger a function in the code/process my shardingmanager is in?

#

hmm the last one looks promising

#

so after sending, how can i set up the"onMessage" event in the master to process the message?

smoky spire
viral spade
#

ye i saw this, but then again this is a Shard not the ShardingManager

smoky spire
#

ShardingManager#shards

viral spade
#

So i have to set the event for each shard separately?

smoky spire
#

ig idrk

viral spade
#

well thanks anyways you helped me a lot

fiery stream
#
  File "c:\Users\Jassm\Desktop\Alpha\alpha\client.py", line 87, in get_context
    ctx = await self.get_context(message, cls=cls)
  File "c:\Users\Jassm\Desktop\Alpha\alpha\client.py", line 87, in get_context
    ctx = await self.get_context(message, cls=cls)
  File "c:\Users\Jassm\Desktop\Alpha\alpha\client.py", line 87, in get_context
    ctx = await self.get_context(message, cls=cls)
  [Previous line repeated 984 more times]
RecursionError: maximum recursion depth exceeded```
#

help

turbid bough
#

Stackoverflow

fiery stream
#

i tied that

#

im postponing that for now

#

python is a headache

turbid bough
#

??

#

No, you are getting a stackoverflow error

#

Can you send over the code?

fiery stream
#

k wait up

#
        self, message: discord.Message, *, cls=commands.Context
    ) -> commands.Context:
      
        ctx = await super().get_context(message, cls=cls)

        if ctx.command:
            ctx._ = functools.partial(
                cog=ctx.command.cog_name,
            )

        return ctx``` @turbid bough
fiery stream
#

TypeError: Iterable command_prefix or list returned from get_prefix must contain only strings, not dict thats the error now

astral yoke
#

How would I make a warn command with quick.db? I know the database code like db.get db.set db.fetch but how would you make it so it would make multiples instead of just going on top of the first one for a warn command that shows the persons warns?

for 11.6.1

fast trench
#

if cashBal and addedCash are both numbers shouldn't it add it together? right now it just puts it like cashBalladdedCash instead of actually adding the 2 numbers together...const newCash = cashBal + addedcash; it works on another command...

#

so say if both are 1 it puts it as 11 and not 2

#

it works if one of them is an actual number...

#

nvm it started working randomly 🤷‍♂️

pale vessel
#

use parseInt()

fast trench
#

nope...not how I fixed it

digital lake
#

-p adios amor christain

#

Bruh

balmy knoll
#

My bot's offline, but I can't figure out why. I'm not getting any console errors.

smoky spire
#

Did you turn it on

balmy knoll
#

@smoky spire Yes, at the moment, it is on glitch

earnest phoenix
#

lol

smoky spire
#

Glitch isn't a 24/7 host, it goes down regularly

torn nebula
#

you can use uptimerobot to host 24/7

earnest phoenix
#

or actually get a proper host

honest perch
#

uptime robot isnt a host

#

its for calculating downtimes by pinging a website

balmy knoll
#

@torn nebula Yes i use uptimerobot to ping the code every 5 minutes, but the bot is always offline

honest perch
#

does uptime robot say its offline

balmy knoll
#

No for uptime robot it's online

#

And I'm not getting any console errors on Glitch

honest perch
#

if you type in refresh in the console?

balmy knoll
#

Nothing happens

honest perch
#

what about curl -I https://discordapp.com/api/v7/gateway

#

screenshot the results

balmy knoll
honest perch
#

you have been ratelimited

balmy knoll
#

@honest perch So what am I supposed to do?

honest perch
#

it tells you what to do in the threa

#

thread

copper cradle
#

you're supposed to read

molten coral
#

hi

#

Hi have a little problem

#

(and I don't speak english very well)

winter basalt
#

just give your question, no need to have permission to ask

molten coral
#

oh thx

#

It's a noob's problem sry °-°" : I would like to add an object in a json file (data of my bot).
But my code actually overwrite my existing code (sry again for bad english).
Here my code ^^ : ```js
const fs = require('fs');

let rawdata = fs.readFileSync('data.json');
let dataBot = JSON.parse(rawdata);
console.log(dataBot);

let newserver = {
name: "Server's name",
serverbotprefix: "!",
cmdchannel: '(ex)645644648984796489964',
langage: 'English',
};

let data = JSON.stringify(newserver, null, 2);
fs.writeFileSync('data.json', data);

Thx for helping ^^
tight plinth
#

dont use json as bot db

#

its a bad idea

molten coral
#

ow, it's a friend said to use a json file

modest maple
#

then your friend is an idiot

molten coral
#

ow o_o"

#

why ? it's not good ?

pale vessel
#

no

molten coral
#

oh

quartz kindle
#

i mean, nothing wrong using json, but json has a lot of problems you will need to develop solutions for, while proper databases already do it for you

molten coral
#

._.

#

so what should i do?

quartz kindle
#

if you want to keep using json, the reason your code is not working is that json can only be processed the entire file at a time, so you need to read the entire file, change the entire file and save the entire file.
otherwise try learning how to use a database like SQLite

molten coral
#

thx I'll learn how it's work ^-^

balmy knoll
#

Why can't i install the heroku package on my project?

npm ERR! path /app/node_modules/tar/node_modules/.bin/mkdirp
npm ERR! code EEXIST
npm ERR! Refusing to delete /app/node_modules/tar/node_modules/.bin/mkdirp: ../../../../../../mkdirp/1.0.4/node_modules/mkdirp/bin/cmd.js symlink target is not controlled by npm /app/node_modules/tar/node_modules/mkdirp
npm ERR! File exists: /app/node_modules/tar/node_modules/.bin/mkdirp
npm ERR! Move it away, and try again.

npm ERR! A complete log of this run can be found in:
npm ERR!     /tmp/npm-cache/12.0.0/_logs/2020-05-20T09_48_07_160Z-debug.log
quartz kindle
#

what package? what are you trying to install?

balmy knoll
#

@quartz kindle npm i heroku

quartz kindle
#

??

#

heroku is not a package?

tight plinth
quartz kindle
#

or what?

tight plinth
#

learn how to read errors

#

idfk about heroku package

quartz kindle
#

is your bot in heroku?

tight plinth
quartz kindle
#

hosted in heroku?

tight plinth
#

it exists

earnest phoenix
#

How to get existing express app from dblapi.js

balmy knoll
#

@quartz kindle Now i try to export my project form Glitch to GitHub, then i try to host the project with heroku

quartz kindle
#

@earnest phoenix webhookServer: server

#

where server is your express.js server instance

earnest phoenix
#

wdym?

#

webhook server?

quartz kindle
#

in your dblapi.js webhook options, there is a webhookServer option

#

if you're trying to add an existing server to dblapi

earnest phoenix
#

okie i will see documentation

quartz kindle
#

@balmy knoll is there a reason you want to install the heroku package? you dont need it

earnest phoenix
#

Got it

mossy vine
#

did you just post your token

slender thistle
#

@balmy knoll If that token is valid, please regenerate it immediately

balmy knoll
#

@slender thistle My error in paste the token

#

Sorry

#

@quartz kindle I wanted to install heroku directly on glitch without going through github. But I can't install heroku on glitch.

quartz kindle
#

thats not how it works

solid falcon
#

Hello guys, I want to make a game that can PvP, but I don't know to build a matchmaking, can someone help me? I'm using discord.py

quartz kindle
#

heroku is a hosting service, a competitor of glitch

earnest phoenix
quartz kindle
#

the heroku package is simply a tool to communicate with the heroku server

#

it doesnt do anything else

#

if you want to move to heroku, you need to create a heroku account and project, and upload your bot there

earnest phoenix
#

whats wrong?

quartz kindle
#

remove webhookPort since webhookServer replaces it

earnest phoenix
#

k

quartz kindle
#

how do you start your express server?

#

app.listen(process.env.PORT)?

earnest phoenix
#

lol

#

Wiat Yes

quartz kindle
#

express doesnt start automatically

earnest phoenix
#

app.listen(process.env.PORT)

#

this

quartz kindle
#

then do this

#
const server = app.listen(process.env.PORT)

....
webhookServer: server
earnest phoenix
#

ook

#

errors fixed

#

Thx

solid falcon
balmy knoll
#

Error: FFmpeg/avconv not found! How can i fix this error? If i host on Glitch, i haven't any error, while on heroku, i get this error

haughty night
#

Go to settings and then add buildpacks

#

Should work

void bane
#

Hello, I forgot to add some administrative commands to the bot, can I work on the bot because I added it to a top.gg

haughty night
#

You can

winter basalt
#

of course you can

void bane
#

Okay thanks

winter basalt
#

the emote is flashy

void bane
#

Heart this is goed?

winter basalt
#

👍

void bane
balmy knoll
#

@haughty night I try | Edit: All work, thanks

haughty night
#

Np

earnest phoenix
#
              .addField("Nickname", `${target.nickname !== null ? `${target.nickname}` : " None"}`, true)

why at nickname it says undefined?

wheat jolt
#

because it's undefined?

earnest phoenix
#

in v11 it worked :/

zenith terrace
#

u in v12 then?

earnest phoenix
#

yes

wheat jolt
#

you should do !target.nickname ?

earnest phoenix
#

i tried

#

same thing

lean warren
#

hey 🙂

quartz kindle
#

just do target.nickname || "None"

wheat jolt
#

^

earnest phoenix
#

ok

#

and one more thing

#
const verlvl = {
        0: "None",
        1: "Low",
        2: "Medium",
        3: "Hard",
        4: "Epic"
    }


        .addField("Nivel Securitate", verlvl[message.guild.verificationLevel], true)
#

at security level it says undefined aswell

wheat jolt
#

Guild#verificationLevel is a string

#

not an int

earnest phoenix
#

oh

#

ok ty

wheat jolt
#

np

zenith terrace
#

@earnest phoenix did u sort out the nickname?

earnest phoenix
#

@zenith terrace yes

zenith terrace
#

alright

#

funny cause I have
.addField("Nickname", `${member.nickname !== null ? `Nickname: ${member.nickname}` : + "None"}`, true) and it works fine lol

#

.addField("Nickname", `${target.nickname !== null ? `${target.nickname}` : " None"}`, true)

Oh you didnt have the + after the : thats why lol

earnest phoenix
#

Hello I'm looking for someone who could help me? Dm me

honest perch
#

what do you need help with?

earnest phoenix
#

I'm looking for code to learn because I'm starting

#

don't ask to ask - just ask your question

honest perch
#

just google language_name course

earnest phoenix
#

Ok thank you I'll try

#

i'd personally recommend codecademy if you're willing to spend a few bucks or your school has a partnership with them

#

No thanks I'm already paying for my minecraft server

balmy knoll
#

At the moment I entered my project on github and then I host it with Heroku. The problem is mainly one: restarting heroku or updating the code, the json files in which save some data are reset. How can I fix it? Maybe save the contents of the json file before making changes?

earnest phoenix
#

don't use heroku or glitch

pale vessel
#

heroku has ephemeral filesystem

#

it'll reset every time the dyno restart

#

if you have no other option, use a remote database

#

otherwise don't use heroku or glitch

balmy knoll
#

@pale vessel Remote database like?

pale vessel
#

mysql postgres

earnest phoenix
#

I'm really a noob in code I would like to know if you know and mp me so I learn please

#

no one is going to teach you for free

#

Ha damage

winter basalt
#

see youtube

earnest phoenix
#

huh?

pale vessel
#

no

winter basalt
#

or google

earnest phoenix
#

Ps: I'm on Android

pale vessel
#

youtube is not an option

earnest phoenix
#

I don't have a computer.

winter basalt
#

thats sad

earnest phoenix
#

uh, if you want to do anything related to CS (programming etc.) you need some form of a pc

#

Ha it's problematic

#

indeed it is

#

phones cannot be used as development machines

#

Yes I suspected it

#

firstly because they're too weak, and second because ARM

winter basalt
#

you can learn before getting a computer but that doesnt feel right

#

lul

earnest phoenix
#

Yes indeed

turbid bough
#

@earnest phoenix actually, it could work like this:

const verlvl = {
    "None": 0,
    "Low": 1,
    "Medium": 2,
    "Hard": 3,
    "Epic": 4
}```
#

oh wait, nvm

zenith terrace
#

firstly because they're too weak, and second because ARM
@earnest phoenix arm LULUL

wild mist
#

How do i get channel youtube name using ytdl-core?

pale vessel
#

get stats or whatever it's called

#

read their docs

wild mist
#

No channel name there

quartz kindle
#

check the author field

wild mist
#

[object object]

quartz kindle
#

if you're sending it as a message, you need to serialize it

#

JSON.stringify(video.author)

wild mist
#

K it worked i just need to make it as normal not JSON

#

K thanks for helping

sudden geyser
#

and second because ARM
What makes ARM contribute to not being able to develop on mobile?

earnest phoenix
#
bUser.hasPermission is not a function

code:


let bUser = message.mentions.users.first();
if(!bUser.hasPermission("MANAGE_MESSAGES")) return message.channel.send(":no_entry_sign: **Nu pot bana un moderator!**");
sudden geyser
#

bUser is an instance of User. You're looking for an instance of GuildMember

#

If you look in the docs about message.mentions, you can replace .users for .members

earnest phoenix
#

oh, ok

#

@sudden geyser can i use const bUser = getUserFromMention(args[0]); instead?

sudden geyser
#

I don't know what getUserFromMention does or is supposed to do.

#

Try it out and see.

earnest phoenix
#

ok

zenith terrace
#

@earnest phoenix v11 or 12

earnest phoenix
#

v12

zenith terrace
#

Its not .hasPermission anymore in v12

#

Its permissions.has I believe

#

Lemme check here

sudden geyser
#

hasPermission is still a method.

earnest phoenix
#

.hasPermission still works on some of my commands like kick/mute/addrole etc but idk why at my ban command it don't work

zenith terrace
#

Ah

earnest phoenix
#

sorry for my language, i'm in hurry 🙂

zenith terrace
#

I think I was looking at role permission this whole tine

#

Time*

royal portal
#

for some reason I'm getting cannot send an empty message

#
    if(msg.content.startsWith('test')) {
        try {
            get('https://blox.dev/embed.html').then(res => {
                msg.channel.send(res.body)
            });
        } catch(err) {
            return msg.channel.send(err.stack);
        }
    }
});
sudden geyser
#

You should await get if it returns a promise.

pale vessel
#

you need to await the body

sudden geyser
#

To go along with that, what is body supposed to be?

pale vessel
#

what package are you using?

royal portal
#

snekfetch

pale vessel
#

uh

earnest phoenix
#

isn't snekfetch kinda ded

pale vessel
#

bruh

#

yes

#

deprecated

sudden geyser
#

You should use a package that's not deprecated

#

Like node-fetch

pale vessel
#

or axios

royal portal
#

ok i installed node-fetch

sudden geyser
#

alright now read the docs for an example http request

royal portal
#

get is not a function

pale vessel
#
const res = await fetch(url);
const body = await res.text();```
#

that's an example

#

you can provide options after the url if you need to

#

e.g. method and headers

#

make sure to handle errors

royal portal
#

hm

pale vessel
#

hmm?

royal portal
#

get is not defined

pale vessel
#

what are you doing

#

i gave you an example

royal portal
#

i mean

#

its not a function

pale vessel
#

there's docs too

#

there's nothing that says "get" in the example either

#

good luck dude

earnest phoenix
#
  let muterole = message.guild.roles.cache.find(role => role.name === "Muted");
  let tomute = message.mentions.users.first();

await(tomute.addRole(muterole.id));

Cannot read property 'id' of undefined

pale vessel
#

muterole is undefined

#

there's no role called Muted

earnest phoenix
#
if(!muterole){
    try{
      muterole = await message.guild.createRole({
        name: "Muted",
        color: "#000000",
        permissions:[]
      })
      message.guild.channels.forEach(async (channel, id) => {
        await channel.overwritePermissions(muterole, {
          SEND_MESSAGES: false,
          ADD_REACTIONS: false
        });
      });
    }catch(e){
      console.log(e.stack);
    }
  }
#

i forgit this

#

=))

#

forgot*

pale vessel
#

isn't it roles.create ?

#

v12

earnest phoenix
#

idk, i just updated to v12

pale vessel
#

read docs

#

instead of "idk"

earnest phoenix
#

link please?

pale vessel
#

oh my god