#development

1 messages · Page 797 of 1

vagrant tree
#

it really doesnt like this line: ```py
message, user = pending_tasks[ctx.message.author]
KeyError: <Member id=402805485364969473 name='dracount' discriminator='3902' bot=False nick=None guild=<Guild id=676127269294571530 name='dracounts' shard_id=None chunked=True member_count=2>>

modest maple
#

what is ur code now

#

i think u slightly miss understood my last statement xD

vagrant tree
#

😓 ```py
def check(m):
try:
return m.author == ctx.message.author and m.channel == ctx.message.channel and int(m.content) > 0 and int(m.content) < 11
except:
print('failed...',m.content)
return False

    try:
        message = bot.wait_for('message', timeout=300.0, check=check)
        print('completed check!!!',message)
        message, user = pending_tasks[ctx.message.author]
    except asyncio.TimeoutError:
        await ctx.send('Timeout')
    else:
        await ctx.send('Cool, thanks!')
    
    print('im not sure whats going on...',message, user)

    selection_message = await bot.wait_for('message',check=check)
#

i really thought there would be a better way of cancelling old commands 🤔

grave jacinth
#

hey guys im using discord.js

summer torrent
#

so?

grave jacinth
#

whats yours

modest maple
#

yehhhh u complicating dis

#

big time

earnest phoenix
#

Mines a pikachu

summer torrent
#

whats yours
@grave jacinth same

grave jacinth
#

ok xd

modest maple
#

@vagrant tree you dont need

            message, user = pending_tasks[ctx.message.author]```

at all
#

you need to await wait_for

#

that gives you your message object

grave jacinth
#

what you think about glitch

modest maple
#

that check will ignore any events that are not acting within the time frame of X user in X channel

#

i would lower your time out

#

i understand you're trying to limit how many of those checks you have going at once

#

i would keep a standard dict with userId and a Bool if its really needed

#

set bool to false when the task is done

#

if its not its set to true

#

if when we check the userId in the dict its true we just return or do something there

earnest phoenix
#

@grave jacinth It works fine for small bots but if you plan to do anything intensive get a VPS if possible

regal saddle
#

i switched from python to js...Translate the code is kinda aids pandasad

modest maple
#

ofc it is

#

they are completely diffrent syntaxes

regal saddle
#

yep

modest maple
#

and one handles alot more

grave jacinth
#

ok i need host or vps

regal saddle
#

Im working with modules to get it a bit better 🙂

modest maple
#

y did u even switch from py to js

regal saddle
#

dont know, python was kinda weird

#

for me

#

pls dont hurt me chief zoomeyes

vagrant tree
#

yes, thanks for the help. half understood code from stackoverflow is a trap

#

i dont suppose its possible on a new command to kill any existing commands from the same author?

modest maple
#

not rlly easily

#

you start getting into rather advanced areas of asyncio at that point

vagrant tree
#

ok. im just gonna let this thing execute twice. i dont see any easy solution to this right now... maybe ill try again another time

modest maple
#

i mean that code will only trigger once

#

once that check is true itll fire

#

and thats it

#

wont fire again

vagrant tree
#

how its meant to work is: ```
?command select A
<options 1-10 A embed shown>
10
<show option 10>

my issue:
?command select A
<options 1-10 A embed shown>
?command select B
<options 1-10 B embed shown>
5
<show option 5A>
<show option 5B>

quartz kindle
#

one way is to somehow disable/cancel existing waiters, another way is to track states in memory

#

since select A and select B are separate commands, they will be treated separately. if you want one of them to override the other, you could have some variable tracking the current state, and have both commands read/write to the same variable to figure out which page is being shown right now

vagrant tree
#

i am really surprised this is not a common issue

quartz kindle
#

its not a common issue because people rarely use separate commands that await for options

#

and when they do, its because they want people to open both options at once

modest maple
#

send ur code again

#

u are doing this

#

very very weirdly

quartz kindle
#

and also, users will rarely ever type both commands, they will answer the first commend before attempting to open the second one

vagrant tree
#
        await ctx.send(embed=embeded,content='Search details')

        def check(m):
            try:
                return m.author == ctx.message.author and m.channel == ctx.message.channel and int(m.content) > 0 and int(m.content) < 11
            except:
                print('failed...',m.content)
                return False

        try:
            selection_message = await bot.wait_for('message',check=check)
        except asyncio.TimeoutError:
            await ctx.send('Timeout')
        else:
            await ctx.send('Cool, thanks!')
        
        print('selection message = ',selection_message)
        selection = selection_message.content
modest maple
#

you know that will never time out now right?

regal saddle
#

that js?

modest maple
#

that would be python

#

notice the distinct lack of {}

regal saddle
#

youre right

vagrant tree
#

well since i dont actually know how to cancel a previous im going to just get the timeout working and move on from there

modest maple
#

that wont timeout

#

that will cause many a issues

vagrant tree
#

yes i need to work on that

modest maple
#

set timeout = to 30 or somthing

#

otherthan that

#

looks alright

vagrant tree
#

@modest maple thanks for all the help. much appreciated

modest maple
#

np

amber fractal
#

Hey CF you know what RuntimeError: Timeout context manager should be used inside a task means?

slim heart
#

okay so would it be better for times mutes to set a timeout if it's within 5 minutes or something like that to more accurately mute at a specific time rather than being on the minute or several? like accuracy > scalability idk

amber fractal
#

I always went with checking the mute database (or whatever) every 5 minutes and checking the times

#

I think setting a timeout for every mute just wouldnt be a good idea (on a bigger bot)

slim heart
#

well a setTimeout for anything within small time

quartz kindle
#

i would use a timeout and also store the timers in the db, to resume the timeouts on process restarts

#

shouldnt be much of a problem to have a few thousand timeouts running

kindred wadi
#
const moment = require('moment');
const Discord = require('discord.js');
const ayarlar = require('../ayarlar.json');
const snekfetch = require('snekfetch');

var prefix = ayarlar.prefix;

module.exports = async client => {
  
  client.appInfo = await client.fetchApplication();
setInterval( async () => {
      client.appInfo = await client.fetchApplication();
    }, 60000);
  require("../util/dashboard.js")(client);
console.log('>>Playing updated.');
console.log('Bot joined.');
console.log(`[${moment().format('YYYY-MM-DD HH:mm:ss')}] BOT:  ` + client.channels.size + ` channel, ` + client.guilds.size + ` server ` + client.guilds.reduce((a, b) => a + b.memberCount, 0).toLocaleString() + ` Online!`);
    var Games = [
      
        `🚀 ${client.guilds.size} Server | 🚀 ${client.users.size} User`
    ];
  
  setInterval(function() {
    var random = Math.floor(Math.random()*(Games.length-0+1)+0);
    client.user.setActivity(Games[random], { type: "STREAMING", url: "STREAMLINK" } );
  }, 2 * 2000);

};```

😥 Old bot
quartz kindle
#

if your bot is that big that requires tens of thousands of timeouts, you could split and group them in batches of 1 second or 5 seconds or something like that and round the timers to that

#

another option would be to combine the best of both worlds. have an interval running every minute or 5 minutes or so, and fire a timeout for each mute that will expire in less than the interval minute(s)

modest maple
#

I'd just use a Cron system

#

Just set time events so when it's X time Tigger the event with a payload of users etc...

topaz fjord
#

isn't snekfetch deprecated

#

it is

hoary elm
#

Yeah they recommend using node-fetch now instead

earnest phoenix
#

how 2 watch for redis expire event

#

ie i set the value like so, how do i watch for its expirey

slim heart
#

I've never been an avid linux user but im looking into moving from windows server.
I do need some help (and if anyone is good with it and willing to help hmu)
but i do have a question, what are the replacements for exe's in terms of actual running applications? Like right now I run my mongodb.exe and it's like a legitimate application in the task bar. Instead is it going to be like a service? Or what alternative etc. I've no idea at this point

topaz fjord
#

mongodb has a linux version

#

@slim heart

#

it depends on the services/.exe you use

slim heart
#

i know that but how does that work, im just making an example out of it

topaz fjord
#

most have a linux counterpart

hoary elm
#
 ... 
}```

