#development
1 messages · Page 1385 of 1
possible to remove the space between the two (addField)
can you elaborate?
remove space here
yeah, not possible
Guys, is there a node library that you can use to ping yourself if an errors happens in your bot?
you don't need any specific library for that
create an error handler that sends errors to you
how does it sends the error to me exactly?
grab the user (you) and send the message via DMs or grab your server and get a special channel and send errors there instead
Why the bot doesn't edits the message?
It just says edited but the embed doesn't changes
try specifying the embed, message.edit({ embed: embedat })
i'll try
since it's not an instance of MessageEmbed, it might not be able to set it properly
ok thanks
so you use commands to show new pages?
@lusty quest yes
why does it then take this long?
i use Reactions to switch pages and its relatively fast
but again i have a dedicated Database
only after a restart?
no
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
what is the error?
^
shouldn't be
weap
@outer perch Yeah lmao i think i wrote wrong cause it's translated
The original code is correct
Wait
what is the error?
@lusty quest If in the db there's two weapons of the same type it return error
br or pt?
where r u from?
Italy, i know english, just dont mind my error cause when i write fast i makes always error LMAO
yikes k
not really
Oh
all i would say you have a duplicated entry into the database. make each weapon unique or prevent duplications
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
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
continuing
working intentionally with duplicates and databases is not really good practise
@lusty quest I see
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
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
cuz only the main embed has this load problem
@north birch you could still call them by name
the name doesnt need to be unique
exept if the name is the unique id
the thing is I really want that gif there
the downside of gifs is they take ages to load
I don't remember compressing the file
the thing is I really want that gif there
@outer perch Try sending the gif in a message.channel.send()
I should try it again using TinyGif or somthing
how large is the gif?
bcs it also depends on client side performance (internet speed)
6MB
hmm its fine i guess
yea thats your connection
it's not a huge problem
maybe you can get it down to 3mb
the other comands take at max 1sec.
yea thats normal
shit's fine, just trying to check any performance issues
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?
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
Okay so
can i connect database mongodb on my pc and then use heroku to host it?
can i connect database mongodb on my pc and then use heroku to host it?
@earnest phoenix I think aws is better than heroku
yes you can
or get a free mongodb
bcs for the DB hosted on your PC you need to forward ports
Try it out it will make your life easier
@earnest phoenix I think aws is better than heroku
i am now downloading mongodb compass is that good?
i am new to databases sorry
google MongoDB atlas this is a MongoDB host they also offer a free tier
i wasted 3 hours making database in txt file and it didnt work well so i want real database
i know
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
but you wont loose any data bcs of Heroku
it works on hosts that wont nuke your server if you restart
all free hosts suck. if you got a credit card Google and AWS offer 1 free year
google also got a free tier of VPS but they are really low powered
what hosts are there for free?
@earnest phoenix AWS Free tier
@north birch you still need a credit card
Oh yeah
It's still free
so heroku is only option
Just enter it
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
the credit card is only needed for validation
Maybe AWS/Google/Azure student plan dont need credit card?
look my contury isnt rich so i cant affor hosting ok?
you only need a credit card for validation, it will not be charged
yes but where tf i will find credit card
ohh this issue
Theres many solution
Your country does not have credit cards?
@hollow sedge in some countries they are uncommon
Huh didn't know that
my country has but i dont
@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
like ive got now one for about 1 1/2 years even tho i work now for almost 8 years
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
well @lusty quest I could reduce the size by around 60%, but the quality gets way worse
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
@outer perch if you are fine with the load times
How can I add a reaction to a message with a custom emoji like that ?
@sand dune https://stackoverflow.com/questions/48982061/how-do-you-have-a-bot-add-a-reaction-using-a-custom-emoji if you're using discord.py
@earnest phoenix it where just an example bcs they are here also uncommon
not a big problem for how it is now
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
ok nvm i am here because i want to connect discord.py to mongodb
can someone help
i can help with mongo but not py
i am stuck with create database
python hurts my brain
yes me too
such abnormal ways to write code
are you sure you need to pay for credit cards?
usually they are only needed for verification not for payments in the first year
Oh ok
lol it's ok I don't think you would be comfortable with using AWS anyway
well you need linux knowledge
Well setting up codedeploys too..heroku just has all that setup automatically
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
That's quite easy with any DB
yea
yes but i dont know how to do it
so..you just have to pick one
firebase or MongoDB atlas are some ok entry points
both offer free Tiers
now what
but i think they want each a Credit card for verification
Im the only one that use AWS EC2 to host bot? lmao
i use Digitalocean Droplets
i use Digitalocean Droplets
@lusty quest Never heard about
how can i connect to database in python
Take a look at this: https://www.w3schools.com/python/python_mongodb_getstarted.asp
@earnest phoenix
thank you
@earnest phoenix
yes
Is .edu for non-US?
Is .edu for non-US?
@hollow sedge I got .edu in italy
what is edu
@earnest phoenix Normally, shool gives students email that end with .edu
You could try GitHub student, not sure if they have anything that would get you server though
ok what database that is free you want me to use?
I think that's mostly colleges actually
ok what database that is free you want me to use?
@earnest phoenix Idk
@earnest phoenix I thought you said mongodb?
is mongodb good enough?
All dbs are free
MongoDB Atlas is free
i just downloaded it
(you dont need to pay for hosting)
All dbs are free
@hollow sedge I think's he is talking about online db
i am now folowing instruction on w3schools
But he said he downloaded it
But he said he downloaded it
@hollow sedge Then idk lmao
also not all DBs are free. some are licensed and you need to buy one
oh my bad
that sucks
also not all DBs are free. some are licensed and you need to buy one
@lusty quest Oh
Most of the ones popular on here are free though
but this is more in enterprise space
Yeah I was about to say most of the paid ones would be for enterprise
like the big boy databases that handle terrabytes worth of calls
do i need to run database on my computer?
not really
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
not really
@lusty quest is it yes?
Typically you would have it on your server or in the cloud
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?
so i need to keep my pc running database all time?
@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
@earnest phoenix just run the database in your code editor
so i need to keep my pc running database all time?
@earnest phoenix yes
i run my bot on heroku
WTH? Run the database in your code editor?
@earnest phoenix yes
@lusty quest is there any way to not run?
What does that mean
@main trench message.author.roles.cache.add(db logged role)
you need .cache in there
Mb didn't realize that was discord.js
use something like MongoDB atlas free tier
where i can find it
@outer perch thanks
@earnest phoenix https://www.mongodb.com/cloud/atlas
I am checking my code
Guys somebody know well quick.db? I need to make a table with it but table quick.db docs is offline
is there a maximum of calls for the functions?
ok where i can get ip of mongodb client
Rip
this line myclient = pymongo.MongoClient("mongodb://localhost:27017/")
where i can find
https://quickdb.js.org/overview/docs
@hollow sedge Actually the db.table docs
this line myclient = pymongo.MongoClient("mongodb://localhost:27017/")
@earnest phoenix that's only if you downloaded it
@north birch https://quickdb.js.org/overview/docs#table here
Why are you looking at the docs in GitHub lol
I was clicking on method
Oh
i am confused
Lol
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?
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
ill try the role code thanks
So wait im confused, @lusty quest how should i make that table?
@balmy knoll you can attach the DB to your client or import it
¯_(ツ)_/¯
would have to think about it myself first too
Sorry, but I didn't quite understand. Could you explain it better?
@outer perch why not just const memberToMute = message.guild.member(args[0].replace(/<@!?|>/g, "")) or something? you made a whole function for that
would have to think about it myself first too
@lusty quest I think i the filter will not work
if you make your DB connection somewhere you can call the connection in other files too with requiring the Model
@pale vessel why did you change your name?
because h
hey guys
@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
https://hatebin.com/fjzmucbqrf i have this code. It sends pokemon coordinates from a website. How can i save the previous coordinates to a variable?
you may have to log it in a db
did hastebin change their colors?
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)
would remove request its outdated now for a while
owh really?
yes its deprecated
owh i am not even using it
i dont even know why that module is defined in my project.
why also cheerio? did you want to scrape a website?
no i forgot to delete them.
guys I have a problem with fonts
so you want to save a coordinate temporary?
yeah exactly.
use a Database
I have Comic Sans font stored in my bot
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?
just overwrite it every time you update
can't i just use json and store the lat1 and lng1 in the database?
using fs to write?
I have Comic Sans font stored in my bot
both the online version and the pc version (dev.) read those .ttfs
but the online shows the font way more narrow than the offline
thats relatively heavy writing for a json file lol
forget I guess I can fix it
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('🎰')
})```
there are 2 ways. listen to the reaction_add event or use a collector
How to use collector?
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
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
if(command === 'new'){
if(!message.author.id == 500933509859246100)return;
message.delete({timeout: 0});
message.channel.send(allarg).then(function(message){
message.react('🎰')
})
}```
the command*
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
ahh forgot that lmao
@lusty quest message.reactions.cache.get(':slot_machine:').users
If i use that, it works?
try and see
hmm new error (node:17936) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body
name: This field is required
but i can't see
name needs to be a string
guild.channels.create('new-channel', { type: 'text', permissionOverwrites: permissionOverwriteArray, reason: 'New channel added for fun!' });
message.guild.channels.create('name')
hmm
ill try it
he wants to define if its a Text or voice channel
oh
now it just makes a channel called "name" hmm trying to make it work like *create text [specified name]
pass the string from the command to the function
message.guild.channels.create('name', {
type: 'voice or text',
permissionOverwrites: [
{
id: message.author.id,
deny: ['VIEW_CHANNEL'],
},
],
});```
try this
he wants to make a command to creat channels
it is
but the passing of the name for the channel is flaky
unless i do '${args[2]}' that could work
also yes i know its supposed to be `` but discord text is weird
args[2].toString() doesnt work?
i havet given that a shot yet trying other options first
"" or `` or '' defines a string in js
Cannot read property 'toString' of undefined hmm
well
tricky
console.log(typeOf(args[2])) what is the output?
@lusty quest How can i do it?
?
<add.reaction>
add role***
you add the reaction in the step before it?
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
like one of my teachers said once. You dont need to know everything, you just need to know where its written
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
write it in C#?
C# is multi threaded js is single threaded
also discord.net as example makes it pretty easy
Aight so "args[2]" didn't work so now I'm out of ideas might need to save this for a later project
what does the print i gave you output?
It makes a channel called "name"
Wait
No ok the toString code gave me a error
Saying toString is not a function
wtf
You need to specify users
?
provide an id
I'm adding the type of code now
how can i tag a user
if it is a string you should be able to just use the variable
hhelp?
wot
i guess
eris or d.js?
js
both are js
discord.js
@earnest phoenix you can do either const users = however you have users to be specified or let users = the same thing as in const
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? 
any ideas about kick/ban commands
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?
whats the difference between let and const
@earnest phoenix im not asking to be spoon fed
@earnest phoenix language?
@earnest phoenix ty
use a timer or use the cron module
setTimeout(function() {
// unmute
), muteduration}```
is this a bad way to do it

