#development

1 messages · Page 533 of 1

midnight widget
#

is it frozen?

graceful warren
#

nop

vernal rivet
#

Lol

midnight widget
#

ok then just let it

graceful warren
#

like it's blocked but I can make selections etc

vernal rivet
#

Discord had an connection issue

midnight widget
#

Again

graceful warren
#

well I will let him make his things

vernal rivet
#

What did I miss?

graceful warren
#

I don't knwo bro

midnight widget
#

Discord's demise yet again

vernal rivet
#

What library are you using?

midnight widget
graceful warren
#

yes

#

I followed a tutorial

vernal rivet
#

OwO use discord.js

graceful warren
#

I used this

vernal rivet
#

Follow source code

graceful warren
#

you mean when I put the command to make with .js and not with .io?

vernal rivet
#

Look up source code on YouTube and follow his tutorial

midnight widget
#

no, that's just the name of the library

graceful warren
#

what is a source codeee?

vernal rivet
#

Youtuber

graceful warren
#

oh ok

#

and he made a tutorial for a discord bot?

#

cuz I need one for my discord server

vernal rivet
#

Yes

graceful warren
#

and it's working?

vernal rivet
#

Yes, I followed his tutorial, he tells what does what, and how to do this

graceful warren
#

umm 29 episodes?

#

brb

vernal rivet
#

Go from the beginning

#

@me if you have a problem with something @graceful warren

graceful warren
#

sure, thank you 😃

vernal rivet
#

Np

earnest phoenix
#

@rustic obsidian mmh.. okay

graceful warren
#

@vernal rivet

#

problem or not problem?

#

cuz I see ERR!

midnight widget
#

no it's fine, go ahead and run it

graceful warren
#

ok ty

vernal rivet
#

No prolem

graceful warren
#

nah im done

#

i let this off

#

I don't get the same folders like him

#

I don't get any folder

vernal rivet
#

Really?

#

Discord.js?

#

npm install discord.js

#

It should have made a new folder called node-modules, and discord.js should be in there

#

Oh @graceful warren look up bufferutil and do a npm install, then install discord.js

graceful warren
#

I'll do it tomorrow but ty

earnest phoenix
#

Discord shutdown all bots. Luca will go off soon

loud salmon
#

@earnest phoenix its connection issues

earnest phoenix
#

oof

loud salmon
#

not discord doing it on purpose

graceful warren
#

guys

#

hello

loud salmon
#

hi

graceful warren
#

guys, I restarted the npm tutorial thing and now it's loading, I'll let this for 1 hour loading and maybe something will pass I don't know

vernal rivet
#

By loading what do you mean @graceful warren

inner jewel
#

discord is having issues right now

vernal rivet
#

Do we know how bad it is?

native folio
keen drift
#

required?

gloomy fog
#

bot updating stats with same token
but i can't get votes

hoary stag
late hill
#

Maybe you need to update

inner jewel
#

wrong token

gloomy fog
#

I Changed Token Tried Again Still Having same error

inner jewel
#

are you using the DBL token or the bot token

quartz kindle
#

i believe he said updating stats works but votes doesnt, same token

vernal rivet
#

?

high anchor
#

hi, silly question

#
Optional packages
    bufferutil to greatly speed up the WebSocket when not using uws (npm install bufferutil)
    erlpack for significantly faster WebSocket data (de)serialisation (npm install hammerandchisel/erlpack)
    uws for a much faster WebSocket connection (npm install uws)
#

how do i configure erlpack with discordjs

#

or is it automatic when it detects it in my dependencies

#

is it in peerDependencies?

bright spear
#

just install it normally

#

but it'll still WARN in npm

#

cuz it installs from github

visual zenith
high anchor
#

sweet, thanks!

#

hopefully ill see a perf boost

valid vessel
#

@gleaming glen botumdaki hatayı duzeltdim Fenon'S botunu eklermisin

rustic obsidian
#

Uh can someone help with something

#

Like, i want the bot to react to it's own helplist, and if you click on one of the emoji's, it goes to the other helppage.

#

Like this: < >

knotty steeple
#

you can make a reaction collector

#

and then check if someone reacts with any of those

#

if they do you can edit the message

amber junco
#

How do I resolve it

keen drift
#

"error"

#

says warn

#

no i ce

earnest phoenix
#

@earnest phoenix haha same

#

Its their shit and you can do like nothing

#

Only call the api endpoint for correct vote count Thonk

amber junco
#

I mean Discord.js did not install

rustic obsidian
#

@knotty steeple Thanks!

foggy sand
#

@amber junco try 1.) latest npm (npm install -g npm) - 2.) add exception to your antivir, to ignore node_modules folder in your project - 3.) rm -rf node_modules package-lock.json - 4.) npm install ... that should work

amber junco
#

ok

#

Nope

#

Did not work

foggy sand
#

you're using vscode? and is it running right now? if so close it and try to temrinate a instances of node and try to install then

sick cloud
#

@rustic obsidian discord.js?

#

if you use it then you can follow my guide for reaction help

rustic obsidian
#

I'd love to

#

Because i'm kinda stuck right now, i know how to let my bot react to messages, but not to embeds.

#

And yeah discord.js

sick cloud
#

first pinned message

rustic obsidian
#

Thanks

sick cloud
#

follow it and mention or dm me if you need help

#

np

earnest phoenix
#

Hi

#

Who can help me ?

#

I want make a welcome message with canvas but is not work

night imp
#

Post code and error

earnest phoenix
#

I supp my code

#

I delete

night imp
earnest phoenix
#

😢

night imp
#

Undo?

earnest phoenix
#

You can just send code ?

night imp
#

I can't just send you the exact code b

#

You have to work on it yourself

#

This channel is for help, not freelancing

earnest phoenix
#

Plzzzz i delete my code ...

#

Or you have a tutorial for canvas welcome message ?

#

@night imp

night imp
#

I don't have one, there are others online

earnest phoenix
#

Of ?

night imp
#
heady anvil
#

better than google

earnest phoenix
#

@night imp my code :

