#development

1 messages · Page 565 of 1

earnest phoenix
#

so like

amber fractal
#

Save the message object as a vaiable to refer to it later then you can edit it

earnest phoenix
#

Tried

#

Tried

lusty dew
#

so how could I restart my bot a long with the commands so the saved changes to the code takes effect?

earnest phoenix
#

hmm everytime I try to search voice receiver I get dbl ads for @drowsy fjord

grand raft
#
let message = msg.channel.send("Hello world");
message.edit("Hello world 2").then(() => {
  message.edit("Hello world 3");
});```
earnest phoenix
#

:(

amber fractal
#

@lusty dew could just make a reload command

grand raft
#

just use pm2 watch mode

#

it'll restart your bot when it detects changed source files

lusty dew
#

Hm

grand raft
#

or nodemon if you don't want to use a process manager

lusty dew
#

How would I do that?

grand raft
#

but I'd recommend the process manager

lusty dew
#

Last time I made something like that

#

it didn't actually work

#

It said it reloaded the command but it didn;t

quartz kindle
#

i use pm2

grand raft
#
npm i -g pm2
pm2 start yourbot.js --watch .
earnest phoenix
#

But I want to like make 2 s before editing message?

lusty dew
#

Whom are you talking to?

grand raft
#

@lusty dew you

lusty dew
#

Ah o

amber fractal
#

@earnest phoenix setTimeout

lusty dew
#

ok

amber fractal
#

In js anyways

earnest phoenix
#

I send code

lusty dew
#

how exactly does pm2 work though?

grand raft
#

It runs as a daemon/service process

#

and then runs your nodejs processes underneath it

earnest phoenix
#
message.channel.send(`*lol*`)
 .then((msg)=>{
setTimeout(function(){
msg.edit('*haah*');
}, 1000)}).then((mssg) => {
                       mssg.edit(`Gotttem`);
                       }, 1000)}
                   }```
grand raft
#

also Bots, like this:

