#development

1 messages · Page 791 of 1

earnest phoenix
#

run what command

torn nebula
#

node -v

earnest phoenix
#

ty

torn nebula
#

node .

neat ingot
#

see im confuzed, cause if npm install worked, why didnt node command?

#

and if node -v works, why not node file.js

earnest phoenix
#

I LOVE YOU

mossy vine
#

code errors?

earnest phoenix
#

ILY ILY ILY!!!!

neat ingot
#

lmao

earnest phoenix
#

ILY

#

SMOOCHES

#

NO HOMO

neat ingot
#

WLU2

#

ALLHOMO<3

earnest phoenix
#

full no homo

neat ingot
#

lol

earnest phoenix
#

final offer

neat ingot
#

ok i take ❤️

earnest phoenix
#

:>

#

:))))

#

ty

#

okay

neat ingot
#

gl with your bot dude 🙂

earnest phoenix
#

now how do i do anything with this xd

#

ty

#

good luck with whatever your making

neat ingot
earnest phoenix
#

what is that.

neat ingot
#

pretty much the only refeerence you will need

earnest phoenix
#

ohh hell no

neat ingot
#

it documents all discord js functions and features

earnest phoenix
#

im going BIG

#

dekita

neat ingot
#

yo

earnest phoenix
#

how long does it take to code a bot?

neat ingot
#

idk, ive been programming mine since late december. other members from here ive spoken to are 3+ years

#

but their bots are live and in production

earnest phoenix
#

zoink

#

im just

#

uhm

#

yikes

neat ingot
#

my bot hasnt even passed approval process yet lol

earnest phoenix
#

wdym approval?

neat ingot
#

tbf, i only submitted it yesterday

earnest phoenix
#

ohh

#

im making a bot that will pm you every 30 mins with alot of stock market stats

neat ingot
#

ooohhhh

#

interesting

torn nebula
earnest phoenix
#

oop

#

sorry

#

<3 sai

neat ingot
#

i think you should make pm optional though, and have a command to check the info at will 🙂

earnest phoenix
#

yea

#

talk in dms?

neat ingot
#

sure

pulsar lantern
#

That's not gonna work, due to rate limits lmao

#

Unless you do it with just a few ppl

violet nimbus
#

When I am trying to post server count it says 400 error


at IncomingMessage.res.on (/rbd/pnpm-volume/256ccade-fb85-42e6-882f-cd3dd81f765c/node_modules/.registry.npmjs.org/dblapi.js/2.3.1/node_modules/dblapi.js/src/index.js:118:25)2:57 PM

at IncomingMessage.emit (events.js:194:15)2:57 PM

at endReadableNT (_stream_readable.js:1125:12)2:57 PM

at process._tickCallback (internal/process/next_tick.js:63:19)2:57 PM

2:57 PM

(node:1697) 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)2:57 PM

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

quartz kindle
#

are you using discord.js v12?

tight plinth
#

@violet nimbus

violet nimbus
#

@tight plinth yeah

#

@quartz kindle it's 11.5.1

quartz kindle
#

@violet nimbus how are you using the library? show your code

earnest phoenix
#

Anybody know what this means or how to prevent it? I don't have the code for the bot as I am asking for somebody else.
Python is the langauge used
concurrent.futures._base.TimeoutError

slender thistle
#

Full traceback could help more

earnest phoenix
#

?

#

I don't have the code and that's all the info the bot's owner gave.

#

You there?

amber fractal
#

Then ask them for a stacktrace

earnest phoenix
#

I'm trying

wicked pivot
#

is it possible to know how many messages a user has written?

earnest phoenix
#

bots can't access that endpoint

slender thistle
#

Bots can't fetch that information directly

safe kayak
#

Which apk gor pc is best to create a bot

earnest phoenix
#

so no, not without repeatedly getting messages until the channel creation which is considered api abuse

slender thistle
#

Alright this got weird in a moment

#

There's no "apk" for PC to create a bot

#

A bot is code running under a bot account

safe kayak
#

I mean’d how ? Where

safe kayak
#

@earnest phoenix where i have to do !

earnest phoenix
#

Make the code?

safe kayak
#

Yes

earnest phoenix
#

Well first of all what programming langauge do you want to use?

copper cradle
#

Learn something, there are hundreds of programming langs out there which you can easily learn

#

I recommend python since it's a high level lang

earnest phoenix
#

top level? Thonk

slender thistle
#

high-level

copper cradle
#

Ah yes

#

Thanks for correcting me shiv

safe kayak
#

Example visual studio code @earnest phoenix

copper cradle
#

U just need a text editor

#

and there are hundreds

#

Vs code is a nice option

safe kayak
#

I don’t have a lot of info i wanna learn

copper cradle
#

You can learn online for free or get a paid course

safe kayak
#

What is your opinion

copper cradle
#

🤷‍♂️

safe kayak
#

Thank you a lot

copper cradle
#

Np

earnest phoenix
#

that's all the info the bot owner is willing to provide

ember cloud
#

Yeh

#

Nothing else

earnest phoenix
#

Where did everybody go?

ember cloud
#

Home

#

🤣😊

static lynx
#

hard to fix an error with no code 🤷‍♂️

quartz kindle
#

@earnest phoenix can you explain the situation a bit more? like, who is the bot owner, and who programmed the bot?

#

and where is the bot running?

earnest phoenix
#

hold on

static lynx
#

why does that matter 🥺

earnest phoenix
#

Because the bot owner only provided that link

static lynx
#

tell him to provide more

earnest phoenix
#

@frank wyvern Is the owner

static lynx
#

i get it that it’s a failed api request?

quartz kindle
#

this is an issue the programmer of the bot should solve, or whoever is responsible for maintaining the bot's code

static lynx
#

or ask stack overflow😳

quartz kindle
#

yeah but stackoverflow wont help if he isnt the one who coded it

wicked pivot
amber fractal
#

Your libs docs probably.

summer torrent
#

@wicked pivot which lib do you use?

wicked pivot
#

discordjs

summer torrent
#

(master)

#

use a database

#

when user created a new request save it to database

sinful belfry
#

mongodb is pretty easy to use

summer torrent
#

^

sinful belfry
#

i did sorta the same thing with my bot

summer torrent
#

or enmap

sinful belfry
#

sure

summer torrent
wicked pivot
#

@summer torrent master ?

summer torrent
#

discord.js v12

wicked pivot
#

sad

summer torrent
#

v11 has no method about nitro

wicked pivot
#

I am in version 11.5.1 sad

copper cradle
#

I mean

sinful belfry
#

is there a way to send a custom emoji from only having the emoji name or id?

#

w/ discord.js

wicked pivot
#
\:emojiname:```
slender thistle
#

<:name:id>

wicked pivot
#

the bot must be on the server where there is the custom emoji

sinful belfry
#

oh damn yeah ty

#

yeah thanks

summer torrent
#
message.channel.send(client.emojis.find(a => a.name === "emoji name"))```
sinful belfry
#

thank you

safe kayak
#

@open frost

