#development

1 messages · Page 1385 of 1

slender thistle
#

be it via copy pasting code or thinking logically

wicked pivot
pale vessel
#

can you elaborate?

wicked pivot
pale vessel
#

yeah, not possible

novel kelp
#

i think you can not

#

maybe you should try setDescription

rancid sand
#

Guys, is there a node library that you can use to ping yourself if an errors happens in your bot?

pale vessel
#

you don't need any specific library for that

#

create an error handler that sends errors to you

rancid sand
#

how does it sends the error to me exactly?

pale vessel
#

grab the user (you) and send the message via DMs or grab your server and get a special channel and send errors there instead

ember lodge
#

Why the bot doesn't edits the message?

#

It just says edited but the embed doesn't changes

pale vessel
#

try specifying the embed, message.edit({ embed: embedat })

ember lodge
#

i'll try

pale vessel
#

since it's not an instance of MessageEmbed, it might not be able to set it properly

ember lodge
#

ok thanks

outer perch
#

so you use commands to show new pages?
@lusty quest yes

lusty quest
#

why does it then take this long?

#

i use Reactions to switch pages and its relatively fast

#

but again i have a dedicated Database

outer perch
#

the problem is to just open up the store the 1st time

#

nothing more

lusty quest
#

only after a restart?

outer perch
#

no

north birch
#

