#development

1 messages · Page 913 of 1

white anvil
#

ok my only guess is that ur token is invalid

#

¯_(ツ)_/¯

#

if ready isnt firing

high geode
#

bro

#

he doesnt send

#

the log message

white anvil
#

yeah because ready isnt firing...

#

which is caused by invalid token in majority of cases

high geode
#

imposible

#

they arent errors

#

wth

#

and token is corect

#

trust me

white anvil
#

does anything get logged when you run this code

high geode
#

since i changed this

hasty sparrow
#

Shouldn't it be bot.login?

high geode
#

bot.on('ready', () => {
// put code here
})

#

since i changed this

#

the bot

white anvil
#

oh probably

high geode
#

doesnt works

#

..

white anvil
#

u have a mismatch

high geode
#

no

#

wait

white anvil
#

u have bot.on and client.login

#

they reference different things

high geode
#

i deleted your thing

white anvil
#

whats the name of ur bot client

high geode
#

NOW IT WORKS

#

...

#

is because this is wrong

#

bot.on('ready', () => {
// put code here
})

white anvil
#

change it to client.on

#

instead of bot.on

high geode
#

i know

frail ocean
#

This is why you shouldn't have client and bot both defined, like I said earlier.

high geode
#

but it works

#

then i must write

#

bot.login

earnest phoenix
#
.addField("Invite me!", `Your text here: [invite](generate)`)```
high geode
#

not client.login

#

the token was valid

#

🤦‍♂️

white anvil
#

bruh do u define client anywhere

#

ur code is so confusing

earnest phoenix
#

i added this field but its not working, the link might be invaild but its a discord invite link

high geode
#

TypeError: Cannot read property 'channels' of undefined

#

what error is this

earnest phoenix
#

https://discord.com/oauth2/authorize?client_id=${client.user.id}&scope=bot&permissions=392192

high geode
#

......

#

TypeError: Cannot read property 'channels' of undefined

white anvil
#

is this inside the ready

high geode
#

WHAT THE HELL

#

yes

frail ocean
high geode
#

wait

#

bot.guilds.get("700671859800408105").channels.get("707662830081540178").send('a votat voxility')
^
TypeError: Cannot read property 'channels' of undefined

frail ocean
#

Line 2 and 4, both defined

hasty sparrow
#

Why 2 clients!?

high geode
#

this is my code

#

and client.login

frail ocean
#

https://discord.com/oauth2/authorize?client_id=${client.user.id}&scope=bot&permissions=392192
@earnest phoenix What does it send as? Any errors?

high geode
#

under it

white anvil
#

..

#

u need

#

well idk what u need i dont use discord.js

#

i assume u need bot.login and bot.on in this instance

hasty sparrow
#

Create one client, log in and listen to the ready event

white anvil
#

not client

high geode
#

wait

frail ocean
#

You shouldn't have client and bot, choose one or the other, else it gets confusing.

high geode
#

WAIT

#

IT WORKED

white anvil
#

yeah client is useless here

high geode
#

but another error

#

bot.user.tag

#

wait

#

what

#

wait

frail ocean
#

bot.user.tag (again why you shouldn't have both)

earnest phoenix
#

its ok i fixed it

white anvil
#

just delete ur client variable altogether

#

its not even doing anything?

hasty sparrow
#

Lots of bad copypasting

white anvil
#

tru

high geode
#

wait

#

IT WORKS

#

YAYY

#

can someone vote pls?

#

i need to test

white anvil
#

u can vote

high geode
#

i areleady

#

voted

earnest phoenix
#

@high geode use the test vote function

high geode
#

where is that

#

what {vote.user.tag

#

is

#

vote.user = id

#

i need really#0001

#

the tag

#

vote.tag

#

?

earnest phoenix
#

well, you're screwed then, wait for 12 hours

#

we arent your vote guinea pigs

high geode
#

thanks for help

#

😉

#

=)))

#

@frail ocean

#

i did it

#

but what is the user tag

#

function

#

vote.user.tag is the id

#

how can i do it to show really#0001

#

?

frail ocean
#
let user = client.users.get(vote.user)
let tag = user.tag```
#

Since vote.user is the id

high geode
#

vote

#

is not defined

#

i dont want the id

#

bro

#

i want the tag

#

really#0001

frail ocean
#
let user = client.users.get(vote.user)
let tag = user.tag```
high geode
#

vote

#

is

#

not

#

defined

#

error

frail ocean
sacred mountain
#

Hi. I made a function at the bottom of my code but I’m trying to add something that mentions guild but when I run it, it just says guild is not defined. I’m not sure how to define it because I thought it is just part of discord.js

earnest phoenix
sacred mountain
#

Sure

#

One sec

#

                const channelChannelID = guild.channels.find(channel => channel.name === collected.last().content)

                message.channel.send(channelChannelID)
#

it says guild isnt defined

frail ocean
#

Define guild.

sacred mountain
#

how tho

summer torrent
#

then define it

#

show full code

frail ocean
#
let guild = message.guild```

or smth, depends how you've done it.
sacred mountain
#

no bc its like hundreds of lines long

#

oh

#

ok

#

guild.channels.find is not a function

#

RIP

#

now what do i do

#

im just trying to get it to check if the specified channel is in the guild

quartz kindle
#

discord.js v12?

sacred mountain
#

yh

quartz kindle
#

channels.cache.find

sacred mountain
#

oh

#

DiscordAPIError: Cannot send an empty message its not an empty message...

frail ocean
#

console.log

to check.

summer torrent
#

channelChannelID is a collection

quartz kindle
#

it didnt find any channel

sacred mountain
#

umm

#

but the channel is in the guild

#
                const channelChannelID = guild.channels.cache.find(channel => channel.name === collected.last().content)

                message.channel.send(channelChannelID)``` is this definitely correct for checking if its in the guild then sending back the id
#

well all i really want it to do is send a message to that channel

quartz kindle
#

console.log(channelChannelID)

sacred mountain
#

k

#

undefined

quartz kindle
#

exactly

sacred mountain
#

why tho

quartz kindle
#

that means the channel was not found

sacred mountain
#

but its in the guild

quartz kindle
#

so double check your find parameters

#

for example, console.log(collected.last().content)

earnest phoenix
#

My code. I was using Glitch.com as host

const DBL = require('dblapi.js');
const dbl = new DBL(process.env.TOP_GG, { webhookPort: process.env.PORT });
dbl.webhook.on('ready', hook => {
  console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
  console.log(`User with ID ${vote.user} just voted!`);
});

This is not working

quartz kindle
#

you dont need port 3000 in the url

earnest phoenix
#

oh

quartz kindle
#

just .me/dblwebhook

earnest phoenix
#

Still nothing happens

#

wait

#

IT WORKS

#

Ty

#

*its too late to work

sacred mountain
#

@quartz kindle i put js console.log(collected.last().content) console.log(channelChannelID) and it logs the channel id but then undefined

quartz kindle
#

collected.last().content is the channel id?

earnest phoenix
sacred mountain
#

apparently so...

quartz kindle
sacred mountain
#

idk why it is the id tho

#

shouldnt it be what i typed?

quartz kindle
#

what did you type?

sacred mountain
#

#spam

#

which is a legit channel

quartz kindle
#

@earnest phoenix check #mod-logs for your bot's ID, it might have been kicked

#

@sacred mountain thats a channel mention

#

it will show up in the message content as [#895739845793845](/guild/264445053596991498/channel/895739845793845/)

sacred mountain
#

yh

#

so now if i wanted to send a message in that channel what would i do

quartz kindle
#

so your find function is doing if channel.name === [#384598375305](/guild/264445053596991498/channel/384598375305/)

earnest phoenix
#

@quartz kindle I fixed how to add back

quartz kindle
#

@earnest phoenix dm the mod who kicked it

earnest phoenix
#

ok

sacred mountain
#

Tim how do I send a message to that channel now

#

So like store it in quick.db then later send a message to it

quartz kindle
#

you can use message.mentions.channels

sacred mountain
#

ok

quartz kindle
#

the same way you use message.mentions.users or .members

sacred mountain
#

Ohh

#

So if I stored it by doing db.set(key, message.mentions.channels) then how would I later send a message to that channel

#

@quartz kindle Would I do ```
Const thechannel = dB.fetch(key)