let message = msg.channel.send("Hello world");
message.edit("Hello world 2").then(() => {
    setTimeout(() => {
        message.edit("Hello world 3");
    }, 2000);
});```
earnest phoenix
#

i want to do 3-4 times

grand raft
#

call setTimeout 3-4 times then

#

just with increasing time

lusty dew
#

So would it stop working if my computer went to sleep?

grand raft
#

you don't really have to wait for the .then() but it's good practice

#

yes it would

#

nothing runs if your computer is asleep

lusty dew
#

Welp looks like ima have to keep my pc from going to sleep

#

:/

grand raft
#

Do you have anything else you could run it on?

#

If it's a lightweight bot you could even just buy a raspberry pi ($35 for the most expensive model) and run it on that

#

or $5 for the cheapest but I'm not sure how well that would run a bot

amber fractal
#

A vps cost $3 tho

quartz kindle
#

if its a lightweight bot, even glitch/heroku can run it

grand raft
#

rpi is a one-time investment and can be repurposed later

quartz kindle
#

if you're the one paying electricity bills, a vps will be cheaper than a pi

amber fractal
#

You still have to rely on your internet tho, no?

#

And that

lusty dew
#

I have $0 so ima have to try and make glitch or heroku work somehow

quartz kindle
#

and yea, vps internet is a gazillion times better than any home internet out there

#

unless you're on like 1gb/1gb fiber

amber fractal
grand raft
#

even then unless you have business internet it's probably can be against your ISP ToS to run a discord bot

quartz kindle
#

wut

amber fractal
#

Never heard that one before

grand raft
#

home-grade internet can have clauses saying you can't run an external service someone else can access

quartz kindle
#

what kind of ISP would disallow people to run home-based services/servers? wtf

grand raft
#

Mine for one blurplepepe

quartz kindle
#

i've never seen that lmao

#

ripp

amber fractal
#

Rip port forwarding

grand raft
#

it's a bit of a gray area for discord bots since you're not actually hosting a serivce so much as communicating with discord, but you should probably still check

inner jewel
#

you don't have third parties accessing your stuff if you run a discord bot

#

it's just outbound connections

quartz kindle
#

technically, there is no difference between a discord client and a discord bot, as far as networking is concerned

#

the discord app uses the same websocket system as a discord bot

grand raft
#

other than that a bot on thousands of servers would generate a lot more traffic

inner jewel
#

and since encryption is a thing they can't detect if it's a client or a bot

quartz kindle
#

yeah, if your isp doesnt offer unlimited data

#

you're most likely screwed

#

my bot uses about 10gb/mo on 600 guilds

amber fractal
#

Think about the bandwidth 😢

grand raft
#

plus if you get a vps in a big datacenter you're more likely to be closer to a discord server, or at least have a bigger pipe connecting you to it, which can result in lower ping for your bot

quartz kindle
#

yup, which is very important

inner jewel
#

just move to NYC

quartz kindle
#

thats where the gateway is?

grand raft
#

I'd rather not spend two weeks in traffic a day

inner jewel
#

it's close to NYC

#

the whole api

lusty dew
#

Can someone help me set up glitch?

#

or heroku

#

either one is fine

lusty dew
#

thx

#

Do music bots work well on glitch?

marble needle
#

no

earnest phoenix
#

^

lusty dew
#

oof

#

Mk

#

Glitch website keeps crashing...

#

Is there a guide on Heroku?

split iris
#

i tried to authorize my bot, but its not showing up on the my bots page. Any help?

earnest phoenix
#

you should get a vps

#

because glitch isn’t gonna be a valid host for long term

rugged terrace
#

how do you get an embed looking like this

#

oh nvm

earnest phoenix
#

Soemone know how to add role to specific badge?

#

if(message.author.premium) return console.log('Is it') return undefined

sick cloud
#

i've made a mod mail bot but am wondering what people would suggest as the best way for the user to identify what guild to send the message to

#

i could use IDs, ie send [id] [message..], however IDs arent user friendly

earnest phoenix
#

Huh

#

I dont understand

sick cloud
#

my question?

earnest phoenix
#

Yes

#

My english is bad

sick cloud
#

then let someone else answer it, you dont have to

earnest phoenix
#

sorry for disturbing
but does anyone has a way to put an image inside an image with jimp?
im making a profile command

cerulean haven
#

is password = webhook token in api

restive bough
#

huh

earnest phoenix
#

lanes$help

dreamy breach
#

Someone know how to code a stats api for Brawlstars game?

quartz kindle
#

does this game have a public api?

mossy vine
#

it doesnt

#

after a quick search i have found 2 broken apis for the game

#

none of them work

#

not anymore*

topaz fjord
dreamy breach
#

This api is currently down 😦

#

I want to create my own api to remove down moment.

#

Because i’m the first brawlstars statistics bot atm 👀

quartz kindle
#

well, where are you going to take the data from?

mossy vine
#

^

quartz kindle
#

is there any official website that has the data you need?

topaz fjord
#

Just sweet talk supercell till they give you access to player stats mmLol

dreamy breach
#

But this two websites are down 5h a day.

quartz kindle
#

how do they get the data tho? they are not official are they?

topaz fjord
#

I don't think they are

dreamy breach
#

Unofficial api yes

quartz kindle
#

so find out where they get the data from

dreamy breach
#

They don’t want to tell me 😭

#

I already google this for 10h x)

#

But i found nothing

#

I think, when you have the beginning, after it’s easier

topaz fjord
#

Wait wut

#

Guilded has brawl stars stats

dreamy breach
#

No x)

topaz fjord
#

And they have a discord bot as well

dreamy breach
#

It’s stats for tournaments

#

Not brawlstars stats

topaz fjord
dreamy breach
#

Isn’t for team stats only?

#

Like matches, wins

late hill
#

Hello cuties,
Are the rate limits for sending messages per guild?
I'm wondering because, would it be possible for the bot to get ratelimited if a guild is very actively using the bot 👀

Got an answer nvm

tulip ledge
#

Hey I'm planning on buying a VPS on OVH but can it host a mysql database? And what should I take like Ubuntu or what?

quartz kindle
#

any vps can host a database

#

but you need to install it and set it up yourself

#

ubuntu is a standard choice yes, i believe most people use it

earnest phoenix
#

If I am using heroku and github, if I already deployed my project and it's running on heroku , will it stop if I deleted the files on github?

#

I have heroku performance L

knotty steeple
#

how do you send a dm to someone with eris?

#

wait nvm

topaz fjord
#

Rtfd

cobalt dune
#

Hey so Im trying to edit an embed with a command to be able to edit any embed message. It works as Im only trying to edit the body of the embed, only trouble Im having is that I want the properties of the original title, color, etc to stay the same but only edit what I write in so "body"

keen drift
#

Clone, edit

ruby dust
#

in worst case scenario you can always just recreate the same embed with the changes you want to edit it

earnest phoenix
#

I posted my bot this morning and I waited almost all day to check
Please see

amber fractal
#

Can take up to a week

earnest phoenix
#

@earnest phoenix

west raptor
#

@earnest phoenix hi

earnest phoenix
#

Ok.

west raptor
#

so what's your code

earnest phoenix
#

DMs.

west raptor
#

why

#

just do it here

earnest phoenix
#

I’ll show it.

odd void
#

@earnest phoenix just do it here so other people who are scrambling with the same situation will get help easily by searching.

earnest phoenix
#

IDK>

restive halo
#

Would it be safe to just use .hasPermissions("KICK_MEMBERS") to check for if someone has mod status

mossy vine
#

are you actually writing code in google docs

earnest phoenix
#

My friends been over for the week while his parents were splitting up, he coded it, he left..

#

idk what it is tho

knotty steeple
#
con.query("SELECT * FROM counter;", (err, results, fields) => {
                if(err) {
                    utils.log(err, true)
                }
                id = results[0].counter + 1
            })

i have a variable set here id but when i use it somehow it says its undefined

con.query({
                sql: "INSERT INTO thing (userID, option, id) VALUES (?, ?, ?)",
                values: [uid, args[0], id]
            }, (err, results, fields) => {
                if(err) {
                    utils.log(err, true)
                }
})

when it inserts into the table it is null, which means its undefined
but if i do something like msg.channel.createMessage(id) its not undefined?

#

pls explain because im dumb

earnest phoenix
#

I still need help

#

Can someone pls dm me

knotty steeple
#

dont code in google docs

earnest phoenix
#

I didn’t

#

I moved it their.

feral heath
#

best ide

inner jewel
#

move the code that depends on id inside the callback

earnest phoenix
#

idk what that means. My friend made this. I just want to know how to get it online and what its prefix is... can someone dm me.

knotty steeple
#

put the code on hastebin

#

@inner jewel huh

earnest phoenix
#

Can someone pls help

knotty steeple
#
put the code on hastebin```
earnest phoenix
#

K. When I get back to ox

#

Ox

#

Ox

#

Pc

restive halo
#

So I'm trying to add the ability to change prefix.
And I'm using the code: if (message.member.hasPermissions("KICK_MEMBERS")) {}
To check for mod status for it.
Will this work or is there something else to use?

amber fractal
#

Usually people use manage server, dont they?

knotty steeple
#

your preference

restive halo
#

Could change to manage server instead and have it say you need that perm to use the command

knotty steeple
#

how long can author names be?

amber fractal
#

2-32 characters

earnest phoenix
knotty steeple
#

make it yourself

earnest phoenix
#

I can't code...

knotty steeple
#

then learn

earnest phoenix
#

Mate, I'm just asking for simple help..

knotty steeple
#

mate, im telling you your friend cant code for you all the time

earnest phoenix
#

He won't. He just made 1 bot.

#

Please.

next wedge
#

hy

earnest phoenix
#

pls

knotty steeple
#

learn

#

a

earnest phoenix
#

MAte.

#

Stop.

knotty steeple
#

programming

#

language

earnest phoenix
#

STOP>

#

Stop telling me that!

#

He's correct

amber fractal
#

We wont spoonfeed and we cant help if you dont know what your doing a small bit

knotty steeple
#

^

earnest phoenix
#

Learn how to code

#

I just want to know the damn prefix.

lusty dew
#

Did I come at a bad time?

earnest phoenix
#

I do! I just can't find the prefix.

knotty steeple
#

but before you said you dont know how to code

lusty dew
#

👀

amber fractal
#

Theres an array at the top that is prefixes tho

knotty steeple
#

shh

amber fractal
knotty steeple
#

reee

#

its a whole bot

amber fractal
#

is it one file

knotty steeple
#

yes

#