lusty quest
#
for(x in array) {
    const log = bot.players.get(guildid,array[x])
data.push(log)

}``` I generate Unix timestamps for in the command set past x days. after this i want to retrive logs from the x days from an enmap database. the timestamps i push into an array but for some reason i cant get any data back from the database. (i use the unix timestamp as key)
late hill
#

what is array

lusty quest
#

an array of the Unix timestamps

#

var d = new Date();
d.setDate(d.getDate() - i);
d.setHours(0, 0, 0, 0);
day = d/1000
array.push(day)
    i++;
  };

  console.log(array)

let x
for(x in array) {
    const log = bot.players.get(guildid,array[x])
data.push(log)

}    ```
late hill
#

your 2nd parameter signifies a property to get from the object

#

Did you put the timestamp as a property

#

How did you save this data to your enmap

lusty quest
#

the guild.id is set above this code with const guildid = message.guild.id

late hill
#

yes

#

but what does bot.players.get(guildid) look like

#

the full thing

lusty quest
#

how i set the data in the database?

late hill
#

yes

lusty quest
#
    bot.guilds.forEach(guild => {
        
       date= Math.floor(new Date().setHours(0,0,0,0) / 1000)

    var members = guild.memberCount
  
console.log(members)
    bot.players.set(guild.id,members,date)

})    
}``` gets called by an timeout every day at a set time
late hill
#

I don't think that works the way you think it does

lusty quest
#

when i run it manually without the loop for getting data is works

late hill
#

You should try logging bot.players.get(guildid)

#

and see what it actually looks like

#

idk enmaps are weird

lusty quest
#

i dont want to retrive every log in the enmap just the last few.

late hill
#

It's basically just an extended map

#

You're mapping certain objects to guild id's

#

In the code up above you're attempting to fetch one of those objects and get it's "timestamp_here" property

#

I'm questioning if that property exists to begin with

lusty quest
#

its set as key for the log for the day.

#

when i run just get(guildid) i get back an array of the timestamps and the log attached to it

late hill
#

Maybe that's the issue

#

If it's an array of them you probably won't be able to use the actual timestamp the way you did

#

Because it's likely using that timestamp as an index on the array instead

vale python
#

hello

#

im losing my sanity please help me

#

I have a currency bot every command works but leaderboard doesnt work

#

doesn't give any error

#
const db = require('quick.db')

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


    let money = db.startsWith(`money_${message.guild.id}`, { sort: '.data'})
    let content = "";

    for (let i = 0; i < money.length; i++) {
        let user = bot.users.get(money[i].ID.split('_')[2]).username

        content += `${i+1}. ${user} ~ ${money[i].data}$\n`
    }

    const embed = new Discord.RichEmbed()
    .setAuthor(`${message.guild.name} - Leaderboard!`, message.guild.iconURL)
    .setDescription(content)
    .setColor(0x51267)

    message.channel.send(embed)




}```
tight yacht
#

Jw if there is a way to change to emote used to claim kakera. I am color blind and the purple and blue mess me up all the time.

lusty quest
#

@late hill i use the same way to get my per server config. and this works. the only difference here is that i have a unix timestamp instead of a name

late hill
#

It's also an array?

#

If you literally just saved an array of timestamps on it, there's pretty much nothing you can get from that

#

The same thing would happen if you just saved an array of names

#

you'd need some kind of key-value pair

lusty quest
#

yea just realized it. but i think im already know a solution

late hill
#

from an object instead of an array

quartz kindle
#

@tight yacht i think you're in the wrong server

tight yacht
#

Damn it

#

Lol

analog walrus
#

Btw, anyone knows why mysql keeps returning error timeout?

slender thistle
#

inb4 server not running

analog walrus
#

Whenever I try to make query and/or connect

#

Server is online always

#

It works for local databases

#

But for external databases, one hosted elsewhere, it does not...

slender thistle
#

Connection credentials wrong? uwaa

analog walrus
#

Nope

#

I checked it all

slender thistle
pulsar lantern
#

@vale python what exactly doesn't work in that code? What does the command do?

analog walrus
#

And since in the topic of mysql, anyone knows why "new PDO" causes 503 error?

#

^^php

#

The one before that is nodejs

wicked pivot
#

since a few days my " setThumbnail "is no longer displayed

earnest phoenix
#

you don't provide a proper image url to it then

wicked pivot
#

before it worked

#
.setThumbnail(`${user.displayAvatarURL}`)```
earnest phoenix
#

discord is having a moment rn though

#

thumbnails arent showing up on embeds at all

wicked pivot
#

so it doesn't come from us?

#

must we wait for discord to fix this?

earnest phoenix
#

you still need to provide a proper url for it if you dont but yes

#

gotta wait for discord sadFelyne

quartz kindle
#

discord devs must be like "sigh... not again" every single week lol

earnest phoenix
#

their infrastructure is probably so badly designed

#

and the recent additions for the past few months are... well, shit

quartz kindle
#

non-planned additions are always a pain to add

#

you gotta hack stuff into your code, and slowly it becomes a big ass mess

#

half of discord's features were probably never planned

peak bloom
#

i doubt it's that badly designed when it supports 25bn messages per month from 10m concurrent users

amber fractal
#

Tfw they disable events but it's still garbage

peak bloom
#

my head would explode trying to optimize for even a tiny fraction of that workload lol

slender thistle
#

When padding-bottom in CSS decides to go from right nekoHmph

quartz kindle
#

css = microsoft word

earnest phoenix
#

i doubt it's that badly designed when it supports 25bn messages per month from 10m concurrent users
so does messenger or viber but they don't have issues literally every single week

quartz kindle
#

change one thing and the entire page gets broken

slender thistle
#

Nah MS Word isn't that fucked in my cases

#

It's HTML/CSS that always screws me over

#

Why did it move to the right what

quartz kindle
#

that means you know how to use ms word correctly xD

slender thistle
#

😂

quartz kindle
#

so many people dont know how to take images out of the text flow

#

or that you can even do that in ms word

slender thistle
hoary elm
#

Quick question using Discord.JS I know the fucntion but for some reason it just doesn't want to come to me I am making a welcome message for when a user joins the server so I am using the guildMemberAdd event but I want it to return if the user is a bot I thought if(member.user.bot) return would work but no luck

#

Also no errors just doesn't work as expected honestly doesn't work at all

quartz kindle
#

it should work

hoary elm
#

Yeah that's what I thought

quartz kindle
#

can you console.log(member) or console.log(member.user)?

hoary elm
#

It will console log them but it still sends out the welcome message for some reason

quartz kindle
#

can you show your code?

hoary elm
#

Of course

#

One sec

#

I also use discord.js 11.5.1 don't know if that matters any but 🤷🏻‍♂️

quartz kindle
#

do you have any other onMemberAdd event? any other instance of the bot?

hoary elm
#

No just that one and this is the only instance of the bot for now still a pretty fresh bot so

quartz kindle
#

what does console.log(member.user.bot) return?

hoary elm
#

member is not defined

#

Which honestly makes no sense

rough current
#

Someone write on python?

modest maple
#

yes

hoary elm
#

There is lots of people here whobuse python it's a pretty popular language

rough current
slender thistle
#

sup

west spoke
#

just say "python" and shivaco will pop in

hoary elm
#

Lol

rough current
#

In docs bad example

amber fractal
modest maple
#

https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.wait_for

Waiting for a user to reply:

@client.event
async def on_message(message):
    if message.content.startswith('$greet'):
        channel = message.channel
        await channel.send('Say hello!')

        def check(m):
            return m.content == 'hello' and m.channel == channel

        msg = await client.wait_for('message', check=check)
        await channel.send('Hello {.author}!'.format(msg))```