#
            
                const canvas = Canvas.createCanvas(700, 250);
                const ctx = canvas.getContext('2d');
            
                const background = await Canvas.loadImage('./wallpaper.png');
                ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
            
                ctx.strokeStyle = '#74037b';
                ctx.strokeRect(0, 0, canvas.width, canvas.height);
            
                // Slightly smaller text placed above the member's display name
                ctx.font = '28px sans-serif';
                ctx.fillStyle = '#ffffff';
                ctx.fillText('Welcome to the server,', canvas.width / 2.5, canvas.height / 3.5);
            
                // Add an exclamation point here and below
                ctx.font = applyText(canvas, `${sender.displayName}!`);
                ctx.fillStyle = '#ffffff';
                ctx.fillText(`${sender.displayName}!`, canvas.width / 2.5, canvas.height / 1.8);
            
                ctx.beginPath();
                ctx.arc(125, 125, 100, 0, Math.PI * 2, true);
                ctx.closePath();
                ctx.clip();
            
                const { body: buffer } = await snekfetch.get(sender.user.displayAvatarURL);
                const avatar = await Canvas.loadImage(buffer);
                ctx.drawImage(avatar, 25, 25, 200, 200);
            
                const attachment = new Discord.Attachment(canvas.toBuffer(), 'welcome-image.png');
            
                message.channel.send(`Welcome to the server, ${sender}!`, attachment);
            break;```
#

Error :

#
(node:8246) UnhandledPromiseRejectionWarning: ReferenceError: applyText is not defined
    at Client.bot.on (/home/Akimitsu_Dev/commandes.js:76:17)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
(node:8246) 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: 3)```
#

So ? @night imp

night imp
#

your missing a function

#

called applyText

#

if your going to use a tutorial don't just skip to the end

earnest phoenix
#

Mmmmhh ok i go test

jagged birch
#

Is jimp or canvas better for image manipulation?

languid dragon
#

anybody know a good documentation generator thingo

shell blade
austere fossil
#

is it possible to push something to an array in a json file using node?

#

this is what i have right now but im not sure if it even works tbh

settingsFor[message.guild.id].prefixes.push(args[0].toLowerCase())```
languid dragon
#

are you using json as a database?

austere fossil
#

yeah

mossy vine
#

@austere fossil load the array from the json you want to write to it, make changes, then write back to file

austere fossil
#

so i need to load the values of the array

#

then add to them

#

then write it again

mossy vine
#

exactly

austere fossil
#

why didnt i think of that

#

it seems so simple

#

thanks

empty owl
#

what is the difference between let and var

mossy vine
#

let is only available in the scope while var is available in the entire file

empty owl
#

ok

#

what about const

mossy vine
#

const is un unchangable variable

#

it acts as var, but you cant change it

empty owl
#

ok

#

to change a var dont u do var again?

mossy vine
#

nope

#

only do var to define it

#

for example

#
var cool = 0

cool = 1
console.log(cool) //1
empty owl
#

o ok

#

how do we do a round trip ping

#
  message.channel.send("Ping! " +  message.createdTimestamp - new Date().getTime() + " ms");   
  message.channel.send(`💓${bot.ping} ms`)
west raptor
#

let also works @mossy vine

empty owl
#

um so how do u do a roundtrip ping

mossy vine
#

@west raptor he was asking abuot var

#

so i responded with an example abuot var

west raptor
#

o

#

oh i see now

#

im dumb

#

sorry

empty owl
#

and how do I d an api ping

#

message.channel.send(API: ${bot.api.ping} ms)?

west raptor
#

what

knotty steeple
#

bot.ping

#

also why is eris mentions so weird

west raptor
knotty steeple
#

like

#

i make a command and i want to get the first mention

#

no problem

#

i run the command and i mention 1 person it gets everything

#

if i mention 2 people it gets the second one

#

which is weird

earnest phoenix
#

I figured it out

#

Ok so

#

I was trying to make a button

#

That was in a link

#

And I think i got it

#

Is it

#

<a href="link"><button> text </button> </a>

#

@loud salmon Would this be right?

loud salmon
#

not sure, i dont really work with html

earnest phoenix
#

Oh

#

Darn

#

Who does?

languid dragon
#

yes

#

yes that would work fine

#

an easier way to achieve that would just to do this

<style>
    .link-button {
        /* the styles for your button here */
    }
</style>

<nav-or-something-else>

    <a class="link-button" href="https://url.to/site">Some Text</a>

</>
earnest phoenix
#

I have a function that returns a value (via return result;), how can I pull that result after calling the function (blox.getByID("347890719");)?

#

NodeJS.

#

the value of the expression

#

so let/const/var coolResultValue = callFunctionHere(with, arguments);

#

Hmm.. Let me see.

#

This is only if the function is synchronous though.

#

if it isnt add await

#

If it's async, attach a callback or use async await

#
let result = blox.getByID(result, "347890719");
console.log(result);```
#

Such as that?

#

uhhhh

#

weird naming scheme but ok

#

¯_(ツ)_/¯

#

i dont think you want that first arg

#

so just blox.getByID("thing here")

#

It returns undefined,

#

Yet if I console.log the variable in the function, it returns the correct thing.

#

whats your code where you call the function

#
    var request = require('request');

    request({url: `https://myapi.com/${id}`, json: true}, function(err, res, json) {
      if (err) {
        throw err;
      }
      let result = json.Username;
      return result;
    });
};
#

where you call it

#

not the function definition

#
    
let result = blox.getByID("347890719");
console.log(result);```
#

ahhh

#

youll need to make a promise

#

and resolve that promise with result

#
new Promise((resolve, reject) => {
/*
Use resolve(something) to "return"
Use reject(something) to "throw"
*/
});
#

hi

#

i need help

#

exports.conf or export conf

#

depends on the lang

#

discord.js

#

it also depends on what you're trying to do

#

and whether you're using es6 modules

#

no reboot command

#

wait

#

@earnest phoenix Where do I put the function in that?

#

const Discord = require(discord.js); const moment = require(moment`);

exports.run = (client, message, args) => {
message.channcel.sendMessage(Pls Say yes``)
.then(() => {
message.channel.awaitMessages(response => response.content ==="yes", {)
max:1,
time:10000
errors: [time],
})
.then((collected) => {
message.channel.sendMessage(**rebooting.**).then(message => {
console.log([${moment().format('YYYY-MM-DD HH:mm:ss')}] Bot yeniden başlatılıyor...)
process.exit(1);
}).catch(console.error)
})
.catch(() => {
message.channel.sendMessage('cancelled.');
});
});
};