its a one file python music bot

#

as it looks like

amber fractal
#

Python syntax hurts my eyes mmLol

#

I have to learn it next year tho

lusty dew
#

Oof

knotty steeple
#

i dont help the spoonfed

#

so i will go

earnest phoenix
#

the bots broke

#

idk how to work it

#

lol

knotty steeple
#

aw

#

so sad

earnest phoenix
#

🤦

knotty steeple
#

take a python course and code the bot yourself

earnest phoenix
#

NVm

knotty steeple
#

what are the max amount of characters for a description in an embed

inner jewel
#

2048 iirc

amber fractal
#

2048

#

Yes

knotty steeple
#

ok cool

#

and a user can post 1024

#

in a message

inner jewel
#

a message can have 2k chars

knotty steeple
#

wait what

amber fractal
#

A user message can have 2000 characters

earnest phoenix
#

If your good with python pls dm me. I need help.

ruby dust
#

or just ask here

#

there's nothing private in helping someone

amber fractal
#

I think its because he wants code, not help.

earnest phoenix
#

No

#

I have an error

restive halo
#

Got the code set up (and db) for changing prefix but when I tried changing it as a test it didnt actually work.
Using discord.js and mongo for the db

earnest phoenix
restive halo
#

Can show the code if needed cause got a repo set up with the main file in

earnest phoenix
#

@earnest phoenix did you copy code?

#

Hmm?

restive halo
#

Looks like it's missing required libs

earnest phoenix
#

if yes you won't know how to download requirements

#

DMs.

#

No

#

Alright

#

If you are good with python can you please help me? (DMS) I have a code with an error, and need help fixing it.

#

1)No
2)You've been asked to learn how to code before you actually do so, and looks like you are copy coding since you don't even know how to download the lib requirements (sorry if this is too har for you but if you want to be better at coding, you need to learn).

#

I'm just asking for simple help, I don't want to fully learn coding just to fix this error.

restive halo
#

I mean if you're not willing to learn then how can we help

earnest phoenix
#

I am.

#

Im just looking for help on that error so i can fix it.

bright spear
#

@earnest phoenix nobody will help you if you don't actually learn the language

earnest phoenix
#

Nevermind, I figured it out.

bright spear
#

Don't copy paste code

restive halo
#

Is it alright if I post a github link to my bots code?
Need someone to check and see if I've done something wrong cause cant change prefixes. But nothing is crashing so...

Also its using discord.js and mongo

earnest phoenix
#

Yeah

bright spear
#

Sure

restive halo
#

Alright got what's wrong
Mongo is async so it returns the value after the message gets sent

knotty steeple
#

let's say i have an array of objects, like this

const objects = [{"e": 10, "respects": 69}, {"e": 23, "respects": 13}]
``` how could i make a field for each object in the array?
quartz kindle
#

a for loop?

knotty steeple
#

o k

#

uh

#

idk

quartz kindle
#

you mean add each of them to an embed as a field?

knotty steeple
#

yes

quartz kindle
#
objects.forEach(item => {
    embed.addField(item.e,item.respects)
})``` ?
#

or whatever the embed constructor is

knotty steeple
#

i dont use rich embeds i just use the embed option for createMessage

quartz kindle
#

you make a literal embed object?

knotty steeple
#

yes

quartz kindle
#
let embed = {};
objects.forEach(item => {
    embed.addField(item.e,item.respects)
})
#

same thing

knotty steeple
#

wew

quartz kindle
#

just instead of the addField

#

you set the fields yourself

#

wheres that embed visualizer

#

brb

knotty steeple
quartz kindle
#

yeah that

carmine echo
#

I need help with oauth. I'm trying to make my bot's invite to redirect to a page. under scopes I selected bot, under bot perms I selected admin, under redirect url I selected the url I need. I copied the link, but it still doesn't redirect after authorizing. Can I post the link? in `` thingies of course

quartz kindle
#
let embed = {fields:[]};
objects.forEach(item => {
    embed.fields.push({name:item.e,value:item.respects})
})```
knotty steeple
#

oooh

#

i see

#

ok thanks

#

so how much fields can you have in an embed

carmine echo
#

25

knotty steeple
#

wut

carmine echo
#

Yes. 25.

knotty steeple
#

the fuc

carmine echo
open inlet
#

lol

earnest phoenix
#

If you are good with python, Please DM me. I need help with some errors.

#

you're annoying

#

Me?

#

i've been working on this damn project for 5 hours now, everytime i look here you are asking for help in dms

#

Mate, ive asked 2x.

#

I just need help lolzo.

opaque eagle
#

I'm still a little new to Vim, and I try to do this:

  1. I open my .vimrc file and paste this: ```
    call plug#begin('~/.vim/plugged')

Plug 'scrooloose/nerdtree'
Plug 'morhetz/gruvbox'
Plug 'vim-airline/vim-airline'
Plug 'valloric/youcompleteme'
Plug 'mattn/emmet-vim'
Plug 'w0rp/ale'
Plug 'pangloss/vim-javascript'

syntax on
filetype plugin indent on2. Then, I go do the install command. 3. At the very end, this command pops up, and it pops up every time I open vim.sh
Vim: Caught deadly signal SEGV
Error detected while processing function <SNR>50_PollServerReady[7]..<SNR>50_Pyeval:Vim: Finished.