Waiting for user to add a reaction

```py
@client.event
async def on_message(message):
    if message.content.startswith('$thumb'):
        channel = message.channel
        await channel.send('Send me that 👍 reaction, mate')

        def check(reaction, user):
            return user == message.author and str(reaction.emoji) == '👍'

        try:
            reaction, user = await client.wait_for('reaction_add', timeout=60.0, check=check)
        except asyncio.TimeoutError:
            await channel.send('👎')
        else:
            await channel.send('👍')```
#

sigh

rough current
#

He have only one emoji

slender thistle
#

Можешь уточнить, в чём конкретно состоит проблема?

rough current
#

Ты русский?

#

Преводчик

slender thistle
#

От части

rough current
#

Понял

#

НУ кароче

#

Мне надо чтобы бот тригерился на пару реакций

#

И мог выбирать на какую именно нажали

#

Например 👎 и 👍

quartz kindle
#

@hoary elm if the guildMemberAdd event is firing an empty member object then something is very wrong lol

hoary elm
#

Yeah that's why I said it makes no sense since to my knowledge member should be defined in that event

slender thistle
#

Ок, а ты как хочешь реализовать? Когда бот должен ожидать этих реакций?

rough current
#

Например команда хелп

quartz kindle
#

try adding this ```js
client.on("raw", r => {
if(r.t === "GUILD_MEMBER_ADD") { console.log(r); }
})

rough current
#

И бот нашет какую реакцию нужно для какой категории

#

И пользователь уже выбирает что ему смотреть

#

Ну мне нужна только помощь в реакциях

#

Чтобы мог смотреть какую именно нажали

hoary elm
#

Ok I'll add that and see what happens..

slender thistle
#

в параметре check для функции wait_for просто уточни message.channel == m.content и возможно ещё добавить message.author == m.author

rough current
#

Я уже пробывал

#

Ничего выдает

slender thistle
#

А, извиняюсь, я немного перепутал сами события

rough current
#

Ага

#

Ты мне за месейдж

#

Пояснил

stable horizon
#

Help it's in elvish

slender thistle
#
        def check(reaction, user):
            return user == message.author and reaction.message.channel == message.channel and reaction.emoji in [лист нужных тебе реакций]

        reaction, user = await client.wait_for('reaction_add', check = check)
        if reaction == реакция_1:
          # код1
        if reaction == реакция_2:
          # код2
quartz kindle
#

no its vodka

slender thistle
#

Тебе нужно убедиться, что на сообщение реакцию ставит именно тот пользователь, который использовал команду и то, что реакция была произведена в том же канале

#

и сразу проверяешь мол реакция из нужных

#

Надеюсь код примерно понятен nekohmm

rough current
#

Полностью понятен

rough current
#

@slender thistle, thx SOO much

slender thistle
#

👍

quartz kindle
#

with what?

vague kite
#

How would I create a voice channel??

#

I tried message.guild.createChannel(....) but it keeps saying createChannel isn't a function

torn quartz
#

Whats your discord version

vague kite
#

Newest one

#

Packages is set to: github:discordjs/discord.js

#
      message.guild.createChannel(
            "Test",
            'voice',
            {
                overwrites: "",
                reason: 'New temp channel'
            }
        );
      return message.channel.send("Channel Create!")

This is the current code I'm trying to use

zenith orchid
#

@vague kite

vague kite
#

Yeah what's up??

zenith orchid
#

createChannel({type:"voice"})

vague kite
#

I still get the same error

zenith orchid
#

Aaa

#

V12

#

message.guild.channels.create("some name", {type: "voice"})

vague kite
#

Ahh okay thank you ❤️

zenith orchid
vague kite
#

Ohh that's actually so helpful idk when V12 came out but I just updated everything in the bot took me so long to find out most of it is using .cache to get stuff now

#

Thanks that'll help a lot with everything ❤️

quartz kindle
#

technically v12 didnt come out yet

analog walrus
#

👀

#

Github

tight plinth
#

Technically v12 comes out (kinda)

quartz kindle
#

it still an in-development version, althought its been in development for many years now and many people use it even with breaking changes happening often

tight plinth
#

Every bot dev g'can get it

earnest phoenix
#

Okay

#

How made cored embed for site

#

This aqua

zenith orchid
#

Meta tags

earnest phoenix
#

Ammm sorry

#

I am stupid

#

What this

#

@zenith orchid

#

<meta color>?

zenith orchid
earnest phoenix
#

<meta color>?

#

For colored embed

#

I need meat color

#

Or what

#

@zenith orchid

#

Not working

zenith orchid
#

@earnest phoenix

earnest phoenix
#

?

zenith orchid
blissful scaffold
#

theme-color is for the color

zenith orchid
#

I guess this is what you are looking for

earnest phoenix
#

Amm

zenith orchid
#

Not worked

earnest phoenix
#

Wait

zenith orchid
#

Not worked
@zenith orchid

earnest phoenix
#

Oooo

modest maple
#

my good man

earnest phoenix
modest maple
#

have you heard of this thing

#

caled

#

HASTEBIN

earnest phoenix
#

?

#

No

modest maple
#

use it

#

looking at the screenshot makes my eyes bleed

earnest phoenix
#

Mmm

slender thistle
#

It's definitely better than not being able to open pastebin when someone posted their traceback there

blissful scaffold
#

I think there is a 30 minute cache, so after you edit it it can take 30 minutes before you see the change

earnest phoenix
#

Okay

#

I wait

blissful scaffold
#

also for an image you need <meta name="og:image" content="image url here">
you can remove the other image tags

earnest phoenix
#

Wow

#

Wow

zenith orchid
#

I think if you wait for clear cache, its worked.

earnest phoenix
#

Yes

#

Thanks

#

<3

#

@zenith orchid

zenith orchid
#

Yes?

vague kite
#

Okay one last question how would I edit the channels permissions as I create the bot??

quartz kindle
#

as you create the bot? you mean when your bot joins a guild?

vague kite
#

Create the bot

muted vortex
mossy vine
#

npm install

quartz kindle
#

thats not an error

#

it says it installed successfully

mossy vine
#

why would you run node-fetch install wtf

muted vortex
#

I mean the WARN bits

mossy vine
#

ignore them

muted vortex
#

because the first WARN says to use node-fetch

mossy vine
#

you can mostly ignore the WARNs

quartz kindle
#

the warn is not for you

muted vortex
#

do I need to deal with the "requires a peer" WARN bit?

mossy vine
#

no

quartz kindle
#

its discord.js v11 that uses a deprecated library, thats what the warning is for

muted vortex
#

ok then

quartz kindle
#

peer dependencies are optional

#

and uws is not recommended

#

its known to cause a lot of issues

muted vortex
#

funny I have trouble with this bit but I'll be able to understand the actual coding. 😜

viral spade
#

Hello, i have a question about sharding..

Assume i have 2 different bots, both sharded and with the same amount of shards. BUT with completely random servers that invited them. Although its random, some servers will have invited both bots. Will these servers be on the same shard id for both bots?

i am assuming this is the case because of the sharding calculation formula (guild_id >> 22) % num_shards == shard_id, which says to me, that the shardid is only dependend on the actual guild id (and amount of shards), which should be the same for both bots.

split hazel
#

I tried to google an answer but couldnt, im interested to know how online games like pubg, minecraft, clash royale, brawl stars etc track where characters are on the map and how do they deliver the information to the client so quickly and smoothly

quartz kindle
#

@viral spade yes i believe so

slender thistle
#

websockets

viral spade
#

@quartz kindle Follow up question: But that also means that, if i am extremely unlucky it could be that of my 10 shards started, only the first will have 1k servers, but the rest none?

split hazel
#

well no shit but even websockets have minimal latency

slender thistle
#

All I know is they're speedy
nekopeek

split hazel
#

im not very interested in that, but rather on how they track where characters are on the map

amber fractal
quartz kindle
#

@viral spade supposedly yes, although i've never seen a strong deviation in guild ids and shards, idk how i would explain it

amber fractal
#

This is an entire tutorial

#

If you're really interested

#

It's 7 parts

#

But a lot of it is unity specific (obviously)

quartz kindle
#

i dont know much about game design, but my take is the client using UDP to stream packets to the server

#

most games, character positions is not synchronized so you often see glitchy movement when lag happens

split hazel
#

well yeah, i've also seen the client take over the character movements, mostly in clash royale

#

and when slight lag happens, the characters get moved back to where the server belives it is

quartz kindle
#

yeah, they use many corrections to resync positions

#

and predictive movement/pathing

mystic violet
#
var rethink = require('rethinkdb')

opts = {"host":"localhost", db:"EzDB"}

rethink.connect(opts, function (err, conn) {
    if(err) console.log(err)
    rethink.connection = conn
})```
#