Message.thechannel.send(“test”)

quartz kindle
#

no and no

sacred mountain
#

Oh

quartz kindle
#

did you ever use message.mentions before?

sacred mountain
#

What do you mean?

#

In the function or ever

quartz kindle
#

ever

sacred mountain
#

Oh

#

Yes

quartz kindle
#

then you know how to use it

sacred mountain
#

Not in that way no

quartz kindle
#

channel mentions work the same as user mentions or member mentions

sacred mountain
#

Ik

quartz kindle
#

how did you use user or member mentions before?

sacred mountain
#

Can’t remember

#

Something on one of my first bots

quartz kindle
#

dont you have any code that uses them?

sacred mountain
#

Idk it would take a while to find it but I didn’t use it sending a message to it

#

Wait

#

I might have

#

One sec

#

Yup

#

Found it

quartz kindle
#

so you'll notice you cannot use message.mentions.channels directly

#

because it contains a list of mentions, not a single channel

sacred mountain
#

Yh

quartz kindle
#

so you should know what to do

sacred mountain
#

Yh

#

I’ve got it now

quartz kindle
#

now, you cannot store an entire channel in a database

zenith terrace
#

Why the capppsss

quartz kindle
#

because a channel is a complex structure that only works inside the program's memory, it cannot be transferred to a database or any other program

#

so you need to save only the channel id in the database

neat ingot
#

where there is a will, there is a way! 😛

#

but wouldnt that be against tos anyway??

high geode
#

what's the problem?

neat ingot
#

user is undefined, cannot read 'tag' from undefined.

high geode
#

so

#

i want to announce

#

the vote for my bot

hasty sparrow
#

Maybe the user isn't cached yet

high geode
#

but I want my name

#

or the user name before

#

i use "discord.js": "^11.4.2",

#

any ideas to fix?

neat ingot
#

isnt it only a member who has 'tag', not user?

#

like, isnt 'tag' exclusive to a member>?

high geode
#

idk

#

i didnt wrote tgat

#

@frail ocean wrote

neat ingot
high geode
#
let user = client.users.get(vote.user)
let tag = user.tag```
#

he wrote it

neat ingot
#

ahh ok lol

high geode
#

do you have any ideas

#

how can I do

#

to show the name

#

before the vote

#

like

#

really#0001 voted voxility

hasty sparrow
#

@earnest phoenix Get the guild count and update the bot's status

neat ingot
#

oh, seems users has the tag, not members. lol

#

my bad 😄

high geode
#

so

#

what must i do to make it work?

hasty sparrow
#

What library are you using?

high geode
#

me?

hasty sparrow
#

No, Genesiz

frail ocean
#

@high geode this is basic stuff...

.send(tag+" message here")

hasty sparrow
#

v11 or v12?

high geode
#

@high geode this is basic stuff...

.send(tag+" message here")
@frail ocean i need when someone votes

zenith terrace
#

message.mentions.channels.first().id I believe it was

high geode
#

hmm lemme test

frail ocean
#

@high geode I said what you needed earlier, multiple times.

high geode
#

wth

#

and if I use

#
let user = client.users.get(vote.user)
let tag = user.tag```
#

let tag = user.tag
^
TypeError: Cannot read property 'tag' of undefined

#

what the hell

hasty sparrow
frail ocean
mossy vine
#

let is scoped so you are defining tag outside of the scope

#

im not really sure if that belongs in api as its just a code error

#

but ok

lusty quest
#

is it possible to get the message ID of an embed you send in a command? want to store the message id for editing the embed later

hasty sparrow
#

Tag isn't defined anywhere, stop just copypasting code without giving it the slightest thought

quartz kindle
#

@high geode you are mixing client and bot

zenith terrace
#

I mean you could of just used the code it shown instead of adding the let user things

console.log(`User with ID ${vote.user} just voted!`); });

But just make it look for a channel instead of console and change it from vote.user to vote.user.tag

hasty sparrow
#

@lusty quest .send() returns a promise that resolves to the message object

lusty quest
#

thx

tight plinth
neat ingot
#

v12? @tight plinth

tight plinth
#

yes

neat ingot
#

perhaps the cache doesnt have the user data or something? not sure on that one dude sry 😦

tight plinth
#

f

cinder patio
#

Then it'd be cannot read property fetchFlags of undefined, wouldn't it?

neat ingot
#

yea it should be if that was the case

tight plinth
#

I tried with message.author.fetchFlags(), same error

neat ingot
#

oooohhh

#

it seems v12 didnt have fetchFlags but 'stable' does, according to docs

#

are you sure your on latest v12?

sacred mountain
#

Im very confused. js let thechannel = newMessage.mentions.channels.first() if(!thechannel) return message.channel.send(`Either I could not find the channel specified in this server or you did not specify one`) returns that it cant find it even though i provided one

cinder patio
#

I think it's worth asking in the discord.js server cause it may be a bug

tight plinth
#

no im not

#

in in v12.0.0

#

lemme try to upgrade...

neat ingot
#

yea, lemme know if that sorts it 🙂

#

not that ik what to do if it doesnt...

#

lol

zenith terrace
#

message.mentions.channels.first().id I believe it was
@zenith terrace @sacred mountain

tight plinth
#

or wait lemme see

sacred mountain
#

I tried that

#

Cannot read property Id of undefined

zenith terrace
#

Wait what are you trying to do

tight plinth
#

ye im in 12.0.0

zenith terrace
#

As in command

sacred mountain
#

Me?

#

...

quartz kindle
#

fetchFlags was added after v12 become stable afaik

#

so it should be added in v12.1 or something

tight plinth
#

my bot wuld not work in discordjs v12.1, but apparnetly now it does in v12.2

#

thx u guys

zenith terrace
#

when I havent updated my v12 code yet