line 4:
Exception MemoryError: MemoryError() in <module 'threading' from '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.pyc'> ignored
Segmentation fault: 11```

earnest phoenix
#

Yeah! I'm just trying get it answered and no one will.

quartz kindle
#

because the answer is not simple

#

and requires you to know what you're doing to understand it

#

and you refuse to learn, so...

#

¯_(ツ)_/¯

#

@opaque eagle are you on mac os?

opaque eagle
#

yes

quartz kindle
#

i googled it and it seems to be a common problem in mac os

opaque eagle
#

oh

quartz kindle
opaque eagle
#

I did see it, but I really understand what it talked aabout

#

Never used Python before

quartz kindle
#

i've never used vim, and i dont have a mac, so i cant help

#

but it seems that many people had problems with vim plugins after updating mac

opaque eagle
#

oh

#

Exactly my situation lmao

quartz kindle
#

so you should be able to find solutions online

#

try them all

lusty dew
#

https://paste.tscforum.com/pvfexlasgg.coffeescript Does anyone think this would work?
It is supposed to do
if the coin Multiplier they have = 1x then it won't double the coins and it will show the normal embed
but if they have 2x multiplier it will show the 2x embed
and show the multiplied coins

quartz kindle
#

well, have you tested it?

lusty dew
#

Yea got no errors

#

but I fixed it

#

:>

#

My next thing is making the coin multiplier part

#

Also

#

That brings me to my next question

#

I am trying to make a shop to buy the Coin multiplier

#

and I am trying to give the items ID's

#

so people can say the ID of the item and buy it

#

But how could I make the item ID's?

quartz kindle
#

like an arbitrary unique id?

lusty dew
#

Well

Coinmultiplier would have an ID of 1
Xp multiplier would have an id of 2

#

and so on

quartz kindle
#

well, you have either assign the ids yourself, or you can generate random ids

lusty dew
#

How could I assign the IDs myself?

quartz kindle
#

if you have an sql database, it has an auto incremented unique id

lusty dew
#

I am using MongoDB

#

But like I just said

#

I want to give it my own ID

#

like

#
let items = {
coinMultiplier: {
"id": 1
},
xpMultilier: {
"id": 2
}

}
quartz kindle
#

if you want to find items by their IDs, the IDs should be the keys, and the name should be a field

lusty dew
#

Something like that, then users could do tc!buy 1 or tc!buy 2

quartz kindle
#

so js items = { "1": { name: "coinMultiplier" } }

lusty dew
#

AH

#

Ah ok

quartz kindle
#

this way you can also add more fields if needed

#

for example item description, item price

#

etc

lusty dew
#
                let items = {
                    "1": {
                        name: "CoinMultiplier",
                        price: "100"
                    },
                    "2":{
                        name: "CoinMultiplier a Week",
                        price: "400"
                    }
                }
#

Something like that?

quartz kindle
#

yeah

lusty dew
#

then I can do

#

Wait

#

How could I call upon one of them?

quartz kindle
#

items[id]

lusty dew
#

Ok

#

thought so

#

items[1]

#

items[1].name

#

items[1].price

#

?

quartz kindle
#

its a string, so it has to be items["1"]

lusty dew
#

Ah ok

#

but I could still do the

#

.price or .name

quartz kindle
#

but if you get the id from the discord message, its just the variable items[id]

lusty dew
#

?

quartz kindle
#

yes

lusty dew
#

Mk

#
                let items = {
                    "1": {
                        name: "CoinMultiplier",
                        price: 100
                    },
                    "2":{
                        name: "CoinMultiplier for a week",
                        price: 400
                    }
                }
#

does it have to be like that

#

or can it be

#
                let items = {
                    1: {
                        name: "CoinMultiplier",
                        price: 100
                    },
                    2:{
                        name: "CoinMultiplier for a week",
                        price: 400
                    }
                }
quartz kindle
#

it can be like that

#

but js objects dont work very well with non-string keys

lusty dew
#

Mk

quartz kindle
#

you cant do items.1

#

but you can do items[1]

lusty dew
#

Yea

#

Ill leave it as strings

quartz kindle
#

actually it doesnt make a difference

#

even as strings you still cant do item.1

#

and even as strings, you can still do items[1] as a number

lusty dew
#

Yea

#

I don't really want to do a bunch of checks ugh

#

Is there a faster way to like

#

Oh way

#

Oh wait

#

I can just do

#

is there a way to use both ids?

#

like

#

items[1, 2].price

#

or smth

quartz kindle
#

nope

lusty dew
#

Damn

quartz kindle
#

you need to iterate it

lusty dew
#

?

knotty steeple
#

loop

quartz kindle
#

you want to get a list of prices, right?

lusty dew
#

Yea

#

and check if they have the right money

#

for any of those items

#

so I could do

#

a for loop right?

quartz kindle
#

you can do something like js Object.entries(items).map(item => { return `[${item[0]}] ${item[1].name}: ${item[1].price}` })

#

and you'll get an array containing the list of items with their ids and prices

lusty dew
#

Hm

#

I was just gonna do something like this

#
if(data.bal >= items[1].price){
data.bal -= items[1].pric
data.coinMultiplier = "2x"
}else{
message.channel.send(`You don't have sufficient funds! You have ${data.bal} you need ${data.bal - items[1].price} more coins to purchase this item!`)
}
#

something like that

#

and I think that is how I would get how much they would need more

#

I am not completely sure

quartz kindle
#

yeah that will work

#

just switch them around in the message, or you'll get you need negativenumber more coins

#

xD

lusty dew
#

Yea

#

True

#

XD

#

It'd be nice though

#

if I could loop through all the prices

#

so if they do

#

tc!buy 1

#

it will check their bal with that price

#

and if they do the second one

#

it will also check their bal with the price of that item

#

I don't want to have to do a bunch of checks

quartz kindle
#

you dont need to do a bunch of checks

#

just do it the same way you did the above

lusty dew
#

Hm?

quartz kindle
#

if you want to work on multiple items, just use loops

lusty dew
#

That is what I was gong to do

#

But I am not very good with loops

#

Oof

#

Ill figure it out though

#

!

#

You been a ton of help already

#

Thanks ❤

quartz kindle
#

👍

last lava
#

So my code pushes this error
throw err; // Unhandled 'error' event
^
Error [ERR_UNHANDLED_ERROR]: Unhandled error. ([object Object])

quartz kindle
#

discord.js?

last lava
#

and idk how to fix it

#

yes

knotty steeple
#

you have to handle the error

#

add a error event

last lava
#

k

knotty steeple
#
bot.on("error", console.error)```
quartz kindle
#

^

knotty steeple
#

but most of the i get that error is because the internet went out

lusty dew
#

^

#

I also get that error if My pc goes to sleep if I am hosting on my pc like a nub

#

welp

#

Looks like ima have to do a bunch of checks

#

I can't get the for loop to work

#

:/

quartz kindle
#

what are you trying?

lusty dew
#

for(price in items){

}

amber fractal
#

is items an object?

lusty dew
#

yea

amber fractal
#

}```
#

That doesnt work?

lusty dew
#

var?

quartz kindle
#

for in lets you iterate over keys, so price here is not the item price, its the item id

lusty dew
#

Ok

#

Oh

#

so I should do

#

for of?

amber fractal
#

