#development

1 messages · Page 945 of 1

viral mortar
#

oh

astral yoke
#

someone dm advertised me and they have my bot in there server

#

and i wanna like

#

have the bot leave the server its self

magic jackal
#

Hmm, what lib? @astral yoke

quartz kindle
#

in discord.js its simply guild.leave()

astral yoke
#

so if i make a command

#

like

magic jackal
#

But thats it there

astral yoke
#

guildleave

#

all i can do is run guild.leave()?

magic jackal
#

You can pass an ID into the leave()

astral yoke
#

like a serverid?

quartz kindle
#

you will need to specify which guild you want to leave

viral mortar
#

discord is missing so you'll need to push that to the heroku server too
@magic jackal how do i do this, do i put it into the requirements.txt

magic jackal
#

@viral mortar Same way you did with everything else dependency wise

#

just with discord now

#

it needs to be in your requirements so you can install the requirements on the heroku server

#

So if its required, make sure its in there.

viral mortar
#

ok

magic jackal
#

Should work out smoothly

#

@earnest phoenix We have no idea what you're talking about. I need more context :^)

quartz kindle
#

you mean a simple math command?

#

all programming languages have built in math operators

#

it should be as simple as variable + anothervariable

magic jackal
#

ye

quartz kindle
#

you may need to convert them to numbers first

#

because discord gives you text by default

mystic violet
#

@quartz kindle Im sending that too a lavalink type server

quartz kindle
#

if you do 5 + 5 as text, the result will be 55

mystic violet
#

its deprecated (but still works) im trying to make it work like a lib called discord.js-andesite

#

basically extending shoukaku

quartz kindle
#

you can convert text to number by using Number, for example Number("5")

#

@mystic violet i've seen that error happen when the server crashes

#

or the payload causes the server to crash for some reason

mystic violet
#

weird

magic jackal
#

@quartz kindle btw for returning a true user count for everything on the client, isn't it client.users.cache.size or is it something different, caching is being weird rn

quartz kindle
#

a true user count can only be obtained by reducing guild.memberCount

magic jackal
#

well i would like everything, all across all guilds

quartz kindle
#

users.cache = cached users only

#

yes, you need to use a reduce function on guild.memberCount

magic jackal
#

true, so its not stored in client?

#

mk

viral mortar
#

@magic jackal omg thank you so much it works! : D

magic jackal
#

pogey @viral mortar

#

I'm useful!

quartz kindle
#

client.guilds.cache.reduce((total,guild) => total + guild.memberCount, 0)

viral mortar
#

lol

#

thanks again

earnest phoenix
#

how are you reading the file? with fs.readFile?
@quartz kindle yes

quartz kindle
#

read it with require instead

earnest phoenix
#

?

quartz kindle
#

let myfile = require("./myfile.json")

earnest phoenix
#

but what changes that if i read it

#

with fs

quartz kindle
#

fs.readFile reads a file from disk1

#

require reads a file from disk and stores a copy of it in the require cache

earnest phoenix
#

wait

quartz kindle
#

so the next time you require the same file, it reads the copy of it in the cache, instead of reading it from disk again

earnest phoenix
#

but can you read it with only let myfile = require("./myfile.json")
@quartz kindle

#

im confused

magic jackal
#

you can read files into your app with require

#

require will pull the whole contents into a variable

earnest phoenix
#

oh

magic jackal
earnest phoenix
#

and then i need to check for the guild.id

quartz kindle
#

.cache.reduce (my bad)

earnest phoenix
#

right?

#

and if that is there

#

delete it with the function i wrote earlier

quartz kindle
#

yes

#

and you still need to use fs.writeFile

earnest phoenix
#

yes

#

thank you i’ll try that tomorrow

#

goodnight

quartz kindle
#

gn

magic jackal
#

nice

#

rip ram usage for only 63 guilds

earnest phoenix
#

sniff i smell bd sniff

magic jackal
#

@earnest phoenix Powercord

#

much better tbh

smoky spire
#

Nodejs isn't a language mmulu

quartz kindle
#

discord.js eats ram for breakfast

#

unless you put a leash on it and hit it with a whip :^)

west raptor
#

300Mb of ram wtf

quartz kindle
#

quite normal if presences are enabled and you're using a non-modified discord.js and no cache sweeping

west raptor
#

pretty yikes

magic jackal
#

NodeJS is my language

#

joke.mp4 missed also nobody asked

regal saddle
#

?

hasty lotus
#

Hey is there any way to compare the position of 2 users ? (In js) like know their both highest role and know who is higher than the other ? (Pls Ping me I don’t read every messages 😉 )

earnest phoenix
#

you asked the question, check up on the channel for the answers lol

grab the highest role of both users and compare their position

hasty lotus
#

Yep but how ?

earnest phoenix
#

i think you can use the sort method, order by descending order and grab the first value in that

#

account for that a user might not have any roles

hasty lotus
#

No he always have the everyone role

#

The role doesn’t displays but it exists

earnest phoenix
#

yeah except the everyone role

#

i know

hasty lotus
#

But isn’t there any property for this ?

earnest phoenix
#

in which lib

hasty lotus
#

Like msg.author.position > user.position

#

x)

#

Discord js

#

11.6.4

earnest phoenix
#

no and you don't need it

#

cause you can do it yourself

#

lol

#

also you might want to consider updating to v13

#

v12

#

discord is soon going to force stateless design with intents, d.js v11 doesn't support intents

hasty lotus
#

Hey got it

#

message.member.highestRole.comparePositionTo(message.mentions.members.first().highestRole

#

)

#

Tu stackoverflow x))

#

Ty*

#

I’ll try

earnest phoenix
#

why did i even expect of you to even attempt to approach the problem yourself lol

hasty lotus
#

x)))

amber fractal
#

one day you will learn that figuring the problem out for yourself is much more beneficial than "how do one compare roles d.js!@!?"

hasty lotus
#

Well not for me

#

I know how to develop

earnest phoenix
hasty lotus
#

Just I’m quite new with djs

#

And instead of loosing long hours to learn it by heart I ask if someone knows

#

😉

#

It’s my way to learn maybe not yours, but it’s mine

earnest phoenix
#

you are not learning though

#

that isn't learning

#

you're teaching yourself a bad behaviour pattern

hasty lotus
#

For me it is

#

Well this is working great for me

#

Why are you saying that it’s not If i tell you it is ?

earnest phoenix
#

one could say that independent problem solving correlates to intelligence but lets not go there

hasty lotus
#

I’m developer since 2 years now and I know how I work

earnest phoenix
#

im way too tired to deal with a help vampire

hasty lotus
#

If for me this works don’t say it doesn’t

#

You’re not with me so you can’t really know

#

That’s why the only information you have is what I say

#

And because it’s the only one you have you should trust it 😉

amber fractal
#