exports.conf = {
enabled: true,
guildonly: false,
aliases: [],
permlevel: 4
};

`

#

@earnest phoenix you put the code for the function inside the promise's constructor's argument

#

@earnest phoenix that's correct iirc

#

Well wasn't I right

#

no

#

It was asynchronous

#

try module.exports

#

    });```
#

So you need to attach a callback to the getID

#

no nc

#

the fuckk

#

put it inside the function

#

ah

#

exports.help = { name: 'reboot', description: 'admin', usage: 'reboot' };

or

exports help = { name: '!marco reboot', description: 'admin', usage: '!marco reboot' };

#

Sounds like this is now a basic JavaScript issue

#

I see.

#

🤦 yes it is

#

I found np

#

i'm incapable of explaining well, search on MDN for promises or something

#
    blox.getByID("347890719");
    console.log(resolve)
    });```
#

(this is what you should do first before asking)

#

Sorry, I'm trying to learn a new language.

#

which is why you shouldn't dive headfirst into something you don't know

#

Well, I've made it pretty far.

#

I just need help with this one thing.

#

@earnest phoenix copy the code from blox.getByID

#

Mk.

#

except return something -> resolve(something)

#

and throw something -> reject(something)

#

The point is I'm trying to make it a package.

#

ok

#

so wait

#

that doesn't really change anything

#
exports.getByID = function(id) {
    var request = require('request');

    request({url: `https://api.roblox.com/Users/${id}`, json: true}, function(err, res, json) {
      if (err) {
        throw err;
      }
      let result = json.Username;
       resolve(result);
       reject(result);
    });
};
#

Yeah. Its just super confusing.

#

Python is much simpler.

#

i beg to differ

#

but ok

#

ok but

#

how do i do it

#

!

#

what you do is

#

uh huh

#

copy it in between the {} in ```js
new Promise((resolve, reject) => {

}):

#

oh shit

#

and use resolve when you want to return something

#

from there, where you call the function, use async/await or .then to obtain the result

#

Just stop

#

Stop blindly guessing

#

Just stop

#

And actually make an attempt to learn.

#

exactly

#
new Promise((resolve, reject) => {
  exports.getByID = function(id) {
    var request = require('request');

    request({url: `https://api.roblox.com/Users/${id}`, json: true}, function(err, res, json) {
      if (err) {
        throw err;
      }
      let result = json.Username;
       resolve(result);
      
    });
};
});```
#

Hi

#

So, that would be in my module. Correct?

#

Who can help me ?

#

I want send a message to all user of my discord

#

NC, please

#

I try : message.guild.members.send('Test')

#

We are trying our best

#

What? I am asking for help.

#

But is not work

#

you're asking for us to completely teach you something you dont know

#

I did as he said, and pasted it in.

#

We are not here to teach you JavaScript.

#

Plz ?

#

That's why the internet exists

#

It is a simple question, I'm not asking you to teach me it.

#

oh wait

#

it isnt

#

IAM that is not correct

#

i just noticed that

#

im dumb

#

its better

#

Who can respond me plz ?

#

It would be so easy for you to just walk me through it, I've already spent an hour and a half on looking for a solution.

#

How can I fix that code?

#

i've tried explaining it to you

#

several times

#

By learning JavaScript.

#

exactly

#

Stop you squabble in this channel ....!

#

Plz

#

I've watched like 20 videos on it already.

#

Instead of driving us crazy, make an attempt to learn

#

That's why I asked?

#

I want to learn.

#

Shut up @earnest phoenix

#

you could have asked somewhere where an automated program (like a webserver) could have responded

#

instead of having to drive real humans insane

#

When I say make an attempt, I don't mean asking and expecting to be spoon-fed.

#

@earnest phoenix you can help me ?

#

I'm not asking to be spoon-fed, I'm asking how to fix it.

#

Sure...

#

@earnest phoenix message.guild.members.send('Test') Are you trying to DM all users?

#

you're asking that, and then refusing to learn

#

Yes$

#

Something so basic

#

nc that's wrong

mossy vine
#

@earnest phoenix no, dont send messages to all of your users, your bot will be kicked from here if it does

earnest phoenix
#

^

#

Just all users of my discord

#

So 180 members

mossy vine
#

still bad idea

earnest phoenix
#

still not a good idea

mossy vine
#

just tag everyone

earnest phoenix
#

No ...

mossy vine
#

why not?

#

its way simpler

#

and isnt borderline api abuse

earnest phoenix
#

Why not my idea?

#

a) api abuse

mossy vine
#

because its fucking annoying

earnest phoenix
#

b) super annoying

mossy vine
#

just tag everyone

earnest phoenix
#

No dm 180 users

#

exactly

#

Is not abuse

#

no dm

#

Just 180 ....

#

"just"

mossy vine
#

"just 180"

earnest phoenix
#

thats a lot of people

#

@earnest phoenix alright. Mind explaining one last time why the code is incorrect?

#

just tag everyone or here if you're so obsessed with annoying people in your server

#

Pl give me code for this

#

@earnest phoenix if you werent expecting to be spoon-fed, then you should have understood what IAM said.

#

I want

#

Send a mesage to all peaple of my discord

#

@earnest phoenix you want to export a function that returns a promise that contains the original body of the getByID function with the addition of the use of resolve

#

So ?

#

which was not what i meant

#

@earnest phoenix Yes. I do, yet how do I do that?

#

NC I'm done. I've told you out exactly what you need to do

#

@earnest phoenix ?

#

IAM has explained it correctly

#

@earnest phoenix What did you mean?

#

What code did you want me to copy...

#

parts of that code

#

more precisely the body of the function

#

What part?

#

Ah.

#

Alright.

#

?.......

#

Plz i'm here

#

I'm not a ghost

#

@earnest phoenix you shouldnt dm every user in your server. period.

#

@earnest phoenix Nobody will help you abuse Discord's API.

#

By body, do you mean:

    var request = require('request');

    request({url: `https://api.roblox.com/Users/${id}`, json: true}, function(err, res, json) {
      if (err) {
        throw err;
      }
      let result = json.Username;

      
    });
};```
#

Or do I keep the resolves?

mossy vine
#

@earnest phoenix stop randomly tagging people, we wont help you abuse the api and annoy your members

earnest phoenix
#

So help me

#

Cyber: "we wont help you"
Gauthus: "So help me"

mossy vine
#

no help

#

what is your native language? @earnest phoenix

earnest phoenix
#

Mystery

#

Die.

mossy vine
#

what

west raptor
#

@mossy vine What was he asking?

mossy vine
#

@west raptor wants to send dm to all members of his serevr

west raptor
#

lol

#

@earnest phoenix Yea no

earnest phoenix
#

a server of 180+ people i might add

west raptor
#

Thats API abuse

modern sable
#

whats happening here

west raptor
#

nothing

mossy vine
#

kid wants to be spoonfed api abuse

earnest phoenix
#

crazy people

#

help vampires

#

api abusers

mossy vine
#

and insulting comment

earnest phoenix
#

utter anarchy

mossy vine
#

sdcroll up

languid dragon
#

@earnest phoenix that's against Discord Terms of Service and nobody here will help you with it

earnest phoenix
#

Can someone help me with setting up customprefix system per guild,
this is the code I have, but it doesn't respond to setprefix in the db
https://hastebin.com/upesacoyeh.js

#
  • make a db
  • fetch from db
brittle nova
#

any benefits to using classes for commands?

earnest phoenix
#

I have done @earnest phoenix >_>

#

@brittle nova Maybe if you like OOP

#

Some people prefer functional programming, so they use functions

earnest phoenix
#

how can i prevent someone from using bot commands?

ruby dust
#

like a blacklist?

earnest phoenix
#

yes

ruby dust
#

check if they are blacklisted before processing commands on their behalf

earnest phoenix
#

but how can i do that, lets say bot gets their ID

#

writes it in blacklist .json

ruby dust
#

if that's your setup, then check your so called blacklist.json if they are in it or not

earnest phoenix
#

i didnt try it just thinking about it

grave mist
#
dbl.on('vote', vote => {
  console.log(`User with ID ${vote.user.id} just voted!`);
});

Does this work
I tried it and it didn't work and didn't send any errors

bright spear
#

@grave mist well you'll need to set up the webhook in your bot's edit page

grave mist
#

Else it won't work?

bright spear
#

yes

grave mist
#

But I can't understand that webhook thing

#

Do I have to set webhook port etc?

bright spear
#

yes

grave mist
#

It can be random number?

bright spear
#

no

grave mist
#

Then?

#

And I don't have to include client in new DBL?

bright spear
#

dblapi.js will set up a webserver on the port you specify

#

client is for server count posting it has nothing to do with webhooks

grave mist
#

So I have to define them again?

#

I thought I could edit

#

So this will work?

#
const dbl2 = new DBL('mydbltoken', { webhookPort: 5000, webhookAuth: 'xd' });
dbl2.webhook.on('vote', vote => {
  console.log(`User with ID ${vote.user} just voted!`);
});```
bright spear
#