of is a collection iterator

quartz kindle
#

for of will iterate over values, so price would become the entire item object, with all is sub keys

amber fractal
#

Wait

#

I thought it was a collection iterator mmLol

lusty dew
#

So how could I get price then?

amber fractal
#

items[price]

#

or whatever the var is

#

because the obj[key] returns a value

quartz kindle
#

you can use whichever loop you want, just use the context properly

lusty dew
#

cause I want them to be able to do tc!buy 1 and it checks the price of item ID 1 or tc!buy 2 and it checks the price of item ID 2

quartz kindle
#

example ```js
for(a in items) {
console.log(items[a].price)
}
for(a of items) {
console.log(a.price)
}

lusty dew
#

What is the a?

quartz kindle
#

the value of the current item

lusty dew
#

Ah so if they tried to buy the first item

#

it would check the price of that item?

#

and if they tried to buy the second one it would check the price of the second item

quartz kindle
#

also, apparently for of doesnt work for objects, only for arrays

lusty dew
#

oh

amber fractal
#

I use of to iterate collections

quartz kindle
#

i dont get what you're trying to do tho, this is for iterating over all items

#

you dont need to check prices of all items if they want to buy just one

lusty dew
#

Well I am just trying to prevent me from having to do

#
if(data.bal >= items[1].price){
//gives coinMultiplier 2x and subtracts coins
}else{
//tells them they have insufficient funds
}

if(data.bal >= items[2].price){
//gives coinMultiplier 2x and subtracts coins
}else{
//tells them they have insufficient funds
}

if(data.bal >= items[3].price){
//gives coinMultiplier 2x and subtracts coins
}else{
//tells them they have insufficient funds
}
#

and so on

quartz kindle
#

why do you need to do that?

#

if they want to buy item 1, just check item 1, dont check other items

lusty dew
#

To check if they have the right amount of coinse

#

but if they want to buy item 2

#

:/

quartz kindle
#

just check item 2

#

dont check others

lusty dew
#
if(data.bal >= items[`${args}`].price){
//gives coinMultiplier 2x and subtracts coins
}else{
//tells them they have insufficient funds
}

couldn't I do that?

#

so if they do

#

tc!buy 1 it will check price for 1

quartz kindle
#

thats exactly what you should do, i though you were already doing that from the beginning lol

#

but you're doing it wrong

#

you dont need to convert anything

lusty dew
#

yea

quartz kindle
#

items[args]

#

if args is already the value you want

lusty dew
#

oh yea

quartz kindle
#

else, you need to extract the value from args

lusty dew
#

Hm

#

thanks

#

I made this much more hard then it needed

amber fractal
#

If you have an object like this:

  item1: {
    desc: "",
    price: 100
  },
item2: {
    desc: "",
    price: 200
  }
}```
console.log(obj.item1.price) // 100
console.log(obj.item2.price) // 200
quartz kindle
#

lmao

lusty dew
#

Sorry for wasting your time

amber fractal
#

Its not a waste of time if you learned

lusty dew
#

Troof

#

Thanks <3

last lava
#

is anyone familiar with the "message.channel.overwritePermissions" function in discord.js

lusty dew
#

Mhm

#

A lot of people are

#

I bet

last lava
#

is there a function to overwrite the permission throughout the whole server?

lusty dew
#

You would need to use a loop

last lava
#

oof

lusty dew
#

here is an example of a loop I use

#
message.guild.channels.forEach(async (channel, id) => {
//overwritePermission function here
})
#

That is how I do it

last lava
#

okay

lusty dew
#

Although

last lava
#

?

lusty dew
#

It isn't that good for big bots or so I heard

last lava
#

lol

#

its a linear complexity

lusty dew
#

Since it can be API abuse for big bots or just servers that have a tone of channels

last lava
#

but its fine

lusty dew
#

ton*

last lava
#

its not like the server has 69 channels...

#

but thx

#

ima implement this into my code

quartz kindle
#

the only alternative is to use roles instead of channels

#

or override category permissions

#

and make channels sync with category

last lava
#

im currently using roles

#

but i wanted to simplify it

lusty dew
#

Hey tim

#
data.coinMultiplier = "2x"
#

I just realized a thing I didn't think of and now I can't figure it out

#

Coin Multiplier is not the only item on the shop

#

There is also xpMultiplier

#

But I can't figure out how I would do if they bot the Coin multiplier make it 2x and if they bought xp Multiplier make it 2x

#

could I just do

#

a check?

earnest phoenix
#

What do you want exactly

quartz kindle
#

xp and coins are two different things, right? so they should be two different properties

lusty dew
#

Yea

quartz kindle
#

like data.cointmulti and data.xpmulti

#

also

#

if you want to remove some checks, since you want to simplify your code

#

instead of data.coinMultiplier = "2x" just do data.coinMultiplier = 2

lusty dew
#

I can;t

quartz kindle
#

this way, you can do coins * data.coinMultiplier

#

instead of if(coinmultiplier == "2x") { coins * 2 }

lusty dew
#
    client.checkUserExist = (message) => {
        client.loadUserData(message.author.id, data => {
            if (data != null) return
            data = {
                id: message.author.id,
                bal: client.settings.starting_balance,
                xp: client.settings.startingXP,
                levels: 0,
                coinMultiplier: "1x",
                xpMultiplier: '1x'
            }
            client.writeUserData(message.author.id, data, () => {
                client.log(`Successfully created account for ${message.author.username}#${message.author.discriminator}`)
            })
        })
    }
earnest phoenix
#

Delete string

lusty dew
#

This is how I have my Database stuff set up

#

I have coinMultiplier: "1x"

quartz kindle
#

just change it

earnest phoenix
#

Delete the string WatatenIsAHorrorAnime

lusty dew
#

But I guess I could do

quartz kindle
#

do the same as you do with levels

earnest phoenix
#

I do coin multiplier on my bot

quartz kindle
#

use a number instead of a string

lusty dew
#

@earnest phoenix Cool

earnest phoenix
#

Text want string, and number doesn't want it

lusty dew
#

You make no sense

#

sorry

#
else if (data.coinMultipler == 2)
#

I could do that

#

Instead of checking if coinMultiplier == "2x"

#

But

#

Still how would the bot know if they bought Coin multiplier or Xp multiplier?

#

cause if I just did