```client.expire(id, idYouPicked)``` should work from what the docs say  @earnest phoenix

https://redis.io/commands/expire
topaz fjord
#

through systemctl / services

#

they run as daemons in the background

slim heart
#

like rn i can login to my vps and there's a mongodb.exe app running on the taskbar what's the replacement

topaz fjord
#

you can set it up to boot with the server

slim heart
#

ah so like a background service

topaz fjord
#

yeah

slim heart
#

interesting okay. thnx for that

topaz fjord
#

np

#

@slim heart also, if there are programs that don't typically run as daemons, you can create service files to make it run as one

slim heart
#

okay, ill have to lookup how to do that, sounds great tho

topaz fjord
#

ye

earnest phoenix
#

@hoary elm im not trying to manually expire

#

im trying to watch for expires

hoary elm
#

Oh my bad

#

🤦🏻‍♂️

#

Misread what you said

#

That's what currently holds their "watch or notification on whatever " events

#

All the commands affecting a given key.

All the keys receiving an LPUSH operation.

All the keys expiring in the database 0.

#

This is what is currently possible with it

#

If that doesn't help then I'm sure what you are looking for exists but I can't find it at the moment and don't know it off the top of my head

dense drift
#

Does anyone know why this doesn't work?

newMember.roles.every(function (value) {
   if (oldMember.roles.find(r => r.id == value.id) == null) {```

I'm trying to list the roles that are changed. This is indeed under guildMemberUpdate.
sudden geyser
#

can you show the entire block of code please

#

also are you using stable or master

dense drift
#

Actually, I have a feeling it was working. Lol

#

hmm

#

Maybe not, okay here ya go

#
//...

      var Changes = {
        unknown: 0,
        addedRole: 1,
        removedRole: 2,
        username: 3,
        nickname: 4,
        avatar: 5
      }
      var change = Changes.unknown

//...
         var addedRole = ''
         newMember.roles.every(function (value) {
           if (oldMember.roles.find(r => r.id == value.id)) {
             change = Changes.addedRole
             addedRole = value.id
             console.log(addedRole)
           }
         })

//...
case Changes.addedRole:
                log.send({embed: {
                    color: 0x0099ff,
                    title: 'Role Added',
                    thumbnail: {
                        url: `${newMember.user.displayAvatarURL}`,
                        },
                    author: {
                        name: "FrogBot",
                        icon_url: `${config.avatar}`,
                        url: "https://www.patreon.com/HephBot",
                    },
                    fields: [
                        {
                            name: 'User',
                            value: oldMember.displayName,
                            inline: true,
                        },        
                        {
                            name: 'Old Roles',
                            value: oldMember.roles.map(r => `${r}`).filter(r => r !== `@everyone`).join(' '),
                            inline: true,
                        },        
                        {
                            name: 'Role Added',
                            value: `<@${addedRole}>`,
                            inline: true,
                        },    
                    ],
                    timestamp: new Date(),
                }})
///...```
#

And honestly, I don't know if I'm on stable or master, is there a way to check?

hoary elm
#

Package.json what version of discord.js

dense drift
#

11.5.1

hoary elm
#

So you're using stable

dense drift
#

Good to know 😛

hoary elm
#

I believe anyways, as far as I know 11.5.1 is stable 12 is master but I could be wrong lol

dense drift
#

Works for me

dense drift
#
newMember.roles.every(function (value) {
           if (oldMember.roles.find(r => r.id == value.id)) {
             change = Changes.addedRole
             addedRole = value.name
             //console.log(addedRole)
           }
         })```

This returns @earnest phoenix
#

I personally don't think it should, anyone know why it does?

#

Please @ me if you know what's up. I'm still confused but I'm taking a break. I can use any help anyone will provide.

slender thistle
#

Is <!DOCTYPE html> really required in HTML

hoary elm
#

🤔

low wasp
#

@slender thistle no

#

but most browsers put it in when you inspect element if its not included

slender thistle
#

ty

charred jetty
#

How to get total dbl votes?

#

For discord.js

earnest phoenix
#

you their API

lavish seal
#

when i do the command s!say it deletes the command but doesnt echo it, what did i do wrong

#

also ive decided to rewrite the entire bot i did yesterday on my pc rather than that glitch site

copper cradle
#

you're not even making the bot send the message

#

@lavish seal

lavish seal
#

nevermind lol

earnest phoenix
#
let not = /no(o+)t/i;
console.log(not.test("nnoott"));
// -> true

i don't get why this returns true, to my understanding "+" only lets the "o" repeat not the "n" or "t"

dense drift
#

because it's there

#

nnoott

#

nnoott

earnest phoenix
#

🤔

#

Anyone here

earnest phoenix
#

have you tried not copypasting code

delicate zephyr
unique glade
#

How to change the channel where the invite is made

#

How

glass crag
#

Is there any plugin to Discord.js for easy bot management and statistics monitoring?

#

Id like to get stats, charts over installs/usage, server directory etc for the bot, and Id hope someone made something standardised plug-and-play for discord.js

peak venture
#

how would i iterate over all guilds in which my bot to find guilds from which i have ids?

dense drift
#

forEach

peak venture
#

client.channels.get('channelid').then(channel.delete())

.then is not a function?

#

i need to wait for this output though

earnest phoenix
#

how can i make a anti invite command?

lament tusk
#

for some reason when i tag my bot on my phone it responds, but through my laptop it doesn't, and I've no idea why :')

earnest phoenix
#

Does anyone know which permission is needed to check audit logs

#

I think it was manage guild but I have forgotten

summer torrent
#

VIEW_AUDIT_LOG

earnest phoenix
#

Really

#

That became a perm

#

lmao

#

Oh no sry

#

I asked it wrong

#

I meant the invites my bad

slender thistle
#

MANAGE_GUILD

earnest phoenix
#

Haven't slept yet so I am not thinking right atm

#

Thanks

summer torrent
earnest phoenix
#

I didn't find it on that link

bitter sundial
#

I think it requires a combination of create invite and manage guild

earnest phoenix
#

They really need to make a perm just to read invites

bitter sundial
#

I dont think so

#

but they need to add hierarchy to channel overrides and add a permission for modifying slowmode separately

earnest phoenix
#

will my bot get aprooved today?

#

idk

earnest phoenix
#

@lament tusk use <@id> and <@!id> i think this is the problem ;)

slender thistle
#

!@

earnest phoenix
#

@slender thistle

#

Oh on Phone this is without

slender thistle
#

nvm it's @!

earnest phoenix
#

Yeah i have said that

#

👀

quartz kindle
#

i was doing it wrong for a long time too lol

copper cradle
#

bruh

#

what does @! do

#

@copper cradle

earnest phoenix
#

self ping lol

quartz kindle
#

it used to be to differentiate members with nicknames

#

if the member had a nickname set, your bot would receive !id instead of id

#

but now its not like that anymore, your bot pretty much always receives !id

copper cradle
#

seriously

#

well

#

that's kinda stupid

quartz kindle
#

anyways if you want your bot to handle mentions, it needs to handle both versions because you never know

copper cradle
#

¯\_(ツ)_/¯

earnest phoenix
#

how can i make a ping for help command in d.js latest stable?

summer torrent
#

client.ping

earnest phoenix
#

:|

quartz kindle
#

what do you mean?

earnest phoenix
#

when i mention the bot i get an embed

earnest phoenix
#

Thank you

dense drift
#

It currently returns @everyone whenever a role is updated, therefore posting the user roles, and then @everyone is the one added, no matter if I add or remove anything.

quartz kindle
#
addedRole = newMember.roles.find(r => !oldMember.roles.has(r.id));
removedRole = oldMember.roles.find(r => !newMember.roles.has(r.id))```
#

these should work better

earnest phoenix
#

I need a shard if my bot is in this server?

#

Bot has started, with 20703 users, in 108 channels of 4 guilds.

modest maple
#

Ni

#

No

#

You need to shard when you get close to 2.5k guilds

#

At 2.5k guilds discord won't let you login unless you shard

earnest phoenix
#

Thank you

lament tusk
#

@earnest phoenix thanks a lot!

earnest phoenix
#

@lament tusk np

slow pike
#

What's a shard?

quartz kindle
#

a shard is a discord connection

#

once a bot reaches 2500 guilds, sharding becomes required, which means splitting your bot into multiple connections

#

so a single connection doesnt get overloaded

slow pike
#

do you do that in programming or there's support for that, in Discord .NET for example

#

i know there is a property of shards, i just need to add more of those?

quartz kindle
#

let me check

quartz kindle
slow pike
#

oh

#

nevermind 😄

weak parrot
#

No they're not the same but using them can be quite similair depending on what you're trying to do.

#

DSharpPlus and Discord.Net both have really easy sharding anyway ¯_(ツ)_/¯

quartz kindle
slow pike
#

It seems there's a dedicated class for it, just DiscordShardedClient

night thicket
#

no.yardım

grim aspen
slim heart
#

would
start.sh

node x
start.sh```
create a restarting program?
mossy vine
#

seems so, yeah

slim heart
#

(and yes ik pm2 i'm just doing this for a specific program that can manage the pm2 so obv i cant host it on there lol) also that's what i do on bat but i'm turning into linux

mossy vine
#

./start.sh but otherwise yeah

#

yeah that works

slim heart
#

ah alr thnx

slim heart
#

what's like the standard directory for all the files to be held for a server in linux?

#

i remember like something but idk

quartz kindle
#

for user files? it depends, could be /root or /home or /username

#

or even /home/username

#

most likely when you connect via ssh, it should default to the correct folder

slim heart
#

for things that the server should be hosting, not like for personal use

#

so like the place where id put all my bot files and applications to be ran

#

like rn in windows i just have all my files in C:/Workspace

slim heart
#

also where would things like database data go?

pine bear
#

I ran npm init -y on node.js but it didn't really work.

earnest phoenix
#

what didnt work

pine bear
#

npm init -y

quartz kindle
#

@slim heart i put them in the default folders

#

/root/bot1 or /home/bot1

#

whatever the ssh opens by default

#

same with databases, if a db is only used by one project, put it in its folder as well

#

if the db is used by many projects, put it in a dedicated folder

slim heart
#

i think imma do /home/jpb will be like my workspace dir

#

i was told in djs to do it

quartz kindle
#

yeah should be fine

#

i basically use whatever ssh defaults to as my workspace

#

since i dont use the server for anything other than the things im hosting

slim heart
#

right

quartz kindle
#

@pine bear explain what you mean by "didnt work". what didnt work? what did you want to happen and what did happen?

pine bear
#

Uhh, it either says that you shouldn't jive the npm without the reply or that the token is uncertain or undefined.

earnest phoenix
pine bear
#

That doesn't help much

earnest phoenix
slim heart
#

@modern sable

modern sable
pine bear
#

Still doesn't help my question

earnest phoenix
#

who ?

#

why ?

slim heart
#

he mentioned you, it's you, stop

earnest phoenix
#

who ?

#

me ?

slim heart
#

y e s

pine bear
#

Ahem

storm bluff
#
    at item.request.gen.end (/rbd/pnpm-volume/7662943d-6ec2-4cd3-8f5f-911407c3e786/node_modules/.registry.npmjs.org/discord.js/11.5.1/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:85:15)
    at then (/rbd/pnpm-volume/7662943d-6ec2-4cd3-8f5f-911407c3e786/node_modules/.registry.npmjs.org/snekfetch/3.6.4/node_modules/snekfetch/src/index.js:215:21)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
(node:325) 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: 2)
(node:325) [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.```
help
slim heart
#

what're you trying to do?

#

and what's the code

storm bluff
#

i am trying to make webhook sand when bot ready

slim heart
#

and code

quartz kindle
#

@pine bear what you said makes no sense and gives us 0 information about the actual problem. what are you actually trying to achieve?

storm bluff
#
    const hook = new Discord.WebhookClient('675984258011234304', process.env.webhooktoken);
    hook.send(" ", {username: 'Spidey Bot', avatarURL: '', embeds: ["hii"]});
});```
slim heart
#

a method not allowed is a strange error to get when using a built in djs function. try doing npm i discord.js to update it?

storm bluff
#

okey

#

@slim heart not work

quartz kindle
#

do hook.send(...).catch(console.log)

pine bear
#

I'm trying to achieve the download of discord.js

slim heart
#

@pine bear master or stable?

pine bear
#

Of discord.js?

slim heart
#

yes

quartz kindle
#

@pine bear do you have node.js installed?

pine bear
#

Yes

quartz kindle
#

did you do npm init and follow the instructions?

storm bluff
#
    at item.request.gen.end (/rbd/pnpm-volume/7662943d-6ec2-4cd3-8f5f-911407c3e786/node_modules/.registry.npmjs.org/discord.js/11.5.1/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:85:15)
    at then (/rbd/pnpm-volume/7662943d-6ec2-4cd3-8f5f-911407c3e786/node_modules/.registry.npmjs.org/snekfetch/3.6.4/node_modules/snekfetch/src/index.js:215:21)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
  name: 'DiscordAPIError',
  message: '405: Method Not Allowed',
  path: '/api/v7/webhooks/675984258011234304?wait=true',
  code: 0,
  method: 'POST' }``` 
@quartz kindle
quartz kindle
#

it will ask you for things like package name, description, author, etc... you have to fill them out

#

also dont forget to use the cd command to make sure you're in the right folder, ie, the folder where you want to install discord.js and begin your bot project

slim heart
#

yeah method not allowed

#

it's strange i don't know how that happen other than being out of date or djs is error

pine bear
#

cd command?

mossy vine
#

oh so you have never worked with a cmd/terminal

slim heart
#

actually unless the webhook is invalid

pine bear
#

Yes

slim heart
#

@storm bluff are you sure you have the webhooks id instead of something like the channel id?

storm bluff
#

yes

quartz kindle
#

@pine bear are you using windows?

slim heart
#

try and copy it in again

pine bear
#

Yes, but it's a really old version of it.

quartz kindle
#

really old version?

#

which version?

slim heart
#

@storm bluff the only way i can reproduce is by putting in a bad ID, where are you copying it from to make sure?

storm bluff
#

@slim heart i am trying but, he tell me the old error

#

ya i am sure id it work

quartz kindle
slim heart
#

where did you copy it from not asking for confirmation lol

storm bluff
#

yes

pine bear
#

Idk, but the last update was made some 5 years ago.

quartz kindle
#

you dont know if its windows XP, windows vista, windows 7, windows 8, windows 10?

pine bear
#

Windows 10

quartz kindle
#

then its not a problem

#

you have your cmd open right?

#

the command window

#

type node -v

#

what does it say?

slim heart
#

i copied the id you gave me @storm bluff and it's indeed an invalid id

pine bear
#

Run it on Node.js?

quartz kindle
#

in your command window

slim heart
#

and for reference this would happen if the id is right and token is wrong

storm bluff
#

@slim heart i fix it

#

thanks

slim heart
#

👌

pine bear
#

command window?

slim heart
#

yes in cmd catra

pine bear
#

Sorry, somethings I don't know sometimes.

quartz kindle
#

this is the command prompt, aka command window, aka cmd

pine bear
#

Er. . . how do I figure out how to open that window?

quartz kindle
#

start menu -> type cmd

slim heart
#

win+r, type "cmd", press enter or this ^

plain wyvern
quartz kindle
#

css in your long description

pine bear
#

Idk, I found command prompt

quartz kindle
#

yes open that

scenic kelp
#

that is it

quartz kindle
#

now type node -v and press enter

plain wyvern
#

I'm not very good with css but I know how to change objects that I created, in the case of dblsite I don't know what the name of the css is

quartz kindle
#

right click -> inspect element

pine bear
#

It says 'node' is not recognized as a internal or external command, operable program or batch file.

quartz kindle
#

then node is not installed correctly. if you installed it, you need to restart your pc after installing

scenic kelp
#

Also if it is installed verify that it's in your PATH

quartz kindle
#

the installer does that, but updated path is not applied until restart

pine bear
#

I forgot how you restart one of these things

quartz kindle
#

you need to restart windows

#

after installing node.js

pine bear
#

Hold down power button?

quartz kindle
#

jesus christ

#

how old are you?

pine bear
#

16

earnest phoenix
quartz kindle
scenic kelp
#

Are you trolling?

pine bear
#

No lmao

unique nimbus
#

what

earnest phoenix
#

Why is someone trying to get into programming when they can't even computer

pine bear
#

Well, now I remember

#

Lmao so true, but I'll get it soon, I hope.

earnest phoenix
quartz kindle
#

honestly you might be better off using something like discord bot maker

slender thistle
#

DBM dev: you got the money?

pine bear
#

I think have to pay for that, you honestly think I didn't try that yet.

quartz kindle
#

welp, then good luck

#

did you restart your computer yet?

pine bear
#

Yep,

quartz kindle
#

try running node -v again

pine bear
#

Tried, same results

quartz kindle
#

download version 12.16.1 LTS

#

install again

#

when the install finishes, restart your computer again

#

make sure it shows this part like this

#

add to PATH must be enabled, like in the image above

pine bear
#

κ

#

It works.

quartz kindle
#

alright

#

now where do you want to have your bot? which folder do you want to install it in?

pine bear
#

Uhh, is it optional where I want it in?

earnest phoenix
#

yes

pine bear
#

κ

#

I'm just going to make a new folder named mydiscordbot

quartz kindle
#

alright, so make it, then open it, then do this:

#

hold the SHIFT key in your keyboard, and right click anywhere inside the folder

#

and chose "open command window here"

scenic kelp
#

wait that's a thing

earnest phoenix
#

I didn't actually know that peepoWeird

scenic kelp
#

i've been cding all these years

earnest phoenix
#

^

quartz kindle
#

hue

scenic kelp
#

eh I use windows terminal so

pine bear
#

I used windows PowerShell because there was no other option

quartz kindle
#

once the command window opens, it should show the full path of your folder right before the blinking line, ie: C:/users/myuser/desktop/mybotfolder>_ or whatever location you put your folder in

pine bear
#

Yes

quartz kindle
#

now type npm init

#

it will ask you a few questions, like the project name, description, author, etc

#

just follow the instructions

#

you can skip any question by pressing the enter key, it will just use the default value

pine bear
#

It says test command.

quartz kindle
#

just skip it

pine bear
#

So that's done

quartz kindle
#

good

#

now you should have a package.json file

#

in the folder

pine bear
#

That's neat.

quartz kindle
#

how go back to the command prompt, open it again if you closed it (by using the shift-rightclick method)

#

and type npm install discord.js

pine bear
#

Ok

#

Done

quartz kindle
#

now you need to create a file called index.js or yourbotname.js whatever you prefer

#

but the file needs to have a .js extension

#

you need to enable extensions in order to see it

#

you enable extensions like this

tight plinth
#

Quick question : how to webhook in djs

quartz kindle
#

send a webhook to discord?

tight plinth
#

Was searching this page, can't find it anywhere

#

Thx

#

I'll learn myself for now

quartz kindle
#

(this is for creating and sending a discord webhook to discord, it has nothing to do with top.gg webhooks or any other)

#

just to make sure we're on the same page

pine bear
#

I think I did it.

quartz kindle
#

so now you should have 3 things in your folder

#

node_modules
mybot.js
package.json

pine bear
#

It only says
-node_modules
-package.json
-package-lock.json

quartz kindle
pine bear
#

Uhh? Something went wrong.

#

I think the file package-lock.json was supposed to be yourbotname

quartz kindle
#

no

#

package-lock.json is an auto-generated file

#

just leave it there

pine bear
#

Mhm, I see

quartz kindle
#

now you should have

node_modules
myfile.js
package.json
package-lock.json

pine bear
#

Ok

#

There

quartz kindle
#

now you need a code editor, a program to help you code

#

there are many out there, like notepad++, sublime text, visual studio code, brackets, atom...

#

just chose one, download it and install it

#

they're all free

pine bear
#

Done

#

Long time ago

quartz kindle
#

ok

#

now open myfile.js in your code editor

#

this file is where you will program your bot

#

now since you're using discord.js, you should check the discord.js documentation and guides for how to use it

#

you can skip the parts about installing and setting up linters and whatever

sudden geyser
#

now you're just teaching them nodejs at this point

quartz kindle
#

i was teaching them how to use a computer

#

Lol

pine bear
#

Lmao

native jay
#

hey everyone

#

how long does it usually take to get the bot verified?

quartz kindle
#

@pine bear anyways, read up those links, study it in detail, its not a easy subject, programming can be quite hard to get into, and you need lots of logical thinking. for example, the basic example is this: ```js
const Discord = require('discord.js');
const client = new Discord.Client();

client.on('ready', () => {
console.log(Logged in as ${client.user.tag}!);
});

client.on('message', msg => {
if (msg.content === 'ping') {
msg.reply('pong');
}
});

client.login('token');```

#

the first lines setup discord.js in your code, then you add some functions for what the bot should do, then you login to discord with your bot token

#

this is a barebones setup

#

you can copy and paste this into your myfile.js if you want to start with that

#

then save the file

#

and you can run your bot by going back to your command window and typing node myfile.js

#

then its just a matter of coding, saving, running, etc

native jay
#

Tim

quartz kindle
#

@native jay about 2 weeks

native jay
#

and all this time the bot should be online?

mossy vine
#

yes

quartz kindle
#

preferably yes

pine bear
#

Visual studio code doesn't seem to be making my file show

quartz kindle
#

just right-click myfile.js and go to open with -> vistual studio code

native jay
#

okay... github is giving me trouble... let me make some changes

#

github is down for now

pine bear
#

It doesn't show that option for some reason.

warm marsh
#

Use open with and then choose another app

pine bear
#

Nvm, I know it was a folder, and I forgot to move the file to that folder.

warm marsh
#

Tim, I respect you.

pine bear
#

Lmao

#

Stop teasing me

quartz kindle
#

@warm marsh @_@

mossy vine
#

can a single js websocket server handle the stress of about 100-400 users inputting something in the span of 3-5 seconds, if yes, would it have any significant memory/cpu usage complications

quartz kindle
#

depends on what the server has to do with each request

#

if it just some mild in-memory text processing, it should be easily able to handle thousands per second

#

as the complexity of the request increases, so will the cpu usage

#

memory wont be affected much, unless you're working on large payloads

mossy vine
#

most complexity would be incrementing a counter i think

#

rest of it can be processed elsewhere without handling input

quartz kindle
#

then you should be fine

mossy vine
#

aight thanks

pine bear
#

Does client.login('token'); does token have to be the bots actual token?

cursive dagger
#

yes

modest maple
#

guess

pine bear
#

Who tf keeps pinging me?

earnest phoenix
#

.

#

V

pine bear
#

I'm done, sort of.

#

@spare goblet invite links

tight plinth
#

Is there any js api for instagram

summer torrent
#

for get user data?

tight plinth
#

Post in a channel when a specific user posts

blissful scaffold
#

instafeed maybe

tight plinth
#

Seems a good one

#

Thx

copper cradle
#

there's no such thing as lang secific api

pine bear
#

Ok, I have the first few code down

pine bear
#

How do I get the JavaScript code into the bot now?

earnest phoenix
#

make sure you have your bots token in the code, must likely under client.login('token'), and then you want to run node myfile.js

tight plinth
#

U just put the js code in index.js

quartz kindle
#

the bot IS the file you created earlier, remember?

#

all code should be inside that file

pine bear
#

Ok

tight plinth
#

If you think your bot is ready to run launch a terminal, use the CD command to go to ur bot folder and then do npm start

#

Wait no

#

U should do npm index.js

quartz kindle
#

he named his file something else

#

so it should be node myfile.js or whatever he named the file

pine bear
#

Mmm,

grave jacinth
#

hey guys i upload my all documents glitch but doesnt working

earnest phoenix
#

what?

grave jacinth
#

i make bot on atom

earnest phoenix
#

yea

grave jacinth
#

and i upload all documents glitch

tight plinth
#

How can I queue Playlist in ytdl-core

earnest phoenix
#

@grave jacinth what type of documents?

grave jacinth
#

js

earnest phoenix
#

so, do u using command handler?

grave jacinth
#

for now yes

slim heart
#

is there any sort of way to set like a globally accessible variable for any node program without have to add anything to the code like no requiring or anything like that especially since i want it accessible from programs that are in all sorts of different locations so i'd have to write it purposeful for each different one (and no absolute paths)

pine bear
#

I'm stuck on actually getting the bot online

slim heart
#

you've been here all day mate, it's safe to assume you expect someone to write it for you at this point. watch some guides, stop wasting people's times when you can very easily figure it out for yourself.

pine bear
#

Mmm

grizzled raven
#

what are the ```js
Error: Client network socket disconnected before secure TLS connection was established

/* and also... */
Error: socket hang up

errors?
#

because

#

my bot keeps getting them

earnest phoenix
#

oof

wide ridge
#

@twilit rapids

twilit rapids
#

Might want to use Contabo

modest maple
#

yup

#

thats a fucking lot for shit specs

wide ridge
#

the next one is

twilit rapids
#

4 GB RAM / 2 CPU Cores for 4 Euro a month

modest maple
#

@twilit rapids we just got contabo's biggest Dedi which is <333

grizzled raven
#

bruhh what should i do K_vPensiveBread

twilit rapids
#

BRUH

grizzled raven
#

should i restart my bot

twilit rapids
#

Don't flex on me like that

earnest phoenix
#

@grizzled raven what is your problem?

earnest phoenix
#

restart

twilit rapids
#

@modest maple do you have it with /56 IPv6 subnet

grizzled raven
#

are you sure?

earnest phoenix
#

@grizzled raven try restart

twilit rapids
#

Because that's what I need for Chip to survive

grizzled raven
#

timo has that ever happened to you?

modest maple
#

i'd have to ask Zotz

grizzled raven
#

nevermind actually

#

ill just

#

hhhhhhuhhh

twilit rapids
#

That's just bad luck

#

Not much you can do about that

grizzled raven
#

me?

twilit rapids
#

@modest maple also, do you have 10 or 20 CPU cores

modest maple
#

we have 10

grizzled raven
#

ok ill take that as a yes

modest maple
#

for now

earnest phoenix
#

@grizzled raven just try an restart

twilit rapids
#

Chip is 74 servers away from 20k now

grizzled raven
#

and the bot still works, it just triggers events multiple times

twilit rapids
grizzled raven
#

i guess ill risk it

twilit rapids
#

and yes it was to you TheNoob

modest maple
#

@twilit rapids we have /64 IPV6

twilit rapids
#

I see

#

Can I put a LavaLink node on your DEDI

earnest phoenix
#

what IPV6 do?

twilit rapids
#

Uh, a bit hard to explain

earnest phoenix
#

ok

modest maple
#

how much reasources does it use

#

xD

twilit rapids
#

0.5 core / 2 GB RAM

earnest phoenix
#

!leval client.guilds.size

#

hm

twilit rapids
#

Probably even less

grizzled raven
#

ok its back nevermind

earnest phoenix
#

sorry

#

worng channel

modest maple
#

would you be willing to support DMV as a trade off @twilit rapids xD

twilit rapids
#

uh

#

sure I guess

modest maple
#

ill ask Zotz how much the site is using atm

#

and how much we have spare

#

should be enough tho xD

twilit rapids
#

You probably have a Discord server for it

#

Send it to me in DMs

#

Starting at 4 euro a month

grizzled raven
#

you have to buy a domain seperate, right?

twilit rapids
#

Yeah

earnest phoenix
#

@grizzled raven you can get a free subdomain

grizzled raven
#

huh

earnest phoenix
#

with free https

minor junco
earnest phoenix
#

free cpanel aswell

grizzled raven
#

i wasnt smart enough to be able to process how you would set that stuff up so i passed on contabo

earnest phoenix
#

@grizzled raven you restarted the bot?

grizzled raven
#

yes

earnest phoenix
#

it works?

grizzled raven
#

yes

modest maple
#

@twilit rapids Ill Dm you when Zotz gets back to me

twilit rapids
#

alright

modest maple
#

i dont wanna say yes until we know its not gonna affect anything

earnest phoenix
#

hey rules bot offline ?

nocturne grove
#

Does anyone have any idea why guild.name returned undefined with the guildCreate event? This happened only once, I just tested it twice and it did work then.

earnest phoenix
#

@twilit rapids

twilit rapids
#

what?

amber fractal
#

He asked a question about a bot that has nothing to do with this server

#

hey rules bot offline ?

twilit rapids
#

-wrongserver @earnest phoenix

gilded plankBOT
#

@earnest phoenix

Hey! We think you have our server mistaken. We do not provide support, help, or advice for any bot. You need to click on the "Support Server" button on the bot's page, not the "Join Discord" button at the top of our website. If there isn't a button that says Join Support Server, then we can't help you. Sorry :(

native jay
#

What's a shard

twilit rapids
#

You can login using e.g. FileZilla and upload your files via your computer

low wasp
#

you can use git if its on github

twilit rapids
#

Then via console you can also login and run your code

low wasp
#

git pull origin master

modest maple
#

@twilit rapids The big sad, Zotz said he'd have to politely decline

twilit rapids
#

That's fine

nocturne grove
#

Does anyone have any idea why guild.name returned undefined with the guildCreate event, while guild.id returned like expected? This happened only once, I just tested it twice and it did work then.
anyone has a reason for this?

west spoke
#

possible bug, as guildCreate =! guildJoin

#

or any sort of join event

elfin jasper
#

So I have been trying to code a bot to just send random messages to a specific channel every minute or so. The problem I run into is that when trying to use client.run(TOKEN) which is defined as my bot's token, I am met with an error "AttributeError: 'set' object has no attribute 'strip'"

slender thistle
nocturne grove
#

but guildJoin isn't listed on discord.js.org, are you certain that is a thing?

#

oh btw, I'm using discordjs

elfin jasper
slender thistle
#
import discord
print(discord.__version__)```
nocturne grove
#

@west spoke should I do something with the bug? Thank you btw

modest maple
#

@elfin jasper send your code

west spoke
#

@nocturne grove if it's working fine now, then it is not needed. If it happens again, I'd ask the d.js server.

slender thistle
#

What's the TOKEN variable looking like

elfin jasper
modest maple
#

its a dict looking at what hes got

slender thistle
#

It's a fucking set

modest maple
#

i cant see the () properly

elfin jasper
#

line?

modest maple
#

where you define DISCORD_TOKEN

#

you have it surounded in either {} or () i cant make it out

#

remove that

slender thistle
#

Do you know what type {'something'} will be?

modest maple
#

also

#

btw

#

your like

#

a year out of date in d.py version

#

using async rather than 1.3

nocturne grove
#

@west spoke thank you! 👍

elfin jasper
#

i'm out of date?

#

honestly, i'd never even used python before until last night

slender thistle
#

from dotprint(...)??? nekothinking

elfin jasper
#

i'm dumb

#

I will say, most of it was copy and paste from guides

slender thistle
#

Yeah, that's not exactly recommended

elfin jasper
#

i've been getting that feeling

slender thistle
#

I recommend getting the hang of Python itself first before getting to complex libraries like discord.py

elfin jasper
#

will do

#

any tutorials or such that you would personally recommend?

slender thistle
elfin jasper
#

apprecitated

modest maple
#

@slender thistle not like its the offical docs or anything

slender thistle
#

:^)