you dont need to define it again

#

you can use one dbl instance for both webhooks and server count posting

grave mist
#

But I have to use client for server count right

#

And webhookport auth for webhook

#

How to do like you said

steel heath
#

Is it possible to clear the members/messages or other things that is caching and eating from memory a lot with a code that can be evaled?

topaz fjord
#

yes

#

if you're using master d.js there's .sweep I think

bright spear
#

@grave mist ```js
const dbl = new DBL('mydbltoken', { webhookPort: 5000, webhookAuth: 'xd'}, client)

grave mist
#

Ok thanks

robust jackal
#

is there a bot that anyone knows of that if I type a specific word/phrase into the chat a role is given?

bright spear
#

yes

#

dyno

#

well

#

you'll need to run a command

robust jackal
#

alright

#

what is the command?

#

or does it have to be custom

grave mist
#

?role @earnest phoenix <role you wanna give>

#

Oof it pinged an user sorry for the ping dude

robust jackal
#

I am talking a non-admin and mod command

grave mist
#

Why

#

Anyway role is given right

robust jackal
#

i.e someone joines a server and says a word/phrase and has a role named "secret club" a role that only a few people should know how to get. its not for this scenario but that is the overall porpose

bright spear
#

yeah just make a custom command

#
{!role {user} +rolename}```
robust jackal
#

will this be bot automated or is this a command I still have to type to giveb them the role?

grave mist
#

Is there something like emit event

#

So that I can check that vote thing without voting actually

bright spear
#

@robust jackal automated, only they need to type the custom command

#

@grave mist test button in ur bot edit page

robust jackal
#

ok

#

if the word was "wood" how would that custom command be changed?

steel heath
#

@topaz fjord how to sweep

topaz fjord
#
#

@steel heath

steel heath
#

thanks you

grave mist
#

@bright spear I clicked test button but it didn't log that user voted

bright spear
#

did you set up the webhook in your bots code and in the dbl edit page?

grave mist
#

Didn't in edit page

#

Idk what to do there

bright spear
#

well your bot needs to be connected to an ip or domain

grave mist
#

To test it?

bright spear
#

that can be used to connect to the webserver

#

no

#

to use a webhook

grave mist
#

Wtf

#

How can I connect it

bright spear
#

where are you hosting your bot

grave mist
#

Glitch

bright spear
#

oh

#

do you already have webserver code using express?

grave mist
#
setInterval(() => {
  http.get(`http://${process.env.PROJECT_DOMAIN}.glitch.me/`);
}, 80000);```this?
bright spear
#

no, the code with express

grave mist
#
app.get("/", (request, response) => {
  response.sendStatus(200);
});
```this?
bright spear
#

yeah

#

whats your listener code

grave mist
#

Idk I just followed a guide once to set up my bot

bright spear
#

your app.listen code

grave mist
#

There's no such thing in my main file

bright spear
#

is your app.get code in your main file

grave mist
#

Yes

#

Even to know someone has voted, I have to do these many things?

bright spear
#

no...

#

these are only for webhooks

#

to immediately know when someone votes

grave mist
#

I just wanna know the id of the guy who votes

#

Nothing else

bright spear
#

you want to know as soon as they vote?

#

or you want to check if they have voted

grave mist
#

If A votes, bot should say A voted with his ID

#

Not checking

#

I know how to check

bright spear
#

yeah then you'll need to use webhooks

grave mist
#

Rip

bright spear
#

its not that complicated if you know js

grave mist
#