#
                    if (data.bal >= items[args[1]].price) {
                        data.bal -= items[args[1]].price
                        data.coinMultiplier += 2
                        data.xpMultiplier += 2
                    }
#

wouldn't this just add them both?

quartz kindle
#

two things

#
  1. you dont need that if anymore
#

you dont need to check if multiplier equals to 2 or not

lusty dew
#

I am not

quartz kindle
#

simply always multiply by the multiplier

lusty dew
#

That is adding

#

wait

#

honestly

#

I am dumb

#

I am adding 2

#

not adding it to the number 2

#

oof

quartz kindle
#

also, when people buy

#

you should check what was it that they bought lol

lusty dew
#

Yea

#

I can't figure that part out

#

:/

#

That is what I been saying

#

and asking for help on

quartz kindle
#

if(items[args[1]].name === "coinMultiplier")

#

thats why you have a name field in your items

lusty dew
#

Ah ok

#

Wow that was simple

#

I clearly don't think hard enough

#

But it goes By ID

#

So I should use

#

use .id?

#

or what

#

Wait nvm

sick cloud
#

if i'm making just a simple bot, would sqlite do as a db for it?

quartz kindle
#

according to my research, sqlite is the best database for most bots actually

keen drift
#

according to my research, glitch is the best host

quartz kindle
#

@_@

sick cloud
#

i use rethinkdb everywhere

#

and i just don't wanna use it for this

quartz kindle
#

the thing is, why would you use a database server when you only have a single process using it?

sick cloud
#

because i have shards

#

and its realtime so it can communicate with my website

quartz kindle
#

the only time a database server would make sense is if your bot is sharded into multiple processes or across machines, or you need external access via apis

#

so for small bots, its usually not needed

#

and sqlite has already proven itself to be able to handle millions of requests

keen drift
#

I started out with a json storage engine

#

then I ported it over to mongo as the demand got higher

quartz kindle
#

im still using json as well, because i dont have time/motivation to rewrite everything

#

but i plan to rewrite it to sqlite

#

i think that even with shards, sqlite will do fine in a single machine

#

i would only move to a database server if i were to split it into multiple machines/instances

keen drift
#

I started sharding my database

inner jewel
quartz kindle
#

well, once your bot gets really big, like i assume yours is

#

then you go on an adventure

keen drift
#

yes, miserable adventure

quartz kindle
#

to find where you could optimize stuff

#

xD

keen drift
#

the more you grow, the less docs there are

inner jewel
#

even on huge bots most dbs can handle it without breaking a sweat

quartz kindle
#

with great power comes great responsibility

keen drift
#

except I don't have responsibility

inner jewel
#

pretty much any real db can handle tens of thousands of queries per second at least

quartz kindle
#

even sqlite can

keen drift
#

really just want to get replication up for my db

#

had an incident before where a node magically won't boot

#

👏🏾

quartz kindle
#

rip

#

is reaction role not available right now?

keen drift
#

public invite is not available

quartz kindle
#

a friend was trying to add it

keen drift
#

there's another invite link that goes thru the full oauth flow

#

so I can rate limit it

quartz kindle
#

cool

hushed berry
#

What's wrong with RR 🤔🤔 @keen drift

keen drift
#

nothing Thonk

sick cloud
#

{ [Error: SQLITE_CANTOPEN: unable to open database file] errno: 14, code: 'SQLITE_CANTOPEN' }

#

whats up here

keen drift
#

could be a lot of things

sick cloud
#

thats all i get

#

ok dw it was a stupid path issue

last lava
#

im still stuck

#

im trying to make a function to go through each channel and mute a user

#

so far the function is message.guild.channels.forEach(overwritePermissions(mutedmember.id, {
VIEW_CHANNEL: true,
SEND_MESSAGES: false
}))

lusty dew
#

that should be correct

#

Just without the .id at the end of mutedmember

#

here

inner jewel
#

what's the issue?

lusty dew
#
message.guild.channels.forEach(
await channel.overwritePermissions(mutedmember.id, { 
VIEW_CHANNEL: true, SEND_MESSAGES: false 
}));
inner jewel
#

wrong

lusty dew
#

That should work better

inner jewel
#

that code won't work

lusty dew
#

It works for me

inner jewel
#

it's 100% invalid

lusty dew
#

Perfectly fine

last lava
#

...

inner jewel
#
message.guild.channels.forEach(
    await channel.overwritePermissions(mutedmember.id, { 
        VIEW_CHANNEL: true, SEND_MESSAGES: false 
    })
);```
lusty dew
#

.

#

you need async

#

if you are using await

last lava
#

btw, im new to this whole bot thing

#

so any advice?

inner jewel
#

you pass the result of overwritePermissions to forEach

#

and i can guarantee you that is not a function

#

also you don't need to await if you don't use the result

lusty dew
#

I do

#

¯_(ツ)_/¯

last lava
#

its a method

lusty dew
#

But you do you guys

inner jewel
#

it's useless and just adds overhead

#

¯_(ツ)_/¯

#

and gc pressure

#

@last lava any reason you're not using a mute role instead?

#

it's way faster to mute

#

a guild can have 500 channels

#

you'd send 500 requests to discord to mute a member

last lava
#

i dont find it consistent

inner jewel
#

vs a single one to add a mute role

keen drift
#

consistent Thonk

last lava
#

for some reason, my role doesnt mute for the channel the person is in

#

but does for all other channels

inner jewel
#

then your permissions are wrong

last lava
#

i double checked them...

inner jewel
#

then it's impossible to mute

#

if any permission overwrite allows a permission, it will be granted

#

regardless of denies

last lava
#

probably what the prob was

quartz kindle
#

that forEach doesnt even have a callback

inner jewel
#

^

#

you never pass a function to it

#

you pass the result of overwritePermissions

earnest phoenix
#

I’m having an issue with some errors in my code. Anyone good with Python? If so please dm or ping me.

last lava
#

so should i just stick with assigning a role?

quartz kindle
#

using a role is better, but its a pain to update the channels for it

last lava
#

okay

lusty dew
#

how can I make it so when they do tc!shop it dms them the shop embed and then they can just send the [itemid] they want to buy. Cause rn it is lookin for the item number when I do tc!shop

last lava
#

should i create a new role, or have one premade

quartz kindle
#

you can do it the channel way, you're just missing the callback in the function: .forEach(channel => do something with channel here)

earnest phoenix
#

If you are good with python, please ping or DM me.

lusty dew
#

If you create the role gotta check if it exists after so it doesn't keep creating the role after every single time the mute cmd is used

#

keeps trying to create*

last lava
#

thats what i used prev

#

@quartz kindle like this
message.guild.channels.forEach(channel => channel.overwritePermissions(mutedmember.id, {
VIEW_CHANNEL: true, SEND_MESSAGES: false
}))

sick cloud
#

use codeblocks

#

```js