but this will only work non persistant if you restart it will not contunou
@earnest phoenix lol thats not spoonfeeding
@earnest phoenix yes
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
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
heyo
yea it doesnt recocnize the value as string
how would u check something 5-10 minutes
only js delay method i know is settimeout
start a timer when the bot starts
but that runs in a new thread
yea
start the timer using what
delay
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?
i have a delay running that resets itself after the check is done
setTimeout(function2, 3000);
what is the : doing there
setTimeout(function2, 3000);
@lusty quest you just said that was a bad method
@vale garden
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
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
i still dont understand what that : is
its how u call methods in some languages
thats easy. make a async function and inside of it you await the timeout
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? 
for(i; i<5; i++){ $.doTimeout(5000,function(){
return false;}, true);}```
i found this on google
should i use this
async function timeout(){
await setTimeout(3000)
//do what you want when its done
}
wait
and then put that in for loop i think
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
superbrain 8 can you help me?
idk havent really looked into this stuff
ok thx anyway
or try map(messages => messages.content
oh ok
instead of first()
huh
the error?
you forgot the ; after the
its not needed
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)
}```
and u put one after
huh
so like this? @lusty quest
but goot practise
delete that
ohh wait yea its on the wrong position
u see what i mean now
@lusty quest Once i setted the db table, how i fetch it?
lol
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)
}```
@north birch what do you use for the db
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
quick.db, mongo, sql or wat
yeah ik
@north birch what do you use for the db
@vale garden quick.db
@earnest phoenix did you removed the ; in the line before the setUrl?
@vale garden quick.db
@north birch you dodb.get(<key>)
Yeah but how to get the data that's inside the table?
@north birch idk never used quick.db
@north birch idk never used quick.db
@lusty quest Ripp
Yeah but how to get the data that's inside the table?
@north birch do you mean all data
@north birch do you mean all data
@vale garden No once you create a new .table
and it still errors out?
How to get the data from that table
for that do db.all()
@lusty quest but the delay will still end if the js script is paused
for that do
db.all()
@vale garden i'll try, ty!
therefore rendering even a database unreliable
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
ok
wait ill just make a new bot that has only the mute
that should work
so it wont need to be updated
how can i tag a user 
channel.send(`@${member.displayName}`)
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
(node:1228) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'all' of undefined
@vale garden Uhm
so turns out args[2] was supposed to be args[1] thats why i got so many errors 
gg
Lol
unless you havent defined db or something
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
anyways gtg bye
you know that every array starts at 0
^^^
@silver lintel await the loop when its done send the message
Someome knows discord.js and is in to make a bot?
Last time I worked with a complete noob
🤣
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#
What did i do wrong?
Set up
var weapons2 = new db.table('weapons2')
Get
var weapons2 = weapons2.all()
@vale garden
you overwrite your weapons2 value with something else
also dont use var. var is deprecated and only there to keep old scripts working
So i need to do:
var weap2 = weapons2.all()
alright
and let for stuff you want to overwrite
@silver lintel However, your success message will be: ✅ | Successfully deleted all messages in <##development >
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 🤔
message.channel already mentions the channel if im right
no i wrote now a few Bots in JS and started to learn C# a few weeks ago
bcs ive got bored
ah ok
@earnest phoenix it does but adding the tag is for making sure since not everything parses the channel object to a mention
(node:428) UnhandledPromiseRejectionWarning: ReferenceError: weapons2 is not defined
Ah this b1tch
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 Please dont say those words
@earnest phoenix Sorry
U gotta define it
yes
can you read errors?
Im talking to @north birch
me too
O
Loool
ye
and u didnt defined weapons2
@earnest phoenix i did:
var weapons2 = new db.table('weapons2')
Nope lmao im not that noob
i am not noob too and i made database in txt file
new db.table(...) doesn't seem right in my eyes
I need to take the table that is defined in another command, idk how to do this
wich db ur using?
quick.db
Oo
then its only db.table() iirc
Trying rn
guys i need help with pymongo
guys i need help with pymongo
@earnest phoenix I can help you!
I am very familiar with it
thanks
What’s wrong
so i am new to pymongo
ah yes
and i want to make format like
Py mongo is great I use it personally
user_id : amount_of_sarmas
yes
and i want to store it like that
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 ?
bosnian food in this case currency
Oh nice 👍
so i do something like this?
post = {"_id": ctx.author.id, "sarma": 1}
collection.insert_one(post)
2 mins I’m on mobile XD
ok xd
i made a kick command
but everybody can kick
even if they dont have perm to kick
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:
ok ty
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?
@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
so i can get users amount of sarmas?
2 sec
query = {"_id": ctx.author.id}
r = collection.find(query)
for result in r:
user_saram = result["saram"]
await ctx.send(user_saram)
@earnest phoenix
sarma
@limber flume it was set to this
@eternal solstice oh your using JavaScript
yeah
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
Can you not use member.roles.cache.has('role ID'); @eternal solstice
how to do it
@earnest phoenix let me show u
what do i replace it with
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
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
@eternal osprey you defined it inside a function
its not gonna be defined anywhere outside that function
also the function is not returning anything
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
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
oh you use update_one()
What are you trying to do
Yeah !
thank you
why the unnecessary int(1)
No it doesn't
Bruh don’t bully I’m on mobile
i am using pymongo because i was dumb and made database in txt file
Also you could use find_one
It was really hard doing that
not if I can use collection.find()
works the same way
...
sean way is better i think
.find can return multiple documents as opposed to .find_one
Maybe not in this case
yes
can I recieve vote updates for my bot without a webhook?
Oh.well
idrk how they work
You do you
python ?
can I recieve vote updates for my bot without a webhook?
@upper elm no
how do i code a bot?
Webhooks are exactly what receives the vote requests

how do i code a bot?
@earnest phoenix really
no
Your green name
im kidding lol

Ez
limit 
This isn't #memes-and-media for shitposting
@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
how do i actually set it to the main reason
if ctx.message.author.id in collection: something like that
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);```
how do i actually set it to the main reason
@eternal solstice your code looks correct. What is wrong with it?
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?
to remove a channel would message.guild.channels.remove(channel) work?
@eternal osprey yes
@main trench no
@main trench then what is wrong with it?
no
Think of the cache only for getting stuff
any solution
and in the text, add the variable like args2 there
@main trench you need to get the channel then call the delete method (<GuildChannel>.delete()).
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.
@eternal solstice change your code so instead of it saying "Optional reason..." specify reason then do
.ban({reason: reason})
but in v12 it shouldbe js const fetchedChannel = message.guild.channels.cache.get(channel_id); fetchedChannel.delete();
guild.channels.cache.get(...) returns a GuildChannel, then you can call .delete() on it.
or am i stupid
yeah that's correct
@main trench im using Javascript
@eternal solstice i am too
for ban reason
<guild>.<member>.ban({ reason: <reason>})
yeah thats how it works
and u can also add days ofc
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?
thanks it worked
oh god
@main trench can you help me with the code
the code im currently using
is a mess
sure
thanks
I keep getting pinged
@eternal osprey lastcoordinate must be defined at the very start of the function then when the toRad function is invoked, modify it's value
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
function calcCrow(lat1, lng1, lat2, lng2) {
let lastcoordinate;
function toRad(value) {
lastcoordinate = value * Math.PI / 180;
}
// Rest of the code here
}```
sa
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
const*
We're modifying the value of the first variable not making another variable with the same name
Remove var
Yes
@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:
it still returns undefined tho?
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
library, database?
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
@modern sable see above
UHM
It’s a scam
Moderators ?
ty
late
Ye
Sorry if my indentation is bad I’m on mobile
But how would I do stuff for every server?
yes ^
@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()
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?
Very messy but should work
ok thanks
ps spoonfeeding is bad and doesn't help much
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.
um...
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:
` is the key right next to the 1 key
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
ctrl c

its giving an error
Did you deleted the channel?
Or something else weirds
no
idk
for guild in client.guilds:
guild.id
@slender thistle updatemongothingy guildid {value of whatever}?
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?
collection.update_one to update already existing document, collection.insert_one to insert a document
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
ping command? (java script)
It's just that I'm a hardass about checking shit manually
@earnest phoenix is it ${client.ws.ping}
@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
Define "all users"
i will remove emoji and try
Just literally get all documents from the collection?
@slender thistle you to me?
Yes
@earnest phoenix idk i was also asking for the ping command XD
We don't give code straight up
If you want an explicit/detailed explanation, directly ask for one
Provide an empty dictionary to collection.find
If you want to get all available data from your database, sure
yes thats what i want
you can then sort it with .sort on the returned object per necessity
but i am getting <pymongo.cursor.Cursor object at 0x0000014E759FD7F0> instead of dictionary
is there a filter function on the find()
or a fineOne()
so you don't just grab everything from the db
literally the passed dictionary
i did this


