#development

1 messages Β· Page 872 of 1

cerulean pebble
#

bot b even not have EVAL command

quartz kindle
#

do you have 2 bots in the same file?

cerulean pebble
#

yes

quartz kindle
#

show code

cerulean pebble
#

but bot b not have eval command

#
const fs = require('fs');
const Discord = require('discord.js');

exports.run = (client, message) => {
    if (message.author.id !== '699962233974816838') {
        return message.channel.send(`\`πŸ“›\` ${message.author} You don't have permissions to execute that command.`);
    }

    function clean(text) {
        if (typeof (text) === 'string') {
            return text.replace(/`/g, '`' + String.fromCharCode(8203)).replace(/@/g, '@' + String.fromCharCode(8203));
        }
        return text;
    }
    let args = message.content.split(' ').slice(1);
    let cont = message.content.split(' ').slice(1).join(' ');
    message.channel.send('Evaluating...').then(msg => {
#
try {
            let code = args.join(' ');
            let evaled = eval(code);

            if (typeof evaled !== 'string') {
                evaled = require('util').inspect(evaled);
            }
            if (evaled.length > 2000) {
                try {
                    let evalcode1 = new Discord.RichEmbed()
            .setAuthor(`Eval by ${message.author.tag}`, `https://cdn.discordapp.com/emojis/314405560701419520.png`)
            .setDescription(`**Input:**\n\n\`\`\`js\n${cont}\`\`\``, true)
            .addField(`\u200b`, `**Output:**\n\n\`\`\`Output too long, logged to ${__dirname}\\eval.txt\`\`\``, true)
            .setColor(0x00FF00)
            .setFooter(`Node.js - Time taken: ${Date.now() - message.createdTimestamp} ms`, `https://images-ext-2.discordapp.net/eyJ1cmwiOiJodHRwczovL2Euc2FmZS5tb2UvVUJFVWwucG5nIn0.LbWCXwiUul3udoS7s20IJYW8xus`);
                    msg.edit({
                        embed: evalcode1
                    });
                    return fs.writeFile(`eval.txt`, `${clean(evaled)}`);
#
   } catch (err) {
                    let errorcode1 = new Discord.RichEmbed()
            .setAuthor(`Eval by ${message.author.tag}`, `https://cdn.discordapp.com/emojis/314405560701419520.png`)
            .setDescription(`**Input:**\n\n\`\`\`js\n${cont}\`\`\``, true)
            .addField(`\u200b`, `**Output:**\n\n\`\`\`js\nOutput too long, logged to ${__dirname}\\eval.txt\`\`\``, true)
            .setColor(0xFF0000)
            .setFooter(`Node.js - Time taken: ${Date.now() - message.createdTimestamp} ms `, `https://images-ext-2.discordapp.net/eyJ1cmwiOiJodHRwczovL2Euc2FmZS5tb2UvVUJFVWwucG5nIn0.LbWCXwiUul3udoS7s20IJYW8xus`);
                    msg.edit({
                        embed: errorcode1
                    });
                    return fs.writeFile(`eval.txt`, `${clean(err)}`);
                }
            }
#
let evalcode = new Discord.RichEmbed()
        .setAuthor(`Eval by ${message.author.tag}`, `https://cdn.discordapp.com/emojis/314405560701419520.png`)
        .setDescription(`**:rofl: Input:**\n\n\`\`\`js\n${cont}\`\`\``, true)
        .addField(`\u200b`, `** :rofl: Output:**\n\n\`\`\`js\n${clean(evaled)}\`\`\``, true)
        .setColor(0x00FF00)
        .setFooter(`Node.js - Time taken: ${Date.now() - message.createdTimestamp} ms`, `https://images-ext-2.discordapp.net/eyJ1cmwiOiJodHRwczovL2Euc2FmZS5tb2UvVUJFVWwucG5nIn0.LbWCXwiUul3udoS7s20IJYW8xus`);
            msg.edit({
                embed: evalcode
            }).catch(e => logger.error(e));
        } catch (err) {
            let errorcode = new Discord.RichEmbed()
        .setAuthor(`Eval by ${message.author.tag}`, `https://cdn.discordapp.com/emojis/314405560701419520.png`)
        .setDescription(`**:rofl: Input:**\n\n\`\`\`js\n${cont}\`\`\``, true)
        .addField(`\u200b`, `**:rofl:Output:**\`\`\`js\n${clean(err)}\`\`\``, true)
        .setColor(0xFF0000)
        .setFooter(`Node.js - Time taken: ${Date.now() - message.createdTimestamp} `, `https://images-ext-2.discordapp.net/eyJ1cmwiOiJodHRwczovL2Euc2FmZS5tb2UvVUJFVWwucG5nIn0.LbWCXwiUul3udoS7s20IJYW8xus`);
            msg.edit({
                embed: errorcode
            }).catch(e => logger.error(e));
        }
    });
};
#

@quartz kindle

#

shiro is a stupid and a cancer girl

knotty steeple
#

thats a really long eval command

#

holy fuck

cerulean pebble
#

@knotty steeple that' not problem

quartz kindle
#

show where you run this command

#

your message event

cerulean pebble
#

i have picture

#

error mode

quartz kindle
#

your message event

#

where you execute this command

cerulean pebble
quartz kindle
#

dude

cerulean pebble
#

normal mode πŸ™‚

quartz kindle
#

your code

cerulean pebble
#

i just have 2 picture

#

can prove my error

quartz kindle
#

i want to see your code, the place in the code where you run this command

#

jesus

cerulean pebble
#

where ? you mean my PC

quartz kindle
#

your message event

cerulean pebble
#

ahh i do not have you mean even in console.log

#

?

#

*event

unique nimbus
#

what

quartz kindle
#

client.on("message", message => {
blablabla
command.run()
})

#

this

finite bough
#

he means command handler

#

command handler text in ur main file

cerulean pebble
#

command heandler ?

#

wait

quartz kindle
#

just show your full main file

cerulean pebble
#
client.on('message', message => {

    let args = message.content.slice(prefix.length).trim().split(' ');
    let cmd = args.shift().toLowerCase();

    if (message.author.bot) return;
    if (!message.content.startsWith(prefix)) return;

    try {
   
      delete require.cache[require.resolve(`./commands/${cmd}.js`)];

      let ops = {
          ownerID: ownerID,
          active: active
      }

        let commandFile = require(`./commands/${cmd}.js`);
        commandFile.run(client, message, args, ops);
      } catch (e) {
        
    }
  });
#

just show your full main file
@quartz kindle all index.js

finite bough
#

@quartz kindle your welcome xD

cerulean pebble
#

2 bot is same 95% so i will show only 1

quartz kindle
#

but you have 2 bots in the same file no?

#

so i want to see the full file

cerulean pebble
#

no

#

hmm

quartz kindle
#

then what do you have?

cerulean pebble
#

here

#

2 other files

pale vessel
#

oml

quartz kindle
#

but its two different bots?

cerulean pebble
#

yes

quartz kindle
#

or is the same bot?

cerulean pebble
#

different

quartz kindle
#

different tokens?

cerulean pebble
#

yes

#

so i want to ask

grave yew
#

Hi, I need help with doing two API calls in one discord.py command

tight plinth
#

eris

#

I tried log message.channel, IT WORKS

cerulean pebble
#

@quartz kindle hmm but i have prove that my bot connect in a moment

grave yew
#
@bot.command(pass_context=True,hidden=True)
async def spotify(ctx, *, arg):
    """[Info] Search for albums and tracks on Spotify."""
    async with aiohttp.ClientSession() as session:
        async with session.post('https://accounts.spotify.com/api/token', headers={'Authorization': 'Basic '+ config.spotifyapikey}, data={"grant_type": "client_credentials"}) as r:
            if r.status == 200:
                js = await r.json()
                print('Obtained Spotify Token.')
                spottoke = (js['access_token'])
                print('Spottoke variable defined.')
        async with session.post('https://api.spotify.com/v1/search?q={arg}&type=artists&limit=1', headers={'Authorization': 'Bearer '+ spottoke}) as r:
            if r.status == 200:
                js = await r.json()
                print('Printing JSON.')
                await ctx.send(js['artists']['items']['external_urls']['spotify'])```
#

it gets up to printing Spottoke variable defined. but doesn't do the second API call.

cerulean pebble
#

hmm

#

some how they connect and do reset command in monent

#

some fucking how

quartz kindle
#

@tight plinth did you try this if(!message.channel) { console.log(message) }

tight plinth
#

I tried

grave yew
#

it gets up to printing Spottoke variable defined. but doesn't do the second API call.
I'm making it search an artist on spotify and print out their URL from a JSON object.

tight plinth
#

it just logs message fine

cerulean pebble
#

i am confused

#

i have the most strange problem

#

in all discord problem

earnest phoenix
#

Tim look in DM's please

tight plinth
#

oh wait

cerulean pebble
#

lol tim

quartz kindle
#

@earnest phoenix you said you put those checks in a message event, and that makes 0 sense

cerulean pebble
#

do you have a idea

tight plinth
#

it logs smth

earnest phoenix
#

Yeah but why saying it this way?

tight plinth
#

so sometimes there is no message.channel at all

earnest phoenix
#

Deleted it already btw, I got that its wrong myself

tight plinth
#

interesting

quartz kindle
#

@cerulean pebble you either have a a weird conflict somewhere, a broken prefix, or you forgot old bot code in the new bot. i cant help you without seeing the full code

tight plinth
#

hmmmmmm

#

interesting

cerulean pebble
#

@quartz kindle sad

#

but the error gone

#

when i delete command

#

i just want to know

#

what happen and why god want to kill me

quartz kindle
#

@earnest phoenix i said it that way because that will either error if you put it in the global scope, or will destroy your bot with an infinite loop of creating events if you put it inside the command

earnest phoenix
#

Well its okay

tight plinth
earnest phoenix
#

As I said, I saw it was not good and deleted it

tight plinth
#

message = null sometimes?

#

what the fuck

pale vessel
#

interesting

earnest phoenix
#

interesting

grave yew
#

Does anybody know how to run an asyncio API call directly after another in one command?

quartz kindle
#

are you accidentally passing a null message from your index file?

tight plinth
earnest phoenix
#

Tim, will using the thing you told me where I can hold huge numbers lag my bot?

tight plinth
#

m exists because closing embeds of playlist counts as messageUpdate, and the playlist function re adds the same playlist twice but thats not the problem here

quartz kindle
#

message is the first parameter, oldMessage is the second (at least according to this)

cerulean pebble
#

@quartz kindle i remember i use same dbl token for 2 bot

#

for testing

tight plinth
#

oh lol

earnest phoenix
#

Tim, will using the thing you told me where I can hold huge numbers lag my bot?

quartz kindle
#

most likely not

earnest phoenix
#

how is it called ?

quartz kindle
#

you can use bigInt, which is native javascript

#

or you can use a library, there are many libraries in npm

#

like bignumber.js

earnest phoenix
#

and what do i do? just install it ?

#

or do i need to change anything in the code too ?

quartz kindle
#

you need to change everything

#

for example, if you use bigInt, you need to add n to all numbers

#

500n

earnest phoenix
#

oh

quartz kindle
#

if you use a library, you need to use whatever the library tells you to do

earnest phoenix
#

cant i make anything else instead?

lyric mountain
#

you can't have await inside a synchronous method

grave yew
#
@bot.command(pass_context=True,hidden=True)
async def spotify(ctx, *, arg):
    """[Info] Search for albums and tracks on Spotify."""
    async with aiohttp.ClientSession() as session:
        async with session.post('https://accounts.spotify.com/api/token', headers={'Authorization': 'Basic '+ config.spotifyapikey}, data={"grant_type": "client_credentials"}) as r:
            if r.status == 200:
                js = await r.json()
                print('Obtained Spotify Token.')
                spottoke = (js['access_token'])
                print('Spottoke variable defined.')
        async with aiohttp.ClientSession() as session:
        async with session.post('https://api.spotify.com/v1/search?q={arg}&type=artists&limit=1', headers={'Authorization': 'Bearer '+ spottoke}) as r1:
            if r1.status == 200:
                js = await r1.json()
                print('Printing JSON.')
                await ctx.send(js['artists'])```
#

i'm trying to get two api calls in one command but it only gets up to defining the spotify token

quartz kindle
#

@stuck scaffold you need to broadcastEval an async function

#

boradcastEval("(async function(){ await bla() })()")

slender thistle
#

I see creating another session inside a session

tight plinth
quartz kindle
#

yes looks fine

stuck scaffold
#

thx Tim

grave yew
#

I see creating another session inside a session
@slender thistle i don't know what to do rn can you help me :P

tight plinth
#

I just want to know where a member voice channel is stored, and how to get it

lyric mountain
tight plinth
#

true, thats duckduckgo

grave yew
#

duckduckgo detected [ninja'd]

tight plinth
#

but still

slender thistle
#

Just put the second async with stuff outside of the very first async with

tight plinth
#

and no, I'll never use google

grave yew
#

ok thank you

lyric mountain
#

then say "duckduckgo is trash"

slender thistle
#

Or

lyric mountain
#

buuuu~~

slender thistle
#

don't create another session at all

#

Re-use the one you create

grave yew
#
@bot.command(pass_context=True,hidden=True)
async def spotify(ctx, *, arg):
    """[Info] Search for albums and tracks on Spotify."""
    async with aiohttp.ClientSession() as session:
        async with session.post('https://accounts.spotify.com/api/token', headers={'Authorization': 'Basic '+ config.spotifyapikey}, data={"grant_type": "client_credentials"}) as r:
            if r.status == 200:
                js = await r.json()
                print('Obtained Spotify Token.')
                spottoke = (js['access_token'])
                print('Spottoke variable defined.')
    async with aiohttp.ClientSession() as session:
        async with session.post('https://api.spotify.com/v1/search?q={arg}&type=artists&limit=1', headers={'Authorization': 'Bearer '+ spottoke}) as r1:
            if r1.status == 200:
                js = await r1.json()
                print('Printing JSON.')
                await ctx.send(js['artists'])```
#

i put my code as that

#

same result

#

just gets up to print('Spottoke variable defined.')

slender thistle
#

Indent the second async with

#

Uhh

grave yew
#

hmm?

slender thistle
#

Just use one client session

grave yew
#

kk

#
@bot.command(pass_context=True,hidden=True)
async def spotify(ctx, *, arg):
    """[Info] Search for albums and tracks on Spotify."""
    async with aiohttp.ClientSession() as session:
        async with session.post('https://accounts.spotify.com/api/token', headers={'Authorization': 'Basic '+ config.spotifyapikey}, data={"grant_type": "client_credentials"}) as r:
            if r.status == 200:
                js = await r.json()
                print('Obtained Spotify Token.')
                spottoke = (js['access_token'])
                print('Spottoke variable defined.')
        async with session.post('https://api.spotify.com/v1/search?q={arg}&type=artists&limit=1', headers={'Authorization': 'Bearer '+ spottoke}) as r1:
            if r1.status == 200:
                js = await r1.json()
                print('Printing JSON.')
                await ctx.send(js['artists'])```
#

what about now

slender thistle
#

Try it

grave yew
#

ok

earnest phoenix
#

@quartz kindle
what if i use parseInt(args[1])
where do i put the n

grave yew
#

same result

#

i still only get up to Spottoke variable defined.

quartz kindle
#

@earnest phoenix you use BigInt(args[1]) instead

#

and when you save them into your database, you need to save it as a string

#

for example 93475938n.toString()

#

and when you load the number from your database, you also need to load it with BigInt(fetchedNumber)

#

either change this to client or change function() to () =>

earnest phoenix
#

Error: Cannot find module './build/Release/bigint'

finite bough
#
 if(x[xchance === "a"]){
           await msg.edit(`congrats <@${message.author.id}> you won the race! as a reward i give u ${random}$`)
              res.money = res.money + random
            res.save().catch(err => console.log(err))
#

do i have to use .then() in order to match the randoms?

earnest phoenix
#

Error: Cannot find module './build/Release/bigint'
help

#

fixed πŸ™‚

#

pls help

#

have you tried reading the error

pale vessel
#

you're so funny

tight plinth
#

its me or eris docs sucks

#

where can I find channel mentions

earnest phoenix
#

hello gays

pale vessel
#

yeah, eris docs is not that good

late hill
finite bough
#

hmm

quartz kindle
#

that would be to mention the channel, i think they want to find channel mentions in a message

grave yew
#

Sorry about my stupid question, I just plugged the API call for an error code and got a 405 error. Thanks for your help anyway.

#

OHH

#

I WAS USING POST INSTEAD OF GET

#

STUPID

quartz kindle
earnest phoenix
#

Does anyone know how to use async to do multiple things at once?

quartz kindle
#

in javascript yes

earnest phoenix
#

don't mix async with threading

quartz kindle
#

@stuck scaffold what is if(newUser.username.includes(a)) {

#

its not in the code you showed

earnest phoenix
#

I mean in python

quartz kindle
#

let b = "${newUser.username}"
if(b.includes(a))

crimson vapor
#

is it just me or is the shard broadcastEval kinda annoying

#

wouldnt it be easier to pass a function

#

and each shard would just do the function

#

like a callback

turbid bough
#

omg i dont understand this

#

Can't cast database type bigint[] to Decimal[]

#

even when my variable is a ulong[]

#

or it could be that variable that is double[], but that isnt bigint[]

split hazel
#

@crimson vapor would be very inefficient and buggy as processes communicate via an ipc/child process connection, which you cannot send things like classes

crimson vapor
#

oh

split hazel
#

quite a lot of limitations

turbid bough
#

man why does postgres not support ulongs...

quartz kindle
#

the best way would be to define the function in the shards themselves

split hazel
#

yup

quartz kindle
#

and call the function from broadcastEval

crimson vapor
#

the evals get access to this.client right

#

so you could define this.functions as your functions then just call them with the information you need

split hazel
#

this is the client itself of that shard

earnest phoenix
#

please i need help

#

let dmGuild = message.guild

#

let memberarray = dmGuild.members.array();

turbid bough
#

holy shit i cant believe i fixed it, it did not work before

warm marsh
#

@earnest phoenix what version?

earnest phoenix
#

how i can put that do not message.guild and do message.channels.get(channel id)

#

let dmGuild = message.guild
let memberarray = dmGuild.members.array();

#

when i put it

#

it says me

#

i need to do it but with a guild id

warm marsh
#

client.guilds.cache.get(id).members.cache.array()

#

?

earnest phoenix
#

i try it

#

one moment

#

it dont work

#

it says the same

warm marsh
#

That's if you're using V12

earnest phoenix
#

v11

warm marsh
#

client.guilds.get(id)

earnest phoenix
#

i remove .cache

warm marsh
#

Yeah

earnest phoenix
#

dont work

crimson vapor
#

dmGuild?

warm marsh
#

Same error?

crimson vapor
#

what is that?

earnest phoenix
#

yep

warm marsh
#

Try console logging client

crimson vapor
#

wait no

earnest phoenix
#

ok

#

we are tryting

#

let dmGuild = message.guild
let memberarray = dmGuild.members.array();

#

this

#

but with a guild id

#

and this dont work

warm marsh
#

A channel id?

crimson vapor
#

can you use cods blocks?

earnest phoenix
#

client.guilds.get(id).members..array()

#

guild id*

crimson vapor
#

are you using this in a dm?

warm marsh
#

client.guilds.fetch(guildID).members.array();

earnest phoenix
#

no

#

i dont using in in a dm

#

im using it in a guild

#

client.guilds.fetch(guildID).members.array();
@warm marsh this dont work

warm marsh
#

console.log client

earnest phoenix
#

ok

robust moth
earnest phoenix
#

it sys a lot of things

split hazel
#

since when could you fetch guilds lmfao

robust moth
warm marsh
#

idk

#

I just woke up

crimson vapor
#

that code wouldnt work in 11 lol

#

guilds.fetch() is for 12

earnest phoenix
#

ok

split hazel
#

props is undefined

#

im on master and yet do not see a fetch option

earnest phoenix
#

Speedy one moment please

robust moth
#

@split hazel but props.conf is true

quartz kindle
#

one of the files has no conf

split hazel
#

what i was about to say lol

earnest phoenix
#

let dmGuild = message.guild
let memberarray = dmGuild.members.array();
@earnest phoenix so?

#

look up please

split hazel
#

you should add an empty object if one does not have a config

robust moth
#

@quartz kindle yes

split hazel
#

actually no the command shouldnt load regardless

earnest phoenix
#

@warm marsh

#

i use console.log client

warm marsh
#

Right?

earnest phoenix
#

it says a lot of things

crimson vapor
#

ah yes, d.js-commando

earnest phoenix
#

so?

crimson vapor
#

nothing

earnest phoenix
#

ok

split hazel
#

and most likely copy pasted code

crimson vapor
#

you should switch off because its still on d.js 11 or even lower

earnest phoenix
#

you dont define x

#

so?
@earnest phoenix can someone help me?

crimson vapor
#

does .map work with async functions

#

I do not remember

earnest phoenix
#

:/

crimson vapor
#

@earnest phoenix send the code that is causing the error in code blocks and send the important part of the error

earnest phoenix
#
        let dmGuild = message.guild
        let role = message.mentions.roles.first();
        var msg = message.content;


        try {
            msg = msg.substring(msg.indexOf("dmall") + 5);
        } catch(error) {
            console.log(error);
            return;
        }

        if(!msg || msg.length <= 1) {
            const embed = new Discord.RichEmbed()
                .addField("❌ Failed to send", "Message not specified")
                .addField("πŸ‘€ Listen up!", "Every character past the command will be sent,\nand apparently there was nothing to send.");
            message.channel.send({ embed: embed });
            return;
        }
        console.log(client)
        let memberarray = dmGuild.members.array();
        let membercount = memberarray.length;```
#

this is error part

#

it dont have error

#

i want to do that let memberarray work with a guild id

crimson vapor
#

@stuck scaffold I think I know your problem

#

you used ${x.guild} when if wasnt needed

earnest phoenix
#

:/

quartz kindle
#

@stuck scaffold the code outside the eval function is one thing, the code inside the eval function is a completely separate thing, they cannot see each other

earnest phoenix
#

:/

quartz kindle
#

you can import things from outside the eval function into it, by using ${}

#

so when you use ${x.guild} you try to get x.guild from outside the eval, not from inside it

#

there is no x outside the eval

earnest phoenix
#

can you help me Tim?

quartz kindle
#

what is it?

earnest phoenix
#

look up

#

the code

quartz kindle
#

are you using discord.js v11?

earnest phoenix
#

yep

#

if i put client.guilds.get(id ) it dont work

#

it says this

quartz kindle
#

that means the guild was not found

earnest phoenix
#

but the bot was in the guild

quartz kindle
#

show the code

crimson vapor
#

guild IDs are too big for js numbers, you need to use a string, that could be a problem

earnest phoenix
#

guild IDs are too big for js numbers, you need to use a string, that could be a problem

quartz kindle
#

there is no Schema inside the eval

earnest phoenix
#

how i fix it?

crimson vapor
#

`${id}`

earnest phoenix
#

ok

quartz kindle
#

@earnest phoenix how do you call client.guilds.get(id)?

#

what is id?

fleet mason
#

server id

earnest phoenix
#

it was `there id

quartz kindle
#

show how you define id

fleet mason
earnest phoenix
#

i dont define it, i put server id

quartz kindle
#

how do you put it?

earnest phoenix
#

but with ``

quartz kindle
#

like this id = 29385987580?

earnest phoenix
#

no

quartz kindle
#

or like this id = "3485735"

crimson vapor
#
id = `server id`
```?
earnest phoenix
#

client.guilds.get(`there id`)

crimson vapor
#

that the actual code?

earnest phoenix
#

yep

quartz kindle
#

like this .get(83475387450) or like this .get("39745937593")

earnest phoenix
#

""

fleet mason
#

last

quartz kindle
#

and you're sure the id is correct and your bot is inside the guild?

earnest phoenix
#

yep

golden condor
#

I am trying to connect to a cpanel mysql db and I am not sure how to use mysql (with queries and that) and how to connect, could someone help me out or send a guide or something. Thanks in advance (btw i us node.js and discord.js v12)

crimson vapor
#

wait are you using "there id"

#

im confused

#

because "there id" is not an ID

quartz kindle
#

console.log(client.guilds.get(id))

trim nexus
#

@golden condor follow a tutorial on youtube

earnest phoenix
#

ok

golden condor
#

I am tryna find one but I can't

#

If someone could walk me through it or help me out with it that would be greag

trim nexus
quartz kindle
#

yes it will be greag

trim nexus
earnest phoenix
#

lol why

crimson vapor
#

mind deleting the embeds?

#

can I see a screenshot of your code @earnest phoenix

#

the entire function

earnest phoenix
#

look up

#

i put it up

crimson vapor
#

no, a screenshot if possible

earnest phoenix
#

ok

quartz kindle
crimson vapor
#

exactly why I like screenshots

trim nexus
#

wait what

quartz kindle
#

but he says it returns undefined

#

so the id being wrong or the guild not being in the bot is the only possible explanation

earnest phoenix
#

i change the id

#

but nothing

#

i put 2 differents ids that the bot are in

#

but it says undefined

#

?
i change that

crimson vapor
#

@stuck scaffold the path is wrong

stuck scaffold
#

no, true

#

models/tags

earnest phoenix
#

@quartz kindle if i put let dmGuild = message.guild work

crimson vapor
#

I am not sure the structure of your folders but it needs to be different

#

@earnest phoenix yes

earnest phoenix
#

but i need it with a id

crimson vapor
#

why?

#

if you need the guild, message.guild should work fine?

earnest phoenix
#

btu i need another guild

#

not my guild

crimson vapor
#

I see

#

ok

#

yes I know

#

the path is wrong

#

can I see a screenshot of all of your files and folders?

stuck scaffold
earnest phoenix
#

but why message.guild.get("id") dont work?

#

i need it please, someone

crimson vapor
#

you have the wrong ID most likely

#

the problem is that your file is not in ./models/tags relative to this.client

#

you could say client.Schema = require("X") and use this.Schema and not define it

earnest phoenix
#

i put this server id

#

console.log(client.guilds.get("264445053596991498"))

#

why

crimson vapor
#

console.log(client.guilds.map(m => m.id))

#

do that

earnest phoenix
crimson vapor
#

dont worry about m its a placeholder

earnest phoenix
#

ok

crimson vapor
#

its a habit of mine to use m for .map functions

#

idk what to call them

earnest phoenix
crimson vapor
#

OOOOOO

#

this.client not client

#

because you are using commando

earnest phoenix
#

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

#

oh....

#

yes

#

im using commando

crimson vapor
#

yes

earnest phoenix
#

and what i do?

crimson vapor
#

console.log(this.client.guilds.map(m => m.id)

#

and replace client with this.client everywhere else iirc

earnest phoenix
#

ok

#

Now Work!!!!!1

#

Thanks

crimson vapor
#

np

#

no

#

here paste the code here again

#

no

#

wrong in a few ways

#

you dont need to redefine client

#

you can use this.client

#

client would be a string using "${client}" not an object

#

^

#

and "./models/tags" does not exist relative to this path

#

try const Schema = ${Schema}

quartz kindle
#

you cant pass classes and complex data through broadcastEval

crimson vapor
#

wait why not?

quartz kindle
#

because it uses IPC

crimson vapor
#

so strings but no objects?

quartz kindle
#

inter-process communication only supports simple data, just like network requests

#

stringified objects yes

#

but not classes

crimson vapor
#

oh

#

I did not know

stuck scaffold
#

what should I do pepowot

quartz kindle
#

@stuck scaffold for some reason, the other shards have a different path structure, so you have to try a different path

#

try console.log(process.cwd()) both outside and inside the eval

crimson vapor
#

what is process.cwd()?

quartz kindle
#

current working directory

crimson vapor
#

oh

stuck scaffold
quartz kindle
#

is it the same in all shards?

#

also inside broadcastEval?

stuck scaffold
#

yes

crimson vapor
#

what is the structure of all of the folders?

earnest phoenix
#

And this repeats infinitely

#

Basically my error;

/rbd/pnpm-volume/11354043-98a0-45d1-a8e3-a5382aaa7f46/node_modules/.registry.npmjs.org/discord.js/12.1.1/node_modules/discord.js/src/client/Client.js:41
} catch {
^
SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:617:28)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/rbd/pnpm-volume/11354043-98a0-45d1-a8e3-a5382aaa7f46/node_modules/.registry.npmjs.org/discord.js/12.1.1/node_modules/discord.js/src/index.js:8:11)

quartz kindle
#

discord.js v12 requires node.js v12 or higher

#

update your node.js

#

if you're using glitch, set it in your package.json under engines

clever garnet
#

help plez

crimson vapor
#

you need to show more, I assume you have a ) or } in the wrong place

clever garnet
#

@crimson vapor im sending it

#

its going through

#

ok is thtoug

#

h

crimson vapor
#

up a few lines, you have an if statment?

clever garnet
#

@crimson vapor

crimson vapor
#

try changing the else () to else {}

sudden geyser
clever garnet
#

wdym

crimson vapor
#

idk

quartz kindle
#

}).catch

finite bough
#

tim u are a god

crimson vapor
#

tim is the only god

grizzled raven
#

vsc literally shows lines

quartz kindle
#

build me a temple and send me donations

grizzled raven
#

and you can see that the else doesnt match

#

tim can i be your son

quartz kindle
#

jesus is my only son (#offtopic)

grizzled raven
#

i wanted to say something relevant here but i forgot lol

balmy knoll
#

How can i get the channel id from category.children function? discord.js

opaque eagle
#

I haven't done bot dev in a while but I need to write a small bot now, and idk why this is happening.
I'm using Eris with JavaScript

import { CustomClient } from "./structures/CustomClient";
new CustomClient().connect();```
Here's how I've defined **CustomClient**: <https://gist.github.com/SinistreCyborg/96fb3af2a38d00775e06a2a6a03807ea>
#

If I attach a .then() after CustomClient.connect() and make it console.log() something, it does log it

#

but the process ends right after it connects

#
$ node -r esm main
connected!
✨ Done in 1.53s.```
#

connected! is from the .then() i tried to attach

earnest phoenix
#

How would I select just this?

#

In CSS.

heavy marsh
#

For a bot to add a role to a user, does the bot need Manager Role permission?

earnest phoenix
#

Yes, unless it has the Administrator permission.

heavy marsh
#

Oh ...

#

OK thanks

lyric mountain
#

literally .page .container

earnest phoenix
#

No, I'll show you why

#

This is all the things that are selected with .page .container

slender thistle
#

.longdescription?

earnest phoenix
#

Ignores this area.

golden condor
quartz kindle
#

@earnest phoenix you only want the parent container, not the children?

lyric mountain
#

@earnest phoenix

trim nexus
#

@trim nexus thanks man
@golden condor you're welcome

golden condor
#

:)

lyric mountain
#

always look for the class names/id in the css block below the element one

earnest phoenix
#

@quartz kindle yessir, I want to give the background an RGBA colour (I'll edit in inspect so you know what I mean)

quartz kindle
earnest phoenix
quartz kindle
#

to get only the parent container, use .page > .container

earnest phoenix
#

It didn't do anything πŸ€”

#
.page > .container {
    background-color:red;  
}

Using red as a test.

near ether
#

does anyone know where i could look up info on the way djs caches messages and other things?
i have a memory leak that i originally thought was because of my code, but it seems like its actually djs caching a ridiculous amount of data

quartz kindle
#

@earnest phoenix then .wrapper-page > .container

#

@near ether v11 or v12?

near ether
#

v12

earnest phoenix
#

Thank you @quartz kindle

quartz kindle
#

v12 stores caches in client.users.cache, client.guilds.cache client.channels.cache guild.channels.cache guild.members.cache guild.roles.cache guild.voicestates.cache and guild.presences.cache

earnest phoenix
#

Is there any way to make a collapsible header on my bot page?

near ether
#

thanks tim

quartz kindle
#

border-collapse: collapse if using divs and regular borders

near ether
#

do those caches grow infinitely?

#

or is there a cap on how many messages it will store?

quartz kindle
#

channel.messages.cache can be controlled from the client options

#

so it only grows as defined there (default being max 200 messages per channel)

#

all others grow infinitely, except guild.cache.presences, which caps at 25k i think

near ether
#

thanks so much

#

ive been trying to fix a leak for like a month now

#

and i decided to disable all commands and just let my bot run

#

it was consuming memory at the same rate

quartz kindle
#

yes thats how discord.js works

#

how many guilds?

near ether
#

around 10 or 11k i havent check in a month

#

probably 12k+ at this point

quartz kindle
#

yeah, you should probably start looking into caching solutions

#

there are two main solutions: regular cache sweeping and modifying discord.js

#

cache sweeping is easy to implement, but is not as effective and may cost quite a bit of cpu

#

modifying discord.js can be done in a variety of ways, i tried my own hand at it and released a library that does it, but it doesnt support all discord.js features, so it might not suit your use case

near ether
#

i see

#

i can definitely afford the cpu usage

#

its basically unused

#

thanks for the help tim

quartz kindle
#

yes

near ether
#

awesome

#

thanks!

earnest phoenix
#

How can I remove the white line on the side of the image?
SOLVED:

.columns .bot-img {
    box-shadow: none !important;
}
golden condor
#

tryna use mysql

#

Having trouble connecting using my cpanel db

robust moth
#

How can I make command disable code...... Any example ??

earnest phoenix
#

What do you mean? @robust moth

golden condor
#

Please help

#

I am really confused

robust moth
#

@earnest phoenix I mean

Then command run..
Otherwise command run stop```
earnest phoenix
#
let enabled = false
if(enabled) {
  // code
} else { return }
golden condor
#

How do you use mysql

#

cpanel mysql

#

pls help me out

lyric mountain
#

or you don't know how to use MySQL itself?

golden condor
#

I am tryna connect to a db using cpanel

#

I could use the guide thanks for I can't connect

nocturne grove
#

Did something about timings with certain client events change in v12? My bot acts weird now ... 😒

lyric mountain
golden condor
#

thx

#

doesn't show how to connect

#

Yes it does

#

never mind

#

thx

lyric mountain
#

lol

golden condor
#

I needed wildcard

earnest phoenix
#

What kind of database is recommended for guild chat logs?

#

Why would you store them?

modest maple
#

that is

#

a interesting breach of privacy to say the least

unique nimbus
#

Why are you storing Chat Logs

#

Is it all Chat Logs

earnest phoenix
#

Isn't that how moderating bots keep track of deleted messages?

lyric mountain
#

if you store all messages in your db your host is gonna explode

#

Isn't that how moderating bots keep track of deleted messages?
@earnest phoenix no

#

that's caching

#

you store last N messages sent in servers in an array/collection, then recover it if you need

#

but it's gone when you kill your app

earnest phoenix
#

I have so many questions rn

lyric mountain
#

and if you set the limit to be, say, 50 messages, the 51th message will become the 50th and the 1st will be uncached

earnest phoenix
#
  1. recover a deleted message?
lyric mountain
#

this kind of thing needs a message cache

#

also snipe commands

#

like the one Dank Memer have

earnest phoenix
#

Can't read the text in your screenshot

#

What is it ?

#

Oh are those embeds in a channel

lyric mountain
#

it's a "a message was deleted in X channel"

#

and it contains the message content

#

it's a mod log

earnest phoenix
#

So they store the logs in a private channel?

#

In the guild

lyric mountain
#

the bot tracks messages edited/deleted in that guild

#

each server owner can opt to enable this

#

what I'm trying to say is that if you need to get a message that was deleted you gotta make a cache

#

else you'll get a null object

quartz kindle
#

discord.js stores the last 200 messages per channel by default

earnest phoenix
#

What if a user wish to view all the deleted msg warns etc. Of a specific member?

golden condor
#

Mysqlite db keeps disconnecting

earnest phoenix
#

How would I disable the hover effect?

#

heya

#

im stuck on my website and with oauth2

lyric mountain
#

discord.js stores the last 200 messages per channel by default
@quartz kindle yeah, in my case I had to manually make a cache 😫

earnest phoenix
#

Problem: okay I have a website which is mainly built in HTML. However, I use Javascript for a different page of my website as well as CSS. In my website, I'm trying to add an Oauth2, but sadly doesn't work. It does authorise you but I'm stuck on how to make the website get to show your profile and username. 😫

finite bough
#
Math.floor(Math.random() * (max - min) ) + min;
``` should give a value between the max value and min value right?
quartz kindle
#

@earnest phoenix the problem is, you should not store user content without their permission, so in order to create a massive database of messages, you need to get their permission first, which means, the bot needs to ask the guild owners for permission to collect messages, and then the guild must ask all its users permissions to have their messages collected

#

which doesnt really work for a public bot

#

so you're stuck with caching recent messages only

finite bough
#

tim

lyric mountain
#

also very, VERY rarely you'll need to get a message older than 2-3 days

earnest phoenix
#

ok im just waiting for someone to respond to me

trim nexus
#

why do you manually cache if you rarely need messages older than 2-3 days

lyric mountain
#

I'll shorten your waiting time: post a log or code here

earnest phoenix
#

log?

trim nexus
#

@ kuuhaku

lyric mountain
#

why do you manually cache if you rarely need messages older than 2-3 days
@trim nexus I'm not using discord.js, JDA doesn't automatically cache stuff

quartz kindle
#

@earnest phoenix that is not enough information

earnest phoenix
#

ok so

#

one sec

#

@quartz kindle can i talk to you in DMs?

#

Problem: okay I have a website which is mainly built in HTML. However, I use Javascript for a different page of my website as well as CSS. In my website, I'm trying to add an Oauth2, but sadly doesn't work. It does authorise you but I'm stuck on how to make the website get to show your profile and username. 😫
@earnest phoenix
you cannot use oauth2 by using plain vanilla js, html & css

#

you need a backend server

#

wdym by backend

#

oh jesus

#

oh yes

quartz kindle
#

@earnest phoenix where does your html file come from?

#

where is it hosted?

earnest phoenix
#

glitch

quartz kindle
#

then you do have a backend

finite bough
#

can u answer my small question real quick?

quartz kindle
#

probably express.js

earnest phoenix
#

but it doesnt work python well

#

but that wont work cuz

#

repl.it isnt controlling the website

finite bough
#

cry

#
Math.floor(Math.random() * (max - min) ) + min;

should give a value between the max value and min value right?

earnest phoenix
#

i don't know i don't do js

finite bough
#

oh hmm oki

#

timmmmyyyy

quartz kindle
#

@finite bough it should

finite bough
#
else if(res.carsowned === 'RENAULT 2CV') random = Math.floor(Math.random() * 100 - 25 ) + 25

earnest phoenix
#

how would i make a backend server? and wouldnt there be an alternative?

restive furnace
#

theres server templates, but just simply log the guild object, i think it works like that

golden condor
#

mysql keeps randomly ending the connection

earnest phoenix
#

@restive furnace me?

restive furnace
#

yes

earnest phoenix
#

wait

#

can u talk to my friend, he knows more coding

#

he isnt in this server cuz hes baned

golden condor
#

mysql keeps randomly ending the connection
I am tryna set it up and it's really annoying

restive furnace
#

i really cant right now help, sorry.. try google something "make clone of a server d.js" or something

earnest phoenix
#

d.js?

mossy vine
#

@earnest phoenix damn thanks for posting that link its a great guide

golden condor
#

You can map all the channels

earnest phoenix
#

why would i clone..- im so confused

restive furnace
#

discord.js or what ever you're using, oopsie i forgot that theres more than only discord.js, change "d.js" to your library

earnest phoenix
#

im making a website, not a bot

#

yeah cyber it came up on my explore page and i bookmarked it cause i thought it's really useful

golden condor
#

Tryna use mysql db and it keeps randomly terminating the connection

trim nexus
#

is it successfully connecting in the first place?

lyric mountain
#

mysql keeps randomly ending the connection
@golden condor use a pooling library to keep the connection active

#

mysql kills the connection after 11400 seconds

#

iirc

quartz kindle
#

@earnest phoenix that roadmap makes me feel like a noob

#

lmao

golden condor
#

@lyric mountain how

lyric mountain
#

use a pooling library

golden condor
#

which is

lyric mountain
#

for java we have c3p0

#

for javascript idk

quartz kindle
#

there should many many for js

#

@golden condor which mysql library are you using?

golden condor
#

mysql

lyric mountain
#

may I ask u

#

why do you have the password, IP and login in your code?

golden condor
#

I am just testing it

#

I will keep it inside a seperate file

#

I am tryna setip atm

lyric mountain
#

ah, sure then

quartz kindle
#

there's a huge list of libraries that offer pooling and connection management for the mysql library

golden condor
#

Ok

#

How do I use

quartz kindle
#

just pick one, and look at their docs

golden condor
#

Or do I just install it

earnest phoenix
#

mysql or mongo?

quartz kindle
#

whatever you prefer

golden condor
#

I could use either

#

But mongo seems easier

#

But I also dunno how to use that

#

And mysql comes with my cpanel

slow cape
#
let msg = await message.channel.send("Generating...");  
    let tar = message.mentions.users.first();
    let user = tar
    if (!tar) tar = message.author
    let profilepic = tar.avatarURL;
    let url = `https://eclyssia-api.tk/api/v1/triggered?url=${profilepic}`;

    fetch(url, {
        headers: {
          
        }
    }).then(async res => {
        await message.channel.send({
           files: [{
               attachment: res.body,
               name: `${tar.tag}-triggered.gif`
           }]
        }).then(() => message.channel.stopTyping());
    }).catch(e => console.error(e));
    msg.delete();

#

it justs seding a link to nothing

#

Hm

wheat jolt
#

so I have an array with some chunks
[{pos: 0, size: 4, url: 'someurl'}, {pos: 4, size: 7, url: 'someurl'}, {pos: 11, size: 5, url: 'someurl'}, {pos: 16, size: 10, url: 'someurl'}, {pos: 26, size: 9, url: 'someurl'}, {pos: 35, size: 15, url: 'someurl'}]
What function can I use for .filter to get the chunks needed to get the bytes from pos 15 to pos 30?

lyric mountain
#

Hm
@slow cape check whether that file is a valid image file

#

so I have an array with some chunks
[{pos: 0, size: 4, url: 'someurl'}, {pos: 4, size: 7, url: 'someurl'}, {pos: 11, size: 5, url: 'someurl'}, {pos: 16, size: 10, url: 'someurl'}, {pos: 26, size: 9, url: 'someurl'}, {pos: 35, size: 15, url: 'someurl'}]
What function can I use for .filter to get the chunks needed to get the bytes from pos 15 to pos 30?
@wheat jolt .filter(entry => entry.pos >= 15 && entry.pos <= 30)

blazing portal
#

Is there a way in Discord.js v12 to check if the bot has the power to assign a role to a user? Or do i have to get that info based on the positions of the role?

lyric mountain
#

Is there a way in Discord.js v12 to check if the bot has the power to assign a role to a user? Or do i have to get that info based on the positions of the role?
@blazing portal check whether the bot has MANAGE_ROLES permission

blazing portal
#

that's all? doesn't it have to be below the bot user role too or smth?

lyric mountain
#

yes, that too

blazing portal
#

ok, thanks πŸ™‚

wheat jolt
#

thanks @lyric mountain

leaden rover
#

Is it prohibited to use Heroku for adding the bot? What if I'm offline for a moment, and I can't keep up my bot(s)?

lyric mountain
#

Is it prohibited to use Heroku for adding the bot? What if I'm offline for a moment, and I can't keep up my bot(s)?
@leaden rover with heroku you can keep your bot 20/7 without reaching the quota

leaden rover
#

Ok

lyric mountain
#

BUT

#

you gotta try to reach 24/7

leaden rover
#

Ok

lyric mountain
#

so either register a credit card to get extended quota or buy a vps

leaden rover
#

vps?

lyric mountain
#

virtual private server

leaden rover
#

Ok

#

Is that paid?

unique nimbus
#

a VPS is the best way to host a bot and others

lyric mountain
#

obviously

unique nimbus
#

VPS is paid

leaden rover
#

Ok

lyric mountain
#

but cheap tho

unique nimbus
#

However has better specs

#

and security

leaden rover
#

Looks like I have to wait until I'm a fully fledged dev. and get into College xD

#

Sorry for being off-topic

unique nimbus
#

A lot of people here is 14-16 and has a VPS

#

or use Heroku/Glitch

leaden rover
#

I'm 14

lyric mountain
#

you......really said your age didn't u?

unique nimbus
#

It doesn't really matter much how old you are unless you are under 13

lyric mountain
#

ik

earnest phoenix
#

I have a VPS and not 18 lol

#

anyone can do it

unique nimbus
#

I have a VPS and not 18

lyric mountain
#

again, ik

leaden rover
#

Ok

#

At least I saved $1337 xD

#

Not really

earnest phoenix
#

ok

leaden rover
#

Yes...

gentle arch
#

Pls

#

Help me

lyric mountain
#

-ask2ask

#

tonkku lemme do it!

#

lol

#

don't ask for help, just say your issue

spare goblet
#

-ask2ask

gilded plankBOT
#

Don't ask to ask.
Just ask your question, it wastes time if you say "i need help" or "can someone help me?" instead of just saying what the problem is. Save your time and other people's time and just ask the question.

Please read https://dontasktoask.com/ for an explanation on why this is an issue.

gentle arch
#

What write in HTML when add bot in top.gg

spare goblet
#

Your bot info

gentle arch
#

Pls example

#

In dm

#

I don't understand

spare goblet
#

Put your bots command list

#

Or your bots features

gentle arch
#

Ohhh

lyric mountain
#
Hi, I'm bot blablabla, and I do nice things in your server.
My features involve....blablabla...
etc
etc
etc
#

just describe your bot

gentle arch
#

TUB use??

spare goblet
#

What

gentle arch
#

I'm bot

#

Tub. < ----

lyric mountain
#

just talk about your bot

gentle arch
#

Sorry

#

Space

#

Use??

#

@spare goblet

#

Space use??

sudden geyser
#

You write about your bot in the long description. 300 characters minimum. It's not difficult.

gentle arch
#

Space can use??

sudden geyser
#

What

earnest phoenix
#

should this not return false (js)
Number.isInteger(parseInt("2.1")) ?
i want the exact behaviour of isInteger but my var is a string like "2"(expect to be true) or "2.1" (expect to be false)

spare goblet
#

Can you not tag me
Also idk

gentle arch
#

Okey

#

I can use space?

spare goblet
#

@earnest phoenix you can just use isNaN(parseInt(value))

#

What space

sudden geyser
#

parseInt("2.1") becomes 2

lyric mountain
#

I can use space?
@gentle arch you can use any kind of digit

earnest phoenix
#

oh i see

#

but why does isNan work then?

spare goblet
#

Check if it's NaN

#

You're trying to check if it's a number, right (?)

earnest phoenix
#

does it return true on "2.1" ?

spare goblet
#

It returns false.

gentle arch
#

Russian here??

spare goblet
#

@gentle arch message shivaco#0001 , they know Russian.

earnest phoenix
#

but "2.1" becomes 2 when run through parseInt?

gentle arch
#

Thanks

spare goblet
#

Yes.

#

Just do Number("2.1") if you need it to be a 2.1

sudden geyser
#

You can also use parseFloat

earnest phoenix
#

hmm okay, just to be clear i want a function that returns false on "2.1" and true on for example "2"

sudden geyser
#

But Number.isInteger(2.1) returns false

earnest phoenix
#

so number.isInterger(parseFloat(var)) ?

#

does parseFloat make "2" into 2.0 ?

spare goblet
#

Okay then do Number.isInteger(Number(value))

gentle arch
#

He is don't answer me((

earnest phoenix
#

okay that seems like what i am looking for

queen needle
#
bot.on("message", message => {
  let args = message.content.substring(PREFIX.length).split(" ");
let bal = coins[message.author.id].coins;
  switch (args[0]) {
    case "give":
      
      coins[args[2]] = {
      coins: coins[args[2]].coins + args[1]
    }; 
      
      if(args[1] > bal){
message.channel.send("You are trying to give more then you have")
      }
      
      
      
      message.channel.send(message.author + ' gave' + args[2] + args[1] + 'coins')
      
       fs.writeFile("./coins.json", JSON.stringify(coins), err => {
      if (err) console.error(err);
    });
      
      break;
  }
});``` could anyone help me with my give command it doesn't work
sudden geyser
#

do you get an error

spare goblet
#

@gentle arch be patient

sudden geyser
#

Cinnamon role, you should safeguard your code. What is each argument supposed to be (args[1] = user? args[2] = coin give amount?)

Also, you should avoid using JSON as a database.

turbid bough
#

thats what i did! it was fun

#

(not really)

sudden geyser
#

until it breaks owoAngryBaguette

finite bough
#

json db best

lyric mountain
#

you either brake or break

turbid bough
#

you know how big json db if you are going to store user data

finite bough
#

worst case scenario all memory gone

turbid bough
#

where can you store bot information that only requires one row of the table, on a database?

#

instead of a table

#

or do you have to have a table?

lyric mountain
#

in a table

#

a table is just an entity in the database

#

like, you can't have characteristics floating around without an entity

#

you need a body to have eyes

turbid bough
gentle arch
#

Sorry

queen needle
#

yeah args 1 should be the person and args 2 should be the amount of coins

sudden geyser
#

But you're doing this in your code: js coins[args[2]] = { coins: coins[args[2]].coins + args[1] };
Should it not be args[1] as the user? How are you going to safeguard your code to make sure args[1] is an existing user ID? Why are you adding the user to the coin count?

indigo folio
#

@queen needle have you thought about using sqlite rather than json?

#

if you're storing on drive anyway

queen needle
#

for right now im using json

#

but if i can figure out how to use sqlite on another bot and get it to work ill switch to that

indigo folio
#

there's a node module called enmap you can use. it uses 2 main functions, enmap.get() and enmap.set(). its very simple

queen needle
#

but it should check to see the args1 the coins how much that is and args2 the user then it should see if i have enough coins if i do then subtract that amount from my coins and gadd it to the other users coins amount and send a message saying that

#

ill try on my other bot

indigo folio
#

as for your issue with your code

#
coins[args[2]] = {
  coins: coins[args[2]].coins + args[1]
};
#

i can't figure out what is happening here

queen needle
#

neither can i

#

i just took a piece of code from another command hoping it woulf work

indigo folio
#

but another thing i would suggest doing, args[2] is a number count, yes?

queen needle
#

what?

#

args 2 is the user

indigo folio
#

my bad, i meant 1

sudden geyser
#

but if i can figure out how to use sqlite on another bot and get it to work ill switch to that
You could even use an ORM like Sequelize to make working with databases easier.

indigo folio
#

i would suggest parsing args[1] as an int

queen needle
#

args1 is the coin amount yes

#

how

#

?

indigo folio
#

parseInt(args[1])

#

will return an integer if args[1] is a number, or NaN if it is a string

#

to make sure people don't pass in an argument that isn't a number

#

but i do not think i can help with your main problem with the command

queen needle
#

like ^give fish or something

indigo folio
#

yeah

queen needle
#

ill follow a coin system video on enmap

#

and if it works ill switch that to my main bot

indigo folio
#

if you'd like, i can make an example of the command you're trying to make using enmap

queen needle
#

sure

earnest phoenix
#

@indigo folio
Saw what you wrote
Just wanted to say that using (Number(args[1])) will also work

#

ParseInt will too so just use your way

#

how do you delete an object in a json file using fs. ?
my current approach is to load the json file into a var, delete the objects inside that var, then replace the json file with the var

but perhaps there is a method to delete an object directly?

turbid bough
#

you want to replace the whole json file with an another object?

#

or a part of the json file?

earnest phoenix
#

no, just delete an object in the json file, which consist of several objects

turbid bough
#

javascript right?

earnest phoenix
#

so i guess delete part of the json file, and yes node.js

turbid bough
#

uh, you dont need to "delete a part" of the json file

#

if you are actually deleting text

#

you could probably try to assign undefined to that variable when you turn it into a json object

#

not sure how converting it back to json text will appear as

#

or you could override the variable

#

using JSON.parse() and JSON.stringify()

queen needle
#

@indigo folio if i wanted to edit the coins myself would i be able too

slow cape
#

@lyric mountain how do I check if it’s a valid image

earnest phoenix
#

What arw you trying to do @queen needle

lyric hawk
#

await server.create_role(name="Name", permissions=discord.Permissions(manage_guild=True), reason="Reason") < Hey, I don't understand how to create a permissions object to feed create_role() in discord.py, it returns unexpected keyword

indigo folio
#

@queen needle there is an sqlite browser for windows, so yes

#

you mean change the counts in the file, right?

#

you can also create commands to modify counts as well

turbid bough
#

you could try downloading the image and check the file headers if its an image.

#

not sure what exactly "valid image" is

queen needle
#

yes like if i wanted to change the amount of coins i had

earnest phoenix
#

Hi

#

Help me pls

#

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! canvas@2.6.1 install: node-pre-gyp install --fallback-to-build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the canvas@2.6.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Aspectra\AppData\Roaming\npm-cache_logs\2020-04-15T20_35_18_924Z-debug.log

#

Δ° download canvas modules

#

And error

finite bough
#

install node gyp 1st

earnest phoenix
#

How

#

Pnpm install node gyp?

quartz kindle
#

@earnest phoenix the actual reason for the error is logged before that part

wise quartz
#

How to add a cooldown to a command?
(Ping on response)

#

Nvm found if

earnest phoenix
#

Alright so my user need to select a server , and the server will be listed as reaction from
0️⃣ to πŸ”Ÿ in reaction
For reaction 0 id 0000001
For reaction 1 id 77777777
For reaction 3 id 85858585

#

Does anyone have a trick ? Couldn't find any good way to do that

#

on node, try setTimeout(function(){if(msg.content == "bla bla bla)}, length)

#

@wise quartz

quartz kindle
#

he said he already found it lol

wise quartz
#

Its okay i found it also its python

earnest phoenix
#

ok

wise quartz
#

πŸ˜‚

#

Ty tho

quartz kindle
#

@earnest phoenix reactionCollector or awaitReactions

earnest phoenix
#

I know about reactionCollector

#

but like how to connect Reaction1 to SERVERID1
Reaction2 to SERVERID2

quartz kindle
#

you need to code that yourself

#

if(reaction === 1) { id1 } else if(...) ...

earnest phoenix
#

ik that but i don't have any idea so im asking for some informations, someone talked to me about discordjs server mapping

#

Yeah and how can i know that id1 is reaction 1 ?

quartz kindle
#

because you code it to be id1

earnest phoenix
#

How am i suposed ? I don't know how much servers the user will have

#

I don't know if the user have 12 servers or two

wise quartz
#

What language?

earnest phoenix
#

NodeJS

quartz kindle
#

what servers?

wise quartz
#

Yeah cant help u

earnest phoenix
#

Bot servers

quartz kindle
#

so you dont want to show a predefined list? what do you want to show?

earnest phoenix
#

Its hard to explain

static trench
earnest phoenix
#

The user do

#

Serverlist

#

and then for each server

wise quartz
#

You want to see how many servers every user of your bot has?

earnest phoenix
#

reaction1 for a server

#

reaction2 for another

#

when he react i select the server related to the reaction but, how to define by advance because it won't be the same server every time

quartz kindle
#

then you need to scan your guilds for this person

wise quartz
#

@static trench await message.add_reaction('emoji uni code')
Define your await with message

static trench
#

Thy

#

Thx

wise quartz
#

Hope it works lol

quartz kindle
#

let guildsThisPersonHas = client.guilds.cache.filter(guild => guild.members.cache.has(userID)).map(guild => guild.id)

#

this will give you a list like this [id1,id2,id3,id4] etc

#

then you can do if(reaction === 1) { guildsThisPersonHas[0] }

earnest phoenix
#

Ahhh i see !

#

There we Go

lyric mountain
#

@lyric mountain how do I check if it’s a valid image
@slow cape download the file and try to open it

#

If it doesn't open then it's likely being messed somewhere in your code

crimson vapor
#

I mean its abuse but if you are on d.js 11 it would work similar to that

earnest phoenix
#

Why if message content?

#

Are you trying that if the user is banned it will unban him once theres a message?

visual sandal
#

How can I make the text not get pushed to the left... it's been annoying me for a while

crimson vapor
#

what do you mean by that?

visual sandal
#

like. how can i make it so there are only 2 fields per line so it's not so pushed together
or make the embed bigger to fit the data better

turbid bough
#

inline = false

#

will make the field go to the other row

#

then the ones you want to be in the same row, inline = true

visual sandal
#

but wouldn't that make the entire row for 1 field.. is there not a way to have only 2 fields per row

turbid bough
#

well, you can do that

#

you just swap between

#

inline = false, for the first one

#

inline = true, for the second one

#

then inline = false for the third one which will be a new row

#

i think

#

then continue

visual sandal
#

hmm, lemme try

turbid bough
#

but since you have alot of information, you might want to combine some of the fields

visual sandal