```

last lava
#

okay

#
message.guild.channels.forEach(channel => channel.overwritePermissions(mutedmember.id, { 
            VIEW_CHANNEL: true, SEND_MESSAGES: false 
        }))
sick cloud
#

does this make any sense?

if (cooldown != null && (Date.now() - cooldown > 0)) return reply(`You can only use !daily every 24 hours`);
if (cooldown == null) cooldown = Date.now();
#

i'm using dates to make a cooldown system

quartz kindle
#

Date.now() - cooldown will always be > 0

sick cloud
#

so how do i check if the cooldown is equal or greater than a day?

keen drift
#

let d = new Date(); d.setDate(d.getDate() + 1); if lastUse + cooldownDuration > d.timestampthingy

#

somewhat like that

earnest phoenix
#

Anyone good with py? If so... help?

#

Can you check this code to run it? I can’t find it’s errors.

#

@earnest phoenix that's not how you run a bot

#

Mate, it has errors.

#

I just need help fixing them/

inner jewel
#

congratulations on leaking your token

earnest phoenix
#

agh

#

NOES

last lava
#

rip

earnest phoenix
#

Their goes my bot.

#

NO NO NO NO No

lusty dew
#

Just reset token boiyo

#

;)

last lava
#

oof

earnest phoenix
#

Shush

#

I been waiting 2 days for @gilded plank

#

@earnest phoenix first off is it in a python file or are you actually running it from there

errant ocean
#

Wait

lusty dew
#

SyntaxError: await is only valid in async function

#

I get this error

#

even when I add async in

amber fractal
#

My cooldowns are so overworked, but they work

lusty dew
#

Ok?

amber fractal
#

Was referring to a older conversation

sick cloud
#

the function has to be async

spring ember
#

@lusty dew you need the function you are calling the await from to be async

lusty dew
#

@spring ember I already have it handled

spring ember
#

Cool

knotty steeple
#

how would i go by getting the newest 10 rows in sql

#

mysql

knotty steeple
#
SELECT * FROM answers ORDER BY A DESC LIMIT 10```
#

this works

empty steppe
#

Is there a way to add more than 1 reaction of the same type to a message? (py)

knotty steeple
#

how do you add a reaction to a message

empty steppe
#

currently with client.add_reaction(msg, emoji)

knotty steeple
#

repeat that

empty steppe
#

hm it doesnt add more it seems

knotty steeple
#

can u just post code

empty steppe
#

msg = await self.bot.say(embed=await self.generate_embed())
for i, r in enumerate(self.options_reaction):
await self.bot.add_reaction(
msg,
(b'\U0001f1a'.replace(b'a',bytes(hex(224 + (6 + i))[2:], "utf-8"))).decode("unicode-escape")
)
await self.bot.add_reaction(
msg,
(b'\U0001f1a'.replace(b'a', bytes(hex(224 + (6 + i))[2:], "utf-8"))).decode("unicode-escape")
)

knotty steeple
#

codeblock

#

```py
code
```

empty steppe
#
                    await self.bot.add_reaction(
                        msg,
                        (b'\\U0001f1a'.replace(b'a',bytes(hex(224 + (6 + i))[2:], "utf-8"))).decode("unicode-escape")
                    )
                    await self.bot.add_reaction(
                        msg,
                        (b'\\U0001f1a'.replace(b'a', bytes(hex(224 + (6 + i))[2:], "utf-8"))).decode("unicode-escape")
                    )```
#

hm

#

sec

knotty steeple
#

do a loop then

empty steppe
#

well it is a loop and should add each reaction twice

#

(i just copied the lines where it adds the reaction once)

earnest phoenix
#

Hi

knotty steeple
#

arent u adding the same reaction

empty steppe
#

yes

knotty steeple
#

what

#

you cant add 1 reaction twice

empty steppe
#

hehe that was my initial question

#

maybe i formulated it a bit poorly

knotty steeple
#

no it wasnt

#

yes you formatted it badly

empty steppe
#

by reaction of the same type i meant the same reaction

knotty steeple
#

no

earnest phoenix
#

Hi

knotty steeple
empty steppe
#

thanks for the help @knotty steeple
is there a way to save a message including the reactions and repost it?

knotty steeple
#

no

empty steppe
#

okay, i see
then ill have to work around that 😃

#

thanks again

earnest phoenix
earnest phoenix
#

@earnest phoenix done

#

yes

#

If I want to make a user blacklist in json I have to do how?

#

ok

marble needle
#

save userdata you can use to identify the user (hint: choose something that doesn't change) in your json object and wherever you implement your blacklist logic (aka where you want to do something with the blacklist in your code) check if the user in question is in your blacklist. If they are do things you want to do with blacklisted people

earnest phoenix
#
const Discord = require("discord.js");
const bot = new Discord.Client();
exports.run = (client, message, args) => {
    if(message.includes('everyone')) return;
    if(message.includes('here')) return;
    const saywhat = args.join(" ")
    if (saywhat < 1) return message.channel.send("Je n'ai pas fourni de texte à dire ")
        message.channel.send(`**${message.author.username}** dit ` + saywhat)
}
#

@earnest phoenix il me laisse pas faire de say tout simple avec genre même sans everyone ou here

#

Att

#

Ok

#

if(args[0] === 'everyone') return;

#

Ok thx

#

message.includes est dépassé

#

J'avais oublier

#

if(args[0] === 'everyone' && 'here') return;

#

Yes

#

Ok thx

#

Jsp si ca va fonctionner comme ca

#

Ah

#

Avec les & &

#

Alors

#

Mais sans ca fonctionne

#

if(args[0] === 'everyone') return;
if(args[0] === 'here') return;

#

?

#

Oui

#

Ok

#

Go test

#

Merci

#

Il bloque pas @earnest phoenix

#

Il met quand même mdrr

#

@earnest phoenix ta défini comment tes args

#

Ma commande say

#
const Discord = require("discord.js");
const bot = new Discord.Client();
exports.run = (client, message, args) => {
    if(args[0] === 'everyone') return;
    if(args[0] === 'here') return;
    const saywhat = args.join(" ")
    if (saywhat < 1) return message.channel.send("Je n'ai pas fourni de texte à dire ")
        message.channel.send(`**${message.author.username}** dit ` + saywhat)
}```
#