So hm..i got a problem here, i actually use this filter to make equip command in my economy bot, it work but when there are 2 weapons of the same type it return error, what can i do for fix this?

            if(userWeapons == 'Weapon1') {
            message.channel.send('You equipped Weapon1');
            if(isSomethingEquipped === true) {return message.channel.send(Somethingh is already equipped')};
            db.set(${message.author.id}_equippedweapon, 'Weapon1');
            equipweap = db.fetch(${message.author.id}_equippedweapon)
            const filtro = weap;
            const newinv = filtro.filter(weap => weap!= equippedweapon);
            db.set(${message.author.id}_weapon, newinv)}
            else {
                message.channel.send('You dont have this weapon!')
            }

I used quick.db

lusty quest
#

what is the error?

outer perch
#

shouldn't be weap?

lusty quest
#

^

north birch
#

shouldn't be weap
@outer perch Yeah lmao i think i wrote wrong cause it's translated

#

The original code is correct

#

Wait

outer perch
#

*wrote

#

xD

north birch
#

what is the error?
@lusty quest If in the db there's two weapons of the same type it return error

outer perch
#

br or pt?

north birch
#

*wrote
@outer perch okeh

#

You're right again lol

outer perch
#

where r u from?

north birch
#

Italy, i know english, just dont mind my error cause when i write fast i makes always error LMAO

outer perch
#

yikes k

north birch
#

So? Guys?

#

Y'all just died

lusty quest
#

not really

north birch
#

Oh

lusty quest
#

all i would say you have a duplicated entry into the database. make each weapon unique or prevent duplications

north birch
#

I cant prevent duplications cause i need duplications, for example, if somebody loot the same weapons i want to give the user the choice to sell it, use it, trade it

lusty quest
#

make a table with all weapons (unique ids) then just write into the user account the weapons he own (again with unique id)

#

working intentionally with duplicates and databases is not really good practise

outer perch
north birch
#

working intentionally with duplicates and databases is not really good practise
@lusty quest I see

outer perch
#

I guess it's because the main shop embed has a gif to load

#

the others don't

lusty quest
#

i would guess that the cache gets populated when you call the command first. and the cache gets then released after some time

#

ohh a gif

#

yea try without gif

north birch
#

make a table with all weapons (unique ids) then just write into the user account the weapons he own (again with unique id)
@lusty quest Dont know if i can cause i'll need a unique id each time and, i really dont know how to make the filter command if there's an unique id each time

outer perch
#

cuz only the main embed has this load problem

lusty quest
#

@north birch you could still call them by name

#

the name doesnt need to be unique

#

exept if the name is the unique id

outer perch
#

the thing is I really want that gif there

lusty quest
#

the downside of gifs is they take ages to load

outer perch
#

I don't remember compressing the file

north birch
#

the thing is I really want that gif there
@outer perch Try sending the gif in a message.channel.send()

outer perch
#

I should try it again using TinyGif or somthing

lusty quest
#

how large is the gif?

#

bcs it also depends on client side performance (internet speed)

outer perch
#

6MB

lusty quest
#

hmm its fine i guess

outer perch
#

it only takes 2sec. at max

#

to load and send

north birch
#

Hold my gif

lusty quest
#

yea thats your connection

outer perch
#

it's not a huge problem

lusty quest
#

maybe you can get it down to 3mb

outer perch
#

the other comands take at max 1sec.

lusty quest
#

yea thats normal

outer perch
#

shit's fine, just trying to check any performance issues

north birch
#

working intentionally with duplicates and databases is not really good practise
@lusty quest What do you suggest me?

#

If db isn't a good practise what can i use?

lusty quest
#

make a table with all weapons (unique ids) then just write into the user account the weapons he own (again with unique id)

#

DB is always good practise

north birch
#

Okay so

earnest phoenix
#

can i connect database mongodb on my pc and then use heroku to host it?

north birch
#

can i connect database mongodb on my pc and then use heroku to host it?
@earnest phoenix I think aws is better than heroku

lusty quest
#

yes you can

#

or get a free mongodb

#

bcs for the DB hosted on your PC you need to forward ports

north birch
#

Try it out it will make your life easier

@earnest phoenix I think aws is better than heroku

earnest phoenix
#

i am now downloading mongodb compass is that good?

lusty quest
#

its a tool

#

for accessing MongoDB

earnest phoenix
#

i am new to databases sorry

lusty quest
#

google MongoDB atlas this is a MongoDB host they also offer a free tier

earnest phoenix
#

i wasted 3 hours making database in txt file and it didnt work well so i want real database

lusty quest
#

good idea

#

but it will not become easyer

#

unless you know how to use it

earnest phoenix
#

i know

north birch
#

i wasted 3 hours making database in txt file and it didnt work well so i want real database
@earnest phoenix Oh yeah i remember it

lusty quest
#

but you wont loose any data bcs of Heroku

earnest phoenix
#

yes

#

thats why i want database

#

it was terrieble mistake making it in txt file

lusty quest
#

it works on hosts that wont nuke your server if you restart

earnest phoenix
#

what hosts are there for free?

#

heroku is bad

#

but works

lusty quest
#

all free hosts suck. if you got a credit card Google and AWS offer 1 free year

earnest phoenix
#

i dont want to pay

#

i am too poor for that

lusty quest
#

google also got a free tier of VPS but they are really low powered

north birch
#

what hosts are there for free?
@earnest phoenix AWS Free tier

lusty quest
#

@north birch you still need a credit card

north birch
#

Oh yeah

hollow sedge
#

It's still free

earnest phoenix
#

so heroku is only option

hollow sedge
#

Just enter it

earnest phoenix
#

i used heroku for a while, amazon s3 for database storage. it's a suggestion but fuck if I remember how I made it work, though it did

lusty quest
#

the credit card is only needed for validation

north birch
#

Maybe AWS/Google/Azure student plan dont need credit card?

earnest phoenix
#

look my contury isnt rich so i cant affor hosting ok?

hollow sedge
#

? It's free

#

You just enter a credit card

lusty quest
#

you only need a credit card for validation, it will not be charged

earnest phoenix
#

yes but where tf i will find credit card

lusty quest
#

ohh this issue

north birch
#

Theres many solution

hollow sedge
#

Your country does not have credit cards?

north birch
#

Revoult

#

For example

lusty quest
#

@hollow sedge in some countries they are uncommon

hollow sedge
#

Huh didn't know that

earnest phoenix
#

my country has but i dont

north birch
#

@hollow sedge in some countries they are uncommon
@lusty quest Oh

#

my country has but i dont
@earnest phoenix You can try get one free on Revolut or other online banking solution

lusty quest
#

like ive got now one for about 1 1/2 years even tho i work now for almost 8 years

hollow sedge
#

You might want to stick to Heroku anyway as AWS is more complicated. You can always switch to a better host once you feel confident enough

outer perch
#

well @lusty quest I could reduce the size by around 60%, but the quality gets way worse

earnest phoenix
#

like ive got now one for about 1 1/2 years even tho i work now for almost 8 years
@lusty quest we dont have that luxus here

#

like you need to pay for credit cards

lusty quest
#

@outer perch if you are fine with the load times

hollow sedge
lusty quest
#

@earnest phoenix it where just an example bcs they are here also uncommon

outer perch
#

not a big problem for how it is now

north birch
#

How can I add a reaction to a message with a custom emoji like that ?
@sand dune Write \ and then insert your custom emoji on discord, then get the ID and Name of the emoji that will come out and paste on the bot

earnest phoenix
#

ok nvm i am here because i want to connect discord.py to mongodb

#

can someone help

lusty quest
#

i can help with mongo but not py

earnest phoenix
#

i am stuck with create database

outer perch
#

python hurts my brain

earnest phoenix
#

yes me too

outer perch
#

such abnormal ways to write code

hollow sedge
#

are you sure you need to pay for credit cards?

earnest phoenix
#

i dont know

#

i never had one

lusty quest
#

usually they are only needed for verification not for payments in the first year

hollow sedge
#

Oh ok

earnest phoenix
#

ok can you just forget

#

i live in bosnia

hollow sedge
#

lol it's ok I don't think you would be comfortable with using AWS anyway

lusty quest
#

well you need linux knowledge

outer perch
hollow sedge
#

Well setting up codedeploys too..heroku just has all that setup automatically

earnest phoenix
#

ok this is what i want

#

in my bot it has currecny named sarma

#

and i want for each user to save amount of sarmas

#

so something like this Shovel385:12

hollow sedge
#

That's quite easy with any DB

lusty quest
#

yea

earnest phoenix
#

yes but i dont know how to do it

hollow sedge
#

so..you just have to pick one

lusty quest
#

firebase or MongoDB atlas are some ok entry points

earnest phoenix
#

mongodb

#

i downloaded

#

i have created database

lusty quest
#

both offer free Tiers

earnest phoenix
#

now what

lusty quest
#

but i think they want each a Credit card for verification

north birch
#

Im the only one that use AWS EC2 to host bot? lmao

lusty quest
#

i use Digitalocean Droplets

north birch
#

i use Digitalocean Droplets
@lusty quest Never heard about

earnest phoenix
#

how can i connect to database in python

hollow sedge
earnest phoenix
#

thank you

lusty quest
#

Digitalocean is a rather large hoster lol

#

and they call the VPS droplets

north birch
#

@earnest phoenix

earnest phoenix
#

yes

north birch
#

Do you have a school email that end on .edu?

#

If yes you can use Azure Student

earnest phoenix
#

no

#

my ends with .org

north birch
#

Ripp

#

my ends with .org
@earnest phoenix Does it have .edu?

#

Not the personal one

hollow sedge
#

Is .edu for non-US?

earnest phoenix
#

i dont know

#

what is edu

north birch
#

Is .edu for non-US?
@hollow sedge I got .edu in italy

hollow sedge
#

education

#

oh ok

north birch
#

what is edu
@earnest phoenix Normally, shool gives students email that end with .edu

hollow sedge
#

You could try GitHub student, not sure if they have anything that would get you server though

earnest phoenix
#

ok what database that is free you want me to use?

hollow sedge
#

I think that's mostly colleges actually

north birch
#

ok what database that is free you want me to use?
@earnest phoenix Idk

hollow sedge
#

@earnest phoenix I thought you said mongodb?

earnest phoenix
#

is mongodb good enough?

hollow sedge
#

All dbs are free

lusty quest
#

MongoDB Atlas is free

earnest phoenix
#

i just downloaded it

lusty quest
#

(you dont need to pay for hosting)

north birch
#

All dbs are free
@hollow sedge I think's he is talking about online db

earnest phoenix
#

i am now folowing instruction on w3schools

hollow sedge
#

But he said he downloaded it

north birch
#

But he said he downloaded it
@hollow sedge Then idk lmao

lusty quest
#

also not all DBs are free. some are licensed and you need to buy one

hollow sedge
#

oh my bad

earnest phoenix
#

that sucks

north birch
#

also not all DBs are free. some are licensed and you need to buy one
@lusty quest Oh

hollow sedge
#

Most of the ones popular on here are free though

lusty quest
#

but this is more in enterprise space

hollow sedge
#

Yeah I was about to say most of the paid ones would be for enterprise

lusty quest
#

like the big boy databases that handle terrabytes worth of calls

earnest phoenix
#

do i need to run database on my computer?

lusty quest
#

not really

north birch
#

make a table with all weapons (unique ids) then just write into the user account the weapons he own (again with unique id)
@lusty quest Btw im super lucky, quickdb table docs are offline

#

404 Not Found

#

F*ck

earnest phoenix
#

not really
@lusty quest is it yes?

hollow sedge
#

Typically you would have it on your server or in the cloud

main trench
#

hey having some issues with the adding a role i read the docs but didn't get the help i needed get this error when i do message.author.roles.add(db logged role) Cannot read property 'add' of undefined and i get this error when i do message.author.addRole(db logged role) message.author.addRole is not a function anyone know a solution?

earnest phoenix
#

so i need to keep my pc running database all time?

lusty quest
#

@earnest phoenix if you host it on your PC you need to open a Port in your Router to allow external connections. or you also run your bot of your pc

main trench
#

@earnest phoenix just run the database in your code editor

lusty quest
#

so i need to keep my pc running database all time?
@earnest phoenix yes

earnest phoenix
#

i run my bot on heroku

hollow sedge
#

WTH? Run the database in your code editor?

earnest phoenix
#

@earnest phoenix yes
@lusty quest is there any way to not run?

hollow sedge
#

What does that mean

outer perch
#

@main trench message.author.roles.cache.add(db logged role)

#

you need .cache in there

hollow sedge
#

Mb didn't realize that was discord.js

lusty quest
#

use something like MongoDB atlas free tier

earnest phoenix
#

where i can find it

main trench
#

@outer perch thanks

outer perch
#

wait @main trench

#

I'm wrong

hollow sedge
outer perch
#

I am checking my code

north birch
#

Guys somebody know well quick.db? I need to make a table with it but table quick.db docs is offline

wicked pivot
#

is there a maximum of calls for the functions?

earnest phoenix
#

ok where i can get ip of mongodb client

hollow sedge
#

The docs are offline?

#

Lol what

north birch
hollow sedge
earnest phoenix
#

this line myclient = pymongo.MongoClient("mongodb://localhost:27017/")

#

where i can find

north birch
hollow sedge
#

this line myclient = pymongo.MongoClient("mongodb://localhost:27017/")
@earnest phoenix that's only if you downloaded it

main trench
north birch
#

Oh

#

LMAO

hollow sedge
#

Why are you looking at the docs in GitHub lol

north birch
#

I was clicking on method

hollow sedge
#

Oh

north birch
#

This shit

#

Ty lmao

earnest phoenix
#

i am confused

hollow sedge
#

Lol

balmy knoll
#

If I want to open a connection to the MongoDB database (mongodb package) in the index.js file and then use the same connection in other files, for example ban.js, what can I do?

outer perch
#
function getUserFromMention(mention) {
    if (!mention) {
        return message.reply('no mention!').then(msg => msg.delete({ timeout: 5000 })).catch(err => { console.error(err); });
    }

    const matches = mention.match(/^<@!?(\d+)>$/);
    if (!matches) return;
    const id = matches[1];
    return bot.users.cache.get(id);
    }

const mention = getUserFromMention(args[0]);
const memberToMute = message.guild.member(mention);
let muteRole = message.guild.roles.cache.find(role => role.name === 'Muted');

memberToMute.roles.add(muteRole)
``` @main trench I have this
main trench
#

ill try the role code thanks

north birch
#

So wait im confused, @lusty quest how should i make that table?

lusty quest
#

@balmy knoll you can attach the DB to your client or import it

#

¯_(ツ)_/¯

#

would have to think about it myself first too

balmy knoll
#

Sorry, but I didn't quite understand. Could you explain it better?

pale vessel
#

@outer perch why not just const memberToMute = message.guild.member(args[0].replace(/<@!?|>/g, "")) or something? you made a whole function for that

north birch
#

would have to think about it myself first too
@lusty quest I think i the filter will not work

lusty quest
#

if you make your DB connection somewhere you can call the connection in other files too with requiring the Model

north birch
#

Oh wait

#

I have an idea

main trench
#

dang same error

#

its strange since mute.js didnt give me this problem

crimson vapor
#

@pale vessel why did you change your name?

pale vessel
#

because h

crimson vapor
#

oh

#

h p cool

eternal osprey
#

hey guys

outer perch
#

@outer perch why not just const memberToMute = message.guild.member(args[0].replace(/<@!?|>/g, "")) or something? you made a whole function for that
@pale vessel I grabbed it from somewhere and didn't even think about that

eternal osprey
main trench
#

you may have to log it in a db

crimson vapor
#

did hastebin change their colors?

eternal osprey
#

i basically want to save the coordinates from the first message, so i can compare it to the coordiates in the new message (2nd message of the picture)

lusty quest
#

would remove request its outdated now for a while

eternal osprey
#

owh really?

lusty quest
#

yes its deprecated

eternal osprey
#

owh i am not even using it

#

i dont even know why that module is defined in my project.

lusty quest
#

why also cheerio? did you want to scrape a website?

eternal osprey
#

no i forgot to delete them.

outer perch
#

guys I have a problem with fonts

lusty quest
#

so you want to save a coordinate temporary?

eternal osprey
#

yeah exactly.

lusty quest
#

use a Database

outer perch
#

I have Comic Sans font stored in my bot

north birch
#

What if i do something like this @lusty quest

Equip command:

 if(userWeapons == 'Weapon1') {
message.channel.send('You equipped Weapon1');
 if(isSomethingEquipped === true) {return message.channel.send(Somethingh is already equipped')};
db.set(${message.author.id}_equippedweapon, 'Weapon1');
equipweap = db.fetch(${message.author.id}_equippedweapon)
const filtro = weap;
const newinv = filtro.filter(weap => weap!= equippedweapon);
db.set(${message.author.id}_weapon, newinv)}
else {
if(userWeapons2 == 'Weapon1') { 
message.channel.send('You equipped Weapon1');
 if(isSomethingEquipped === true) {return message.channel.send(Somethingh is already equipped')};
db.set(${message.author.id}_equippedweapon, 'Weapon1');
equipweap = db.fetch(${message.author.id}_equippedweapon)
const filtro = weap;
const newinv = filtro.filter(weap => weap!= equippedweapon);
db.set(${message.author.id}_weapon, newinv)}
else {
           message.channel.send('You dont own this weapon, please buy it')
            }```

And set in the buy command that if you already own tthe weapon you're trying to buy create a table and set it as userWeapon2?
lusty quest
#

just overwrite it every time you update

eternal osprey
#

can't i just use json and store the lat1 and lng1 in the database?

#

using fs to write?

outer perch
#

I have Comic Sans font stored in my bot
both the online version and the pc version (dev.) read those .ttfs

lusty quest
#

json got issues with heavy writes

#

it will get corrupted fast

outer perch
#

but the online shows the font way more narrow than the offline

eternal osprey
#

but am i heavy writing?

#

i am only saving 2 variables

#

that change every 20s.

lusty quest
#

thats relatively heavy writing for a json file lol

outer perch
#

forget I guess I can fix it

earnest phoenix
#

Hello please help me. I want to make that when a member adds a reaction to the bot’s message, give the member a role.
Script:

        message.channel.send(allarg).then(function(message){
            message.react('🎰')
        })```
lusty quest
#

there are 2 ways. listen to the reaction_add event or use a collector

earnest phoenix
#

How to use collector?

lusty quest
#

with the downside it works not permanently

#

if you want it to work permanently use the event and make sure to store atleast the id of your react message -> to load it into the cache it after a reboot

earnest phoenix
#

eh

#

i don't know

#

i don't understand

lusty quest
#

the message_react event will fire everytime someone reacts. you can make it this way that it will give someone a role if someone uses a certain reaction on a certain message

earnest phoenix
#
    if(command === 'new'){
        if(!message.author.id == 500933509859246100)return;
        message.delete({timeout: 0});
        message.channel.send(allarg).then(function(message){
            message.react('🎰')
        })
    }```
#

the command*

main trench
#

alright new error im making a create channel command and this is the code message.guild.channels.create(name, {type: text}) and this is the error i get text is not defined

lusty quest
#

message.guild.channels.create(name, {type: `text`}) try this

#

notice the string?

main trench
#

ahh forgot that lmao

earnest phoenix
#

@lusty quest message.reactions.cache.get(':slot_machine:').users
If i use that, it works?

lusty quest
#

try and see

main trench
#

hmm new error (node:17936) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body
name: This field is required

earnest phoenix
#

but i can't see

lusty quest
#

name needs to be a string

#

guild.channels.create('new-channel', { type: 'text', permissionOverwrites: permissionOverwriteArray, reason: 'New channel added for fun!' });

earnest phoenix
#

message.guild.channels.create('name')

main trench
#

hmm

earnest phoenix
#

no?

#

i used this

main trench
#

ill try it

earnest phoenix
#

not good?

#

wtf

lusty quest
#

he wants to define if its a Text or voice channel

earnest phoenix
#

oh

main trench
#

now it just makes a channel called "name" hmm trying to make it work like *create text [specified name]

lusty quest
#

pass the string from the command to the function

earnest phoenix
#
message.guild.channels.create('name', {
  type: 'voice or text',
  permissionOverwrites: [
     {
       id: message.author.id,
       deny: ['VIEW_CHANNEL'],
    },
  ],
});```
#

try this

lusty quest
#

he wants to make a command to creat channels

earnest phoenix
#

it is

lusty quest
#

but the passing of the name for the channel is flaky

main trench
#

unless i do '${args[2]}' that could work

#

also yes i know its supposed to be `` but discord text is weird

lusty quest
#

args[2].toString() doesnt work?

main trench
#

i havet given that a shot yet trying other options first

lusty quest
#

"" or `` or '' defines a string in js

main trench
#

Cannot read property 'toString' of undefined hmm

lusty quest
#

well

main trench
#

tricky

lusty quest
#

console.log(typeOf(args[2])) what is the output?

earnest phoenix
lusty quest
#

?

boreal iron
#

<add.reaction>

earnest phoenix
#

add role***

lusty quest
#

you add the reaction in the step before it?

earnest phoenix
#

add role

lusty quest
earnest phoenix
#

Thanks

#

I know its basic djs lmao

lusty quest
#

sure but this is a link directly to the how to add roles article

#

like one of my teachers said once. You dont need to know everything, you just need to know where its written

mellow pecan
#

im using the official dbm

lusty quest
#

install discord.js v12?

#

also i would suggest asking in the DBM discord

mellow pecan
earnest phoenix
#

like one of my teachers said once. You dont need to know everything, you just need to know where its written
veryfastpats

lusty quest
#

they can help you better

earnest phoenix
#

I bought DBM ~ a year ago xdd

#

(i dont use that)

lusty quest
#

i used it when i started. but after 3 weeks i hit the limitations of the software

#

then i learned js in 2 weeks

#

now i have a bot with about 300 guilds using it and started to learn C# bcs ive got bored

earnest phoenix
#

huh

#

im learninig C# now

#

but i wanna make a bot for my server

lusty quest
#

write it in C#?

earnest phoenix
#

huh

#

js is better

lusty quest
#

C# is multi threaded js is single threaded

main trench
#

Aight so "args[2]" didn't work so now I'm out of ideas might need to save this for a later project

lusty quest
#

what does the print i gave you output?

main trench
#

It makes a channel called "name"

#

Wait

#

No ok the toString code gave me a error

#

Saying toString is not a function

earnest phoenix
main trench
#

You need to specify users

earnest phoenix
#

?

lusty quest
#

not the to String code

#

the typeOf code

earnest phoenix
#

provide an id

main trench
#

I'm adding the type of code now

eternal solstice
#

how can i tag a user

earnest phoenix
#

@eternal solstice

#

uhm

lusty quest
#

if it is a string you should be able to just use the variable

earnest phoenix
#

hhelp?

eternal solstice
#

im still learning how to code a disc bot

#

and need help with a code

earnest phoenix
#

You need to specify users
@main trench lel how?

#

oh what language and library

eternal solstice
#

node

#

stable

earnest phoenix
#

wot

eternal solstice
#

i guess

lusty quest
#

eris or d.js?

eternal solstice
#

js

lusty quest
#

both are js

eternal solstice
#

discord.js

main trench
#

@earnest phoenix you can do either const users = however you have users to be specified or let users = the same thing as in const

stark abyss
#
  message.channel.messages.fetch()
    .then(messages => console.log(`${messages.filter(m => m.author.id === '673362753489993749').first().content} messages`))
    .catch(console.error);```
how do I get the content for all messages not just first()
How do I map this? ![PepeThinkSmart](https://cdn.discordapp.com/emojis/773274017016315905.webp?size=128 "PepeThinkSmart")
eternal solstice
#

any ideas about kick/ban commands

earnest phoenix
#

im making a mute command with a duration parameter

#

when someone is muted, a new thread is ran that counts down the duration, then they're unmuted

#

is that a reasonable way to do this?

eternal solstice
#

whats the difference between let and const

earnest phoenix
#

@earnest phoenix im not asking to be spoon fed

lusty quest
#

@earnest phoenix language?

earnest phoenix
#

jas

#

*js

#

@earnest phoenix Not for u

eternal solstice
#

@earnest phoenix ty

lusty quest
#

use a timer or use the cron module

earnest phoenix
#
setTimeout(function() {
  // unmute
), muteduration}```
#

is this a bad way to do it

lusty quest
#

but this will only work non persistant if you restart it will not contunou

#

@earnest phoenix lol thats not spoonfeeding

#

@earnest phoenix yes

earnest phoenix
#

then whats a good way

#

ik

#

?

main trench
#

message.guild.channels.create(args.slice(2).join(" "), {type: 'text'}) this worked better then the rest but i got this error (node:1220) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body
name: This field is required
oh and the typeOf code threw an error if your gonna ask about that

lusty quest
#

i like to use a database and set there a timestamp in the future. then i have a timer running that checks every 5-10 minutes if the timestamp is reached

vale garden
#

heyo

lusty quest
#

yea it doesnt recocnize the value as string

earnest phoenix
#

how would u check something 5-10 minutes

#

only js delay method i know is settimeout

lusty quest
#

start a timer when the bot starts

earnest phoenix
#

but that runs in a new thread

lusty quest
#

yea

earnest phoenix
#

start the timer using what

lusty quest
#

delay

earnest phoenix
#

what

#
embed.addField(`Ad`, bilgi(body > table > tbody > tr:nth-child(1) > td:nth-child(1) > a).text())

: sign is showing as an error. how do i fix them?

lusty quest
#

i have a delay running that resets itself after the check is done

earnest phoenix
#

i cant find a function called delay

lusty quest
#

setTimeout(function2, 3000);

vale garden
#

what is the : doing there

earnest phoenix
#

setTimeout(function2, 3000);
@lusty quest you just said that was a bad method

#

@vale garden

lusty quest
#

the difference is that i use a Database for the end of the Punishment

#

if you use it directly for it the timer will not continou after a restart

earnest phoenix
#

oh yeah

#

so like if u update ur bot

#

ok

#

but

#

settimeout runs in a new thread, so how would i find out when that delay is over

#

im new to asynchronous programming so im not sure how you do these things

vale garden
#

i still dont understand what that : is

earnest phoenix
#

its how u call methods in some languages

lusty quest
#

thats easy. make a async function and inside of it you await the timeout

stark abyss
#
  message.channel.messages.fetch()
    .then(messages => console.log(`${messages.filter(m => m.author.id === '673362753489993749').first().content} messages`))
    .catch(console.error);```
how do I get the content for all messages not just first()
How do I map this? ![PepeThinkSmart](https://cdn.discordapp.com/emojis/773274017016315905.webp?size=128 "PepeThinkSmart")
earnest phoenix
#
for(i; i<5; i++){ $.doTimeout(5000,function(){

return false;}, true);}```
#

i found this on google

#

should i use this

lusty quest
#
async function timeout(){
await setTimeout(3000)
//do what you want when its done
}
earnest phoenix
#

wait

stark abyss
#

and then put that in for loop i think

earnest phoenix
#

THATs what await does

#

ok

lusty quest
#

await let the code wait until the function that is called with it is done. usually you need it for Database Calls and API calls

stark abyss
#

superbrain 8 can you help me?

lusty quest
#

idk havent really looked into this stuff

stark abyss
#

ok thx anyway

lusty quest
#

or try map(messages => messages.content

stark abyss
#

oh ok

lusty quest
#

instead of first()

earnest phoenix
#

huh

lusty quest
#

the error?

earnest phoenix
lusty quest
#

its not needed

earnest phoenix
#
async function Delay(time) {
    setTimeout(() => { //creates new thread
        while(true) {
            await setTimeout(() => {}, time);
            // if they're mute time is over than unmute, and break the loop

        }
    },0)
}```
vale garden
#

huh

earnest phoenix
#

so like this? @lusty quest

lusty quest
#

but goot practise

earnest phoenix
#

delete that

vale garden
#

semicolon isnt necessary in js

#

it doesnt matter

lusty quest
#

ohh wait yea its on the wrong position

earnest phoenix
#

u see what i mean now

north birch
#

@lusty quest Once i setted the db table, how i fetch it?

vale garden
#

lol

earnest phoenix
#

super is that a reliable way to do that?

#
async function Delay(time) {
    setTimeout(() => { //creates new thread
        while(true) {
            await setTimeout(() => {}, time);
            // if they're mute time is over than unmute, and break the loop, and return the function

        }
    },0)
}```
vale garden
#

@north birch what do you use for the db

lusty quest
#

like i said i prefer to store a timestamp that is in the future in a database and check every 5-10 minutes if the timestamp is now or in the past

vale garden
#

quick.db, mongo, sql or wat

earnest phoenix
#

yeah ik

north birch
#

@north birch what do you use for the db
@vale garden quick.db

earnest phoenix
#

but for the check

#

time check

#

is that a good way to do it

#

read the notes

lusty quest
#

@earnest phoenix did you removed the ; in the line before the setUrl?

vale garden
#

@vale garden quick.db
@north birch you do db.get(<key>)

north birch
#

Yeah but how to get the data that's inside the table?

lusty quest
#

@north birch idk never used quick.db

north birch
#

@north birch idk never used quick.db
@lusty quest Ripp

vale garden
#

Yeah but how to get the data that's inside the table?
@north birch do you mean all data

north birch
#

@north birch do you mean all data
@vale garden No once you create a new .table

lusty quest
#

and it still errors out?

north birch
#

How to get the data from that table

vale garden
#

for that do db.all()

earnest phoenix
#

@lusty quest but the delay will still end if the js script is paused

north birch
#

for that do db.all()
@vale garden i'll try, ty!

earnest phoenix
#

therefore rendering even a database unreliable

vale garden
#

kk

#

this might be useful

#

@north birch

lusty quest
#

yes but if you store the time stamp in a database it will still check every 5-10 minutes if there is a timestamp now or in the past

#

it doesnt matter if the bot went offline

earnest phoenix
#

uhh

#

dont know what that means

#

ill just use my original method

lusty quest
#

ok

earnest phoenix
#

wait ill just make a new bot that has only the mute

#

that should work

#

so it wont need to be updated

eternal solstice
#

how can i tag a user oliypls

earnest phoenix
#

channel.send(`@${member.displayName}`)

lusty quest
#
User Muted -> Create a Timestamp with current date + Punishment Length -> Save the timestamp in my DB with a way to find it -> Start a Timer that checks when it hits 0 If a Timestamp in the Database is now or in the past 
If yes -> Lift punishment; restart timer
if No -> restart timer
``` @earnest phoenix this is how i do it
#

the timer that checks for the timestamps starts when the bot starts

north birch
#

(node:1228) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'all' of undefined
@vale garden Uhm

vale garden
#

it should work

main trench
#

so turns out args[2] was supposed to be args[1] thats why i got so many errors lmao

lusty quest
#

gg

earnest phoenix
#

Lol

vale garden
#

unless you havent defined db or something

silver lintel
#
let fetched;
        do {
          fetched = await message.channel.messages.fetch({ limit: 100 });
          try {
            await message.channel.bulkDelete(fetched);
          } catch (err) {
            message.channel.send("The messages in this channel are too old for me to delete");
            break;
          }
        } while (fetched.size >= 2);
        message.channel.send("✅ | Successfully deleted all the messages in <#" + message.channel + ">")
        .then(msg => msg.delete({ timeout: 3000 }));
``` how do i do it so the message.channel.send("✅ | Successfully deleted all the messages only comes after the do while loop
vale garden
#

anyways gtg bye

lusty quest
#

you know that every array starts at 0

earnest phoenix
#

^^^

lusty quest
#

@silver lintel await the loop when its done send the message

earnest phoenix
#

Someome knows discord.js and is in to make a bot?

#

Last time I worked with a complete noob

#

🤣

lusty quest
#

i have a few bots already running and do here and there some small updates. now i write a API in js and then i write a bot in C#

north birch
#

What did i do wrong?

Set up
var weapons2 = new db.table('weapons2')

Get
var weapons2 = weapons2.all()

@vale garden

lusty quest
#

you overwrite your weapons2 value with something else

#

also dont use var. var is deprecated and only there to keep old scripts working

north birch
#

So i need to do:

var weap2 = weapons2.all()

lusty quest
#

would recommend to use const for stuff you dont want to be overwritten

#

yes

north birch
#

alright

lusty quest
#

and let for stuff you want to overwrite

earnest phoenix
#

@silver lintel However, your success message will be: ✅ | Successfully deleted all messages in <##development >

restive furnace
#

i have a few bots already running and do here and there some small updates. now i write a API in js and then i write a bot in C#
you mean like you test on js, and then you make it in c# for production? if this is what you meant, many of c# bot devs do so and i wonder why 🤔

earnest phoenix
#

message.channel already mentions the channel if im right

lusty quest
#

no i wrote now a few Bots in JS and started to learn C# a few weeks ago

#

bcs ive got bored

restive furnace
#

ah ok

lusty quest
#

@earnest phoenix it does but adding the tag is for making sure since not everything parses the channel object to a mention

earnest phoenix
#

O...

#

i need help with pymongo

north birch
#

(node:428) UnhandledPromiseRejectionWarning: ReferenceError: weapons2 is not defined

Ah this b1tch

earnest phoenix
#

how i can get specific value from user id

#

like

#

users sarma

#

@north birch Please dont say those words

#

how much sarma he has

#

and u didnt defined weapons2

north birch
#

@north birch Please dont say those words
@earnest phoenix Sorry

earnest phoenix
#

U gotta define it

#

yes

#

can you read errors?

#

Im talking to @north birch

#

me too

#

O

#

Loool

#

ye

north birch
#

and u didnt defined weapons2
@earnest phoenix i did:

var weapons2 = new db.table('weapons2')

earnest phoenix
#

errors are helpful

#

where did you define it

#

Ye

#

under it?

#

🤣

north birch
#

Nope lmao im not that noob

earnest phoenix
#

i am not noob too and i made database in txt file

restive furnace
#

new db.table(...) doesn't seem right in my eyes

earnest phoenix
#

Send your code in a bin

#

He

#

ye

#

maybe its a thing

north birch
#

I need to take the table that is defined in another command, idk how to do this

earnest phoenix
#

wich db ur using?

north birch
#

quick.db

earnest phoenix
#

Oo

restive furnace
#

then its only db.table() iirc

earnest phoenix
#

Ye

#

without new

north birch
#

Trying rn

earnest phoenix
#

guys i need help with pymongo

north birch
#

Uhm so..now all data is getting fetched by that table

#

So uhm..not working?

limber flume
#

guys i need help with pymongo
@earnest phoenix I can help you!

#

I am very familiar with it

earnest phoenix
#

thanks

limber flume
#

What’s wrong

earnest phoenix
#

so i am new to pymongo

limber flume
#

ah yes

earnest phoenix
#

and i want to make format like

limber flume
#

Py mongo is great I use it personally

earnest phoenix
#

user_id : amount_of_sarmas

limber flume
#

yes

earnest phoenix
#

and i want to store it like that

limber flume
#

you would have to insert the user into the collection you have made and then update it with user_id and the sarams

#

What is Sarams please ?

earnest phoenix
#

bosnian food in this case currency

limber flume
#

Oh nice 👍

earnest phoenix
#

so i do something like this?

#

post = {"_id": ctx.author.id, "sarma": 1}
collection.insert_one(post)

limber flume
#

well kinda yes... but there is easier way

#

I can show u

earnest phoenix
#

yes

#

show

limber flume
#

2 mins I’m on mobile XD

earnest phoenix
#

ok xd

eternal solstice
#

i made a kick command

#

but everybody can kick

#

even if they dont have perm to kick

limber flume
#
query = {"_id": user.id}
r = collection.find(query)
for result in r:
    #code here for inserting Saram
#

@earnest phoenix

#

even if they dont have perm to kick
@eternal solstice I can help

#

Use the following:

eternal solstice
#

ok ty

earnest phoenix
#
query = {"_id": user.id}
r = collection.find(query)
for result in r:
    #code here for inserting Saram

@limber flume is this for storing or getting?

limber flume
#

@command.has_permission(perm_name=True)

#

@limber flume is this for storing or getting?
@earnest phoenix well what this does is finds the user and then after that u can do whatever

earnest phoenix
#

so i can get users amount of sarmas?

limber flume
#

Yes if you do this

earnest phoenix
#

YES

#

thanks

limber flume
#

2 sec

eternal solstice
#

i want to change role by permission

limber flume
#
query = {"_id": ctx.author.id}
r = collection.find(query)
for result in r:
    user_saram = result["saram"]
     await ctx.send(user_saram)
#

@earnest phoenix

earnest phoenix
#

sarma

limber flume
#

@limber flume it was set to this
@eternal solstice oh your using JavaScript

eternal solstice
#

yeah

earnest phoenix
#

thanks

#

but what if i want to give them +1 sarma

#

i get number of sarmas and add 1 to it

#

and save

#

how to do it

limber flume
#

Can you not use member.roles.cache.has('role ID'); @eternal solstice

#

how to do it
@earnest phoenix let me show u

eternal solstice
#

what do i replace it with

limber flume
#

The role is

#

ID*

eternal osprey
#
 function calcCrow(lat1, lng1, lat2, lng2) 
    {
      var R = 6371; // km
      var dLat = toRad(lat2-lat1);
      var dLon = toRad(lng2-lng1);
      var lat1 = toRad(lat1);
      var lat2 = toRad(lat2);

      var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
        Math.sin(dLon/2) * Math.sin(dLon/2) * Math.cos(lat1) * Math.cos(lat2); 
      var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 
      var d = R * c;
      return d;
    }

    // Converts numeric degrees to radians
    function toRad(Value) 
    {
        const lastcoordinate = Value * Math.PI / 180;
    }
          let text = `**${name}**` + "\n"
                      + `**${raid.gym_name}**` + "\n"
                      + `*${lat1}, ${lng1}*` + "\n"
                      + `**Raid level: **${raid.level}  |  **Pokemon Cp: **${raid.cp}\n`
                      + `**Distance From Last Raid: **${lastcoordinate}` + "\n"
                      + `**Egg Spawn Time: ** ${getFormattedTime(raid.raid_spawn)}\n`
                      + `**Raid Start Time: **${getFormattedTime(raid.raid_start)} | **Raid End Time: **${getFormattedTime(raid.raid_end)}\n`
                      ``` lastcoordinate is not defined
#

pretty sure it is

earnest phoenix
#
query = {"_id": ctx.author.id}
r = collection.find(query)
for result in r:
    user_saram = result["saram"]
     await ctx.send(user_saram)

@limber flume this works thanks

quartz kindle
#

@eternal osprey you defined it inside a function

#

its not gonna be defined anywhere outside that function

#

also the function is not returning anything

eternal osprey
#

how should i fix that?

#

yeah i ssee

#

i forgot to define value

#

it should be d

#

sean what are you trying to type brother?

#

you have been typing for straight 20 minutes

limber flume
#
query = {"_id": ctx.author.id}
r = collection.find(query)
for result in r:
    user_saram = result["saram"]
    added_saram = int(1) + user_saram
collection.update_one({"_id": ctx.author.id}, {"$set": {"saram":  added_saram}})
     await ctx.send(f"I have added {added_saram} to your saram")

@earnest phoenix

#

Sorry if indentation is bad I’m on mobile

earnest phoenix
#

oh you use update_one()

slender thistle
#

What are you trying to do

limber flume
#

Yeah !

earnest phoenix
#

thank you

slender thistle
#

why the unnecessary int(1)

limber flume
#

well just idk 🤷‍♀️

#

Lol

#

Looks nicer ig

slender thistle
#

No it doesn't

limber flume
#

Bruh don’t bully I’m on mobile

earnest phoenix
#

i am using pymongo because i was dumb and made database in txt file

slender thistle
#

Also you could use find_one

limber flume
#

It was really hard doing that

#

not if I can use collection.find()

#

works the same way

#

...

earnest phoenix
#

sean way is better i think

limber flume
#

Maybe not the int()

#

but it still works

slender thistle
#

.find can return multiple documents as opposed to .find_one

limber flume
#

No?

#

when I’m finding the query of the authors I’d lmao

slender thistle
#

Maybe not in this case

limber flume
#

yes

upper elm
#

can I recieve vote updates for my bot without a webhook?

slender thistle
#

Oh.well

upper elm
#

idrk how they work

slender thistle
#

You do you

limber flume
#

python ?

slender thistle
#

can I recieve vote updates for my bot without a webhook?
@upper elm no

upper elm
#

oof ok

#

thx

earnest phoenix
#

how do i code a bot?

slender thistle
#

Webhooks are exactly what receives the vote requests

earnest phoenix
limber flume
#

how do i code a bot?
@earnest phoenix really

earnest phoenix
#

no

limber flume
#

Your green name

earnest phoenix
#

im kidding lol

limber flume
earnest phoenix
#

i need to verify my bot

#

its stuck on 250 servers

limber flume
#

Ez

earnest phoenix
#

limit Sadge

limber flume
#

just verify it

#

lol

slender thistle
earnest phoenix
#

@limber flume how i can add user to database if he isnt in it?

#

how can i check if user is in the database

#

like

eternal solstice
earnest phoenix
slender thistle
#

This is where spoonfeeding gets you

#

nowhere

eternal osprey
#

i still have no clue how to define my lastcoordinate globally:

#
  function calcCrow(lat1, lng1, lat2, lng2) 
    {
      var R = 6371; // km
      var dLat = toRad(lat2-lat1);
      var dLon = toRad(lng2-lng1);
      var lat1 = toRad(lat1);
      var lat2 = toRad(lat2);

      var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
        Math.sin(dLon/2) * Math.sin(dLon/2) * Math.cos(lat1) * Math.cos(lat2); 
      var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 
      var d = R * c;
      return d;
      function toRad(Value) 
    {
        const lastcoordinate = Value * Math.PI / 180;
    }}
    

    
          let text = `**${name}**` + "\n"
                      + `**${raid.gym_name}**` + "\n"
                      + `*${lat1}, ${lng1}*` + "\n"
                      + `**Raid level: **${raid.level}  |  **Pokemon Cp: **${raid.cp}\n`
                      + `**Distance From Last Raid: **${lastcoordinate}` + "\n"
                      + `**Egg Spawn Time: ** ${getFormattedTime(raid.raid_spawn)}\n`
                      + `**Raid Start Time: **${getFormattedTime(raid.raid_start)} | **Raid End Time: **${getFormattedTime(raid.raid_end)}\n`
                      
          let msg = await message.channel.send(text);```
sudden geyser
#

how do i actually set it to the main reason
@eternal solstice your code looks correct. What is wrong with it?

eternal solstice
#

thats what it says

eternal osprey
#

you have to define an args to it,

#

now it will just display the text you put in

#

you want to have something like !kick @fair rover reason right?

main trench
#

to remove a channel would message.guild.channels.remove(channel) work?

eternal solstice
#

@eternal osprey yes

eternal osprey
#

@main trench no

sudden geyser
#

@main trench then what is wrong with it?

eternal osprey
#

if i am not wrong you have to use cache.

#

right?

sudden geyser
#

no

eternal osprey
#

i am not sure tbh

#

shouldn't it?

sudden geyser
#

Think of the cache only for getting stuff

eternal solstice
#

any solution

eternal osprey
#

aha sorry then!

#

@eternal solstice define an args to it. let that be the reason.

eternal solstice
eternal osprey
#

and in the text, add the variable like args2 there

eternal solstice
#

it just keeps spamming this

#

for some reason

sudden geyser
#

@main trench you need to get the channel then call the delete method (<GuildChannel>.delete()).

earnest phoenix
#

Hello! So I'm thinking of a new bot that I wanna make, but I would like to make with someone.

If someone is intrested, knows discord.js (Can read errors, code shit etc) and is experienced dm me.

main trench
#

@eternal solstice change your code so instead of it saying "Optional reason..." specify reason then do
.ban({reason: reason})

eternal osprey
#

but in v12 it shouldbe js const fetchedChannel = message.guild.channels.cache.get(channel_id); fetchedChannel.delete();

sudden geyser
#

guild.channels.cache.get(...) returns a GuildChannel, then you can call .delete() on it.

eternal osprey
#

or am i stupid

sudden geyser
#

yeah that's correct

eternal osprey
#

wait it is the same of waht you just said,.

#

nevermind

eternal solstice
#

@main trench im using Javascript

earnest phoenix
#

<guild>.<member>.ban({ reason: <reason>})

#

I think its something like this

main trench
#

@eternal solstice i am too

earnest phoenix
#

for ban reason

main trench
#

<guild>.<member>.ban({ reason: <reason>})
yeah thats how it works

earnest phoenix
#

and u can also add days ofc

eternal osprey
#
function calcCrow(lat1, lng1, lat2, lng2) 
    {
      var R = 6371; // km
      var dLat = toRad(lat2-lat1);
      var dLon = toRad(lng2-lng1);
      var lat1 = toRad(lat1);
      var lat2 = toRad(lat2);

      var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
        Math.sin(dLon/2) * Math.sin(dLon/2) * Math.cos(lat1) * Math.cos(lat2); 
      var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 
      var d = R * c;
      return d;
      function toRad(Value) 
    {
        const lastcoordinate = Value * Math.PI / 180;
    }}
    

    
          let text = `**${name}**` + "\n"
                      + `**${raid.gym_name}**` + "\n"
                      + `*${lat1}, ${lng1}*` + "\n"
                      + `**Raid level: **${raid.level}  |  **Pokemon Cp: **${raid.cp}\n`
                      + `**Distance From Last Raid: **${lastcoordinate}` + "\n"
                      + `**Egg Spawn Time: ** ${getFormattedTime(raid.raid_spawn)}\n`
                      + `**Raid Start Time: **${getFormattedTime(raid.raid_start)} | **Raid End Time: **${getFormattedTime(raid.raid_end)}\n`
                      
          let msg = await message.channel.send(text);``` sorry for the long code. My lastcoordinate is undefined as it is only declared in the function. How do i define it so, that i can use it in the text under it?
eternal solstice
#

thanks it worked

#

oh god

#

@main trench can you help me with the code

#

the code im currently using

#

is a mess

main trench
#

sure

eternal solstice
#

thanks

fair rover
#

I keep getting pinged

earnest phoenix
#

@eternal osprey lastcoordinate must be defined at the very start of the function then when the toRad function is invoked, modify it's value

eternal osprey
#

my bad

#

i am trying to show examples so i can help others

#

so i use @,,,,,,user,,,,, as an example,

#

huh @earnest phoenix

#

should it be defined at the start of function calCrrow or toRad

#

toRad right

earnest phoenix
#
function calcCrow(lat1, lng1, lat2, lng2) {
let lastcoordinate;
function toRad(value) {
lastcoordinate = value * Math.PI / 180;
}
// Rest of the code here
}```
novel bobcat
#

sa

eternal osprey
#
 function calcCrow(lat1, lng1, lat2, lng2) {
      let lastcoordinate;
      function toRad(Value) 
      {
          var lastcoordinate =  Value * Math.PI / 180;
          
      }
      var R = 6371; // km
      var dLat = toRad(lat2-lat1);
      var dLon = toRad(lng2-lng1);
      var lat1 = toRad(lat1);
      var lat2 = toRad(lat2);

      var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
        Math.sin(dLon/2) * Math.sin(dLon/2) * Math.cos(lat1) * Math.cos(lat2); 
      var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 
      var d = R * c;
      return d;
      
    }``` like this?
#

and then i can call the distance using d

earnest phoenix
#

"var lastcoordinate"

#

Why

eternal osprey
#

const*

earnest phoenix
#

We're modifying the value of the first variable not making another variable with the same name

#

Remove var

eternal osprey
#

okay

#

so i will only leave: lastcoordinate = Value * Math.PI / 180;

earnest phoenix
#

Yes

eternal osprey
#

okay

#

and i should call using the variable lastcoordinate right

limber flume
#

@limber flume how i can add user to database if he isnt in it?
@earnest phoenix make a check if the user is not there

#

for example:

eternal osprey
#

it still returns undefined tho?

drifting wedge
#

How would I go over every server my bot is in, and add it to a database?

#

Like how would I do stuff for every server

slender thistle
#

library, database?

drifting wedge
#

For servers In client.servers

#

Py, mongo

limber flume
#
async def _has_account(self, user_id: int) -> None:
     return bool(collection.find_one(
            {"_id": user_id}
        ))

Then at the start of your command you would do:


if not (await self._has_account(ctx.author.id)):
    #make user account 

@earnest phoenix

drifting wedge
#

I got the adding part

#

But I’d need the id

slender thistle
#

@modern sable see above

limber flume
#

UHM

drifting wedge
#

It’s a scam

limber flume
#

Moderators ?

modern sable
#

ty

drifting wedge
#

@green kestrel

#

Fake steam link

#

It’s a scam

#

Legit

modern sable
#

late

drifting wedge
#

O ok

#

Lol

slender thistle
#

But I’d need the id
@drifting wedge suggest you store it as a string, guild.id

drifting wedge
#

Ye

limber flume
#

Sorry if my indentation is bad I’m on mobile

drifting wedge
#

But how would I do stuff for every server?

slender thistle
#

client.guilds consists of Guild objects

#

use a for-loop

limber flume
#

yes ^

drifting wedge
#

For guilds in client,guilds

#

.id

#

Guilds, get Guild I’d?

slender thistle
#

Name your variables properly ty

earnest phoenix
#

@limber flume thanks but i did this

u = ctx.message.author.name
user = "**" + u + "**"
query = {"_id": ctx.author.id}
r = collection.find(query)
unameQuery2 = collection.find()
a = 0
if ctx.author.id in unameQuery2:
    print("evea")
for result in r:
    print(result)
    print("proje")
    a = a +1
    user_sarma = result["sarma"]
    added_sarma = 1 + user_sarma
    collection.update_one({"_id": ctx.author.id}, {"$set": {"sarma":  added_sarma}})
    await ctx.send(user + f" je ukupno napravio {added_sarma} sarmi.")
if a == 0:
    post = {"_id": ctx.author.id, "sarma": 1}
    collection.insert_one(post)
    await ctx.send(user + f" je ukupno napravio {added_sarma} sarmu.")

@client.command()

limber flume
#

:o

#

lol ok

wicked pivot
#

Hi, I don't know how to explain it but I would like to kind of put a number of _ but every time I place the command the number of _ changes how can I do that?

limber flume
#

Very messy but should work

earnest phoenix
#

i just check if for result in r did

#

yes

#

welcome to my codes

limber flume
#

ok just ping me if u need more help

eternal osprey
#

uhh i might need some help?

#

if possible

earnest phoenix
#

ok thanks

slender thistle
#

ps spoonfeeding is bad and doesn't help much

eternal osprey
#

who's?

#

anyways: ```js
function calcCrow(lat1, lng1, lat2, lng2) {
let lastcoordinate;
function toRad(Value)
{
lastcoordinate = Value * Math.PI / 180;

  }
  var R = 6371; 
  var dLat = toRad(lat2-lat1);
  var dLon = toRad(lng2-lng1);
  var lat1 = toRad(lat1);
  var lat2 = toRad(lat2);

  var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
    Math.sin(dLon/2) * Math.sin(dLon/2) * Math.cos(lat1) * Math.cos(lat2); 
  var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 
  var d = R * c;
  return d;
  
}



      let text = `**${name}**` + "\n"
                  + `**${raid.gym_name}**` + "\n"
                  + `*${lat1}, ${lng1}*` + "\n"
                  + `**Raid level: **${raid.level}  |  **Pokemon Cp: **${raid.cp}\n`
                  + `**Distance From Last Raid: **${lastcoordinate}` + "\n"
                  + `**Egg Spawn Time: ** ${getFormattedTime(raid.raid_spawn)}\n`
                  + `**Raid Start Time: **${getFormattedTime(raid.raid_start)} | **Raid End Time: **${getFormattedTime(raid.raid_end)}\n`
                  ``` my lastcoordinate is still undefined. I followed the instructions of voltrex master but it did not end well.
earnest phoenix
#

anyone know why its sending thrice?

#

and i deleted that command and saved

#

my new code is module.exports = { name: "ping", description: "Pinging the bot", execute(client, message) { message.channel.send(`🏓Latency is ${Date.now() - message.createdTimestamp}ms. API Latency is ${Math.round(client.ws.ping)}ms`); } };

#

anyone?

#

rip

#

u got multiple instances on

#

Thats why it responds many times

#

wdym

#

u got multpile times ur bot running

#

i changed it...

#

like that?

#

i'm not very good at coding...

#

how

#

im out of here

#

oof

#

Jk

#

K

#

The thing is

#

you started your bot multiple times

#

😮

#

Because u used " for text

#

the command wont work

#

it will litterly send your code

#

i used singular quotations...

#

🏓Latency is ${Date.now() - message.createdTimestamp}ms. API Latency is ${Math.round(client.ws.ping)}ms

#

this is what it will send

#

message.channel.send(':ping_pong:Latency is ${Date.now() - message.createdTimestamp}ms.');

#

not like:

crimson vapor
#

use ` not '

#

lol

earnest phoenix
#

o ok

#

ye

#

so `

crimson vapor
#

` is the key right next to the 1 key

earnest phoenix
#

got it

#

ye

#

ik

#

K

#

now restart visual studio code

#

and put your bot back on

#

yes

#

since i dont think you know how to close a terminal

crimson vapor
#

ctrl c

earnest phoenix
#

yes.. but he already has 3 opend

#

😂

#

oHHHH

#

thats why

bold condor
earnest phoenix
#

its giving an error

#

Did you deleted the channel?

#

Or something else weirds

#

no

#

idk

drifting wedge
#

for guild in client.guilds:
guild.id
@slender thistle updatemongothingy guildid {value of whatever}?

north birch
#

If i define a new quick.db table with db.table('table1') it get all the data from that table, anybody know or use quick.db too here?

slender thistle
#

collection.update_one to update already existing document, collection.insert_one to insert a document

earnest phoenix
#

anyone know why this error?

drifting wedge
#

collection.update_one to update already existing document, collection.insert_one to insert a document
@slender thistle you get the idea

#

but update adds it in too

#

if u didnt know

#

like if it doesnt exist it adds it in

slender thistle
#

$setOnInsert?

#

Time to test

drifting wedge
#

upsert

#

upsert = true

slender thistle
#

Oh

#

Yeah

#

Makes sense. Thanks for reminding me

drifting wedge
#

its good to have right?

#

to prevent errors?

eternal solstice
#

ping command? (java script)

slender thistle
#

Well, I don't see how it would harm you in this case

#

So go for it

earnest phoenix
#

@eternal solstice yes

#

@limber flume hey i need help again

#

doesnt work tho

slender thistle
#

It's just that I'm a hardass about checking shit manually

eternal solstice
#

@earnest phoenix is it ${client.ws.ping}

earnest phoenix
#

@limber flume so how i can get all ids and their sarmas like id: amount_of_sarmas

#

no its :ping_pong:Latency is ${Date.now() - message.createdTimestamp}ms.

#

@limber flume like all users and their sarmas

slender thistle
#

Define "all users"

earnest phoenix
#

i will remove emoji and try

slender thistle
#

Just literally get all documents from the collection?

earnest phoenix
#

@slender thistle you to me?

slender thistle
#

Yes

eternal solstice
#

@earnest phoenix idk i was also asking for the ping command XD

earnest phoenix
#

like i want to make leaderboard

#

so i need all

#

users

slender thistle
#

We don't give code straight up

#

If you want an explicit/detailed explanation, directly ask for one

earnest phoenix
#

so how i can get dictionary of ids and sarma

#

from pymongo

slender thistle
#

Provide an empty dictionary to collection.find

earnest phoenix
#

so with collection.find() i can get?

#

@eternal solstice oh lol

slender thistle
#

If you want to get all available data from your database, sure

earnest phoenix
#

yes thats what i want

slender thistle
#

you can then sort it with .sort on the returned object per necessity

earnest phoenix
#

but i am getting <pymongo.cursor.Cursor object at 0x0000014E759FD7F0> instead of dictionary

crimson vapor
#

is there a filter function on the find()

#

or a fineOne()

#

so you don't just grab everything from the db

slender thistle
#

literally the passed dictionary

earnest phoenix
#

i did this