Idk anything about webhook

bright spear
#

you could use dblapi.js and connect it to your express webserver, or just add a route in express

grave mist
#

How to...

bright spear
#

which one

grave mist
#

Which is easy

bright spear
#

both will probably be hard for you

#

tbh

grave mist
#

If you guide me what to do, I can do it correctly

bright spear
#

ok lets just use dblapi.js

#

can you find the app.listen in your code

#

it probably is there somewhere

grave mist
#

Are you sure

#

I can't find it anywhere

bright spear
#

whats the name of your glitch project

grave mist
#

Why

#

You wanna see for yourself?

bright spear
#

i wanna check if it is getting requests

grave mist
#

It is private project, I can invite you

bright spear
#

just tell me the name for now

grave mist
#

You can't see it anyway

#

It is private

bright spear
#

i dont need to see the code

primal egret
grave mist
bright spear
#

yeah

grave mist
#

Quick.db uses it you can find what you want still?

bright spear
#

wut

grave mist
#

quick.db has webviewer

#

So you can still find what you want?

bright spear
#

oh uh

#

idk if you'll be able to set up a webhook on that project if you already have that running a webserver

#

you'll probably need to make a new project

grave mist
#

I can remove that webview

#

Will that work then?

bright spear
#

yeah

#

well we would be able to get it working

grave mist
#

Do you want the port btw

#

It is 3000

bright spear
#

yeah ik

grave mist
#

Done

bright spear
#

ok so

#

can you add the code const server = app.listen(process.env.PORT)

grave mist
#

Then?

bright spear
#

its in the same file as your dbl code right?

grave mist
#

Yes

#

Anything else to add?

bright spear
#

can you make sure the const server is below your app.get code but above your dbl code

grave mist
#

It is

#

And it says OK

bright spear
#

ok good

#

now in your dbl code, change webhookPort: 5000 to webhookServer: server

grave mist
#

Ok

#

Done

bright spear
#

k now that should be good

#

now you can put stuff in your bot's edit page

#

the webhook url should be https://amazing-bot.glitch.me/dblwebhook

grave mist
#

Then?

bright spear
#

the webhook authorization thing should be whatever you set as webhookAuth in your code

grave mist
#

Then save or test

#

Yea it worked tysm

bright spear
#

yw

grave mist
#

It isn't a big process tho you could've said both of them are easy

bright spear
#

lol k

earnest phoenix
#

is there a way to remove that little watermark on the background of the bot page

bright spear
#

wdym

earnest phoenix
#

nvm got it

grave mist
#

Well .user says id then why there's .user.id

#

And .user.username says undefined

bright spear
#

wut

#

what lib?

grave mist
#

dblapi.js

earnest phoenix
#

How do you be gay

bright spear
#

oh

grave mist
#

Oh

#

Then?

bright spear
grave mist
#

K thanks

empty owl
#

I am making a pay command

#

I specifited the amount

#

but

#

it still replies with an error

#
  let mUser = message.mentions.users.first(),
      amount = parseInt(args.join(" ").replace(mUser, ''));
  if (!mUser) return message.reply('you have to include a person to pay!')
  if (isNaN(amount)) return message.reply('you have to include how much money you will pay!')
  let mBal = await db.fetch(`userBalance_${mUser.id}`),
      sBal = await db.fetch(`userBalance_${message.author.id}`);
  if (mBal === null) mBal = 0;
  if (sBal === null) sBal = 0;
  if (amount > sBal) return message.reply('you do not have enough money to pay this person!')
  if (amount < 1) return message.reply("hey you can't pay $0!")
  db.add(`userBalance${mUser.id}`, amount);
  db.subtract(`userBalance${message.author.id}`, amount);
  message.channel.send(`Paid ${amount} to ${mBal.username}!`)
    let payLogEmbed = new Discord.RichEmbed()
      .addField("Pay Log", `${message.author.user.tag} paid ${amount} to ${mUser}!`)
      .addField('Time', `${message.createdTimestamp}`)
  bot.channels.get(521112640815366144).send({embed: payLogEmbed})
empty owl
#

got it

#

so

#

sooooo

#

soOOOO

#

it works

#

but doesnt

#

it sends the success message but doesnt actually pay

#
  let mUser = message.mentions.users.first(),
      amount = parseInt(args[1]);
  if (!mUser) return message.reply('you have to include a person to pay!')
  if (isNaN(amount)) return message.reply('you have to include how much money you will pay!')
  let mBal = await db.fetch(`userBalance_${mUser.id}`),
      sBal = await db.fetch(`userBalance_${message.author.id}`);
  if (mBal === null) mBal = 0;
  if (sBal === null) sBal = 0;
  if (amount > sBal) return message.reply('you do not have enough money to pay this person!')
  if (amount < 1) return message.reply("hey you can't pay $0!")

  db.add(`userBalance${mUser.id}`, amount);
  db.subtract(`userBalance${message.author.id}`, amount);
  message.channel.send(`Paid ${amount} to ${mUser.username}!`)
    let payLogEmbed = new Discord.RichEmbed()
      .addField("Pay Log", `${message.author.user.tag} paid ${amount} to ${mUser}!`)
      .addField('Time', `${message.createdTimestamp}`)
  bot.channels.get(521112640815366144).send({embed: payLogEmbed})
empty owl
#

oh

#

thanks

west raptor
#

yw

hard sorrel
#

hey!

#

I'm wondering on using Individual User Id Voting Check for the past 24 hours.
My bot is in python
I've checked the dbl python lib source code but I havent found any function for this request
Can someone help me with it plz?

bright spear
#

@hard sorrel looks like its not supported by dblpy so you'll need to make a direct request to the api

timber quarry
#

anyone got a few seconds to help code a simple bot? looking for something that monitors a folder and if a new .txt document arrives, prints its contents to a specific channel. im shit at coding.

bright spear
#

nobody's gonna help you code a bot lol

#

if u have a specific question u can ask

timber quarry
#

any idea where I could find folks willing to work a small project?

#

not sure where to start even.\

bright spear
#

not unless you're gonna pay

hard sorrel
#

Ad whats the link torequest plz

bright spear
#

wut

hard sorrel
#

Bcs it only tells bot/id/votes

#

But is the domain the same

bright spear
#

sec

#