sacred mountain
#
                console.log(collected.last().content)
                let newMessage = collected.last().content
                
                let thechannel = newMessage.mentions.channels.first()
                if(!thechannel) return message.channel.send(`Either I could not find the channel specified in this server or you did not specify one`)
                db.set(`thechannel_${message.guild.id}`, thechannel)``` the console then shows ``` [#691631449115459679](/guild/264445053596991498/channel/691631449115459679/)
ReferenceError: mentions is not defined
    at C:\...\index.js:178:40
    at processTicksAndRejections (internal/process/task_queues.js:93:5)``` does anyone know how i can fix this?
neat ingot
#

[#691631449115459679](/guild/264445053596991498/channel/691631449115459679/) is the id of the collected message?

sacred mountain
#

no the channel i mentioned in the message

#

sorry i forgot to explain that

#

but that is a mention

#

so why does it say mentions is not defined

quartz kindle
#

you're trying to get mentions from the content

neat ingot
#

no idea dude, maybe collecting messages doesnt return a full message body or something?

quartz kindle
#

you're doing message.content.mentions

#

its just message.mentions

sacred mountain
#

oh

neat ingot
#

ooooohhhh

#

aha, brain fart 😄

earnest phoenix
#
const Discord = require("discord.js");
let coins = require("../coins.json");
const fs = require("fs");

module.exports.run = async (bot, message, args) => {
    if(!coins[message.author.id]){
        return message.channel.send(":no_entry_sign: **Nu ai nicio moneda!**")
      }
    
    let pUser = message.guild.member(message.mentions.users.first()) || message.guild.members.get(args[0]);
    
    if(!coins[pUser.id]){
      coins[pUser.id] = {
        coins: 0
      };
    }
    
    let pCoins = coins[pUser.id].coins;
    let sCoins = coins[message.author.id].coins;
    
    if(sCoins < args[0]) return message.reply(":no_entry_sign: **Nu ai destule monede!**");
    
    coins[message.author.id] = {
      coins: sCoins - parseInt(args[1])
    };
    
    coins[pUser.id] = {
      coins: pCoins + parseInt(args[1])
    };
    
    message.channel.send(`> :white_check_mark: ${message.author} **i-ai oferit lui** ${pUser} ${args[1]} **monede!**`);
    
    fs.writeFile("../coins.json", JSON.stringify(coins), (err) => {
      if(err) console.log(err)
    });
}

module.exports.help = {
    name: "pay",
    usage: "lt!pay [mention] [suma]"
}

Why if i have 0 coins i can lt!pay me how much i want ?

pale vessel
#

is that a json database

#

yes it is

sacred mountain
#

@quartz kindle @neat ingot i have another problem now js db.set(`thechannel_${message.guild.id}`, thechannel) ... .setDescription(`test channel has been set to ${db.fetch(`thechannel_${message.guild.id}`)}`) returns test channel has been set to [object Object]

neat ingot
#

because your returning the database object i think?

quartz kindle
#

i told you, you cant save the entire channel

#

you have to save only the id

tight plinth
sacred mountain
#

yes but how do i do that

tight plinth
quartz kindle
neat ingot
quartz kindle
#

yes

#

@tight plinth you can do flags.serialize()

tight plinth
#

oh

neat ingot
#

what do the flags flag?

#

like, what are they flagging?

quartz kindle
#

the badges/perks the user has

neat ingot
#

oohh, like nitro etc?

quartz kindle
#

not nitro

#

just those in the FLAGS list

neat ingot
#

consults flags list

quartz kindle
#

its right there in the picture above

neat ingot
#

oha aha

#

never noticed 😄

#

those bughunting flags sound fun 😄

small prairie
#

Tim, You like a clean profile?
you got no badges

junior bobcat
#

Hello, I though (and I read) that a bot can send emojis of a server in other servers it belongs to.
But mine doesn't do it :/ why ?

fast bane
#

what i should make when my bot is invited in DBL server?

zenith terrace
#

You need the emoji ID

earnest phoenix
#

Sooo, can anyone help me or?

junior bobcat
neat ingot
#

send the : id :

#

not the : name :

#

eg: :707892384960348210:

junior bobcat
zenith terrace
#

<:emojiname:emojiID>

junior bobcat
#

oh maybe yes I'll try this

neat ingot
#

oh yea it might be that format

#

cant you just send the raw emoji?

#

thats the only thing i do with emoji - get a list of custom and print

zenith terrace
#

e.g.: ![owner](https://cdn.discordapp.com/emojis/585789630800986114.webp?size=128 "owner")683047469420249176>

<owner683047469420249176>

#

Oop

#

Dont work on users lol

quartz kindle
#

@small prairie idk never felt like doing whatever weird shit you need to do to get them

#

i dont understand the houses thing either lmao

small prairie
#

Lel

#

its literally 2 secstest

#

i want bug hunter badge

junior bobcat
small prairie
#

thats the format

#

wait are u console logging?

#

or sending it in a channel

sacred mountain
#
                let newMessage = collected.last()

                let thechannel = newMessage.mentions.channels.first()

                db.set(`thechannel_${message.guild.id}`, thechannel.id)``` how would i now take .id off the end of it because im trying to send a message to that channel but it doesnt work as thechannel.id, i need to change it into thechannel but im not sure how to do that
junior bobcat
#

sending it in a channel @small prairie

small prairie
quartz kindle
#

@sacred mountain you need to get the channel from the id you have in the database

sacred mountain
#

how do i do that tho

quartz kindle
#

channelID = db.get(whatever)
channel = client.channels.cache.get(channelID)

#

of you're using v12

junior bobcat
#

@small prairie what <:discordbotlist:id> = <:servername:emojiId> ?

tight plinth
#

does anyone have a "shiny BH badge" emoji?

small prairie
#

Ignore that

#

was just checking somehting

hardy vector
#
if (message.content === "=work") {
    let timeoutworked = 36000000
    let worked = await db.fetch(`worked_${message.author.id}`);
    console.log(worked)
    
        if (worked !== null && worked - (Date.now() - worked) > 0) {
        let time = ms(timeoutworked - (Date.now() - worked));
        console.log(time)
        message.channel.send(`You already worked, you can come back and work in **${time.hours}h ${time.minutes}m ${time.seconds}s**!`)
    } else {
    let amountearned = Math.floor(Math.random() * 500) + 1
    let jobs = ["Scientist", "Developer", "Streamer", "Youtuber", "Cashier", "Shopkeeper", "Investor", "Engineer", "Biologist", "Astronomer"]
    let jobworked = jobs[Math.floor(Math.random()*jobs.length)]

    let embed = new Discord.MessageEmbed()
    .setAuthor(`${message.author.tag}, it payed off!`, message.author.displayAvatarURL())
    .setDescription(`${message.author}, You worked as a ${jobworked} and earnt ${amount} coins`)

    message.channel.send(embed)

    db.add(`money_${message.author.id}`, amountearned)
    db.set(`worked_${message.author.id}`, Date.now())
    }
}``` it says you can work again in 9 hours why its set to 1 only
small prairie
#

@junior bobcat That is workin g for me

junior bobcat
#

<:servername:emojiId> ?

grizzled raven
#

@junior bobcat the bot mught not have external reactions perms

junior bobcat
#

oh maybe yes

neat ingot
#

omfg

#

ive just been trying to figure out why my bot now wasnt doing the custom emojiis

#

yes, it was the perms for me

#

:/

#

^ helper function i use, in case it helps

pale vessel
#

UTILS

#

es6 pls

neat ingot
#

no u es6 me -_-

junior bobcat
#

it's working with <:serverId:emojiId> and the permission x) thanks

neat ingot
#

also, when im printing custom emojiis on other servers, i dont need to use <: id: id> thing

pale vessel
#

just use `${emoji} test` if you're on djs

neat ingot
#

im able to just send the raw emojii object

#

${emojii}

pale vessel
#

yes

topaz fjord
#

if it doesn't turn into <> then it can be sent as unicode

pale vessel
#

if you're on eris you need to use <:name🆔>

#

oof

small prairie
#

\😄

topaz fjord
#

:zoomeyes:

#

well

pale vessel
#

cba to fix

topaz fjord
#

forgot that \ escaped the :

pale vessel
#

woah don't

sacred mountain
#

Hi again. I’m making a form of giveaway feature but how would I send a dm to a random user in the guild?

neat ingot
#

get a list of users in an array, pick one at random.

sacred mountain
#

How would I do that

pale vessel
#

use members.first(randomNumber).last()

#

or something

sacred mountain
#

wait when u say randomNumber do you mean a random number or actually type randomNumber

pale vessel
#

where random number is size of the collection

#

smh

neat ingot
#

assuming you have an array of users, you can get a random array elemnt using:
const randFromArray = array[Math.floor(Math.random() * array.length)];

sacred mountain
#

How could I get an array of users

pale vessel
#

ye you can also convert the collection to an array by using .array()

#

or map

#

map is good

neat ingot
#

client.users.cache.array()

pale vessel
#

array is cached

#

so it's not good

#

use map instead

neat ingot
#

ahh, fair enough 😄

sacred mountain
#

How would I do map

pale vessel
#

you pass a function to it

#

it's like using forEach

#

but not really

neat ingot
#

[...collection.values()] seems to be a recommended way to get an array from a collection, which users is.

pale vessel
#

oh nice

neat ingot
#

gotta love destructuring 😄

sacred mountain
#

Wait so guild.members.collection.values()?

pale vessel
#

cache if you're on v12

sacred mountain
#

guild.members.cache.collection.values()?

pale vessel
#

you don't need collection

neat ingot
#

no '.collection'

pale vessel
#

cache is already a collection

sacred mountain
#

Oh

neat ingot
#

^

sacred mountain
#

K

small prairie
#

Can i DM users with my bot when they vote?

#

wrong channel my bad

restive furnace
#

yes

neat ingot
#

dm would only go through if they have enabled dm from members on server

small prairie
#

Aight thanks

sacred mountain
#

I have another question 🤣. How would I send a random thing in the database with like half the key because I have themessage_${message.guild.id} but I want to basically send something random that starts with themessage

hardy vector
#
if (message.content === "=work") {
    let timeoutworked = 36000000
    let worked = await db.fetch(`worked_${message.author.id}`);
    console.log(worked)
    
        if (worked !== null && worked - (Date.now() - worked) > 0) {
        let time = ms(timeoutworked - (Date.now() - worked));
        console.log(time)
        message.channel.send(`You already worked, you can come back and work in **${time.hours}h ${time.minutes}m ${time.seconds}s**!`)
    } else {
    let amountearned = Math.floor(Math.random() * 500) + 1
    let jobs = ["Scientist", "Developer", "Streamer", "Youtuber", "Cashier", "Shopkeeper", "Investor", "Engineer", "Biologist", "Astronomer"]
    let jobworked = jobs[Math.floor(Math.random()*jobs.length)]

    let embed = new Discord.MessageEmbed()
    .setAuthor(`${message.author.tag}, it payed off!`, message.author.displayAvatarURL())
    .setDescription(`${message.author}, You worked as a ${jobworked} and earnt ${amount} coins`)

    message.channel.send(embed)

    db.add(`money_${message.author.id}`, amountearned)
    db.set(`worked_${message.author.id}`, Date.now())
    }
}``` it says you can work again in 9 hours why its set to 1 only

@hardy vector

sacred mountain
#

I have another question 🤣. How would I send a random thing in the database with like half the key because I have themessage_${message.guild.id} but I want to basically send something random that starts with themessage
@neat ingot @pale vessel

hardy vector
#

let time = ms(timeoutworked - (Date.now() - worked));

earnest phoenix
#

how i can restart the bot with a command

hardy vector
#

ms = parse-ms a npm package

sacred mountain
#

I have another question 🤣. How would I send a random thing in the database with like half the key because I have themessage_${message.guild.id} but I want to basically send something random that starts with themessage
@pale vessel @neat ingot

neat ingot
#

which language @earnest phoenix

earnest phoenix
#

discord.js

hardy vector
#

.hours is a method from parse-ms

neat ingot
#

process.emit('SIGNINT')
is what i used to rebot my bot. (node.js)
what this does is send the SIGINT event to the process, which you can hook into to shutdown safely

#

for example:...

#

(sec)

hardy vector
#

basically if i did console.log(time)

#

{
days: 0,
hours: 9,
minutes: 59,
seconds: 50,
milliseconds: 354,
microseconds: 0,
nanoseconds: 0
}

#

that comes up

earnest phoenix
#

wut

neat ingot
earnest phoenix
#

oh

neat ingot
#

the sigint event will shutdown node

#

you can hook it to save data if needed

earnest phoenix
#

what is ur progress

#

it is from js or u have define it

neat ingot
#

'process' is a default node.js thing

earnest phoenix
#

ok

neat ingot
#

contains the running process info

hardy vector
#

@shut inlet wdym by that

sacred mountain
#

@neat ingot when ur done with that are you able to help me. How would I send a random thing in the database with like half the key because I have themessage_${message.guild.id} but I want to basically send something random that starts with themessage

neat ingot
#

by sending process.emit(THING) you are sending an event to the process to trigger it. SIGINT will shut down node. hook it to save data to database or w.e you may need to do, then you can shutdown knowing your database isnt somehow comprimized or corrupted

#

@sacred mountain cant just strip the message.guild.id from the message?
for example "themessage_987123654".replace('_987123654', '')

hardy vector
#

1 hour

#

yes

sacred mountain
#

@neat ingot I don’t want to get rid of that bit it’s just I want it to send a random bit of data where the key starts with themessage_

neat ingot
#

idk what you mean. can you give an example of what a message you want to send would look like?

hardy vector
#

k

sacred mountain
#

@neat ingot me or him?

neat ingot
#

u 😛

sacred mountain
#

Oh

#

So basically

hardy vector
#

ok it worked

#

ty

sacred mountain
#

If there is themessage_198392917 and the data is “hello” and there is also themessage_09485903 and the data is “bye”. I want it to send the data for a random thing that starts with themessage_ so it would be either hello or bye

#

Ignore the italics

#

I’m trying to do _ but it makes it italics

neat ingot
#

lol

sacred mountain
#

So what would I do

neat ingot
#

im still confuzed 😄

sacred mountain
#

RIP

cinder patio
earnest phoenix
#

how i can do -loop?(music)in python

plain gazelle
#

:diamond:

sacred mountain
#

@neat ingot can we go dm bc I can explain better

neat ingot
#

sure, but i respond slower in dm cause i dont look at my notifcations 😄

sacred mountain
#

Oh

#

I will try here then

neat ingot
#

and i can see this chat window constantly on other monitor (but notifications are cut off) 😛

earnest phoenix
#

what will happend when there is no stackoverflow

neat ingot
#

the world would make something better

#

😄

earnest phoenix
#

xD

neat ingot
#

tbh ive always found stack overflow to be very elitist

sacred mountain
#

So let’s say there are 3 things in the database, one called themessage<underscore>83282947392 with the data “one”, one called themessage<underscore>1038492024 with the data “two” and one called welcome<underscore>3927294 with the data “three”. What I’m trying to do is make something that sends a random piece of data from one with the key starting with themessage<underscore> therefore it could randomly send either “one” or “two” but it can’t send “three” because the key doesn’t start with themessage<underscore>

earnest phoenix
#

how i can do -loop?(music)in python

neat ingot
#

oooohhh ok

neat ingot
#

so, lets assume that you are able to get the list of all valid things from the database, in this case, both of themessage_'s . once you have that, just pick a random element and return its data

#

for example

#

[{the_message_0123: 'one'}, {the_message_0124: 'two'}]
^ is the array of messages. then just get a random array element and return the data, something like
const rand = array[Math.floor(Math.random() * array.length)];

sacred mountain
#

But how would I find the ones starting with themessage_

cinder patio
#

depends on the database you're using

sacred mountain
#

Quick.db

#

Yh

neat ingot
#

yea, depends on the database

sacred mountain
#

How would I do it with quick.db

neat ingot
#

i have never used quick db, so idk their query options 😦

sacred mountain
#

Oh

cinder patio
#

yea I don't think you can

#

that's why you shouldn't use quick.db

neat ingot
#

you could get all elements of the database, and then just iterate over them, filtering out the ones that dont match

cinder patio
#

Imagine if you had thousands of elements though

neat ingot
#

oh yea, its not a performant solution at all

cinder patio
#

I recommend switching your database

neat ingot
#

but its a potential solution for smaller databsaes

cinder patio
#

I mean, switching ORMs

sacred mountain
#

Couldn’t I make a table then I won’t have to filter

cinder patio
#

Since quick.db is an ORM for sqlite3

sacred mountain
#

Wait first how would I send a random thing from the whole database

cinder patio
#

you get all the entries in an array, generate a random number between 0 and the array's length

sacred mountain
#

I’m not sure how to convert quick.db into an array

cinder patio
#

.all()

pale vessel
#

imagine not reading the docs

neat ingot
#
const db_data = [
  {the_message_0123: 'one'}, 
  {the_message_0124: 'two'},
  {other_messsage_1: 'tada'}
]
db_data.filter(element => {
    return /the_message_/.test(Object.keys(element)[0])
})

would be one way to filter the elements from the array once you have them. this tests each elements key and ensures it matches the_message_ (note: your database probably doesnt quite store data in the same format, so this probably wont work and is only intended as example)

cinder patio
#

Simplest way to do it is to use a good ORM, not quick.db

neat ingot
#

mongodb/mongoose for lyfe ❤️ (or till i discover something i like more)

earnest phoenix
#

how i can check is there duplicate on databse

neat ingot
#

depends on db

earnest phoenix
#

depends ?

neat ingot
#

yes ?

earnest phoenix
#

?

neat ingot
#

?

earnest phoenix
#

oh i using mysql

neat ingot
#

rip ~ i suck with sql

earnest phoenix
#

😦

neat ingot
#

i mean, most databases allow for some kind of unique key/identifier/element.

earnest phoenix
#

wut

#

bruh i am new in mysql

#

yo @neat ingot

neat ingot
#

ok. i mean, most databases will allow yuo to have data that has to be unique, so it automatically disallows elements that have duplicate data.. for example, an id is generally made to be unique. when the datbase tries to save another with same unique id, it will fail

earnest phoenix
#

i managed to sort the time stuff out now

#

oh

#

i dont understand anything

neat ingot
#

example from mongoose (mongodb)

#

notice how my discorD_id has the 'unique' flag set to true

earnest phoenix
#

only thing im having a problem with now is it not registering the cooldown

#

wait maybe in mysql has unique funciton

#

wait let me see

neat ingot
#

this will disallow saving any new item into that database with the same id

earnest phoenix
#
dbl.webhook.on('vote', async vote => {
  let discord = require('discord.js')
  let embed = new discord.MessageEmbed()
  .setTitle(vote.user.username+" has voted")
  .setColor(client.config.color)
  .setDescription(`
${vote.user.username} has voted **Epoxy** in [top.gg](https://top.gg/bot/697318252744933406/vote)
${vote.user.username} has recived ${client.config.amount.vote}${client.config.emoji.coin}
`)
  .setThumbnail("https://top.gg/images/dblnew.png")
  client.channels.cache.get(client.config.vote).send(embed)
});
neat ingot
#

if i try, database throws a fit and says no

earnest phoenix
#

Help

neat ingot
#

vote.user is just the id? no?

earnest phoenix
#

yes

#

it is id

neat ingot
#

yea

#

so it doesnt have a .username property

#

you would need to use the id, and get the user from your client.users before you can access the specific username data

turbid bough
#

if its just the id, you would have to get user first from discord

neat ingot
#

as far as i remember, sql does support unique keys.

#

been a few years since i used it tho

#

yea it does, thats some code form an old sql highscores list database

turbid bough
#

whats currentList['name'] for?

neat ingot
#

different highscore lists

turbid bough
#

ah yeah nvm, thats yeah for tables

restive furnace
#

does c# have wrapper for mongoose?

junior bobcat
#

is it possible to retrieve messages that has been sent before the bot login ?
I've a channel where I sent "hello"
and with this code it isn't working

// assume we got the channel variable thanks Client.server....
channel.fetch().then(updatedChannel => {
  updatedChannel.messages.cache.each(message => console.log(message));
});
``` nothing has been logged, but I logged the channel and I know the variable `channel` is ok
turbid bough
neat ingot
restive furnace
#

@turbid bough thanks

#

@neat ingot thanks you too

turbid bough
#

@neat ingot thats C lol

neat ingot
#

lmao, my bad 😄

restive furnace
#

aight

neat ingot
#

i did google c# tbf and just grabbed link 1 😄

#

c all seems the same to me 😄

turbid bough
#

c and c# is completely different

neat ingot
#

yea, i know there are differences

turbid bough
#

i would say c and c++ is the same

neat ingot
#

couldnt name you a single one tho

turbid bough
#

its like saying C++ and Java is the same

neat ingot
#

ive never used c#, used c++ a little with arduino and ruby extensions

junior bobcat
#

can u answer me please, and after continue this discussion between langs ? 😛 thanks x)

turbid bough
#

hi here is the answer: answer

junior bobcat
#

c & c++ are like js and jquery if we can compare

restive furnace
#

c++ has more functions at default, what makes it higher level language, c if im right is the lowest level programming language in the world (excluding machine code)

junior bobcat
#

arm

#

is lowest

restive furnace
#

well c++ ≈ node-gyp

earnest phoenix
#

'Access denied for user \'\'@\'localhost\' to database \'bot_cool\'',

#

pls help

#

i am using linux

turbid bough
#

you havent specified an user

earnest phoenix
#

i do

#

user: "thinh",

turbid bough
#

idk it shows nothing?

earnest phoenix
#

or username ??

#

nah nvm

#
const Discord = require("discord.js");

module.exports = {
    name: "uptime",
    category: "info",
    description: "Shows the bots uptime.",
    run: async (client, message, args) => {

        function duration(ms) {
            const sec = Math.floor((ms / 1000) % 60).toString()
            const min = Math.floor((ms / (1000 * 60)) % 60).toString()
            const hrs = Math.floor((ms / (1000 * 60 * 60)) % 60).toString()
            const days = Math.floor((ms / (1000 * 60 * 60 * 24)) % 60).toString()
            return `${days.padStart(1, '0')} days, ${hrs.padStart(2, '0')} hours, ${min.padStart(2, '0')} minutes, ${sec.padStart(2, '0')} seconds, `
        }
    
        message.channel.send(`I have been online for: ${duration(client.uptime)}`)     
    }
}

why doesn't it record the days so it only says 23hrs 59mins then it just goes to seconds and restarts without adding a day

turbid bough
#

omg

#

use date

earnest phoenix
#

Oh it was root not my name

neat ingot
#

@earnest phoenix, i'd recommend using moment and moment duration for formatting times/dates/durations

earnest phoenix
#

wrong adam you pinged

neat ingot
#

oh fk

#

lmao sorry 😄

earnest phoenix
#

its ok

#

plus that works for me so idrk how to convert that into something else

turbid bough
#

is it discord.js?

earnest phoenix
#

yeah

turbid bough
#

idk documentations says .fetch only returns channel, not guildchannel

earnest phoenix
#

oh you meant him

#

thats discord.js tho

turbid bough
#

@junior bobcat you must .fetch() on messages too.

#

for example

#
channel.messages.fetch({ limit: 10 })
  .then(messages => console.log(`Received ${messages.size} messages`))
  .catch(console.error);```
#

when you .fetch a channel it only returns a few data, so you would have to fetch the too messages

#

but, channels should be cached shouldnt it?

junior bobcat
#

oh ok I'll try to fetch messages

#

it's working thanks

earnest phoenix
#

[ RowDataPacket { id: 1, user_id: '545490362568015873', user_coins: '10000' } ] how i can get only user_coins

neat ingot
#

ok, i was on the phone, sorry for slow af reply.
adam, the reason i suggested moment and moment duration, is because its much easier to handle the data, for example, you could do this:

const duration = moment.duration(ms);
const string = duration.format("D [days], H [hrs], m [mins], s [secs]");
earnest phoenix
#

[ RowDataPacket { id: 1, user_id: '545490362568015873', user_coins: '10000' } ] how i can get only user_coins
@neat ingot ?

#

@neat ingot i found the issue

neat ingot
#

otherwise, heres a function to do a similar thing.

function timeConversion(millisec) {
    var seconds = (millisec / 1000).toFixed(1);
    var minutes = (millisec / (1000 * 60)).toFixed(1);
    var hours = (millisec / (1000 * 60 * 60)).toFixed(1);
    var days = (millisec / (1000 * 60 * 60 * 24)).toFixed(1);

    if (seconds < 60) {
        return seconds + " Sec";
    } else if (minutes < 60) {
        return minutes + " Min";
    } else if (hours < 24) {
        return hours + " Hrs";
    } else {
        return days + " Days"
    }
}``` 
src: https://stackoverflow.com/a/32180863/4766190
earnest phoenix
#

i logged a few things
1588857996957
1588854390000
3600000
3606957
the reason its doing that is becuase its seeing it as it over the cooldown
its seeing the cooldown is lower than the now - lastTimeBumped

neat ingot
#

@earnest phoenix just get the .user_coins value from the object?

earnest phoenix
#

undefiened -_-

neat ingot
#
const data = [ RowDataPacket { id: 1, user_id: '545490362568015873', user_coins: '10000' } ] 

data[0].user_coins```
earnest phoenix
#

oh

#

i must of annoyed every last night no one wants to answer hahaha

neat ingot
#

lmao

earnest phoenix
#

including you

#

...

neat ingot
#

i honestly cant remember your exact issue 😛

earnest phoenix
#

okk

neat ingot
#

something with timestamps or something

earnest phoenix
#

yeah i fix the timestamp issues

#

Bruh when they gonna change my name

#

TT

#

but now i can keep bumping without it putting the timer in becuase like i said above

#

1588857996957
1588854390000
3600000
3606957
the reason its doing that is becuase its seeing it as it over the cooldown
its seeing the cooldown is lower than the now - lastTimeBumped

#

which is plus 11 mins

neat ingot
#

whenever i check for a cooldown on a thing, i would check if 'now - timestamp' is greater than some value

earnest phoenix
#

i have here

#

if (now - lastTimeBumped > cooldown) {

neat ingot
#

is your 'cooldown' a value of milliseconds?

earnest phoenix
#

yes

#

3600000

#

is 1 hour basically

#

im logging it like this

#
 }
      const now = Date.now()
      const lastTimeBumped = new Date(result[0].last_time_bumped).getTime()
      if (now - lastTimeBumped > cooldown) {
        console.log(now)
        console.log(lastTimeBumped)
        console.log(cooldown)
        console.log(now - lastTimeBumped)```
copper cradle
#

ask better

#

like

hasty sparrow
#

props.help is undefined

copper cradle
#

I know what you need help with

neat ingot
#

idk why that wouldnt be working :/

copper cradle
#

ofc

earnest phoenix
#

@earnest phoenix Make sure in /commands all files have module.exports.help

#

dek thats what im saying lol

copper cradle
#

they didn't add a help and a name propery

#

to that help property

neat ingot
#

😛

earnest phoenix
#

im gonna log console.log(result[0])

copper cradle
#

that's not the best way of doing it

earnest phoenix
#

Thx

copper cradle
#

that's just the Youtube®️ Tutorial™️ way

neat ingot
#

tbh, the world would be a better place without youtube.

earnest phoenix
copper cradle
#

no

neat ingot
#

much more boring, but yea...

copper cradle
#

if people understood everything from reading

#

it'd be better

earnest phoenix
#

@quartz kindle i done it but now its seeing it higher than the cooldown lol

#

const lastTimeBumped = new Date(result[0].last_time_bumped).getTime() its something in this

copper cradle
#

why are you pinging tim?

earnest phoenix
#

because

copper cradle
#

if I was tim I wouldn't like being always pinged in #development

earnest phoenix
#

well your not tim

amber fractal
copper cradle
#

he isn't even online

earnest phoenix
#

sorry then

#

my bad

neat ingot
#
const lastTimeBumped = new Date("2020-05-07T12:38:55.000Z");
lastTimeBumped.setHours(lastTimeBumped.getHours() + 1);
if (lastTimeBumped - new Date() < 0){

}
#

is an alternative way to check a cooldown

#

by taking the date the action occurred, adding an hour to it, then making sure that time - current time is then < 0

earnest phoenix
#

still lets me bump unlimited

hasty sparrow
#

Do you also update the timestamp?

neat ingot
#

:/

earnest phoenix
#

How i can make auto insert id

#

dek you using timestamp type on sql?

neat ingot
#

nah i dont sql 😛

#

sql hurts my brainz

pale vessel
#

he mongo

neat ingot
#

^ database and personality

earnest phoenix
#

ohhhh hhaha

#

LoL

strange mango
earnest phoenix
#

hahah

#

legit im not sure why the now lasttimebumped is higher than the ooldown lol

neat ingot
#

because the website your trying to link via iframe does not allow iframes

hasty sparrow
#

Because the source website blocks iframes from displaying it's contents

neat ingot
#

^

strange mango
#

oh

neat ingot
hasty sparrow
#

@earnest phoenix Have you got some example values with which we could test your code?

neat ingot
#

is how i got around the iframe issue (thats code my nginx configuration)

quartz kindle
#

@earnest phoenix show full code

neat ingot
#

the part: frame-ancestors 'self' https://top.gg/bot/652216670370398231" is what allows top.gg to iframe my site

strange mango
#

is how i got around the iframe issue (thats code my nginx configuration)
@neat ingot can you paste it here pls

neat ingot
#

my entire nginx.conf? none of us wants that, trust me!

strange mango
#

no, just the csp header

neat ingot
#

its only the content security policy header thats needed anyway

#

add_header Content-Security-Policy "default-src * data: 'unsafe-eval' 'unsafe-inline'; frame-ancestors 'self' https://top.gg/bot/652216670370398231" always;

strange mango
#

thanks

neat ingot
#

np 🙂

hasty sparrow
#

"..., please see warnings below"

earnest phoenix
#

lmao

neat ingot
#

cant avoid that one unfortunately 😦

earnest phoenix
#
  if (command === 'vote') {
    const filter = m => m.content.startsWith(`${config.prefix}vote`);
    channel.awaitMessages(filter, { max: 4, time: 60000, errors: ['time'] })
      .then(collected => console.log(collected.size))
      .catch(collected => console.log(`After a minute, only ${collected.size} out of 4 voted.`));
  }

Channel is not defined

neat ingot
#

however, google only gets a C rating, so idm 🙂

#

oh, D rating for google now ~ rip

#

lol

earnest phoenix
#
if(!args[0]) return message.channel.send(embed)

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

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

      

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

help ? db.startsWith

strange mango
#

and iframe isn't working

hasty sparrow
#

@earnest phoenix Define it, can't just use random variables

topaz fjord
#

hahaha my site has a D rating

neat ingot
#

rip :/

earnest phoenix
#

dek i did what you said now its under the cool down

neat ingot
#

the site i linked tells you your csp stuff like this:

earnest phoenix
#

but still letting me bump hahah

neat ingot
#

wth then lol

#

must be some other issue with the code i think 😦

topaz fjord
#

I'm not gonna fix mine anytime soon

earnest phoenix
#
 if (channelType === 'text') {
                  channelID = c[0]
                  break
                }
              }

              if (now - lastTimeBumped > cooldown) {
                const channel = channels.get(msg.guild.systemChannelID || channelID)
                channel.createInvite().then(invite => {
                  bumpLogic(msg, row, invite)
                  sendEmbed('msg, Bumped .')
                })
              }
            }
          })```
#

most likely an issue here

#

wait no

#

something is wrong with the bumplogic

neat ingot
#

it still shouldnt be calling the bumplogic when its below the cooldown

earnest phoenix
#

well yeah thats what i mean

neat ingot
#

and dw @topaz fjord your on par with google security, just think of it that way 🙂

earnest phoenix
#
if(!args[0]) return message.channel.send(embed)

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

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

      

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

help ? db.startsWith is not a function

hardy vector
#

@shut inlet big problem

#

the code you gave me

neat ingot
#

startsWith is a function for strings

hardy vector
#

counts backwards

neat ingot
#

not a database

hardy vector
#
if (message.content === "=work") {
    let timeoutworked = 3600000
    let worked = await db.fetch(`worked_${message.author.id}`);

    
        if (worked !== null && worked - (Date.now() - worked) > 0) {
        let time = ms(timeoutworked - (Date.now() - worked));

        message.channel.send(`You already worked, you can come back and work in **${time.hours}h ${time.minutes}m ${time.seconds}s**!`)
    } else {
    let amountearned = Math.floor(Math.random() * 500) + 1
    let jobs = ["Scientist", "Developer", "Streamer", "Youtuber", "Cashier", "Shopkeeper", "Investor", "Engineer", "Biologist", "Astronomer"]
    let jobworked = jobs[Math.floor(Math.random()*jobs.length)]

    let embed = new Discord.MessageEmbed()
    .setAuthor(`${message.author.tag}, it payed off!`, message.author.displayAvatarURL())
    .setDescription(`${message.author}, You worked as a ${jobworked} and earnt ${amount} coins`)

    message.channel.send(embed)

    db.add(`money_${message.author.id}`, amountearned)
    db.set(`worked_${message.author.id}`, Date.now())
    }
}```
earnest phoenix
#

3600000
1748409

thats the cooldowns dek

#

which is under cooldown

tulip ledge
#

Anyone know how I can enter certain variables in a json for example:
let json = file.ITEM but the item is a variable?

neat ingot
#
if (1748409 > 3600000) {
  console.log('need refreshed')
} else {
  console.log('doesnt')
}```
hardy vector
#

it puts negative

neat ingot
hardy vector
marble juniper
#

how can I get urls from a string in node.js as an array

topaz fjord
#

what

marble juniper
#

I tried using a node module which did that but it doesn't really work

#

I mean something like

neat ingot
#
"string".match(/(http|ftp|https)://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?/)``` i think
topaz fjord
#

nice spoon-feed

marble juniper
#
"this is a string https://example.com"
neat ingot
#

googling regexp isnt really spoonfeeding 😛

earnest phoenix
#

@neat ingot And what else should i do? i tried 20 different ways and nothing :/

marble juniper
#

I don't understand regexp anyways

hasty sparrow
#

Time to learn it

neat ingot
#

no one does...

#

lol

topaz fjord
#

regexp is the best way to do it

neat ingot
#

is where i got the regexp above

topaz fjord
#

you don't need all of it

#

with some regex magic you can apparently get it all by detecting http(s)

#

damn you regex for not being readable

neat ingot
#

idk what your trying to do sabin, but you need to get the data from your database before you can check if an element from it startsWith()

earnest phoenix
#

my bot does not start, neither on the vps nor on the pc know what it can be?

neat ingot
#

probably some kind of issue.

#

vague question = vague response

topaz fjord
#

do you have an error

neat ingot
#

regexp: /(?:(?:https?|ftp|file):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$])/igm

topaz fjord
neat ingot
#

yea thats a handy site

#

there are a few decent ones for regexp

earnest phoenix
#

my bot was on yesterday, so I'm off now I can't connect it anymore, I've tried to use shards and nothing.

#

it just stays like this.

#

never starts

pale vessel
#

no go away

amber fractal
#

well do you have it log anything?

slender thistle
#

@earnest phoenix Please don't post any invites or OAuth links

earnest phoenix
#

not

neat ingot
#

the only thing i can think of is that your bot is stuck in some kinda infinite loop before it tries to connect, do you log normally anything to console on ready event?

#

like, 'connected' or some crap

#

if not, try logging something on the ready event to see if its ever connecting to discord

sudden geyser
#

already tryed this but i get an empty response
What do you mean?

#

@lusty quest

lusty quest
#

got it sorted out

earnest phoenix
#

@neat ingot
I tried to connect it on a base with nothing, and di a console.log on ready and nothing.

#

How can I define random ?

lyric mountain
#

Math.random() * yourdesirednumber

pale vessel
#

floor

neat ingot
#

^

lyric mountain
#

round would be better

pale vessel
#

ok

lyric mountain
#

since otherwise the upper limit would never be reached

neat ingot
#
Math.floor(Math.random() * number);
Math.round(Math.random() * number);```
earnest phoenix
#

@lyric mountain Can you come in dms please?

lyric mountain
#

subject?

pale vessel
#

sounds suspicious

neat ingot
#

idk then carter, sry 😦

#

i would check my token to make sure its valid, i've had issues with my token becoming invalid due to a lot of reboots in quick succession

earnest phoenix
#

@lyric mountain i have trouble with a code, and i think i can learn easier if we were just us

lyric mountain
#

I'm not a JS dev, there's only a few things I can help you with

earnest phoenix
#

I have trouble with that random thing, i'm trying to make a roulette command

pale vessel
#

how

lyric mountain
earnest phoenix
#
let vip = await db.fetch(`bronze_${user.id}`)
if(vip === true) random = Math.floor(Math.random() * 200) + 1;
if (vip === null) random = Math.floor(Math.random() * 100) + 1;

let embed = new Discord.RichEmbed()
.setDescription(`✅ You robbed ${user} and got away with ${random} coins`)
.setColor("#FFFFFF")
message.channel.send(embed)

db.subtract(`money_${message.guild.id}_${user.id}`, random)
db.add(`money_${message.guild.id}_${user.id}`, random)
db.set(`rob_${message.guild.id}_${user.id}`, Date.now())

isn't this correct?

neat ingot
#

try it and find out 🙂

copper cradle
neat ingot
#

side note: i'd do this to get the max value:

const vip = await db.fetch(`bronze_${user.id}`);
const random = Math.floor(Math.random() * (vip ? 200 : 100)) + 1;
earnest phoenix
#

@neat ingot Ok, ty

neat ingot
#
db.subtract(`money_${message.guild.id}_${user.id}`, random)
db.add(`money_${message.guild.id}_${user.id}`, random)``` is concerning tho
#

its sub/add to the same user. idk if thats desired

high geode
neat ingot
#

but like, its just going to end up the same amount

high geode
#

help?

pale vessel
#

guild is undefined

neat ingot
#

i mean 1000 - 100 + 100 is 1000, you know?

high geode
#

how can i do it

#

per id

#

not per name

pale vessel
#

also, you need to pass a function for .find

neat ingot
#

find can be used like that im sure, but is depreciated.

pale vessel
#

it's deprecated

#

yeah

earnest phoenix
#

👌

neat ingot
#

equivalent function would be e => e.name === 'welcome'

#

so, find(e => e.name === 'welcome')

copper cradle
#

how does member.guild make sense to you

high geode
#

still erroring

pale vessel
#

it should work

high geode
copper cradle
#

@neat ingot yes, it's deprecated

high geode
#

how can i do it for id?

copper cradle
#

how does member.guild make sense to you, again

pale vessel
#

member.guild makes sense tho

high geode
#

it makee sens

#

i can

#

user

slender thistle
#

Is 3d in C# 3 represented in double datatype?

high geode
#

but i dont know const user

#

xd

#

:))