How would I create a table

#

I tried rethink.tableCreate("test")

tight plinth
#

Docs

#

Read the docs

mystic violet
#

I did

#

thats where im getting the code from

#

It says ```js
db.tableCreate(tableName[, options]) → object

r.tableCreate(tableName[, options]) → object```

#

I dont know what "db" is

tight plinth
#

I think db is ur rethink

mystic violet
#

nvm I just saw js r.db('heroes').tableCreate('dc_universe').run(conn, callback);

#

im gonna try that

#

r is rethink

tight plinth
#

Well

#

I know what to do

quartz kindle
#

tricking discord.js into not caching things is fun lmao

#

especially tricking it into working without cached stuff

#

fetching a message without caches:
await client.channels.add({id:"channelid",type:0},client.guilds.add({id:"guildid"},false),false).messages.fetch("messageid",false);

unborn steeple
#

hey I need help im using a package with discord.js called canvas-constructor how would I use canvas-constructor to get an image from a url not a file?

quartz kindle
#

have you checked their documentation?

mystic violet
#

Any good databases that are like quick.db, (as easy) and have the performance of something like rethink or mongo db?

unborn steeple
#

@quartz kindle no lemme read

mossy vine
#

@mystic violet mongodb

#

easy and peformant

unborn steeple
#

@quartz kindle it doesnt show how.

glass crag
#

Ive been seeing an increased amount of HTTPError [AbortError]: The user aborted a request. (Discord.js) now that active server count has gone up.. Any ideas?

smoky spire
#

Api having problems

glass crag
#

Discord API?

smoky spire
#

Yes

grizzled raven
#

whats the difference between the message attachment proxyURL and the url

#

which is better?

earnest phoenix
#

you'd ideally want to use url

#

proxy url is for external images being forwarded through discord

#

and as you can see right now, discord's proxy is down

unborn steeple
#

My bot is having problems, im using canvas-constructor here is my code the bot sends a black background instead of thr image its suppost to be sending.

const { Attachment } = require('discord.js');
const readFile = require('util').promisify(require('fs').readFile);
const { Canvas } = require('canvas-constructor');
const snekfetch = require('snekfetch');

module.exports = {
  name: "beautiful",
  run: async (bot, msg, args) => {
    
	let user = msg.mentions.users.first() || bot.users.get(args[0]);
	if(!user) user = msg.author;
	try{
		const paintMess = await msg.channel.send('Working on it... ');
		const plate = await ('https://cdn.glitch.com/0a96f05c-d7e5-41d5-8422-6adb49bbe599%2Fbeautiful.png?v=1582057361914');
	//	const png = user.avatarURL.replace(/\.gif.+/g, '.png');
		const { body } = await snekfetch.get(user.displayAvatarURL);
		const getBeautiful = new Canvas(634, 675)
		.setColor('#000000')
		.addRect(0, 0, 634, 675)
		.addImage(body, 423, 45, 168, 168)
		.addImage(body, 426, 382, 168, 168)
		.addImage(plate, 0, 0, 634, 675)
		.toBuffer();
		await paintMess.delete();
        return msg.channel.send(new Attachment(getBeautiful, `beautiful-${user}.gif`));
	}catch(e){
		return msg.channel.send(`ERROR: Please try again later or alert my dev's support server can be found on (removed) Error Message: ${e.message}`);
	}
}
}
#

I want it to send the background image

quartz kindle
#

@unborn steeple you need to download the image to use it with canvas

#

the official node-canvas library has a loadImage function that does that

#

if canvas-constructor is updated, it should also have it

#

i looked at canvas-constructor's source code

#

you should be able to use js const { loadImage } = Canvas.internalCanvas;

astral yoke
#

ok so, i have a question, i coded/made a discord moderation bot, added other commands right? i added a command only I can use, it's called !servers. It detects how much servers, then displays it. So like "There's 5 servers!" But, it doesn't work. I've been testing this, so when I would have the bot join a server, it would still say something like "5 servers!" even though there would be six, then I would restart my bot, then it would finally show "6 servers!"

#

If you need my code, here.

#

.

#

.

#

const { ownerid } = require("../../loaders/reader"); //get ownerid from botconfig file

module.exports = {
config: {
name: "servers",
aliases: ["servc"]
},
run: async (bot, message, args) => {
if (message.author.id != ownerid) return; //only owner can use

    try {
        await message.channel.send(`The bot is on ${bot.users.size} servers.`);
    } catch (e) {
        return message.channel.send(`ERROR: ${e.message}`);
    }
}

}

#

does anyone know how I can get is to actually work so it dosent have to restart every time I want to know how much servers are using my bot?

copper cradle
#

Are you getting any errors? Btw change != to !==

neat ingot
#

your checking users size, not servers

copper cradle
#

The difference between == and === is that: == converts the variable values to the same type before performing comparison. This is called type coercion. === does not do any type conversion (coercion) and returns true only if both values and types are identical for the two variables being compared.

#

Oh shit didn't realizs

#

But also change that

neat ingot
#
await message.channel.send(The bot is on ${bot.guilds.size} servers.);
copper cradle
#

No

#

You're missing `

neat ingot
#

oh yea

#

lol, that too

astral yoke
#

Ok, thank you.

#

Let me change that.

queen folio
#

How does the reset_command line in discord.py work?

#

I've found kind of how it works, but now it thinks my command is a variable?

west spoke
#

discord is dying

#

any reason why this crashes? I have no errors, it just randomly stops.

neat ingot
#