https://discordbots.org/api/bots/BOTID/check?userId=USERID
change BOTID and USERID

hard sorrel
#

Also doc tells That authentification is required but what is dbl auth 🤔
Thanks for the help 😜

#

Ty

bright spear
#

add an Authorization header with your bot's DBL API key as the value

hard sorrel
#

I see

#

Ty

#

😆

bright spear
#

yw

dapper cargo
#

Can you put videos in discord embeds?

west raptor
#

uh

#

I don't think so

dapper cargo
#

Shit

timber quarry
#

if i have a python script that requires servercomm as a command line argument what could that be? i.e. #The program should be called in cmd like so: TestBot.py 'directory' 'channel' 'OAuth2 Token'

comline = sys.argv #sys.argv is a list of the arguments/parameters given in the command line
directory = comline[1] #the first parameter
channelcomm = comline[2]
bottoken = comline[3]
servercomm = comline[4]

#

cant figure out what its asking for got the rest going.

formal agate
#

In discord js, im getting an error while using ytdl-core. The error say that the "url" must be a string, i think i know what it means but idk how to do that nor understand if that's al;l there is to it.
Code im using form tutorial:

const voiceChannel = message.member.voiceChannel;
    if (!voiceChannel) return message.channel.send("You must be in a voice channel to play music.");

    const permissions = voiceChannel.permissionsFor(message.client.user);
    if (!permissions.has('CONNECT')) return message.channel.send("I don't have the proper perms to connect to the voice channel.");
    if (!permissions.has('SPEAK')) return message.channel.send("I don't have the proper perms to play music in your current channel.");

    try {
        var connection = await voiceChannel.join();
    } catch (error) {
        console.error(error);
        return message.channel.send(`I was not able to join the voice channel ${error}.`);
    }

    var ytURL = args.join(' ');

    const dispatcher = connection.playStream(ytdl(args))
        .on('end', () => {
            message.channel.send("Music playback has finnished");
            voiceChannel.leave();
        })
        .on('error', error => {
            console.error(error);
        });
    dispatcher.setVolumeLogarithmic(5 / 5);```
#

Error:

    at Url.parse (url.js:152:11)
    at Object.urlParse [as parse] (url.js:146:13)
    at Object.exports.getURLVideoID (D:\STUFF\node_modules\ytdl-core\lib\util.js:270:22)
    at Object.exports.getVideoID (D:\STUFF\node_modules\ytdl-core\lib\util.js:301:20)
    at Function.exports.(anonymous function) [as getInfo] (D:\STUFF\node_modules\ytdl-core\lib\info.js:363:21)
    at ytdl (D:\STUFF\node_modules\ytdl-core\lib\index.js:17:8)
    at Object.exports.run (D:\STUFF\commands\play.js:19:46)
    at process.internalTickCallback (internal/process/next_tick.js:77:7)```
zealous veldt
#

Please properly format your code blocks

pastel mulch
#

mongoose or quick.db

formal agate
#

wdym by format properly @zealous veldt?

#

you mean show the whole code?

zealous veldt
#

no

#

change the start of the block to this

#

```js

#

and then a new line

#

will make it look like js

west raptor
#

@pastel mulch well one is local db and the other is 3rd party so which ever you feel like using tbh

#

```js

#

oof

formal agate
#

happy klep?

zealous veldt
#

there ya go

#

more readable now

formal agate
#

lol

bright spear
#

probably ytdl(args)

#

ig args isnt a string

#

shouldnt it be ytURL?

formal agate
#

this is args

var cont = message.content.slice(prefix.find(p => message.content.startsWith(p)).length).split(" "); //slices off the prefix, then puts it in a array
    var args = cont.slice(1);```
west raptor
#

args is a array

#

not a string

bright spear
#

^

#

did you write your code or did you just steal it

#

cuz it seems u dont know js

formal agate
#

"stole" the command

#

made some mods

#

but its basically the same thing

#

oof

brittle nova
#

My plan for persistent timers is to have an interval on ready every whatever seconds (maybe 5 - 10) to check the database for events that need to be fired and handle them accordingly. This won't be very exact though. If a timer is set for 45 seconds, it may be 50 or 55 seconds before it is handled. Is there a way to have exact and persistent timers without having the interval be less than 1 second?

#

using nodejs and mongodb

earnest phoenix
#

well

#

when the bot starts up

#

you can have it setTimeout to whenever the DB says the event is due

languid dragon
#

@brittle nova what's this for

brittle nova
#

@languid dragon temporary moderation actions for now

sick cloud
#

if your using it on one server its safe ish to cache and check every 3~ seconds

#

my bot for reminders queries the db every 10 seconds, caches and the timer queries the cache every 2 seconds

brittle nova
#

So I guess you can't actually get it exact?

sick cloud
#

not really

#

unless you can stress your db that much

bright spear
#

Well some DBs have subscription thingies where it sends u an update or smth

late hill
#

You could do what iAmThe32Bit suggested to get it ~exact

#

But note that if there's no event saved when you startup it won't do anything

#

You could just set the timeout when you set the event to fix that

#

You can even make it able to do multiple events

#

By setting the timeout to whichever one comes first

#

And at the end you can make it set another timeout for the next one

earnest phoenix
#

guys my audioclient does not play the first time connects any fix?

languid dragon
#

Just check a time stamp every time an event is emitted

#

That way u don't need to fill it with timers

#

@brittle nova

brittle nova
#

It's not an actual event

#

by event I mean something to be done

late hill
#

Yeh

#

Something to be done -> function

#

Execute the function

#

In the timeout

keen drift
#

@coral trellis hey, h0w do you store guild bans, user bans on ur bot

coral trellis
#

Is this a legit question?

keen drift
#

yes

coral trellis
#

You can just store them in a database on ban event

keen drift
#

this is my ban structure

#

how does yours look

coral trellis
#

I don't actually store them anywhere, I just have them sent into the logs channel.

west raptor
#

submit it @dusty oasis

keen drift
#

in the logs channel Thonkang

west raptor
keen drift
#

so how does your bot know what guild to ban

coral trellis
#

Oh wait I mistook your question

#

So like in terms of Global bans?

keen drift
#

yeah

coral trellis
#

Oh I use an API

#

As it's easier and well I have other admins taking care of them as well hap

keen drift
#

so how does the bot know tho

#

I was thinking a task that checks the ban database once a while

#

and compare it to the local cache of guilds

#

if match, leave the guild

coral trellis
#

So I use the API's endpoint with the users ID on member join and if it returns true it bans the user

#

It doesn't loop through all the servers as I am too lazy and it takes too long

keen drift
#

do you do guild ban

#

or just user ban

coral trellis
#

User ban I believe

keen drift
#

i believe PepeEvilThink

coral trellis
#

😩

#

@keen drift I am doing a rewrite of the bot so it doesn't really matter at this stage

keen drift
#

same

#

i'm just trying to plan things out

#

get the foundations done

coral trellis
#

I have an entire repo dedicated to the planning of it all

keen drift
#

i'm currently working on a wireframe

#

gonna post it on my subreddit and get some feedback

#

sort of a like sneak peak and feedback

coral trellis
#

Send me the link so I can take a look

#

Maybe I'll snatch a few ideas

keen drift
#

i'm almost done

#

it's a simple sketch

#

but I want to get some feedback soon

mossy vine
keen drift
#

looks clickable

#

click on it

mossy vine
#

ohh rsplit starts from the right

earnest phoenix
#

can i have 2 arrays in 1 .json?

#

lets say i 2 arrays which are 1 = random numbers and 2 = random strings

late hill
#

Your json has to be an object or an array afaik

#

You could make it an object with 2 arrays

#

Or an array with 2 arrays

earnest phoenix
#
{
    "array1": [
    asdasd,
    123123
]
    "array2": [
    j663,
    123
]
}
#

this is what i meant

late hill
#
{
"firstArray": [1, 2, 3],
"secondArray": ["one", "two", "three"]
}```
mossy vine
#