ah mais

#

J'ai ça moi

#

if(saywhat === 'everyone')

#

Ok

#

met le en dessous de ta const

#

et

#

D'acc

#

if (!saywhat) return message.channel.send("Je n'ai pas fourni de texte à dire ")

#

plus simple

#

Ok

#

Sauf que

#

Maintenant il fait plus de say

#

Wtf

lusty dew
#
data.bal >= items[]

Since I am doing cases what would I put in the [], cause I am wanting to check whichever ID they said it will check the price of that Item
could I just do
data.bal >= items[args[0]]
https://ghostbin.com/paste/wha88
^full code

quartz kindle
#

your code order is wrong

#

first of all, this js message.author.send(shopEmbed).catch(e => { return message.channel.send("Please, enable your dms and try again!") }) will always send, regardless if they have dms enabled or not

#

you should run that only if the dm fails, for example in a catch block, if the dm message fails

lusty dew
#

Ok

quartz kindle
#

then this js setTimeout(() => { message.author.send(`What item would you like? Please say the number of the item you want: Example: 3`) }, 3000) why are you waiting before you send the item list? you're basically trying to wait for an answer before sending anything

#

you should send the list first, and then await messages

lusty dew
#

Bc

#

That message sends before the embed does

#

so I was trying to make it send after

quartz kindle
#

why dont you add the message in the embed? like in the footer

lusty dew
#

Hm try

#

tru*

quartz kindle
#

also, to send messages in the correct order, you shouldnt use an arbitrary set timeout

#

you should wait for the message response

#
.send(message).then(msg => {
    msg.send(another message)
})```
#

or use async/await

lusty dew
#

yea

#

Mk

#

I got all that

quartz kindle
#

now back to the original question

#

if (data.bal >= items[]) { is also in the wrong order, there is nothing yet to compare

#

it should be after the await message

#

so then you just if (data.bal >= items[answer].price) { switch } else { send(insuficient funds) }

#

if fact, you dont need the switch at all

vernal rivet
#

👀

quartz kindle
#

instead of this js switch (parseInt(answer.content)) { case 1: { data.bal -= items[0].price data.coinMultiplier += 1 message.author.send(`You have just bought ${items[0].name}!`) break; } case 2: { data.bal -= items[1].price data.xpMultiplier += 1 message.author.send(`You have just bought ${items[1].name}!`) } } do this ```js
data.bal -= items[answer].price
data[items[answer].name] = 2; // set 2, else if the person buys it twice, he gets multiplier x3. unless thats what you want
message.author.send(You have just bought ${items[answer].name}!)

lusty dew
#

Eh

#

But

#

like

#

Could I still keep the switches?

quartz kindle
#

you dont need them

lusty dew
#

But I want them

#

:/

quartz kindle
#

why lol

lusty dew
#

Bc

#

your code makes no sense

quartz kindle
#

lmfao

#

the problem with the switches is that as you keep adding new items, your switch will be huge

#

and you dont need it all, when you can just directly access the item with the answer

lusty dew
#

but instead of doing name

#

could I just do id

#

?

quartz kindle
#

where?

lusty dew
#

data[items[answer].name]

#

instead of .name

#

since I am wanting to them to use the ID

quartz kindle
#

yes, but that is not whats happening in that part

#

data is your database, the user data

lusty dew
#

Oh?

#

yea

quartz kindle
#

and you want to set the new multiplier

#

so you need to set data.xpMultiplier

lusty dew
#

OH

#

I get it now

#

Ok

quartz kindle
#

so you do the same as data[xpMultiplier]

#

by using the name from the item

lusty dew
#

Wow

#

you just made this tons easier

#

So like that?

quartz kindle
#

remove this message.author.send(shopEmbed)

lusty dew
#

Why?

quartz kindle
#

and add it here

lusty dew
#

Oh

quartz kindle
#
message.member.createDM().then(dmchannel => {
            dmchannel.send(shopembed)
                        let filter = m => m.author.id === message.author.id```
#

actually

#

you dont even need the createDM at all

lusty dew
#

Damn my code is all types of messed up

quartz kindle
#

actually no

#

you need the dm channel

lusty dew
#

....

quartz kindle
#

lmao

#

my bad

lusty dew
#

After I just removed it

#

Lol

quartz kindle
#

ctrl z

lusty dew
#

I went back to far

#

and now ctrl y

#

is not working

#

fuck

#

ok back to normal

quartz kindle
#

anyway, the shopembed should be inside the dm channel

lusty dew
#

Yea

#

got it

quartz kindle
#

now another problem

#

you changed the item names, or maybe i remember them wrong

#

so now they dont match the name that is in data

lusty dew
#

Yea

quartz kindle
#

if you try to do data[items[answer].name] is the same as doing data["Coin Multiplier 2x | Day long"]

lusty dew
#

maybe I could do a second thing

#

like

#

this

#

Could I do something like that

#

?

quartz kindle
#

yes you can

#

but now you have to think, how are your future items going to look like?

astral quail
#

Isn't it item instead? Because of the forEach?

shopEmbed.addField(item.id + ' ' + item.name, '\n' + 'Description ' + item.description + '\n' + 'Price:\n' + item.price)```
quartz kindle
#

are all of your future items going to be stored in their own namespace in data?

lusty dew
#

Not all of em

quartz kindle
#

yes, item also works

lusty dew
#

Some will be role stuff

#

like adding roles

#

and such

quartz kindle
#

so you will need a check later

astral quail
#

Otherwise you can just do a for loop, and those are 3 times faster.

quartz kindle
#

yes, from 10 nanoseconds to 4 nanoseconds

#

:^)

astral quail
#

Depends on the size of the array.

quartz kindle
#

his array has 2 items

lusty dew
#

What kind of check would I need to add?