it doesnt.

#

it helps no one, not even yourself

sudden geyser
#

If that's your way of learning then okay but it'll be more useful down the road if you learn through browsing documentation and trying it out to problem solve

hasty lotus
#

it helps no one, not even yourself
@amber fractal how can you say that without even knowing me ?

#

You don’t know who I am

amber fractal
#

Because google isn't an end all solution

#

One day Stackoverflow wont have your answer

hasty lotus
#

You don’t know my name you don’t know my age you don’t know my profession you don’t know my formations

amber fractal
#

and you'll be fucked because you don't know what you're doing

hasty lotus
#

Yeah maybe and this day I’ll figure out

#

Thank you for caring so much about me

#

But your way of dozing it is useless

wintry sonnet
#
        .setDescription(`🏓\`${Date.now() - message.createdTimestamp}\`ms`);


        message.channel.send(ping);```

Is the ping in this command the API? If not, what is it?
hasty lotus
#

Nah

amber fractal
#

look at the WebSocketManager

hasty lotus
#

This will just show you the time at which the message has been created

wintry sonnet
#

Ok

hasty lotus
#

If you wanna get the api use client.ping 😉

amber fractal
#

well no

#

not in v12

#

which is why you use the docs to see what you're doing.

#

v11 and v12 are different

hasty lotus
#

I know how to read the docs thank you

#

Really thank you for having so much care to me

magic jackal
#

client.ws.ping

amber fractal
#

You also know how to search stackoverflow, doesn't make you a good dev

earnest phoenix
#

comparing message timestamps isn't really accurate, if you want completely accurate REST ping, Date.now before sending message, Date.now after and subtract the two, even better if you can use a stopwatch

hasty lotus
#

But it’s useless

magic jackal
#

There isnt a need for that comment bro, we are all here to help

hasty lotus
#

@amber fractal okey please stop this discussion before it starts to be violent

magic jackal
#

Cry is right

#

Log a timestamp before and after the promise resolves

#

It should give you a reading of the actual total execution time

hasty lotus
#

But this won’t be the latency

#

This will be the speed at which the server runs the command

magic jackal
#

It will be the entire request until the promise resolves

earnest phoenix
#

what

#

what tj said ^

magic jackal
#

This includes server and REST time

#

If you need WS time Discord JS includes that under client.ws.ping

hasty lotus
#

It will be the entire request until the promise resolves
@magic jackal no bcs the first date will be at the beginning of the command so after receiving the message and the last one will be before sending the edit

earnest phoenix
magic jackal
#

???

#

Thats the entire point of the request, youre handing the command through the API

#

im lost, youve confused me

earnest phoenix
#

a snowflake is generated before the rest of the entity, it's why you measure time before sending up until the entity is returned from the request

magic jackal
#

^^^^

#

Log a timestamp outside of the event emit

#

Thats why

cerulean hornet
#

does anyone know why my bot only shows 18k of users and the server has 103k?

earnest phoenix
#

not all members are cached

magic jackal
#

@cerulean hornet client.guilds.cache.reduce((total,guild) => total + guild.memberCount, 0)

#

Use this for a total count

#

This will show you totals, by indexing through each key

cerulean hornet
#

which one is right? I count the total members using this ai command or rely on this command "message.guild.memberCount"

lyric mountain
#

The latter will get you a count of cached members

#

While the former will give u the real count

cerulean hornet
#

what is a count me cached members?

lyric mountain
#

Like, let's say your server has 50 members and the djs cache limit is 30

#

The latter will return you 30 as the total count of members

#

The former will return you 50

#

Note that not using cache can significantly increase memory usage for a short period of time if the amount of users is too big

earnest phoenix
#

how i get the avatar of the mentioned?12v

cerulean hornet
#

then it pays to use the other code?

lyric mountain
#

Depends on the amount of users

#

@earnest phoenix user.avatar iirc

astral yoke
#

i know ops is undefined here but how would i define it how come this errors with

at Object.run (/app/src/commands/music/nowplaying.js:15:23)```
 
```const { RichEmbed } = require("discord.js");
const ytdl = require("ytdl-core");
const hi = require("../../index.js");
module.exports = {
  config: {
    name: "nowplaying",
    description: "playing songs",
    aliases: ["n", "nnowplaying", "np"]
  },
  run: async (bot, message, args, ops) => {
    let premium = bot.db.get(`premium_${message.guild.id}`);
    if (premium === null)
      return message.reply("Sorry but you don't got premium! Buy it today!");
    if (premium) {
    let fetched = ops.active.get(message.guild.id);
    if(!fetched)
        return message.channel.send("There isn't any music playing in this guild!");
        
    let queue = fetched.queue;
    let nowPlaying = queue[0];

    let resp = `__**Now playing**__\n**${nowPlaying.songTitle}** -- Requested by **${nowPlaying.requester}**`;
    message.channel.send(resp);    
}
  }
}```
tired nimbus
#

Is there any way to make a string somewhat obfuscated

#

but still characters

#

like a formula that changes a name to a certain number

#

and the number equals the name and the name equals the number

warm marsh
#

Would using the OS for listing all the files for dynamic handler be better than a recursive function iterating over a dir?

rocky lintel
#

anyone good with .htaccess?

#

I want to block mobile users from my website, because it's not optimized for it yet. And I want it to display a message on the website

warm marsh
#

Wouldn't you just be better using a query and display the error if screen size is too small?

#

As it will allow browsers that use small windows

rocky lintel
#

But I don't want to go in my files again, I want to make like on .htaccess file and done

lyric mountain
#

@tired nimbus if the code is public, a reverse engineer of your code will unravel any obfuscated string

tired nimbus
#

not code just text

lyric mountain
#

Just encrypt it with some SHA key them

#

Like randomly shifting bytes in the string, and using the key as a seed to the randomizer

open oracle
lyric mountain
#

"copied word for word" is bound to have errors

open oracle
#

oh...

lyric mountain
#

Try to understand the code first

#

Most of the time you'll need to adapt it to your situation

open oracle
#

i tried to read it i understood most of it

lyric mountain
#

What error is it giving?

open oracle
#

im just trying to send an embed message

#

one sec

#

im using it on my laptop and its booting up but its slow

#

but i think it said module not found or somethin

lyric mountain
#

Have you imported the discord.js lib?

open oracle
#

yes

#

ivve had a command work before

#

it was the jsbot1

#

wait

#

i didnt include it

#

its still loading up...