elfin jasper
#

i sense sarcasm

#

hmmmm

true ravine
#

Would you say that a one-hour delay between a repeated piece of code is long enough for it not to be API spam?

slender thistle
#

Does it only send one request?

true ravine
#

It's three

#

I can make the delay longer if necessary but 1 hour is a nice number

#

Wait I assume bot.guilds.size is an API request?

clear sluice
#

Yep

true ravine
#

Yeah so three requests every x time

#

I don't really mind what x is

#

That's what I'm asking

#

What should x be ideally

slender thistle
#

You mean is bot.guilds.size sending an HTTP request?

#

bot.guilds is cached tho Thonkang

true ravine
#

Oh so that wouldn't be anything to do with the API?

slender thistle
#

The library will fetch guilds for you and store them in bot.guilds

hushed berry
#

You're not even able to retrieve your bot's guilds via the api

slender thistle
#

Stuff like bot.fetchGuilds() would make sense to send HTTP requests

true ravine
#

Basically I want to log the values of bot.guilds.size to a csv file

#

So in that case I wouldn't be sending any requests to the API?

hushed berry
#

No

true ravine
#

Okay cool thank you

honest perch
#

im stuck on how to add a user count to the bots activity status?

grave jacinth
#

hey guys i cant made setStatus

slender thistle
#