yes you can do that

late hill
#

Your example won't work

#

As it's missing a ","

mossy vine
#

oh yeas its missing the colon

earnest phoenix
#

after ]?

mossy vine
#

not colon

late hill
#

yes

mossy vine
#

the whatitscalled

late hill
#

comma

empty owl
#

Do we refer to jsons as const config = require('./config.json')

config.array

earnest phoenix
#

i dont expect spoonfeeding, but how could i append an string to .json's array?

#

allowing users to append strings

late hill
#

The file extension isn't needed if that's the only file you have with that name @empty owl

empty owl
#

Oh ok

late hill
#

If your json is an array than config will be an array in your case

empty owl
#

ok

earnest phoenix
#
   if (cmd === "writetest") {
         let text = args.join(" ")
         fs.appendFile('test.json', text, function(err, text){
            if (err) console.log(err);
            console.log("Successfully Written to File.")
         });
        }
late hill
#

What are you using that for ^

earnest phoenix
#

im trying to learn how to write .json files

#

then add member ID's

#

to blacklist

late hill
#

I would recommend using a database.

earnest phoenix
#

what do you mean

late hill
#

Store them in a database rather than just a json file

earnest phoenix
#

i dont know what do you mean by "database" ;c

late hill
#

You can read/write data to a database

earnest phoenix
#

app.post('/users', function (req, res) {
// retrieve user posted data from the body
const user = req.body
users.push({
name: user.name,
age: user.age
})
res.send('successfully registered')
})

late hill
#

👀

earnest phoenix
#

its example from the internet

late hill
#

For what? xd

earnest phoenix
#

pskdfjklsdjfsdf

#

do you mean

#

another type of file

late hill
#

I just don't think you should save stuff like that in a json file

#

As I'm pretty sure appendFile would just add it to the bottom

#

And ruin the file

#

There's probably some tricky stuff you can do

earnest phoenix
#

file for each user?

late hill
#

But a database is made for this kind of stuff

#

A database isn't a file 👀

earnest phoenix
#

i didnt mean that

#

if i had blacklist folder

#

than just store each user in separate file

late hill
#

Would work

earnest phoenix
#

google isnt helping me very much

late hill
#

I mean

earnest phoenix
#

nvm, ill find a way

late hill
#

Never a bad time to start learning about databases

#

mlab offers 500mb of storage in their free plans

#

You can use the mongoose package to integrate it in your project

#

It's pretty easy to setup

marsh matrix
#

I need a bit of help extracting posts from reddit

#

Anyone know about this? I'm using Python (discord.py)

earnest phoenix
#
TypeError: Cannot read property 'has' of undefined

do you know this error

lament meteor
#

pretty self explainatory

misty rune
#

^

mossy vine
#

you have been asking this for hours

formal agate
#

Lol

late hill
#

It means whatever u put before .has is undefined 👀

formal agate
#

Or the var, const etc

high anchor
valid frigate
#

reddit has an option to display subreddits as json without an api token bloblul

empty owl
#

@high anchor what are u using it for

earnest phoenix
#

how can bot read if json contains user ID?

#

im trying to figure this out but it doesnt work >(

#

}

empty owl
#

?

valid frigate
#

well first of all if that's javascript you need to wrap the if statement with parentheses like if () {}, second, if you're just looking for a user id it typically doesn't have to be inside a json, you can just put it in an array like ['userid1', 'userid2', ...]

empty owl
#

let a = []

valid frigate
#

if it's an array inside a json, like

{
    users: []
}

then you can just iterate over users using a for loop

#

or use .includes()

empty owl
valid frigate
earnest phoenix
#

oh i see

#

i get idea now

valid frigate
#

👌

earnest phoenix
#

can i use fs.appendfile

empty owl
#

Anyone here certified

earnest phoenix
#

to write json

#

its easier as json

empty owl
#

u know u can just list them out

#

Like '.'.'

earnest phoenix
#

now the problem is in appending userid

#

i can append in normal files

#

e.g. text files

empty owl
#

@valid frigate help him im a noob

valid frigate
#

eh

earnest phoenix
#

turns out its same as in other files

valid frigate
#

i dont understand

earnest phoenix
#