hardy vector
#
if (message.content.startsWith(`${prefix}approve`) && message.author.id === owner) {
        let person = message.mentions.users.first()
        
    }```
 how can i make it so that when i do a!approve @ the bot sends a dm to them saying you're bot was approved
earnest phoenix
#

Hi how to ended song leave voice ? js const channel = message.member.voice.channel; channel.join().then(connection => { connection.play('*****************', { volume: 0.2, }); })

open oracle
#

i went afk its up now

#

its been up for awhile

#

wow that took forever

#

it had some stupid updates

lyric mountain
#

@open oracle remember to do npm install to install the modules if you're working on a copy of an older project

earnest phoenix
#

How can I solve it if I leave the room after the sound playsjs const channel = message.member.voice.channel; channel.join().then(connection => { connection.play('*****************', { volume: 0.2, }); })

open oracle
#

i already did that

#

wait

#

there is no errors now

#

wtf

#

thats my code

#

it still doesnt work

#

nvm there is an error

pale vessel
#

what error

open oracle
#

im getting it

#

there

#

@pale vessel ?

pale vessel
#

sorry, i can't

open oracle
#

its ok

pale vessel
#

because you used pastebin

open oracle
#

oh

#

i can use normal

#

one sec

#
C:\Users\bigtr\firstbot.js:20
                const embed = new Discord.RichEmbed();
                              ^

TypeError: Discord.RichEmbed is not a constructor
    at Client.<anonymous> (C:\Users\bigtr\firstbot.js:20:17)
    at Client.emit (events.js:322:22)
    at MessageCreateAction.handle (C:\Users\bigtr\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
    at Object.module.exports [as MESSAGE_CREATE] (C:\Users\bigtr\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (C:\Users\bigtr\node_modules\discord.js\src\client\websocket\WebSocketManager.js:386:31)
    at WebSocketShard.onPacket (C:\Users\bigtr\node_modules\discord.js\src\client\websocket\WebSocketShard.js:436:22)
    at WebSocketShard.onMessage (C:\Users\bigtr\node_modules\discord.js\src\client\websocket\WebSocketShard.js:293:10)
    at WebSocket.onMessage (C:\Users\bigtr\node_modules\ws\lib\event-target.js:125:16)
    at WebSocket.emit (events.js:310:20)
    at Receiver.receiverOnMessage (C:\Users\bigtr\node_modules\ws\lib\websocket.js:800:20)
#

there

sharp saddle
#

@open oracle your bot is version 12?

pale vessel
#

probably

#

in v12 it's MessageEmbed

sharp saddle
#

if fle is: const embed = new Discord.MessageEmbed

pale vessel
#

add ()

turbid bough
#

add ;

open oracle
#

i already have those

#
client.on('message', message => {
    if(message.author.bot) return;

    if (message.content.toLowerCase() === 'jsbot2') 
    {
        const embed = new Discord.RichEmbed();

        embed.setAuthor(client.user.username, client.user.displayAvatarURL);

        message.channel.send({embed});
    }
});
pale vessel
#

we gave you a potential solution

#

try it

#

and if you're actually on v12, displayAvatarURL is a method so you have to add ()

#

you can also just simply use .send(embed) instead of {embed} because you used the constructor

tired nimbus
#

if you guild has more than 3k members and you want to find a member by a nickname how can I do it

#

Ive tried looping through members of a guild but it seems to only reach a certain group of users

pale vessel
#

you filter them by using member.nickname && member.nickname === something

tired nimbus
#

omg I forgot that it doesnt check their nick if they dont have one

#

nononon

desert phoenix
#

Hi, we're trying to make a bot display what we say in a different channel according to the channel's name, rather than the id.

#

THe reason for this is because we're trying to make it cross-server compatible, so as long as the other server has the channel by the name #something then it will display the thing, given the command in a separate server

open oracle
#

@pale vessel i did this:

client.on('message', message => {
    if(message.author.bot) return;

    if (message.content.toLowerCase() === 'jsbot2') 
    {
        const embed = new Discord.RichEmbed();

        embed.setAuthor(client.user.username, client.user.displayAvatarURL());

        message.channel.send({embed});
    }
});
```is this right?
pale vessel
#

if fle is: const embed = new Discord.MessageEmbed()
@ Igor#5850

#

please read next time

open oracle
#

oh ok

#

where would i put that

pale vessel
#

just change RichEmbed to MessageEmbed

open oracle
#

ok

#

yay it works!

earnest phoenix
#

Greetings I need a little help;
The bot refuses to set up after allowing him all the required permissions even in the channel where it is desginated.
May I get some aid?

#

can someone tell me how to disable message points multiplier for point bot

#

hello

#

support serevre psl

#

HEWLO

#

@true widget

#

@rigid summit

winter basalt
#

?

earnest phoenix
#

i need help

winter basalt
#

with?

earnest phoenix
#

@thorny moth

winter basalt
#

have any errors?

earnest phoenix
#

a bot

#

yes i do

#

i cant get a dam prefic

#

prefix

winter basalt
#

send code and wait for someone, dont mass ping

#

and try to use google aswell

earnest phoenix
#

boi

#

i spent an hour on google

winter basalt
#

ask your question then and wait

#

dont mass ping

#

@scenic kelp this guy right here

#

pls

earnest phoenix
#

what i do

winter basalt
#

called me the b word, mass pinged

#

¯_(ツ)_/¯

earnest phoenix
#

BOI when

scenic kelp
earnest phoenix
#

the web admin said it is

#

holy

scenic kelp
#

that's absolutely not what tonk said

winter basalt
#

^

scenic kelp
#

we are not going to spoonfeed you code

open oracle
#

ok another problem im trying to change the color this is what i have but it doesnt work can anyone help me

client.on('message', message => {
    if(message.author.bot) return;

    if (message.content.toLowerCase() === 'jsbot2') 
    {
        const embed = new Discord.MessageEmbed();

        embed.setAuthor(client.user.username, client.user.displayAvatarURL());
        embed.setColor('GREEN');
        message.channel.send({embed});
    }
});
```but it doesnt work
steel drum
#

@open oracle try using hexadecimal values

#

for the most "green" version of green, it would be ```js
0x00FF00

open oracle
#

i did

#

@steel drum ?

steel drum
#

@open oracle in the code snippit you've provided you passed in string GREEN

#

thats not a hexadecimal..

open oracle
#

i tried hexadecimal

#

it didnt work

#

hello?

#

@steel drum i already tried that

steel drum
#

i dont know what to say to you then

#

i use hexadecimals and they work perfectly fine for me

open oracle
#

ok

#

ok another problem im trying to change the color this is what i have but it doesnt work can anyone help me