What library @honest perch
@grave jacinth More details could help

grave jacinth
#

js

#

ha ok

#

wait a sacond

#

client.on('ready', () => {
console.log(Botun hazır ve aktif ${client.user.tag} );
client.user.setActivity('!medet')
client.user.setStatus('idle')

#

setstatus dont working

zenith orchid
#

D.js

#

Kütüphaneni sormuş dilini değil @grave jacinth

pine bear
#

My bot is supposed to have the code it needs to be online, but it isn't.

grave jacinth
#

bana sormadı onu

zenith orchid
#

Niye js diye cevap verdin?

grave jacinth
#

ok

#

is working

#

thx xd

zenith orchid
#

:D neyse fark etmedin galiba

grave jacinth
#

ya nebilm bana sordu sandım yeni sayılırım

pine bear
#

I dunno, I have the token variable set up and client.login(token) it's supposed to work.

slender thistle
#

whistles violently
More code could help

pine bear
#

Well, lets just say, I've done what I've done to make the bot appear online.

mossy vine
#

any errors

slender thistle
#

Yup, not helpful at all

pine bear
#

Not that I can see

modest maple
#

wait a sec

#

THE BOT IS ONLINE?

#

YES OR NO?

#

also SEND YOUR CODE

slender thistle
#

Yup, Chili is just as violently angry

zenith orchid
#

Relax

slim heart
#

this guys been in here all day trying to get someone to feed him code pretty much, don't give him any mind

pine bear
#

const Discord = require('discord.js');
const client = new Discord.Client();

const prefix = "c!";
const token = "Token";

client,login(token);

modest maple
#

are you useing

#

a

#

,

#

in place of a

#

.

pine bear
#

OOF that's why

modest maple
#

client,login(token);

slender thistle
#

ChillFish isn't chill pogey

pine bear
#

Thx

wide ridge
#

lullllllllll

quartz kindle
#

@true ravine 300mb sounds a bit too much, what does your bot do?

pine bear
#

Lmao it looks like periods not commas

slim heart
#

i assume so but does ubuntu come preinstalled with git?

quartz kindle
#

nvm, your bot is not approved yet

modest maple
#

did your IDE not even notice the fact that hell just got yeeted at that object?

true ravine
#

its probably this server
Nah I'm not in this one because I'm not approved yet - only like 39 cached users

quartz kindle
#

so yeah, the normal ram usage for that amount of caching should be about 70-80mb

#

not 300

true ravine
#

It's just a basic aws vps so there could be all kinds of demons lurking on the machine I haven't discovered

quartz kindle
#

what lib do you use? discord.js?

true ravine
#

Yup

quartz kindle
#

are you using pm2?

true ravine
#

Yeah

quartz kindle
#

and pm2 shows 300mb for your bot?

true ravine
#

No I've only ever seen the ram usage when I restart the bot at like 18mb

#

On pm2 I mean

quartz kindle
#

run pm2 ls or pm2 monit

true ravine
#

Oof says 16 mb

quartz kindle
#

well, 16mb is also not normal lmao

#

the node process itself should use about 40-50mb

true ravine
#

Wait I'm looking at the wrong number

#

53/54mb

quartz kindle
#

alright that sounds more normal

true ravine
#

The 300mb is total system usage so I was assuming most of that was taken up by the bot

#

But no

quartz kindle
#

try running top

honest perch
#

@slender thistle discord.js

quartz kindle
#

assuming your system is linux based

true ravine
#

Yeah ubuntu

slender thistle
#

Getting size of bot.users sounds like an idea

quartz kindle
#

top should show you a list of processes, you can see what is using so much ram

true ravine
#

Which is actual mem usage because I can only see percentage use

quartz kindle
#

RES is the actual memory

#

in kib

#

but %MEM is also accurate

true ravine
#

Things keep popping up and disappearing and some of them have very high res numbers

quartz kindle
#

take a print and post it here

true ravine
#

I'll try and get the things that pop u[

#

up*

pine bear
#

It says, SyntaxError: Unexpected token '=>' when I ran it on the terminal.

dense drift
#
         var removedRole = ''
         if(oldMember.roles.map(r => `${r}`).join(' ') !== newMember.roles.map(r => `${r}`).join(' ')){
         removedRole = oldMember.roles.find(r => !newMember.roles.has(r.id))
         change = Changes.removedRole
         if(!removedRole){
            // check if roles were added
            var addedRole = ''
             addedRole = newMember.roles.find(r => !oldMember.roles.has(r.id));
            change = Changes.addedRole
         }         
         }```

Hey Tim, thanks for the advise, it's working really well now. A new issue that is occurring is it always defaults to added role, even if I remove a role. This is the code that is checking it.
quartz kindle
#

you dont need to do that comparison

#

the removedRole line is enough by it self, you just need to check if it exists

honest perch
#

@slender thistle would i put this ${bot.users} into the status?

slender thistle
#

First, get its size

#

Secondly, yes

quartz kindle
#
removedRole = oldMember.roles.find(...)
if(removedRole) { change = Changes.removedRole; }
honest perch
#

may i ask how to get its size

quartz kindle
#

just add .size to it

dense drift
#
         var removedRole = ''
         var addedRole = ''
         
         // check if roles were removed
         removedRole = oldMember.roles.find(r => !newMember.roles.has(r.id))
         if(removedRole) change = Changes.removedRole

         // check if roles were added
         addedRole = newMember.roles.find(r => !oldMember.roles.has(r.id));
         if(addedRole) change = Changes.addedRole```
#

I'll give that a gander

#

Or should I set removedRole and whatnot to null first?

quartz kindle
#

yes, maybe add an if else if you dont want both changes, but most likely 2 role updates will never happen at once

dense drift
#

Okay 🙂

quartz kindle
#

no need to be null

#

no need to be a string either

#

it can be just var removedRole;

dense drift
#

Ahh, good point

quartz kindle
#

also, maybe consider moving from var to const/let

#

its more modern and consistent

dense drift
#

Okay

#

Any reason to use any over the others? I kind of use them all in my code.

#

Removing still throws this ->

4|bot      |   name: 'DiscordAPIError',
4|bot      |   message:
4|bot      |    'Invalid Form Body\nembed.fields[2].value: Could not interpret "{\'guild\': {\'members\': {}, \'channels\': {}, \'roles\': {}, \'presences\': {}, \'deleted\': False, \'available\': True, \'id\': \'665790892539510804\', \'name\': "Frog\'s Gucci Land", \'icon\': \'0cb6ec6fc645716abb06832f25caae68\', \'splash\': None, \'region\': \'us-east\', \'memberCount\': 35, \'large\': False, \'features\': [], \'applicationID\': None, \'afkTimeout\': 300, \'afkChannelID\': None, \'systemChannelID\': \'665790892539510807\', \'verificationLevel\': 0, \'explicitContentFilter\': 0, \'mfaLevel\': 0, \'joinedTimestamp\': 1579214403013, \'defaultMessageNotifications\': \'ALL\', \'ownerID\': \'177188299943837696\', \'_rawVoiceStates\': {}, \'emojis\': {}}, \'deleted\': False, \'id\': \'676434165356560397\', \'name\': \'Voter\', \'color\': 193800, \'hoist\': True, \'position\': 16, \'permissions\': 104193601, \'managed\': False, \'mentionable\': False}" as string.',
4|bot      |   path: '/api/v7/channels/674548631461691393/messages',
4|bot      |   code: 50035,
4|bot      |   method: 'POST' }```

It throws it twice.
#

Adding does it successfully.

modest maple
#

i love those errors

#

ngl theyre my favourite sort

#

just have a spazz out then works

quartz kindle
#

let and const have a few differences, one of them is that they are strictly locked to the current scope, while var can bleed outside the scope.
another difference is that const will not let you change it after its defined, so its good for not accidentally modifying some data that should not be modified, while let will not let you create another variable with the same name, to prevent you from accidentally overwriting it

dense drift
#

Neat!

#

Thanks for that, I never could figure out the differences.

quartz kindle
#

the error says you are trying to put and entire object in a field

#

it appears to be a guild object

honest perch
#

ok that seemed to work, thanks!

dense drift
#

I'm going to try something, if it does work, I'll laugh and tell you why.

#

hahahaha

#

It worked

#
            case Changes.removedRole:
                log.send({embed: {
                    color: 0x0099ff,
                    title: 'Role Removed',
                    thumbnail: {
                        url: `${newMember.user.displayAvatarURL}`,
                        },
                    author: {
                        name: "FrogBot",
                        icon_url: `${config.avatar}`,
                        url: "https://www.patreon.com/HephBot",
                    },
                    fields: [
                        {
                            name: 'User',
                            value: oldMember.displayName,
                            inline: true,
                        },        
                        {
                            name: 'Old Roles',
                            value: oldMember.roles.map(r => `${r}`).filter(r => r !== `@everyone`).join(' '),
                            inline: true,
                        },        
                        {
                            name: 'Role Removed',
                            value: `${removedRole}`,
                            inline: true,
                        },    
                    ],
                    timestamp: new Date(),
                }})```
#

All I changed was value from

removedRole to ${removedRole}

#

lol

#

Thanks for being touchy JS

quartz kindle
#

ah yes, that will invoke its internal role.toString() method

slender thistle
#

.toString all things

true ravine
#

The high ram usage seems to be because of amazon related stuff, mysql and ubuntu. The reason it was displaying 300mb was because that reading was an average taken over a couple of seconds. I shall leave you to help everyone else now xd

dense drift
#

ahhh

#

Thanks for the help as always 😄

quartz kindle
#

@true ravine still seems like a lot, but makes more sense

#

mysql can use quite a bit as well

true ravine
#

Yeah I use it for quite a few features so I guess it's understandable

dense drift
#

Can someone explain how watching for votes works in JS?

My current script is...

dbl.webhook.on('vote', async vote => {
    console.log(`User <@${vote.user}> (${vote.user}) just voted!`);
    let a = await client.voted.get(vote.user)
    if(!a) {await client.voted.set(vote.user, '1')}
    else{
        let b = +a + 1
        await client.voted.set(vote.user, b)
    }
    await client.guilds.get('665790892539510804').channels.get('676434014759813150')
    .send({embed: {
      color: 0x0099ff,
      title: `New Vote!`,
      url: 'https://top.gg/bot/665786935251304468/vote',
      author: {
          name: 'FrogBot',
          icon_url: `${client.user.displayAvatarURL}`,
          url: `${client.user.displayAvatarURL}`,
      },
      fields: [
          {
              name: 'User',
              value: `<@${vote.user}> (${vote.user})`,
          },
          {
              name: 'User Vote Count',
              value: `${client.voted.get(vote.user)}`,
          },
          {
              name: 'Total Bot Vote Count',
              value: `${dbl.getstats('665786935251304468').points}`,
          },
      ],
    }})
});```

The bot doesn't even respond when someone votes. I'm fairly certain I'm logging in correctly because if I do...

```js
await dbl.hasVoted(msg.author.id).then(async voted => {
            if (!voted) return```

That check works just fine.
earnest phoenix
#

well

#

are you running the webhook webserver

#

and did you put the correct ip and port on dbl's website

#

webhooks are reverse APIs, instead of you making a request to the API, the API instead makes a request to you

dense drift
#
const DBL = require('dblapi.js');
const dbl = new DBL("TOKEN", { webhookPort: 5000, webhookAuth: 'PASSWORD' });
#

I have that in my code as well.

quartz kindle
#

you dont need to put await everywhere

#

.get and .set are not promises nor async functions

dense drift
#

I started throwing that in because I wasn't sure why it wasn't seeing it. 😛

quartz kindle
#

does the console log User just voted?

dense drift
#

No

quartz kindle
#

then your webhook settings are wrong

dense drift
#

Okay, how should I go about fixing it?

quartz kindle
#

what did you put in the webhook settings in the website?

dense drift
#

My VPS IP, and the password I set.

quartz kindle
#

check if your vps requires opening ports

dense drift
#

🤦

#

Probably lol

quartz kindle
#

it depends on the host

dense drift
#

I have OVH

quartz kindle
#

for example, google compute engine requires you to open ports in their control panel

#

check the ovh admin panel

dense drift
#

Hmm, I'm trying to figure out where to go lol

#

Would a menu like this do it?

zenith orchid
#

Source ip i think 0.0.0.0/0

dense drift
#

It doesn't like that 😛

quartz kindle
#

the docs say ip is optional

#

try leaving blank

dense drift
#

Okay

#

Protocol?

quartz kindle
#

tcp

dense drift
#

Okay

#

New options

quartz kindle
#

ports 5000 in both

dense drift
#

Okay, I'll give it a gander

quartz kindle
#

yeah that should do it

dense drift
#

Now how do I test that? Should I restart my bot, and try voting? Or would the 'test' work?

quartz kindle
#

the test should work

dense drift
#

Okie dokie

#

I assume that's okay?

#

The test isn't doing anything.

#

¯_(ツ)_/¯

blissful scaffold
#

the 0's are ok

#

it means that it is listening on every IP address that the server has

dense drift
#

Ah, I didn't know that. Thanks!

#

Hmm, it's odd that nothing comes through

quartz kindle
#

try this as well

#

sudo ufw enable
sudo ufw allow 5000

dense drift
#

ufw isn't a command

#

...could that be an issue? lol

quartz kindle
#

hmm

dense drift
#

I'm running Debian if that helps.

quartz kindle
#

if ufw is not pre-installed, then all ports should be opened by default

#

not sure about debian

dense drift
#

Maybe I'm doing something wrong with signing in then? However the check for if a user has voted works fine...

quartz kindle
#

yeah because the check is a post request

#

its outgoing

#

you could try setting up a simple webserver and see if you can open it in your browser

dense drift
#

I'm hosting my website on the VPS.

quartz kindle
#

is your website running on express?

copper cradle
#

ads

dense drift
#

I don't think so.

copper cradle
quartz kindle
#

how are you running your website?

#

on which server platform

dense drift
#

uhhhh

#

lol

quartz kindle
#

nginx apache node.js

#

litespeed

dense drift
#

I know I'm using apache2

copper cradle
#

actix-web

quartz kindle
#

ok, so one thing you could do is set up a reverse proxy

dense drift
#

I know I followed that one if that helps.

#

A reverse proxy?

quartz kindle
#

basically the idea is

#

to create a second configuration in your website's config file, and apply it for a subdomain for example

#

ie: votes.mywebsite.xyz

#

and in that configuration, use the proxyPass options as above

#

the proxy should point to 127.0.0.1:5000

#

which is a localhost address

#

so votes.mywebsite.com gets internally redirected to localhost:5000 which is where your webhook is running

#

then in the webhook config in top.gg you can use http://votes.mywebsite.xyz/dblwebhook

#

i dont use apache so i dont have much experience with it, but you should be able to find solutions and guides

vagrant tree
#

what is the best way to keep information about specific users e.g. if they select something in your bot, maintain that information for subsequent commands?

quartz kindle
#

if you need it to last through bot restarts and crashes, a database

#

else, an object/array/map/collection in your code

dense drift
#

Okay, thanks Tim, I'll give it a try

vagrant tree
#

thanks

#

to keep track of a specific users info is it best to use message.author? then compare that to every new command to see if the author is there?

honest perch
#

so i managed to get a prefix cmd working but when trying to make the embed to show the new prefix it says this

#

this is the code .setDescription('Set to ${args[0]}');

summer torrent
#

replace ' with `

honest perch
#

Thank you

dense drift
#

Hey @quartz kindle, I think I broke it all. You wouldn't know how to undo the proxy would you?

static trench
#

If I am trying to get a good bot to google and message the answer, what would the python code be?

topaz fjord
#

iptables > ufw

static trench
#

Wdum?

#

What does that do?!

quartz kindle
#

@dense drift just remove the lines you added

dense drift
#

I have, it's not working.

#

😦

quartz kindle
#

did you change anything else?

#

you might need to restart apache as well

dense drift
#

I ran sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000, but then I did sudo iptables -t nat -D PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000

#

It restarts just fine, I just can't get to the site anymore.

quartz kindle
#

oh you did it through iptables

dense drift
#

Well

#

Not originally

quartz kindle
#

so you didnt change anything in your apache config?

dense drift
#

I did

#

However I put it back and rebooted apache

quartz kindle
#

you basically added an iptables rule to redirect ALL traffic from port 80 to 3000

#

which includes requests to your website

dense drift
#

Right, however -D should've removed that

quartz kindle
#

yeah it should

modest maple
#

Has anyone got any previous Experience with Datomic Databases?

quartz kindle
#

@dense drift run this sudo iptables -t nat -v -L PREROUTING -n --line-number

#

post the result

dense drift
#
num   pkts bytes target     prot opt in     out     source               destination   
1      130  6600 REDIRECT   tcp  --  eth0   *       0.0.0.0/0            0.0.0.0/0            tcp dpt:80 redir ports 3000
2        0     0 REDIRECT   tcp  --  eth0   *       0.0.0.0/0            0.0.0.0/0            tcp dpt:80 redir ports 80
quartz kindle
#

now run sudo iptables -t nat -D PREROUTING 1

dense drift
#

holy

#

thank you

#

I was so worried lol

quartz kindle
#

firewalls

#

¯_(ツ)_/¯

#

a pain in the arse