my bot has a few configurable settings that have to be set in order to unlock one of the main features (it spawns enemies to battle, needs the spawn channel to be set, and spawns enabled). How would i be best to show the setup guide to new users?
Would you recommend I have the bot send a 'hi im here' type message when he joins a new guild, showing the vital commands to setup things? or is there a better solution?

quartz kindle
#

rip discord

west spoke
#

also if i send the same messages its because discord is deciding to die

#

Any reason why this crashes>

#

No errors

#

but it just randomly crashes

#

Called it

#

that was 2 mins until it sent

quartz kindle
#

@neat ingot best practice is always to have a help command, you can make it be called by the bot mention as well

neat ingot
#

im in uk and its running fine for me, must be us server issues or something

#

oh wait nvm, lagging now 😄

#

yea, i have the help command, its advertized as my bots status also ('Playing !!help for x users'), you think that is enough though? and the help command doesnt show setup info, it show commands help info. should i add an option for an optional argument like '!!help setup' maybe?

west spoke
#

im seriously confused

#

I researched this, and it said to "poll" the pygame event, and I am

neat ingot
#

i guess i could easily check if a server has used the help command before, and then send additional setup help info if they havent

west spoke
#

im seriously confused

#

ok

#

ok

slender thistle
#

in SQL, is there a performance difference between small "autocommits" and large commits every now and then and what's generally the best practice?

dusky marsh
#

Probably a combination

dense drift
#

So.. I'm confused.

Why isn't this code working?