client.on('message', message => {
    if(message.author.bot) return;

    if (message.content.toLowerCase() === 'jsbot2') 
    {
        const embed = new Discord.MessageEmbed();

        embed.setAuthor(client.user.username, client.user.displayAvatarURL());
        embed.setColor('GREEN');
        message.channel.send({embed});
    }
});
```but it doesnt work

@open oracle anyone else know?

pale vessel
#

discord.js should accept those colors

open oracle
#

do u want me to post the error?

pale vessel
#

sure

open oracle
#

ok

#
internal/modules/cjs/loader.js:960
  throw err;
  ^

Error: Cannot find module 'C:\Users\bigtr\firsbot.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:957:15)
    at Function.Module._load (internal/modules/cjs/loader.js:840:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
    at internal/main/run_main_module.js:18:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
#

there

pale vessel
#

that's not the color's fault

open oracle
#

oh...

pale vessel
#

does that error happen when you try to start the bot?

open oracle
#

uhh ithink let me double check

pale vessel
#

or when you run a command

open oracle
#

when i start it

pale vessel
#

how do you start your bot?

open oracle
#

node firstbot.js

pale vessel
#

in the error it says something about firsbot.js

#

do you know that file?

open oracle
#

ye

pale vessel
#

where did you require that file?

#

oh never mind

mossy vine
#

did you just make a typo in the command

open oracle
#

created it in notepad :/

pale vessel
#

You made a typo

open oracle
#

did you just make a typo in the command
wdym

pale vessel
#

bruh

open oracle
#

OMG

#

I DID

#

IM SO DUMB

pale vessel
#

you pepega

mossy vine
#

the error says firsbot.js is not found, but you siad you wanted to run firstbot.js

open oracle
#

i want to die

neat ingot
#

^ that moment when you realize you should have taken 5 seconds to try figure out your issue before asking for help.

earnest phoenix
#
const warns = require("../../models/warns.js");
const { MessageEmbed } = require("discord.js");

module.exports = {
  name: "warns",
  run: async (bot, message, args) => {
    
    let user = message.mentions.members.first();

    
    if(!user) {
      const q = new MessageEmbed()
      .setColor("#ff9900")
      .setDescription(":no_entry_sign: **You need to specify an user!**")
      .addField("Correct Usage", "lt!warns [userMention]");
      
      message.channel.send(q);
      
      return;
    }
    
    warns.findOne({ Guild: message.guild.id, User: user.id}, async (data, err) => {
      if(err) console.log(err)
      console.log(data.Warns.length)
      if(!data.length) {
        const p = new MessageEmbed()
        .setColor("#ff9900")
        .setDescription(`:white_check_mark: **${user.user.tag} has not got any warns!**`);
        
        message.channel.send(p);
        
        return;
      }
      let f = new MessageEmbed()
      .setTitle(`${user.user.tag}'s warns`)
      .setColor("#ff9900")
      .setDescription(data.map(d => {
        return d.Warns.map((w, i) => `${i} - Moderator: ${message.guild.members.cache.get(w.Moderator).user.tag} Reason: ${w.Reason}`)
      }))
      
      message.channel.send(f);
      
    }) 
  }
}

Cannot read property 'Warns' of null

but in console i still get the data

golden condor
#

Mate you've done it the wrong way round

#

It's err, data not data, err

winter basalt
#

😆

golden condor
#

@earnest phoenix

earnest phoenix
#

@golden condor does this change something ?

golden condor
#

It will work yes

earnest phoenix
#

uhm, ok

golden condor
#

Also change !data.length to !data.Warns.length

earnest phoenix
#

ok

#

@golden condor Now i got this error here

data.map is not a function

.setDescription(data.map(d => {
        return d.Warns.map((w, i) => `${i} - Moderator: ${message.guild.members.cache.get(w.Moderator).user.tag} Reason: ${w.Reason}`)
      }))
cinder patio
#

data.Warns

#

is your array of warnings

earnest phoenix
#

so data.map is wrong

cinder patio
#

yeah

earnest phoenix
#

data.Warns is not a function

cinder patio
#

yeah, it's an array

golden condor
#

It's data.Warns.map

median fox
#

Use eval to try ur code dude

neat ingot
#

are ad's allowed in bots?

#

like, lets say i have a small ad shown at the bottom of a command's embed

#

is that against any kind of tos?

earnest phoenix
#

what is the best module for api

#

(to request api)

cinder patio
#

I use node-fetch

earnest phoenix
#

ok

golden condor
#

That's your bots info

earnest phoenix
#

yes

golden condor
#

You didn't post

earnest phoenix
#

oh

nocturne grove
#

How do some bots have a rounded server size when you invite them?
It says used in x servers and some have a rounded number

neat ingot
#

bent is a good modern api for handling requests from the maker of request which is now depreciated 🙂

nocturne grove
#

are you talking to me?

neat ingot
#

nope 😗

tight forum
lavish compass
#

Hello, could someone help me with a cooldown with mongoDB?

modest maple
#

🤔 why do you need to cooldown your db

tight forum
neat ingot
#

👀

#

i'd love to be the one explaining to users that their data wasnt saved because the database was in cooldown... \s

lavish compass
#

when I reboot the bot, the cooldowns too

hasty sparrow
#

Command cooldowns?

lavish compass
#

yes

neat ingot
#

...

#

someone needs to work on their questioning technique.

tight forum
#

hey @winter basalt

#

can I execute an existing .bat file with c#

neat ingot
#

you should be able to considering you can with almost every language.

#

its just spawning a process via a shell.

tight forum
#

oh

#

ty

neat ingot
#

np 🙂

#

idk c# enough to give any more details im afraid 😦

tight forum
#

time to learn it

neat ingot
#

😛

cinder oxide
#

what

#

you should be learning golang or something

#

though i use c# for unity

#

uwu

robust moth
tight forum
#

you should be learning golang or something
@cinder oxide for execute a batch file?
I think I misunderstood your sentence

hasty sparrow
#

message.language?

tight forum
#

what is that

robust moth
#

message.language?
constructor

neat ingot
#

@robust moth dont use nodemon when developing a bot

#

discord will make your token invalid

#

caause nodemon makes it login every time you make a file change

hasty sparrow
#

Only if you restart your bot very often

neat ingot
#

it happened to me a bunch before i realized wth was happening

#

nodemon restats auto after every single file change

robust moth
#

Ok

neat ingot
#

and if your files autosave...

#

f

hasty sparrow
#

If message.language is a constructor, why are you calling get on it?

cinder oxide
#

oh nvm

#

but golang is cool

tight forum
#

yes i am researching it

#

seems cool

robust moth
#

@hasty sparrow I've gone completely crazy

earnest phoenix
#

omg my bot almost stoped working thank god there is good people to help me

#

wow that was stressful 15 minutes

#

Code:

async def unban(ctx, user: discord.Member, *, reason=None):
  banned_users = await ctx.guild.bans()
  member_name, member_discriminator = member.split('#')

  for ban_entry in banned_users:
    user = ban_entry.user

    if (user.name, user.discriminator == (member_name, member_discriminator):
      await ctx.guild.unban(user)
      await ctx.send(f'Unbanned {user.mention}')
      return```
Error:
```    if (user.name, user.discriminator == (member_name, member_discriminator) :
                                                                             ^
SyntaxError: invalid syntax```
Can someone help?
slender thistle
#

missing a closing parenthesis

#

(P.S you could also just compare IDs)

earnest phoenix
#

F my bad!

frail ocean
tight forum
#

^

earnest phoenix
#

@frail ocean @slender thistle thx for the help

green kestrel
#

Hmm is 214.93mb ram use on 2016 guilds and 300k users reasonable ram use? How much ram are everyone's bots using here, just looking to get a quick survey going see if I can figure out the average ram used per user or per guild

radiant estuary
#

How can i delete a specific element from a array in Javascript?

cinder patio
white anvil
#

@green kestrel depends heavily on library and how much caching you do

green kestrel
#

caching everything

#

in ram and to mysql

white anvil
#

not too bad then probably

#

what library is this

radiant estuary
#

thx

green kestrel
#

aegis.cpp, Jacher

white anvil
#

ah yeah

#

i rlly need to try making a c++ bot lol

green kestrel
#

have "fun" with that! lol

earnest phoenix
#

that is a death sentance

white anvil
#

although if i needed to write stuff in cpp for my bot i'd just make an api for it

green kestrel
#

doing this again, not sure i'd use C++, its really good performance but time to compile and test is an ass

earnest phoenix
#

cpp websockets are uh

#

special

#

implementing the gateway is really hard

green kestrel
#

websockets are abstracted away by aegis in my case cry

#

aegis is a really nice library

#

it uses websocketpp and asio under the hood

white anvil
#

if you compare this to djs

#

you can get 200mb ram easily with djs in like 20 guilds

#

different languages i know but for caching everything 2k guilds and 200mb ram is pretty impressive

earnest phoenix
#

200mb for 2k guilds with cached everything is really good

green kestrel
#

yeah its hard to get a good reading on how much adding guilds is affecting ram in my case too, it always seems to waver around 150-200mb, regardless of how many guilds, it was 180mb ram last november when i only had like 200 guilds lol

white anvil
#

i cache basically nothing and hover at 40mb rss

earnest phoenix
#

my bot used to sit at around 210 with 2k guilds and every member cached

#

though with intents and discord forcing stateless design there won't really be a need for caching

green kestrel
white anvil
#

my cpu hates me but the minimal caching is actually rlly nice to work with

green kestrel
#

i also cant figure out why there was a huge spike in ram use a couple of months ago

#

i suppose the drop around late april coincides with moving to using intents

white anvil
#

theres no problems with managing possibility that entity is not cached

green kestrel
#

it might be websocket buffers to handle all the presence messages or something shrug

white anvil
#

presence update alone was making me exceed my bandwidth limit

green kestrel
#

yeah, look at my bandwidth graph now lol

#

those two spikes are a restart and synching members

#

apart from that, barely goes above 5k/sec any more

white anvil
#

i couldnt even tell you what those spikes are lol

#

but intents have got me down to about 400kbps also

#

i imagtine the majority of that isnt actually from the bot though

#

i only track messages, reactions, and guild updates

earnest phoenix
#

Anyone knows if you can actually code a command, but disable it.

#

Without if statements ^^
Python btw

cinder patio
#

depends on your command handler I guess

white anvil
#

if you have a property on your client with all your commands just remove it from there

#

if you dont then you cant easily

earnest phoenix
#

Alright

cinder patio
#

I have a bot written in D.JS that's in around 180 servers and uses 75MB of RAM max, and it doesn't cache anything

white anvil
#

if you dont cache anything then server count makes no difference

#

or extremely little difference

cinder patio
#

yea, well I cache guilds and roles

white anvil
#

all i cache is messages

#

but that has a limit of 100 items

quartz kindle
#

im running a test using jemalloc with node.js

#

i need to wait a few days for results

earnest phoenix
#
const file = require('../data.json');
if (file.includes(guild.id)) console.log('triggered');

file.includes is not a function

quartz kindle
#

but for a 1 day uptime, my bot's rss usage was about 50mb lower than before

warm marsh
#

@earnest phoenix includes is a method on arrays. Not a JSON object.

quartz kindle
#
thisIsAnArray = [1,2,3,4,5];
thisIsAnObject = {1:10,2:20,3:30}

thisisAnArray.includes(3) // true
thisisAnArray.includes(7) // false

thisIsAnObject[3] // 30
thisIsAnObject[7] // undefined
earnest phoenix
#

😉

quartz kindle
#

because 30 is a "truthy" value, you can do if(thisIsAnObject[3]) {}

earnest phoenix
#

so file[guild.id]

quartz kindle
#

yes

earnest phoenix
#

idk im stupid sometimes sorry

#

same problem as yesterday @quartz kindle

#

which is that it doesn't refresh the json file

warm marsh
#

JSON for you.

earnest phoenix
#

?

quartz kindle
#

are you using glitch?

zenith terrace
#

if you are using glitch then you most likely need to refresh your glitch project or go out of glitch then go back in

#

then the JSON file should update

earnest phoenix
#

im not

cinder patio
#

how are you updating it

quartz kindle
#

then you will need to show more code

neat ingot
#

them some sexy graphs i see @green kestrel @white anvil ❤️

quartz kindle
#

any recommendation for a good monitoring system that supports per-process metrics?

neat ingot
#

netdata does that i beleive

#

the amount of metrics it gives is actually astonishing

#

graphs for days

earnest phoenix
#

how are you updating it
@cinder patio im not, because idont know how to do that

cinder patio
#

then what do you mean by "refreshing"?

quartz kindle
#

@neat ingot i believe i've used netdata, but i couldnt figure out how to get a per-process list

#

its all about the entire system

#

i dont use containers, so i need it to be per-process

neat ingot
#

that kinda data not enough?

quartz kindle
#

nope

#

i wanted for example, a specific node.js's process cpu/ram/network/bandwith graphs

#

or at least monitor a process by pid

neat ingot
#

ahh, i get that from using containers, idk how well it'd work outside of containers though

earnest phoenix
#

then what do you mean by "refreshing"?
It adds the guild.id to the json file, but if i check if the guild.id is in that file without turning off my bot saving the file and then start it again - it doesnt think that the guild.id is in that file
@cinder patio

neat ingot
#

but it does seem to support giving metrics for all the things running on my host machine

quartz kindle
#

you will need to show more code wolfy

earnest phoenix
#

oke

#

ill

quartz kindle
#

@neat ingot i ended up uninstalling it lol

neat ingot
#

lmao

quartz kindle
#

it was a while ago

neat ingot
#

i like it cause its a single container. the other way i was trying was using cadvisot/grafina/prometheus, and needed containers for db and all kinda junk

grizzled raven
#

where do yall get your graphs

neat ingot
#

it woulda been 7 containers just for metrics 😐

#

cadvisor *

#

those graphs above are from netdata noob 🙂

#

the user with the chinese-CF8 name put me onto it 🙂

quartz kindle
#

you need to customize apps.plugin and apps_goups.conf to make it work per process

#

but i couldnt get it to work

grizzled raven
#

netdata

#

is it like some docker thing or

neat ingot
#

it works in docker, it works without

quartz kindle
#

its a software you can install via command line on linux

#

it opens a webserver on some port

#

and you access the graphs from your browser

neat ingot
#

can also super easily define password and such for login to view the metrics

earnest phoenix
#

I think this is everything

neat ingot
earnest phoenix
#

nvm

quartz kindle
#

@earnest phoenix that doesnt help

earnest phoenix
#

what do you need then?

quartz kindle
#

you didnt make the change i told you to do

earnest phoenix
#

ye i did that as wel

quartz kindle
#

use require instead of fs

earnest phoenix
#

changed it back because i had the same problem

neat ingot
#

tbh tim i'd give netdata another bash. for everything it offers in the one package its worth an hour or two of setting up imo 🙂

earnest phoenix
#

i can try it again

#

@quartz kindle

neat ingot
#

super easy to setup like, alerts and junk for when things go offline or w.e

quartz kindle
#

i was kinda worried it would increase resource usage

#

since my instance is only 1 core 1gb

neat ingot
#

thats my usage atm

#

it only seems to use processing when im viewing the data

quartz kindle
#

it does collect metrics offline too

#

so you can see history graphs

earnest phoenix
#

this then

neat ingot
#

yea i mean, it keeps running and junk, but it seems to be really efficient unless its lying to me about its usage 😄

quartz kindle
#

@earnest phoenix yes, but everywhere

earnest phoenix
#

ah

quartz kindle
#

change all your JSON.parse(readFileSync to that

earnest phoenix
#

oke

#

but the problem is in the 2nd part right

#

where it doesnt detect it

quartz kindle
#

thats why you have to change it everywhere

#

@neat ingot i'll give it another try sometime

neat ingot
#

it also allows for fairly easy creation of custom graphs and w.e using simple html 🙂

quartz kindle
#

im just periodically checking my bots using process.memoryUsage() in node lol

neat ingot
#

lmao

quartz kindle
#

i made a handy clientInfo method for that

earnest phoenix
#

await writeFile(filePath, JSON.stringify(data))
with
data[msg.guild.id] = { name: msg.guild.id }; & const filePath = join(__dirname, '..', '/data.json') right?

neat ingot
#

do you programatically save the data to a file to view later? or only when you do it manually?

#

like, does it check every like 5 minutes or w.e and save the data toa file so you can check previous usage and see spikes and the like

quartz kindle
#

im not really controlling usage history

#

just checking current usage and comparing it to what i remember last time i checked lmao

neat ingot
#

lmao

quartz kindle
#

just to make sure its stable

neat ingot
#

24 ping o0

quartz kindle
#

ws ping

neat ingot
#

where you hosting?

#

ahh

quartz kindle
#

rest ping oscilates between 90 and 150

#

usually

earnest phoenix
#

it worked tim

#

it detected the guildid

neat ingot
#

which host provider do you use tim?

quartz kindle
#

galaxygate

#

sometimes discord does this kinda crap lmao

neat ingot
#

i was using digital ocean, moving everything to contabo cause its cheap afffffzzzzz

quartz kindle
earnest phoenix
#

so the reason it worked was because it is copied in the cache right

#

instead of only disk1

neat ingot
#

thats about my average when bots running on current server/my local machine (in uk)

#

i got my new server in new york though as i hear discord latency is good from there 😄

quartz kindle
#

@earnest phoenix yes, essentially you have 2 copies, one in the cache and one in the disk. the disk is only a backup that is used when your bot restarts. the cache copy is where you should do everything with

#

so everything you do, you use the cache version and then save a copy to the file backup

earnest phoenix
#

that makes sense i guess

#

and then when you save the file they sync again?

quartz kindle
#

yes

earnest phoenix
#

oke i understand

#

thanks man

quartz kindle
#

the reason for doing this, is that the cache is much faster than the disk

earnest phoenix
#

and saved

quartz kindle
#

if you did everything using only the disk copy, it would be very slow

earnest phoenix
#

yes

#

and i mycase it wasnt saved either

neat ingot
#

this is for json files with config or something?

earnest phoenix
#

writing to a file

quartz kindle
#

storing guild data in json

earnest phoenix
#

thanks man

#

have a good one

quartz kindle
#

another thing

#

if your bot crashes during saving to file

#

your json file will get corrupted and you will lose all data in it

earnest phoenix
#

that would be a gg

quartz kindle
#

a good way to prevent this, is to save the file in 2 steps: save to a temporary file with a different name, then rename the temporary file to the original file

earnest phoenix
#

oke i have to figure that out soon

#

before i deploy my bot

neat ingot
#

tbh i need to add that into my json data storage module thing

earnest phoenix
#

but why would it crash though?

neat ingot
#

it only records how many times i reboot my bot tho so it wouldnt be catastrophic if it rekt the file

earnest phoenix
#

but why would it crash though?
the same reason why windows crashes

#

any reason

#

oke

#

👍

quartz kindle
#

crashes can happen at any time, because of coding mistakes, not handling errors properly, or in extreme cases, power failures and hardware failures in the machine

earnest phoenix
#

i do catch err

#

but there are ofc other reasons it could happen

quartz kindle
#

if the crash happens exactly while writeFIle is writing to the file, the file will become corrupted

earnest phoenix
#

ah

quartz kindle
#

it takes a bit of bad luck, but can happen

neat ingot
#

when my bot went live, i discovered that people somehow find imaginative ways to break your bot that you would never have thought of.

earnest phoenix
#

or

#

if you shut it down while it is writing a file

quartz kindle
#

yes

earnest phoenix
#

ok ill have to look into that then

#

thanks

#

when my bot went live, i discovered that people somehow find imaginative ways to break your bot that you would never have thought of.
this

#

always write your code so that it's fool proof

neat ingot
#

impossible.

earnest phoenix
#

yes i test it in every case

#

very true

quartz kindle
#

fool-proof is not enough, it needs to be animal-proof

#

your users are brainless animals

winter basalt
#

ok

quartz kindle
#

lmao

winter basalt
#

¯_(ツ)_/¯

earnest phoenix
#

but you should always have a mindset of "someone's going to do their best to break my app"

neat ingot
#

and retard-resistant.

#

tbh, yes.

#

i've had people join my support server specifically for that reason 😄

winter basalt
#

"hmm, what are some ways a retard could think of to break my app"

earnest phoenix
#

microsoft please take that advice and fix your shitty os

quartz kindle
#

for example, typing a command with a 2000 char arg

neat ingot
#

ha, gl with that

#

now thats an interesting one...

#

goes to try

earnest phoenix
#

tim where can i found how to do that

#

backup the file every once in a while

quartz kindle
#

check the node.js's fs documentation

neat ingot
earnest phoenix
#
(node:2752) UnhandledPromiseRejectionWarning: RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values may not be empty.
neat ingot
#

nothin happened ❤️

quartz kindle
#

xD

earnest phoenix
#
  .addField('Antes', oldMessage.content, false)```
quartz kindle
#

my bot used to generate 8000x8000 images from user input, and people can add objects to the image using args and options

#

and people would sometimes use all 2000 chars adding random stuff to the image

#

and it would crash the bot occasionally

earnest phoenix
#

help?

quartz kindle
#

@earnest phoenix the error says it all

#

one of your embed fields is empty, which means, oldMessage.content doesnt exist

neat ingot
#

😄

quartz kindle
#

lmao

neat ingot
#

it sent fine as well 😄

mossy vine
#

why is the id so long tho

earnest phoenix
#

i cant find it

neat ingot
#

uuid v1

quartz kindle
neat ingot
#

duckduckgo lol

quartz kindle
#

yeah

neat ingot
#

never been keen on that engine

quartz kindle
#

it sucks

neat ingot
#

lol

quartz kindle
#

50% of my searches i cant find what im looking for

#

while on google i can

neat ingot
#

its certainly not as user friendly as google, but i guess it has other benefits

quartz kindle
#

they even include a !g command for that reason lmao

#

if you search node fs !g it redirects you to google's search results lmao

neat ingot
#

oh thats neat 😄

#

i guess they kinda had to do something though or users woulda stopped using when they can never find anything 😄

quartz kindle
#

yeah lmao

#

people only use ddg for privacy reasons

#

i decided to give it a try

#

im also using brave browser, decided to give it a try as well

neat ingot
#

side question: anyone got any ideas for commands i can add to my discord minigame bot? this is the list it has atm 🙂

earnest phoenix
#

yes im there

quartz kindle
#

but it has the same issues chrome has

neat ingot
#

ive never tried brave

#

i heard firefox is doing some premium browser thing as well now

quartz kindle
#

my issue is that i never close the browser, and i never shutdown/restart my pc

#

i often go months without a single restart or pc or browser

cinder patio
#

@neat ingot google feud

neat ingot
#

👀

quartz kindle
#

and after a while the browser starts lagging like crazy

neat ingot
#

your poor pc

quartz kindle
#

and im forced to close it and reopen it

neat ingot
#

feud is a game?

cinder patio
quartz kindle
neat ingot
#

i have no idea what this is meant to be lol

earnest phoenix
#

do i need to do that for example every hour

quartz kindle
#

if you want to do periodical backups, yes, but one hour would be too much

#

make it one day or something

earnest phoenix
#

ok

#

so

quartz kindle
#

but if you use the rename technique you should be 99% safe

#

except for system crashes

earnest phoenix
#

so

cinder patio
#

You have to guess the most searched queries that start with something

#

for example "is it wrong to be ____"

quartz kindle
#

gay

neat ingot
#

ooooohhh i see

#

fk that

#

im not using any google api again lol

earnest phoenix
#

I have the main json file - and the backup json file.
it deletes the backup file every 24h, and makes a copy of the main file and calls that backup?

#

you don't have to

#

you can scrape ddg

neat ingot
#

not since they tried to charge me a fortune for map api

earnest phoenix
#

you can also do guess the wikihow article

quartz kindle
#

@earnest phoenix thats a way to do backups yes, but the renaming technique is like this:

  1. save file to "myfile.temp"
  2. rename file from "myfile.temp" to "myfile.json"
earnest phoenix
#

I can also just to fs.constants.COPYFILE_FICLONE_FORCE every 24h, because that will overwrite the copied file right?

quartz kindle
#

thats a constant, not a function

neat ingot
#

would that auto overwrite a file with same name that already exists? ive never tried to rename a file in node 😄

quartz kindle
#

constants are used as options for specific functions, not used by themselves

cinder patio
#

yeah it will

earnest phoenix
#

its a mode

#

this

quartz kindle
#

yes

#

but you dont need it

#

the default already does overwrite it

earnest phoenix
#

can just do

quartz kindle
earnest phoenix
#

oh

#

fs.copyFile('data.json', 'backup.json', callback); should work then right?

quartz kindle
#

yes

earnest phoenix
#

thanks for the help man

#

I really appreciate it

quartz kindle
#

👍

fresh hatch
#

Hey, im making my bot on Glit** but when i add a status its not working

#

@flat kraken

#

You mean this channel, right?

flat kraken
#

Yeah. This channel. But I can't really help

fresh hatch
#

Oh, ok! Dont worry 🙂 Thx anyways 🙂

cinder patio
#

is that Glitch but censored or do you mean something else

#

show us how you're doing it, how is it not working?

#

any errors?

fresh hatch
#

yes, cuz was banned from one server when told this...

#

ok, second

neat ingot
#

lmao you got banned for saying your bot was on glitch?

#

savage

fresh hatch
#

glitch

#

yes for advertising...

neat ingot
#

😐

fresh hatch
#

mhm

neat ingot
#

thats actually hilarious

earnest phoenix
#

thats not considered advertising, what kind of crackhead server was that lol

#

dont tell the name

#

it worked @quartz kindle !

spice smelt
#

hey there, I'm switching to mongoDB and I'm currently trying mongoose. I've seen in the docs you have to use .save() to save, but how to select the collection? thx in advance

earnest phoenix
#

that would be considered advertising

#

thank you so much man

neat ingot
#

you dont need to select the collect a2b

#

you save the document

spice smelt
#

wdym

neat ingot
#

like umm

#

sec ill get code

spice smelt
#

wait

#

I think I understood

neat ingot
#
const datathing = new Model({data});
datathing.save();
spice smelt
#

When I create a new document, I need to specify the model, right?

fresh hatch
#

client.user.setActivity('looking SyntaxRP');

neat ingot
#

yea 🙂

fresh hatch
#

@cinder patio

cinder patio
#

weird that should work

spice smelt
#

and then I use smth like js <mongoCollection>.insert(datathing) right?

cinder patio
#

Try adding {type: "PLAYING"} as the second parameter but I don't think it's required

neat ingot
#

i've never used any insert function with mongoose. I just create a new instance of my model, which is part of a collection, and then call save on it and it inserts itself

spice smelt
#

but how can it find the right collection to go if it isn't specified anywhere?

neat ingot
#

for example, lets say i have a collection of players and some model like:

  const Player = mongoose.model('Player', playerSchema);
  const my_player = new Player({ name: 'Dekita' });
  my_player.save();
#

that auto saves into the 'Player' collection.

spice smelt
#

Okaaaay

#

I think I understood 👍

#

thank you

neat ingot
#

np 😗

spice smelt
#

before you explained, I didn't really understand the difference between schemas and models but now I do

neat ingot
#

a schema is like, a data blueprint, a model is like, a constructor that uses the schema to instantiate the document that will be added to the collection specified when creating said model 🙂

#

or as mongoose says:

spice smelt
#

great, thanks 👌

neat ingot
#

do i need to have the presence intent to set my bots status via setPresence?

quartz kindle
#

not afaik

#

setting status is just bugged af

#

it randomly doesnt work

neat ingot
#

lol

#

it wasnt workinng cause iw as trying to set it with v11 structure

#

ie, game: {} instead of activity: {}

quartz kindle
#

ah xd

neat ingot
#

i wonder if they will ever give bots custom status'

brave rover
neat ingot
#

😮 i thought it was a limitation imposed by discord directly

quartz kindle
#

it is

neat ingot
#

well f then

#

😄

brave rover
quartz kindle
pale light
#

Discord.js v12 .features How can I use

neat ingot
#

i went to link my steam to discord, clicked the little thing to add steam and got this:

#

👀

pale vessel
#

norton?!

hasty sparrow
#

Norton
Nuff said

neat ingot
#

lol yea its just the norton websafe thing 😛

#

i dont actually have any antivirus software other than that 😐

#

and steam community pages load fine normally

hasty sparrow
#

Norton's crap, bin it

earnest phoenix
#

@neat ingot Use Linux, so u dont need antivirus

#

xD

austere gale
#

hey

earnest phoenix
#

Anyone ever used webmin?

austere gale
#

ok so im using glitch .com to code right

#

and i get this issue

#

what do i do

quartz kindle
#

cannot find module genius-lyrics

#

if you're using this module, you need to install it

mossy vine
#

also syntax error

summer torrent
#

🔭

quartz kindle
#

yes, you appear to have more errors that you're not showing

austere gale
#

do i need an api from genius too?

#

i got this code from here

#

im new to coding

#

so im learning as i go

cinder patio
#

I don't think straight up copying from another bot is learning as you go

austere gale
#

i go over it

quartz kindle
neat ingot
#

and how is that a tutorial? its just flat out giving the codebase 😄

quartz kindle
#

the genius-lyrics module does require an api token apparently

austere gale
#

hmmm

quartz kindle
#

but in your case, you need to install it first

austere gale
#

cries in no pc

quartz kindle
#

you need to install it in your glitch project

#

not on your pc

austere gale
#

oh

neat ingot
#

i randomly 'taught' my bot the lyrics to 'big shaq ~ mans not hot' for when people use the math command 😄

quartz kindle
#

click on the add package button

#

and search for it

neat ingot
quartz kindle
#

everyday mans in the block

#

smoke trees

austere gale
#

do i just look up genius api?

quartz kindle
#

you look up the package name

#

its called genius-lyrics

austere gale
#

ok ill try that brb

neat ingot
quartz kindle
#

xD

neat ingot
#

took him ages to say it lol

austere gale
#

ok i installed it

quartz kindle
#

the github project uses genius-lyrics v2

#

you installed v3, which might work differently

#

this is how v3 works

mossy vine
#

how much security does the state thing provide in oauth? is it worth implementing?

quartz kindle
#

it helps against some kinds attacks i guess

austere gale
#

oh ill get vw then

#

v2

limber flume
austere gale
#

do i need to uninstall v3?

quartz kindle
#

The primary reason for using the state parameter is to mitigate CSRF attacks.

When you use state for CSRF mitigation on the redirection endpoint, that means that within the state value there is a unique and non-guessable value associated with each authentication request about to be initiated. It’s that unique and non-guessable value that allows you to prevent the attack by confirming if the value coming from the response matches the one you expect (the one you generated when initiating the request). The state parameter is a string so you can encode any other information in it.

mossy vine
#

yeah but are those attacks easy/harmful enough to be worth implementing additional protection against?

quartz kindle
#

csrf is one of the main attack vectors these days, along with xss, but it does require access to the target machine, via botnets or similar

#

the idea is that you intercept the initial request, send it somewhere else, and return a fake version of it from another machine, before the first machine is able to respond to it

#

or something similar

#

i dont know the details

mossy vine
#

ah

quartz kindle
#

can also be done by man in the middle attacks, so the end result is that you give access to the wrong person

austere gale
#

.

quartz kindle
#

@austere gale if you want to use v2, you need to change the version in your package.json file

clear wraith
austere gale
#

which one would be better

#

i installed v3 but you said my code ran on v2

sudden geyser
#

Roman you need to format the date object.

quartz kindle
#

in javascript

#

@austere gale better would be to change your code to use v3

#

but that requires knowing what you're doing

austere gale
#

how do i do that

#

yeah

quartz kindle
#

you read the v3 documentation and change the code accordingly

austere gale
#

i just got into it 2 weeks sago

quartz kindle
austere gale
#

whats that

quartz kindle
#

their docs

austere gale
#

oh

quartz kindle
#

they have examples

austere gale
#

for v3?

quartz kindle
#

from the looks of it, the examples are out dated

austere gale
#

oof

quartz kindle
#

but just read the docs

austere gale
#

ok will do

robust moth
quartz kindle
#

emit is not a promise

neat ingot
#

@clear wraith if your using javascript i recommend the moment library

paper phoenix
#

He seems to only need to use reportedAt.toLocaleTimeString( )

clear wraith
#

Thanks

earnest phoenix
#

can someone tell me if anything wrong in this

  for extension in initial_extensions:
    try:
      client.load_extension(extension)
    except Exception as e:
      print(f'Failed to load extension {extension}', file=sys.stderr)
      traceback.print_exc()```
```Traceback (most recent call last):
  File "main.py", line 24, in <module>
    traceback.print_exc()
NameError: name 'traceback' is not defined```
tight plinth
#

define trackback

clear wraith
#

^ ^

earnest phoenix
#

i mean i didn't get what to do

clear wraith
#
const Discord = require("discord.js");
const client = new Discord.Client();
client.commands = new Discord.Collection();
let xp = require("./xp.json");

var DBL = require('dblapi.js')
var dbl = new DBL(process.env.DBL, { webhookPort: 5000, webhookAuth: 'password' });

dbl.on("posted", () => {
  console.log("Server count posted!");
});

dbl.on("error", e => {
  console.log(`Oops! ${e}`);
});

dbl.webhook.on('ready', hook => {
  console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
  client.channels.cache.get(715201063375863809).send(`${vote.user} has voted for Cryptic!`)
});

I had someone vote for my bot to test if it will send that a user voted for it in a channel. But it didn't send it in a channel when he voted. Why did it not send the ${vote.user} has voted for Cryptic?

lyric mountain
#

try to do console.log("voted")

cinder patio
#

The ID must be a string

lyric mountain
#

and see if it appears in your console

restive furnace
#

The ID must be a string
^