fs.appendFile("blacklist.json", json , function (err) {

#

jesus fucking christ

#

it overwrites it

quartz kindle
#

appendFile is not meant to be used with json

#

it will break it

#

you have to write the entire file at once

high anchor
#

@empty owl to give my bot reddit post watching

#

If i just grab the json then i cant do any reddit user auth, meaning i cant implement approve/remove posts from Discord

#

Suppose that’s the only drawback

#

Snoowrapper needs an API token tho

empty owl
#

Like a random meme from Reddit?

#

@high anchor

ruby talon
#

(if you're using python use praw for the reddit thing)

slim heart
#

how can i get the bot to know if an emoji exists. cuz i have it working if the bot is in the server with it but with the nitro emojis it cant find it
discord.js

bright spear
#

client.emojis.get('id')

slim heart
#

client.emojis.map(id => id.id).contains(arg[i].replace(/>/, "").split(":")[2])

#

i just do that

#

but im encountering emojis from servers the bot is not in

#

due to nitro users.

#

so sometimes this creates problems

earnest phoenix
bright spear
#

@slim heart if the bot isnt in the server then it wont know the emoji exists

earnest phoenix
#

^

bright spear
#

so you can just check if its undefined/null

slim heart
#

yeah thats what i mean\

#

is there anyway at all i can tell even tho?

earnest phoenix
#

If you are using emojis, I recommend putting the bot in your own server then using your server's emojis across servers.

bright spear
#

uh

#

just if(emoji)

slim heart
#

no for the emojis that are in server the bot doesnt have

#

cuz its not in client.emojis

#

I already have emojis covered for emojis that the bot is already in

#

i literally showed my code above

#

what im asking is if theres any way at all of telling its an emoji if the bot isnt in the server its from

wide ruin
#
const d = require('discord.js')
const fs = require('fs')
const c = new d.Client()
const ms = require('ms')
const token = process.env.TOKEN
const prefix = '?'

c.on('message', async(message) => {
if(message.content.startsWith(prefix)){
  
}

});

c.user.setPresence({
  game: {name: 'with carrots'},
  status: 'idle'
}).then(console.log)
  .catch(console.error)
c.login(token)```
#

Just the start of a js bot has an error

#

Cannot read property setPresence of null

inner jewel
#

because there's no c.user

#

because it hasn't logged in

wide ruin
#

Do I move it up?

#

Just to the end of the consts

inner jewel
#

no

#

you move it to a handler

#

eg ready

quartz kindle
#

you have to use the ready event

wide ruin
#

c.on('ready' => ({

quartz kindle
#

yes

wide ruin
#

{(*

#

Thanks

quartz kindle
#

not the way you did it tho

#

the same way you do the message event

wide ruin
#

With async

quartz kindle
#

you dont need async if you're not using async stuff

wide ruin
#
const d = require('discord.js')
const fs = require('fs')
const c = new d.Client()
const ms = require('ms')
const token = process.env.TOKEN
const prefix = '?'

c.on('message', async(message) => {
if(message.content.startsWith(prefix)){
  
}

});

c.user.setPresence({
  game: {name: 'with carrots'},
  status: 'idle'
}).then(console.log)
  .catch(console.error)

c.on('ready', async(ready) => {
  c.login(token)
})``` this?
#

@inner jewel

inner jewel
#

no

#

you set the presence in the ready handler

wide ruin
#

Oh

sick cloud
#

ready doesnt provide anything

#

its just ()

wide ruin
#

Fixed it, thanks

west raptor
#

I don't think bots can have rich presence @wide ruin

wide ruin
#

I got it from docs

west raptor
#

Still, I'm pretty sure bots can't have rich presence

#

oh

#

wait

#

thats not rich presence

#

my bad

wide ruin
#

Its ok

#

Also

#

Using this method, how can I do watching, listening, playing and streaming?

sick cloud
#

4,3,2,1,0

#

can you get the full url of where a users at

#

in express

#

like if someone clicks something from /profile/id can i get https://website.com/profile/id

quartz kindle
#

req.protocol + req.hostname + req.originalUrl

west raptor
#

@wide ruin with type iirc

wide ruin
#

Wdym @west raptor

high anchor
#

@empty owl yup

empty owl
#

you can use

#

random-puppy api

#

for random image urls from reddit

high anchor
#

Oh. Well, my bot is used on reddit discords... a post watch is a requested feature. Sorry for misunderstanding your question

#

That would be a nice misc command though

bright spear
#

@slim heart exactly, its not in client.emojis, so client.emojis.get('id') will return undefined

slim heart
#

yes

#

you're not understanding my problem

wide ruin
#
const d = require('discord.js')

module.exports.run = async(c, message, command, args, ms) => {
  let ping = Date.now() - message.createdAt()
  let p = new d.RichEmbed()
    .setTitle('Pong!')
    .setDescription(`${ping} ms!`)
    .setColor('00FF00')
  message.channel.send(p)
}``` why doesn't this work?
slim heart
#

I'm trying to see if there's anyway to tell if it's an emoji even tho its not in there

bright spear
#

oh i see

#

you could try https://cdn.discordapp.com/emojis/ID.png

#

it'll be a 404 if its not found

inner jewel
#

@wide ruin that'll just calculate clock differences tho

#

clock difference + time for the ws payload to be received

wide ruin
#

It worked on another bot

#

So what should it be?

#

@inner jewel

empty owl
#

hey

#
    if (code !== "bob") return message.author.send(`${code} is not a code.`).then(message.delete(message))```
#

how do I make it so i can check if its a different code

#

like that?

#
    let codes = [
    "bob",
    "greekyogurt",
      "ligma",
    "despacito",
    ]
      await message.delete
    if (code !== codes) return message.author.send(`${code} is not a code.`).then(message.delete(message))
inner jewel
#

.then(message.delete(message)) is wrong

empty owl
#

why

#

wait

#

dont focus on that

inner jewel
#

and i'm pretty sure await message.delete is invalid syntax

empty owl
#

i have an async

inner jewel
#

also you want Array#includes

empty owl
#

o

inner jewel
#

yes but that's not a function call

empty owl
#

so

inner jewel
#

you're awaiting the delete function

#

not the delete promise

#

you should learn js

empty owl
#

ok

#

but

#

nvm

#
    let codes = [
    "bob",
    "greekyogurt",
      "ligma",
    "despacito",
    ]
    message.delete(message)
    if (code !== codes) return message.author.send(`${code} is not a code.`)
#

Ok need the help now

inner jewel
#

i already gave you the answer

#

Array#includes

empty owl
#

oof

#

Ok

violet dagger
#

same

empty owl
#

@inner jewel so like this?

#
   if (code.includes(codes) === false) return message.author.send(`${code} is not a code.`)