pale vessel
#

unless it's user.guild

#

that would be retarded

high geode
#

yeah

#

:))))))))))

pale vessel
#

how did you define member?

high geode
#

can someone tell me whats const user = ?

#

const member = ""

#

xd

pale vessel
#

yeah and

high geode
#

i dont know the defines

copper cradle
#

🤦‍♂️

pale vessel
#

what is it

high geode
#

wdym

pale vessel
#

ok snails you do this

copper cradle
#

did you define member as "";

#

?

#

no

#

flazepe

high geode
#

yes

#

:))

copper cradle
#

I'm on classes rn

high geode
#

i dont know the defines

neat ingot
#

couldnt have, or guild woulldnt be defined

pale vessel
#

no fuxk you I'm done

copper cradle
#

I only came here to read

neat ingot
#

oh, nvm then... lol

high geode
#

i need const user =

pale vessel
#

my brain is about to explode

high geode
#

can someone tell me pls

copper cradle
#

and sometimes talk

#

show your code

high geode
#

const user = ?

pale vessel
#

what's the ?

high geode
#

define the user

#

i dont know

pale vessel
#

how did you define member

#

you used member.guild

neat ingot
#

you can get the user from the message object

high geode
#

const member = ""

#

i told you

neat ingot
#

assuming you have access to that

quartz kindle
#

lmao

pale vessel
#

you can't be serious

high geode
#

i am

pale vessel
#

lmao

tulip ledge
#

Hi so I'm getting the error that it can't read sell_summary of undefined any idea why? Am I doing something wrong?
data.products[miniontype].sell_summary[0].pricePerUnit (This is an API btw)

quartz kindle
#

omg

hasty sparrow
#

Good grief

pale vessel
#

goodness gracious

high geode
#

😂

neat ingot
strange mango
#

hi, so I'm having issues where iframe are getting blocked, I'm using nginx

quartz kindle
#

@high geode that means you're literally doing "".guild

high geode
#

ik

pale vessel
#

this is like yesterday

high geode
#

:))

#

but i dont knos

#

the defines

quartz kindle
neat ingot
high geode
#

yeah

tulip ledge
#

Hi so I'm getting the error that it can't read sell_summary of undefined any idea why? Am I doing something wrong?
data.products[miniontype].sell_summary[0].pricePerUnit (This is an API btw)+

hasty sparrow
#

No need to repeat yourself so soon