if(msg.content.toLowerCase().includes("discord.gg/" || "discordapp.com/invite/")){
#

I'm logging it, so I can see that it is indeed seeing it.

#

Nvm

#

I'm stupid

#

It was working fine.

copper cradle
#

Lmao

earnest phoenix
#

So I was trying to get the Youtube API in order to create a music bot but I have no idea what scopes to pick

valid holly
#

I need help with Embeds

#

Trying to use Markdown to add hover text over href

#

[Some Text](Some Link "Some Hover Text") tried this.

neat ingot
#

wait @dense drift

#

are you sure that works?

dense drift
#

Well

#

yeah

neat ingot
#

ive never heard of doing a conditional as part of a function call like that

dense drift
#

Just not the second half, I had to separate it.

neat ingot
#

lol yea

#

thats what i was thinking

dense drift
#

So I have includes 1, then includes 2

#

😛

#

I realized a check earlier didn't work

#

That's what my issue actually was

valid holly
#

guys don't talk here

neat ingot
#

the "" || "" would have been like a boolean, either this or this, that then gets checked for included

dense drift
#

I had a ! where it shouldn't have been

valid holly
#

people that can help me won't see my message 😢

dense drift
#

We're discussing code.

valid holly
#

😠

neat ingot
#

can u use markdown to add hover texts?

valid holly
#

yes

neat ingot
#

never heard of that

dense drift
#

Neither have I

#

You can use named links

neat ingot
#

^

#

lets text

#

test*

#
[Some Text](Some Link "Some Hover Text")```
#

oh wait it'd only be in an embed?

valid holly
#

named links also can used in-line named links with hover

neat ingot
#

but that makes no sense

valid holly
#

yes

dense drift
#

I don't get what you're trying to do

neat ingot
#

sec, i consult dr goog

dense drift
#

I know what you mean by hover.. buuut

valid holly
#

Trying to make an ability info system for my rpg bot

#

For instance:
Char: Human
Ability: Taunt

#

If you hover over taunt will show info regarding the ability

dense drift
#

I don't think that's possible.

#

Unless you mean not in Discord, and on a website.

valid holly
#

it should

#

Discord uses Markdown

dense drift
#

Yeah, but not all of it

valid holly
#

embeds support hyperlinks

#

same as webhooks

dense drift
#

Either of those help?

valid holly
#

😠

#

Sir I don't need the docs, I need help from people who did it

#

I saw it over other embeds

#

Just need help parsing the "Hover text" string

#

You guys just don't talk here and would help

dense drift
valid holly
#

output using the hover

#

it will output as a string

#

nvm you can backslash the 2string

#

or use template literals

dense drift
#

Phew, there ya go, try it out yourself

valid holly
#
const Discord = require("discord.js");
let embed = new Discord.RichEmbed()
.addField("Test", `[Yeet](https://google.com "Hover Text")`)
message.channel.send(embed);
dense drift
#

That quiet literally worked just fine.

valid holly
#

Yes I saw it

dense drift
#

So why do you need help?

#

😛

valid holly
#

Not anymore, figured it myself

#

Seems I just needed to backslash the double quotes

neat ingot
#

oh, thats pretty neat, i really didnt know markdown could do that 🙂

valid holly
#

I guess I could've used link() aswell but I like using Markdown more

analog walrus
#

As a general issue, what are webhooks and how do I use one?

#

Webhooks here just any webhooks

valid holly
#

They use POST methods and parse info from a json format

#

A webhook in web development is a method of augmenting or altering the behavior of a web page, or web application, with custom callbacks. These callbacks may be maintained, modified, and managed by third-party users and developers who may not necessarily be affiliated with th...

#

Discord has webhooks aswell

analog walrus
#

But I was wondering how do I make an endpoint using nodejs?

valid holly
#

google it

neat ingot
#

making an endpoint in node is legit one of the easiest things

#
app.get('/route', function(){});
app.post('/route', function(){});
analog walrus
#

Shush

#

I suck at express

#

*pout*

neat ingot
#

huggies

earnest phoenix
#

debating cutting out the restful api of this project and just doing everything inside the bot process

#

to speed up dev time

#

and doing api later

neat ingot
#

imo you would regret that choice later :p

earnest phoenix
#

yea true

#

ill just do it up front

earnest phoenix
#

for some reason i think its calling both then and catch

#

so no reason for both to execute?

bitter sundial
#

if the .then part errors it'll catch that too

earnest phoenix
#

hm

bitter sundial
earnest phoenix
#

mongo stuff

#

on local pc atm

bitter sundial
#

sounded like discord stuff

earnest phoenix
#

mongo stuff

surreal sage
#

how to create a new line in json

earnest phoenix
#

the enter button

bitter sundial
#

\n

surreal sage
#

like:

"json": [
  "alreadyhere",
  "new"
]```
bitter sundial
#

what

surreal sage
#

ok

#
"i got this": [
  "this was already here, new , gets created >",
  "and this comes here"
]```
earnest phoenix
#

read that

surreal sage
earnest phoenix
#

oh god

#

you arent using json to store data, are you?

#

to be fair mongo uses json mmLol

honest jetty
#

I used to have sqlite and that kept breaking my bot loll

#

So I swapped to json, works much better.

dusky marsh
#

Oof.

neat ingot
#

but honestly. that made me laugh way too hard

#

@earnest phoenix

earnest phoenix
#

Can anyone help?

earnest phoenix
#

Hey, I can't get my website to show up on the bot page? using object html.. I trade Iframe too but it doesn't seem to work.

flat pelican
#

It should work if you use it correctly?

earnest phoenix
#

well it spaces out as if it did work

#

but the website doesn't actually show up

#

it's just big white space

flat pelican
#

bot ID?

earnest phoenix
#

I'll add it back what I was doing

flat pelican
#

Hmh okay

earnest phoenix
#

@flat pelican 678564701499686931

flat pelican
#

I mean

#

Put your code in it

earnest phoenix
#

I did

modest maple
#

did you actually save it

earnest phoenix
#

yes, if I click edit this shows up

flat pelican
#

Never add random/duplicated chars as it's a decline reason

#

even for tests

earnest phoenix
#

well it just gives me that its less than 300 chars

#

if I only do html

flat pelican
modest maple
#

in mean like

#

you need text

flat pelican
earnest phoenix
#

there, I added head to it

#

now it just shows the spacing of the width and height

#

well it did atleast when I previewed it

#

and is that code wrong? could you point me to the right direction

modest maple
flat pelican
#

I thought this is how iFrame works

<iframe src="https:/somewebsite.com" width="100%" height="1250px">
</iframe>```
earnest phoenix
#

well im not using iframe

#

but ill try this

modest maple
#

I really need to fix the none existant driver error

#

its the one flaw

#

with the most devistating concequences

earnest phoenix
#

@flat pelican go onto my bot page now

#

i used ur code

flat pelican
#

yeah it didn't work

earnest phoenix
#

so what's the problem?

#

I don't see any errors

#

ohh nvm

#

Mixed Content: The page at 'https://top.gg/bot/678564701499686931/edit' was loaded over HTTPS, but requested an insecure resource 'http://clank.xyz/commands'. This request has been blocked; the content must be served over HTTPS.
guess I gotta get a certificate lol

#

ill just make my description with markdown

prime cliff
#

@earnest phoenix your domain clank.xyz needs to be secure with https

earnest phoenix
#

So exactly what I said

summer torrent
#

Result:

quartz kindle
#
if(voted) {
  cmd.run(...)
} else {
  message,channel.send(...)
}``` assuming you want to block the command if the user did not vote
summer torrent
#

thanks 👍

neat ingot
#

letsencrypt also gives free sll

quartz kindle
#

that website uses letsencrypt

amber fractal
#

I use certbot and cloudflare with full encryption mode

#

I think certbot uses letsencrypt tho

bitter sundial
#

certbot is a cli tool for letsencrypt

quartz kindle
#

afaik letsencrypt is the only free certificate authority, so every thing out there uses them

earnest phoenix
#

If u use cloudflare dont use certbot, just apply ssl in FULL STRICT for cloudflare and this work perfectly logique_hein_50Nuances

quartz kindle
#

The Full (strict) SSL option checks for SSL certificate validity at the origin web server. A self-signed certificate cannot be used. A Cloudflare Origin CA certificate or valid certificate purchased from a Certificate Authority is required to avoid 526 errors.

marble juniper
#
while (coding) brain.offline()
quartz kindle
#

its more efficient to do js while(coding) { if(brain.online) { brain.offline() } }

marble juniper
#

imagine not having all the code in 1 line

quartz kindle
#
while(coding) brain.online ? brain.offline() : null```
marble juniper
#

while(coding){if(brain.online)};brain.offline();

quartz kindle
#
whole(coding) { if(brain) { brain = null } }```
mossy vine
#

@quartz kindle i prefer to use ()() instead of null

marble juniper
#

whole

quartz kindle
#

delete your entire brain

tight plinth
#
while(coding) {
//copy&paste random code
}
quartz kindle
#

jesus that will kill your cpu and ram

amber fractal
#

@earnest phoenix for a .dev site you need a certificate and just using full strict mode doesn't work.

quartz kindle
#

full strict shouldnt work without a certificate in general

earnest phoenix
#

I use only full strict mode and i have (CloudFlare Inc.) In ssl certificat

tight plinth
#

@earnest phoenix where is ur green role

earnest phoenix
#

@tight plinth i have deleted my bot i make a new one later lol

tight plinth
#

Bruh

#

(I'm green coz telk makes me green)

earnest phoenix
#

And i think i can add the functions of my deleted bot in the new

#

Oh

quartz kindle
#

too green, needs to mature a bit more before it can be eaten

earnest phoenix
#

omg

#

nubs

#
while(coding) brain.online && brain.offline()
#

jk that reads so badly

#
$brain.online or die while $coding

in perl except the terminology used is a bit... strong

surreal sage
#

do i have to do ID?

#

no just :

#

nvm

late hill
#

Do you really have to edit it that much

#

you also don't have to create a new embed each time

#

you can simply use the same one but just edit its properties

#

which in the case of editing a message, kind of makes sense too

frozen cedar
#

lOl

#
false = false
true = true
1 = 2
}```
mossy vine
#

except that

#

invalid left-hand side in assignment

earnest phoenix
#

pass the eye bleach

split hazel
#

For some reason, when i attempt to track key holdings with keyup and keydown events, the keyup event immediately follows after the keydown even when the key has not been let go. Is it a bug or

split hazel
#

i figured out it was an issue with a shit keyboard extension i installed, uninstalled and now everything works perfectly

earnest phoenix
#

@frozen cedar wHAa

surreal sage
#

how do i pick a random user out of reactions?

#

or users

modest maple
#

get list of users

#

use some sort of random choice or random number generator for your language

quartz kindle
#

discord.js has collection.random()

earnest phoenix
#

How some servers use 2 second slowmode

surreal sage
#

so like:js var peopleReacted = msg.reactions.get("🎉").users; const winner = peopleReacted.random()

earnest phoenix
ocean frigate
#

🎉

#

\🎉

sinful belfry
#

how can i detect a reaction to an older message in discord.js

cinder patio
flat pelican
#

partials?

sinful lotus
#

or just use raw event

flat pelican
#

We have payloads and use raw events with d.py

#

idk how it is for d.js

static trench
modest maple
#

3.7 probs the best

static trench
#

Ok thx

tight plinth
#

Use js

static trench
#

Huh?

#

Node.js?

tight plinth
#

Yea

static trench
#

Does that work w/ python?

modest maple
#

no

static trench
#

Ok

tight plinth
#

No, of course

modest maple
#

hes just meming

tight plinth
#

:)

static trench
#

Does node.js work with python or no?

modest maple
#

no

static trench
#

Ok

#

I will use python 3.7

modest maple
#

hence why its called node.js not node.py

static trench
#

Idk

copper cradle
#

What kind of question is that

static trench
#

Do i do 3.7.6?

modest maple
#

what

tight plinth
#

3.7.x

#

Any 3.7

static trench
#

I need to download python

tight plinth
#

So yea

static trench
#

Ok

copper cradle
#

Use python 3.8

modest maple
#

i think u wanna learn the basics

static trench
#

To use discord.pu

copper cradle
#

To use the walrus operator mmLol

modest maple
#

cuz you seem new

static trench
#

I am new

tight plinth
static trench
#

I have never coded a bot b41

modest maple
#

and d.py is NOT AN EASY LIB

#

its is not beginner friendly

copper cradle
#

^

static trench
#

Ok

modest maple
#

in any way shape or form

static trench
#

So what do i use?

tight plinth
#

If u want an ez lib d.js is the best

static trench
#

For python

modest maple
#

and you wont get anywhere not knowing the basics

static trench
#

D.js? Is that beginner friendly?

modest maple
#

NO

static trench
#

I know some of python

#

Ok

copper cradle
#

@tight plinth d.js isn't for python

#

Can't you see that .js

modest maple
#

No programming languages which use discord will be begginer friiendly

copper cradle
#

No programming languages which use discord will be begginer friiendly
@modest maple nice wording

modest maple
#

thank you

tight plinth
#

Python+discord isn't beginner friendly

static trench
#

Ok

#

What do i use?

#

Node.js?

modest maple
#

anything + discord isnt beginner friendly

static trench
#

Ok

#

I will learn

#

So i should use node.js??????

#

I am confused

modest maple
#

no

static trench
#

Ok

modest maple
#

jesus dude

tight plinth
#

@static trench try https://store.steampowered.com/app/682130/Discord_Bot_Maker/ : u can make ur bot easily and it will create the code for you

Discord Bot Maker is a powerful bot development tool for the #1 text and voice chat service for gamers: Discord. With this tool, you and your teammates can take your social experience to the next level!ExplanationOne of the most prominent features provided by Discord is the of...

Price

$9.99

Recommendations

806

▶ Play video
static trench
#

What do i use?

copper cradle
#

You gotta use lua

modest maple
#

do you know what the <file>.xyz means

static trench
#

Ok thx

modest maple
#

yh

copper cradle
#

Nooooo

modest maple
#

might aswell use discord bot maker

static trench
#

I know Lua from roblox

copper cradle
#

Don't tell them to use dbm smh

static trench
#

I will use discord bot maker

modest maple
#

or actually learn a programming language properly frist

copper cradle
#

They said they know lua

#

From roblox but

#

Ya know what I mean

static trench
#

Yes

quartz kindle
#

isnt there a discord library for lua?

copper cradle
#

Yes

#

I forgot its name

static trench
#

What does discord bot maker in steam do

#

?

copper cradle
#

discordie i think

tight plinth
#

There is a discord library for basically a'y language

modest maple
#

ima bounce

tight plinth
quartz kindle
#

discordbotmaker is a system that does the bot for you, kind of a scripting thingy, it runs with javascript and node.js

copper cradle
#

Yes discordia is the name

tight plinth
#

Discordia

#

Luca I'm supposed to be whitz

copper cradle
#

Shh don't tell him

#

You're better as a green name

tight plinth
#

No

#

I'm not a legit green name

static trench
#

Ok! To confirm I should use steam discord bot maker?

quartz kindle
#

you should use whatever you want

static trench
#

Ok

tight plinth
#

@static trench use whatever u want

static trench
#

Thx

#

But is bot maker easy to use?

tight plinth
#

Yrs

quartz kindle
#

discord bot maker is for those who dont know programming and dont want to learn programming

static trench
#

And how do i get a green name tag?

quartz kindle
#

everything else requires knowledge of a programming language

static trench
#

@quartz kindle i want to learn but u am not goo

tight plinth
#

By having a verified bot in the website

static trench
#

Good*

#

Ok

#

Thanks everyone

copper cradle
#

Np

sinful belfry
#
      var reactionChannel = client.channels.get(event.d.channel_id);
        reactionChannel
          .fetchMessage(event.d.message_id)
          .then(msg => {
            var guild = client.guilds.find(uGuilds => uGuilds.id === event.d.guild_id);
            var memberRole = guild.roles.find(uRoles => uRoles.name === "NEW MEMBER");
            var member = guild.fetchMember(event.d.user_id);
          console.log(member);
            member.removeRole(memberRole);
          })
          .catch(err => console.log(err));

It keeps saying member.removeRole is not a function and I don't have a clue why. I've been trying to figure it out for the last hour... anyone have any ideas?

earnest phoenix
#

have you tried browsing the docs per sé

sinful belfry
#

discord.js docs?

#

yeah

earnest phoenix
#

fetchMember is a promise iirc

#

anything that has fetch in it's name implies a request to the api

copper cradle
#

You gotta do fetchMember().then(member => member.removeRole())

sinful belfry
#

ah ok ty

#

do u have any recommendations on where i can read up about promises?

copper cradle
#

Mdn

summer torrent
sinful belfry
#

thanks a lot

earnest phoenix
#

read up on async await in js instead

#

it introduces you to the whole scope of asynchronous programming

sinful belfry
#

wow ok thanks

#

i'll check it out

late hill
#

is this your play command

#

you're creating a whole new client

#

..?

copper cradle
#

Kinda

muted vortex
#

I'm trying to do this:

#

"if the client is not predefined" is client referring to node or discord.js ?

quartz kindle
#

it shows two examples, one with a "predefined client" the other without

#

the difference between those two examples is the existence of Discord = require("discord.js") and client = new Discord.Client()

#

therefore it is referring to discord.js

muted vortex
#

which file do those lines go into? package.json, package-lock.json index.js or config.json ?

#

ah, they look like index.js lines

#

I'm learning 😜

quartz kindle
#

they cannot be json files because they contain javascript code

#

json files can only contain storage objects, not code

#

JSON stands for Javascript Object Notation so its quite literally a javascript object written as a string and meant to store simple data

modest maple
#

Restarting servers to install updates is a pain

#

Altho might take this time to check some stuff in bios

wicked pivot
#
if(reaction.emoji.name === "▶️"){
                 if(a === 0){
                     collected.first().remove(collected.first().users.filter(user => user !== bot.user).map(data => data.id).join(""))
                     msg.edit(embed_2)

                     a = 1
                 }else if(a === 1){
                     collected.first().remove(collected.first().users.filter(user => user !== bot.user).map(data => data.id).join(""))
                     msg.edit(embed_3)

                     a = 2
                 }else if(a === 2){
                     collected.first().remove(collected.first().users.filter(user => user !== bot.user).map(data => data.id).join(""))
                     msg.edit(embed_4)

                     a = 0
                 }
             }``` when I click a second time on the reaction it always puts me on the first page (embed_2)
muted vortex
#

bot is working woohoo!

#

now I just need to find a twitter module to add to it

split hazel
#

Following up on a conversation yesterday i made a test browser game which connects users with socket io, i set the client to send keyboard keys pressed to server every 100ms and the server sending the state (player positions, health and bullet positions) every 40ms, but the problem is theres sudden huge packets per second drops from like 30/s to 0. Increasing the latency stops this from happening but the game becomes very choppy and slow. Is there any good way i can mitigate this and use something else instead to stop the packet drops and increase the smoothness

quartz kindle
#

is the server and/or client getting bottlenecked somewhere?

#

@wicked pivot sounds like your a variable is getting redefined/reset

wicked pivot
#

how can I do ?
a and defined above

let a = 0```
#

help me please it's been more than 2 hours that I'm on it that I'm on sad

quartz kindle
#

show full code

wicked pivot
#

look dm @quartz kindle

earnest phoenix
#

also switch exists pls

quartz kindle
#

your reaction collector will only work once

#

you have awaitReactions() with a limit of 1 message, then after the reaction is received, it edits the message and the code finishes and exits

#

it will not await for more reactions

#

you need to either restart the function or use a reaction collector

grizzled raven
#

how do you

#

when you install a package while the program is already running, how do you require it?

#

cause it keeps throwing the "Cannot find module <module>" error

wicked pivot
#

@quartz kindle it's done but it doesn't work

#

not that bad i gave up

copper cradle
#

@wicked pivot send code here

wicked pivot
#
let a = 0
message.channel.send(embed_1).then(async (msg) => {
         await msg.react('▶️')
         await msg.react('🔄')

         restart() // lancé la fonction restart
         async function restart() {

         msg.awaitReactions(filter, { max: 1, time: 60000, errors: ['time']}).then(async(collected) => {
             const reaction = collected.first()

             if(reaction.emoji.name === "▶️"){
                 if(a === 0){
                     collected.first().remove(collected.first().users.filter(user => user !== bot.user).map(data => data.id).join(""))
                     msg.edit(embed_2)

                     a = 1
                 }else if(a === 1){
                     collected.first().remove(collected.first().users.filter(user => user !== bot.user).map(data => data.id).join(""))
                     msg.edit(embed_3)

                     a = 2
                 }else if(a === 2){
                     collected.first().remove(collected.first().users.filter(user => user !== bot.user).map(data => data.id).join(""))
                     msg.edit(embed_4)

                     a = 0
                 }
             }else if(reaction.emoji.name === "🔄"){
                await msg.clearReactions()

                msg.edit(embed_5)
             }
         }).catch(async(err)=> {
            await msg.clearReactions()
            msg.edit(embed_5)
        })
         }
     })
     }```
copper cradle
#

Ok what's the error, I don't want to scroll all the way up

grizzled raven
#

understandable

quartz kindle
#

@wicked pivot what you want to do is not as easy as you think because it requires that the message is cached, and if your bot restarts, it will no longer react to that message, but basically you have two options: a reactionCollector or a recursive function

grizzled raven
#

so i have to restart my bot to use that

#

xd

#

honestly i'll just wait

#

actually

#

no nvm

quartz kindle
#
OPTION ONE
// reaction collector
const collector = message.createReactionCollector(filter, { time: 3600000 }); // work for 1 hour
collector.on('collect', r => console.log(`Collected ${r.emoji.name}`)); // the collect event will be fired every time someone reacts, not only once
collector.on('end', collected => console.log(`Collected ${collected.size} items`));



OPTION TWO
// recursive function
function reactions(msg) {
  msg.awaitReactions(filter,options).then(result => {
    // do the message edit here
    reactions(msg) // restart the reaction function to listen to the next reaction
  })
}
#

@wicked pivot

grizzled raven
#

so if i use that, will i have to use the manager.require instead of require?

wicked pivot
#

sorry I took too much head with this code x)

quartz kindle
#

@grizzled raven yes, you can also check its source code to see how they do it

grizzled raven
#

huh

#

okay

quartz kindle
#

i checked it out of curiosity

#

basically they do it like this

#

resolve module path and entry point from package.json
get main file contents with fs.readFileSync
execute/eval file code in a vm sandbox
return result and cache it as a variable
export it back to you

grizzled raven
#

oh ok cool

#

btw

#

when you read a file, how do you like

#

convert it from buffer bytes to readable string?

#

nevermind#

wooden lance
#

Okay, I'm using discord.js and I made some new commands. No matter what command I try, I always get the same error.

0|index  |     at /root/DiscordBotApp/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:85:15
0|index  |     at /root/DiscordBotApp/node_modules/snekfetch/src/index.js:215:21
0|index  |     at runMicrotasks (<anonymous>)
0|index  |     at processTicksAndRejections (internal/process/task_queues.js:97:5)
0|index  | (node:656010) 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: 10)
``` I've checked, the bot does have permission to send messages in the channel it's trying to (it has admin). I really can not think of anything else to try. Is this possibly a problem on Discord's end or am I doing something wrong? *I've also tried regening my token, didn't fix it.*
static trench
#

Does anyone know a good beginner platform that will help me make a bot? I am on Mac

quartz kindle
#

@wooden lance you'll get more information if you catch the error

#

ie: message.channel.send(...).catch(console.log)

wooden lance
#

okay one sec

rugged tusk
#

Hello people. I have a Python discord bot hosted on Heroku. In the last 3 days, sometimes (low frequency) I get this error when sending embedded messages.
Does anyone have any idea what may be causing this?

  File "/app/.heroku/python/lib/python3.7/site-packages/discord/ext/commands/core.py", line 83, in wrapped
    ret = await coro(*args, **kwargs)
  File "Ve7s.py", line 227, in play
    await Play.go(ctx=ctx, args=args, client=client, partidas=playing, admin=ve7sadmin, vets=VeTs, db=ve7sdb)
  File "/app/Ve7sGame/Play.py", line 141, in go
    await game.task
  File "/app/Ve7sGame/Play.py", line 114, in match
    await gameloop(game, partidas, client)
  File "/app/Ve7sGame/Play.py", line 44, in gameloop
    await game.canal.send(file=File(data, f'hazzu.{ext}'), embed=embeder)
  File "/app/.heroku/python/lib/python3.7/site-packages/discord/abc.py", line 839, in send
    content=content, tts=tts, embed=embed, nonce=nonce)
  File "/app/.heroku/python/lib/python3.7/site-packages/discord/http.py", line 164, in request
    data = await json_or_text(r)
  File "/app/.heroku/python/lib/python3.7/site-packages/discord/http.py", line 43, in json_or_text
    if response.headers['content-type'] == 'application/json':
KeyError: 'content-type'```
quartz kindle
#

@static trench there is no "platform", aside from maybe discord bot maker or something like botghost (the latter is not allowed here). what most people use is a library to connect to the discord API. those exist for a variety of programming languages and environments, but require basic knowledge of programming and coding

wooden lance
#
0|client  |     at /root/DiscordBotApp/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:85:15
0|client  |     at /root/DiscordBotApp/node_modules/snekfetch/src/index.js:215:21
0|client  |     at runMicrotasks (<anonymous>)
0|client  |     at processTicksAndRejections (internal/process/task_queues.js:97:5) {
0|client  |   name: 'DiscordAPIError',
0|client  |   message: '401: Unauthorized',
0|client  |   path: '/api/v7/channels/568991043039526942/messages',
0|client  |   code: 0,
0|client  |   method: 'POST'
0|client  | }
``` yep doesnt have perms to send messages....but it does
quartz kindle
#

unauthorized doesnt necessarily mean missing permissions

#

which channel has that id?

#

is it in a guild where your bot is in?

wooden lance
#

one in my dev server

#

yes it is

quartz kindle
#

does the channel have permission overwrites?

mystic violet
#

is this the right variable names for mongo?

const mongoose = require('mongoose');
mongoose.connect('mongodb://localhost:27017/test', {useNewUrlParser: true, useUnifiedTopology: true});

const Model = mongoose.model('Database', { name: String });

const table = new Model({ name: 'Table' });
table.save().then(() => console.log('Saved!'));```
wooden lance
#

yes but the bot would bypass it anyway, it has administrator

quartz kindle
#

try removing the channel permissions or explicitly adding the bot to them

#

also check the role position. even if it has admin, role positions still matter

wooden lance
#

yep i have

earnest phoenix
#

401 is wrong token

wooden lance
#

but it logged in

earnest phoenix
#

403 are perm issues

quartz kindle
#

did you create a duplicate client?

wooden lance
#

issue found and resolved, when i copied over some code, i obviously copied broken stuff. i found client.token = undefined

quartz kindle
#

why would you do that lol

wooden lance
#

i have no clue

quartz kindle
#

xD

mystic violet
#

How do you open mongodb

#

like the dashboard

quartz kindle
#

mongodb doesnt come with a dashboard