async def buy_this(user,item_name,amount):
item_name = item_name.lower()
name_ = None
for item in mainshop:
name = item["name"].lower()
if name == item_name:
name_ = name
price = item["price"]
break
if name_ == None:
return [False,1]
cost = price*amount
users = await get_bank_data()
bal = await update_bank(user)
if bal[0]<cost:
return [False,2]
try:
index = 0
t = None
for thing in users[str(user.id)]["bag"]:
n = thing["item"]
if n == item_name:
old_amt = thing["amount"]
new_amt = old_amt + amount
users[str(user.id)]["bag"][index]["amount"] = new_amt
t = 1
break
index+=1
if t == None:
obj = {"item": item_name, "amount" : amount}
users[str(user.id)]["bag"].append(obj)
except:
obj = {"item": item_name , "amount": amount}
users[str(user.id)] = [obj]
with open("bank.json", "w") as f:
json.dump(users, f)
await update_bank(user,cost *-1,"wallet")
return [True, "Worked"]
``` buy_this function
#development
1 messages ยท Page 1663 of 1
'../build/Release/sharp.node' cant find it? what do i do?
npm rebuild and then npm install
what lock file?
package-lock file or something like that
i done that same thing
yep
v14.15.4
what's the error stack. You may have to remove dependencies
That is not the stack
I was referring to the npm stack where the error you originally showed came from
.setColor(colore)
.setTitle("Missing Permissions")
.setDescription("yes");
if (message.content.toLowerCase().startsWith(config.prefix + "mute")) {
NHIP.setDescription("You must have the `Kick Members` permission to use this command!")
if (message.member.hasPermission('KICK_MEMBERS')) {
const mutedR = guild.roles.cache.find((role) => role.name.toLowerCase() == "muted");
let noMutedR = new Discord.MessageEmbed()
.setTitle('Missing muted role')
.setDescription('Please make a role named "muted"!');
if(mutedR) return message.channel.send(noMutedR)
message.channel.send('lol')
} else {
message.channel.send(NHIP)
}
}```
..
what
im sending a message where i explain what's wrong
ye
So it sends the missing muted role embed if there is, and if there is not it send "Lol" (i need to replace message.channel.send('lol') with the rest of the code, it is just to test)
btw in the let nhip "colore" is a let that says a hex color
So can someone help me?
what do you still need help with?
it sends the missing muted role embed if there is, and if there is not it send "Lol"
what is it doing now and what do you want it to do
yes and what's the issue with that?
it must check if there is a role called "muted", if there isn't it sends an embed, if there is it sands "Lol", and i need to replace message.channel.send('lol') with the rest of the code
if(mutedR) return message.channel.send(noMutedR)
message.channel.send('lol')
} else {
message.channel.send(NHIP)
}
that doesn't make sense
you return BEFORE sending lol
that's coding basics
i mean that im not english
so i dont understand what you're trying to say
If you dont want to explain it can you just tell me how can i fix this?
ow nvm the else belongs to the permission check
yeah
sry happens but the coding style is horrible
why?
what?
if bla, send1 will send, if not bla, then send2 will send
so the return should give the next step?
dont do it like that
how then?
Wouldn't the code throw a syntax error
what do you mean
what do you want to send?
if there is the muted role, it sends lol, and i need to replace the part that sends lol with the next step of the cmd, and if there isnt i want it to send an embed
that says that there is no muted role
No
let NHIP = new Discord.MessageEmbed()
.setColor(colore)
.setTitle("Missing Permissions")
.setDescription("yes");
if (message.content.toLowerCase().startsWith(config.prefix + "mute"))
{
NHIP.setDescription("You must have the `Kick Members` permission to use this command!");
if(!message.member.hasPermission('KICK_MEMBERS')) message.channel.send(NHIP);
const mutedR = guild.roles.cache.find((role) => role.name.toLowerCase() == "muted");
let noMutedR = new Discord.MessageEmbed()
.setTitle('Missing muted role')
.setDescription('Please make a role named "muted"!');
if(!mutedR) return message.channel.send(noMutedR);
message.channel.send('lol');
}
then what do you want?
you forgot to add a !
if(!mutedR) return message.channel.send(noMutedR);
NOT
if(mutedR) return message.channel.send(noMutedR);
Lol
the } else { still makes no sense
Iits just because i dont really know how to use the ! in coding
it is for the first step, checking if the user has kick member perms
ah
yeah
copy what I wrote, use it, think about it, continue with this style
hm
ill see
i mean your message
wait what?
you didnt remove them
i didnt saw that msg
I don't see any else in my example, you do?
this little boi
! negates a boolean
what
you DID if(mutedR) return message.channel.send(noMutedR);
!true => false
!false => true
ooooooh
the role mutedR was found
but you returned return message.channel.send(noMutedR)
noMutedR not found
if(!mutedR) return message.channel.send(noMutedR);
!mutedR
means if not / if FALSE
ooh
k
the only problem now is that when i started making the cmd i didnt think about if the message had no mentions in it
so i need to add it when i finish it
god damn... trying to install the damn webserver and mailserver for 3 h now... should close Discord 
yeah people here providing support only, they will not code the stuff for you
you really need to learn the basics yourself
soo, this should be the final code, but i need to replace message.channel.send('lol') with a function where the bot gives the mention a role
if (message.content.toLowerCase().startsWith(config.prefix + "mute")) {
let muted = message.content.mentions.members.first()
if(!muted) return;
if(!args[1]) return;
NHIP.setDescription("You must have the `Kick Members` permission to use this command!")
if (message.member.hasPermission('KICK_MEMBERS')) {
const mutedR = guild.roles.cache.find((role) => role.name.toLowerCase() == "muted");
let noMutedR = new Discord.MessageEmbed()
.setTitle('Missing muted role')
.setDescription('Please make a role named "muted"!');
if(!mutedR) return message.channel.send(noMutedR)
message.channel.send('lol')
} else {
message.channel.send(NHIP)
}
}```
and i need to add some embeds for the bot to send for the first 2 returns
instead of using else for the permission check, take a look how I did
i will
well it looks really clean
but idk if i will learn to do it like that
let muted = message.content.mentions.members.first()
if(!muted) return;
if(!args[1]) return;```
you did it here as well
or just copy & pasted the code
idk
i actually already fixed that
i needed to switch up a lil the things, and remove the ! before args
so this is the FINAL code
if (message.content.toLowerCase().startsWith(config.prefix + "mute")) {
if(args[1]) return message.channel.send('Correct usage: ?Mute <userMention>')
let muted = message.mentions.members.first()
if(!muted) return message.channel.send('You must specify who you want to mute!')
NHIP.setDescription("You must have the `Kick Members` permission to use this command!")
if (message.member.hasPermission('KICK_MEMBERS')) {
const mutedR = guild.roles.cache.find((role) => role.name.toLowerCase() == "muted");
let noMutedR = new Discord.MessageEmbed()
.setTitle('Missing muted role')
.setDescription('Please make a role named "muted"!');
if(!mutedR) return message.channel.send(noMutedR)
muted.roles.add(mutedR)
message.channel.send('User succesfully muted!')
} else {
message.channel.send(NHIP)
}
}```
but the muted role's perms are still just a mistery.
and i will leave them like so.
you probably want to invert your args check, since it will fire even if a mention is given
also you have 2 checks for the same thing, you check if args[1] is a thing (not sure if you want args[0] and then again check if a user got mentioned who is also in this case the same as the arg you check one line before
for the mute role, i would suggest to either use a command to create a role with read only permissions or let the user supply a role that will be used to mute user
if(args[1]) return message.channel.send('Correct usage: ?Mute <userMention>')
that's exactly what i wrote
I know I copyed it and pasted here
yea but why?
i want it to fire when there is a mention
if req.session is undefined what does it mean?
that it's undefined
Nvm this is
if (message.content.toLowerCase().startsWith(config.prefix + "mute")) {
if(args[1]) return message.channel.send('Correct usage: ?Mute <userMention>')
let muted = message.mentions.members.first()
if(!muted) return message.channel.send('You must specify who you want to mute!')
NHIP.setDescription("You must have the `Kick Members` permission to use this command!")
if (message.member.hasPermission('KICK_MEMBERS')) {
const mutedR = guild.roles.cache.find((role) => role.name.toLowerCase() == "muted");
let noMutedR = new Discord.MessageEmbed()
.setTitle('Missing muted role')
.setDescription('Please make a role named "muted"!');
if(!mutedR) return message.channel.send(noMutedR)
muted.roles.add(mutedR)
message.channel.send('User succesfully muted!')
mutedR.setPermissions(['VIEW_CHANNEL', 'READ_MESSAGE_HISTORY', 'CONNECT']);
} else {
message.channel.send(NHIP)
}
}
horrid
like i said before, you need to set up proper command handling
the sky is the limit
you can create so many beautiful design patterns
well i think im an ugly person
wtf it's not lmao
okay there's no limit
phew... u saved the day
just make some machine learning bot, feed it the commands you wanna have and link that to discord, no limit, right?
teach it to run :(){ :|:& };:
don't abuse js just because it's bad
mostly TS
depends what project
I don't use TS when I can't
if i'm making a bot i use c#, if i'm making a desktop app i'll most likely mix typescript and c#
๐ฎ
shh move on
well, from what ive heard, php 7 is ok in performance, but problem is still the naming conventions are inconsistent and its too easy to use so theres loads of terrible code floating around
php shouldn't be used today anymore
Now THIS big boi is
๐คฎ
if(args[1]) return message.channel.send('Correct usage: ?Mute <userMention>')
let muted = message.mentions.members.first()
if(!muted) return message.channel.send('You must specify who you want to mute!')
NHIP.setDescription("You must have the `Kick Members` permission to use this command!")
if (message.member.hasPermission('KICK_MEMBERS')) {
const mutedR = guild.roles.cache.find((role) => role.name.toLowerCase() == "muted");
let noMutedR = new Discord.MessageEmbed()
.setColor(colore)
.setTitle('Missing muted role')
.setDescription('Please make a role named "muted"!');
if(!mutedR) return message.channel.send(noMutedR)
muted.roles.add(mutedR)
mutedR.setPermissions(['VIEW_CHANNEL', 'READ_MESSAGE_HISTORY', 'CONNECT']);
let muteDM = new Discord.MessageEmbed()
.setColor(colore)
.setTitle('You got permanently muted! :D')
.setDescription(`Muted from: ${guild.name} \n Muted by: <@${message.author.id}>`)
muted.send(muteDM)
let muteE = new Discord.MessageEmbed()
.setColor(colore)
.setTitle('User Muted!')
.setDescription(`I succesfully muted ${muted.user.name}!`)
message.channel.send(muteE)
} else {
message.channel.send(NHIP)
}
}```
ok in performance isn't good enough anymore
never said i didnt agree with that
and there are more modern and flexible languages capable of what php does and more
too easy to use... lmao - makes it great
yeah, i understand
still more then 60% of all the backend in the 'net is running on PHP
I've pulled out some old python code and having trouble lol
and 50% of that 60% is running on a php version as old as mother teresa
i feel like atleast 50% of those php websites are all wordpress, smileyface
Unfortunately using depreciated functions
Someone help pls
huh nope... google, amazon, ebay etc.
like anybody does
maybe not anymore in 20 years who knows
time is changing
still prefer a server sided engine for security purposes
idk about amazon or ebay but i feel like google wouldnt use php
even PHP 8?
@craggy pine ?
Ignore this cry MS fanboy... I'm gonna send him an exorcist
welllllll
asp.net core is one of the fastest web frameworks out there 
c++, rust and c# have the fastest web frameworks right now
php doesn't even come close to those speeds
ehh, not really a fan of C# but mostly because of the syntax, dont really have anything really against C# itself, just dislike how its namespace > class > method and stuff
lol dude you'll need to be more specific than that
I don't?
python version, which ide, and code inspector setup correctly to use your python version?
yeah that's why I said, time is changing
don't worry about the red line
it will still work
but until all big players have changed their whole infrastructure and it gets more common I bet there will be another 10 years or more until that
Yeah but new people wont use it
you get...
python main.py
or whatever your bot file is called
that proves I'm too old
yeah :P
I've installed it tho
isnt it python3 main.py or does just python already direct to python3?
Anyways. You need to grab the classes or IDs of the text you used. I use a chrome extension to help me grab that info called live css but the color: is what changes text color.
with that random bot I chose, h1 seems to be a class that's used by default so
<style> h1 {
color: whatever;
}
</style>
Lmao
ah i see
@opaque seal
then it's python3
that
I gotta install python3?
was about to say, same path in vscode?
dont know the windows commands to check path honestly
apparently echo %path%
no
when you install python it should ask you if you want to add it to the path
yeah but he seems to be able to run python in a seperate shell outside of vscode
over here
huh?
your path variable might be different in the vscode terminal than in your normal shell, i think
could try this command both in vscode and in a seperate cmd to check if thats actually the case
nothing happends
using a different shell than default windows one then? it should echo your path variable
If you want to add more album records, you can do this by adding records to the top level array., when they say this, do they mean that we can add it after the object?
var ourMusic = [
{
"artist": "Daft Punk",
"title": "Homework",
"release_year": 1997,
"formats": [
"CD",
"Cassette",
"LP"
],
"gold": true
}
];
Unless you're doing front end dev work, you shouldn't use var
var ourMusic = [
{
"artist": "Daft Punk",
"title": "Homework",
"release_year": 1997,
"formats": [
"CD",
"Cassette",
"LP"
],
"gold": true
},
{
"artist": "Daft Punk",
"title": "Homework",
"release_year": 1997,
"formats": [
"CD",
"Cassette",
"LP"
],
"gold": true
}
]
let > var
var has its uses, but most often unnecessary.
let is only for if you want to re-declare the value of something later on in run time. const is preferred as there are interpreter optimizations that come from not being able to change the value of something considering JS is not type strict
honestly, ive never really researched as to why, only thing i heard once was that let is better as var has some weird scoping at some times or something? probably should check sometime
var is not scope locked, which can lead to logical errors if you tend to use similarly named variables. This can cause race conditions in async code execution
im in this picture and i dont like it
reminds me of that meme of "the H in programming stands for Happiness"

What does top level array mean, though?
Can someone help because this doesn't run correctly
async def on_message(message):
if (message.author.id = 712027036511633429:
message.delete()```
Someone said its requirements?
What should i add on?
A binary.
Though I don't know how you managed to get that in your requirements.py file
seems more like some install logs with unicode
top level usually means the furthest back something can go. In your context, it means the main Array which would be ourMusic
vscode
Does it mean, like at the bottom or the root?
as in you shouldn't see that in a .py file
var ourMusic = [
{
"artist": "Daft Punk",
"title": "Homework",
"release_year": 1997,
"formats": [
"CD",
"Cassette",
"LP"
],
"gold": true
},
{
"artist": "Daft Punk",
"title": "Homework",
"release_year": 1997,
"formats": [
"CD",
"Cassette",
"LP"
],
"gold": true
}
]
As you can see, the new record is at the bottom
create a new entry in it. It shouldn't matter where it is in the Array
but top level array means at the root, right?
non closed parenthesis and arent user ids strings? also, ==?
not the root scope. the ourMusic Array in this context is the root
kinda curious, how do people here have their bots hosted?
am just curious if the majority is using a vps, cloud stuff like functions if thats even possible? or cloud applications or using docker or something similar like that?
I use vultr but there's also things like aws, heroku and even self hosting
i got my stuff currently on a gke cluster, kinda hope someone else here aswell so i might be able to ask about rollouts, but still curious how others have it set up
A good option if you're on a budget is a raspberry pi
Is it weird that discord.js docs are kinda confusing to me
Like I get the premise but it's just confusing
discordjs.guide?
wait so for this one I'm not understanding how do i add on to my bot?
= is for assignment
so what should I put instead?
you'd want to use == for comparison
remove the parenthesis
Add )
python
make sure member intents are on and you have to await the delete method. You also have an extra (
o so in message.delete I should delete the extra one right?
yeah and add await since it's a coroutine
@client.event
async def on_message(message):
if message.author.id = 712027036511633429:
await message.delete()```
Ok ty
==
...
IDs are strings in js
user ids are integers
how do I define @client.event?
they're int in python
python does not require ( )
it says undefined name as @client or something
Ahh didnt know that types are different
you just import your client
you need the client, did you name it bot?
discord golang library does string ids aswell
i tried naming it to my bot but it also gave me an error
where did you define your client
at this point im assuming you have the basic bot
might as well show the entire code without the token
async def on_message(message):
if message.author.id == 712027036511633429:
await message.delete()```
this is all of the code currently
o i didn't define the client
i suggest you look at the example bots
like where?
cleint?
Some languages do user IDs as strings because of number rounding precision errors when they reach close to or exceed the max safe 32 bit integer. Discord sends them as strings. discord.py devs probably just thought it was smarter to coerce them to ints

Any idea?
I do always say, snakes are weird
Lmao
Did you code it?
Then there is no way for us or anyone to help. You can ask on the website or report a bug
Ok
if ur gonna use someone else's code try reading the code and see why it isnt working?
oof
This is the only thing that my bot can't do
no
From Luca
it only means you are seriously capped from using a maker
yes
but that doesn't prevent u from being accepted
No this is wrong
ah, yes
As long as he changes stuff it's fine
if it's using the default stuff you'll be rejected
^this
you need at least 51% custom commands
looks like default stuff
@deft jackal Create another botghost bot, dont change anything, and compare it with your bot
If most of the stuff is the same, your bot most likely wont get accepted
Like !help; !help mod; !help level
But
Only bcs my bot can't warn
Did it will be rejected?
It can do other things
Lile
Like*
Levels
if some commands dont work then it will be rejected i think
if 50% don't work
Edy you dont understand me apparently
Ok but only the warn/clearwarn command isn't working
Oh ok
my advice: if you want to make your own bot then you should try coding one yourself
its way better
Chaning the response of the level-up messages isn't unique tho, just saying
Do you have a bunch of custom commands which other bots dont have?
@EDY_1111, You just leveled up to level 5!
I think no
Wait
Wait nvm
It has !say
Isn't like danl memer
Dank*
Dank memer says who say and what say
Like
I am pro
EDY_1111#6089
Take this as an example
๐ฉ
It's a bit older, maybe the requirements are higher now
nice
Yeah and?
if the bot cant do anything then is it really coded lol
what does this have to do with ur problem
They have banned me
can somebody help me with a music system for python 3.9.2??
Does anyone know the method for moving channels on discord.js?
changing the channels position
is that what u mean
can somebody help me with a music system for python 3.9.2??
yes please help
oh no its
@client.event```
@client.event
async def on_message(message):
if message.author.id == 712027036511633429:
await message.delete()```
that should work if not go to the python server
for help
ig
i need help i first created a bot and i need help with blocking links and playing music but idk how u code it
what language???
english
idk im new to this
ohk dms
Who wants to see something brain hurting
yes lol
It took me 3 hours to add 120 anime's + information because i had to type and copy it with hand for a random anime suggest command
yikes
Why not just get the total number of entries on AniList's site, generate a random number in between 1 and the current total, and use that number as the anime ID

Wahh
Ohw well because i wanted total control about what could be send or not you know what i mean

just having my own kind of database
hahaha
But ngl i think it was worth it because it looks sick AS FUCK
LOOK
- Get the total number of entries.
query T {
Page {
pageInfo {
total
}
media {
id
}
}
}```
2. Use the `data.page.pageInfo.total` number to generate a number in between.
3. Send a request for the data.
```graphql
query T($id: Int) {
Page {
media(id: $id) {
# More fields can follow
id
}
}
}
If you want to filter out certain entries, you can always keep repeating step 2 and 3 until you get a valid result (like filtering out adult content)
Your approach (while it is cool) is not sustainable in the future I think
cache 1.
yeah
when I use a <style> tag in a HTML doc, how do I know that it also is using sass so i can nest rules?
or can i even do that?
because it seems like it isn't working
try a mp3 file, see if its work
const soundPath = ./temp/${timestamp}.wav; ???
the timestamp renews the every ms
is it a valid file in the first place
i.e. have you tried playing it
on your pc
is there any error logged
try ffprobing/just running the file through ffmpeg
just to see the output
ffprobe file or ffmpeg -i file lol
ffmpeg != ffprobe
oh my fucking god
it isn't a npm package


guys is there a method to do a math power command?
you can do channel.edit({position: 1}) or what you want the position to be to move a channel
im an hour and 1 minute late but

okay so, the inside is pcm
now
the play method on the VoiceConnection allows you to set the type
https://github.com/discordjs/discord.js/blob/stable/src/client/voice/util/PlayInterface.js#L69 as per here
so try setting the type to converted
play(whatever, { type: "converted" })
okay, correction
Is it possible to use fs to change a bunch of file names in a specific folder at once?
you need to pass a stream so use fs.createReadStream(path) to create a stream and then pass that to play
yeah
yup
is there anywhere where I can ask people to test my bot for some constructive criticism?
can anyone help me make a bass boost command?
so the issue is with re-encoding for whatever reason
what's basically happening normally is
wav file that has PCM data -> djs forwards it to ffmpeg -> ffmpeg converts from PCM to PCM again
except at 48khz stereo
your file is 22khz mono
can anyone help me make a bass boost command?
can you send over some wav file so i can try something out?
so, try using the exact same code except with this file
what
leave your code as is (with streams)
and try using that file i just sent instead
so it's djs fucking something up with ffmpeg or it's format re-encoding that's the problem
which djs version are you on?
your package.json
hm
okay
well
Sa
you're going to have to spawn ffmpeg to convert the file to 48khz stereo
and then use that stream method instead
autism
can anyone help me make a bass boost command?
you need to spawn ffmpeg with these arguments -ar 48000 -ac 2
so your end code would look something like this
const { spawn } = require('child_process');
say.export(text, null, 1, soundPath, (err) => {
const outputFileName = "generate it here or something idk";
const ffmpeg = spawn("ffmpeg", ["-i", soundPath, "-ar", "48000", "-ac", "2", outputFilePath]);
ffmpeg.on("close", (_) => {
//converting here finished, proceed with your regular code, except use outputFilePath when creating the stream
});
});
for this to work ffmpeg needs to be added to your PATH
otherwise just provide a path to the .exe/binary in spawn()
try it and see
oh also
you should probably add .wav to outputFileName
also
don't copypaste my code
there are some mistakes in there

You wrote them intentionally to see if somebody just c&p
We now it.
Tell us the truth!
totally not because i wrote the entire thing in the discord chat
sure
you're still playing soundPath
what program this run in? I only know java
haha
i only learned using the bluej, maybe thats why i couldnt tell, never really got good with writing if and then statments
Just quickly wanted to say, ew, child processes
its not?
according to that log it isn't
show your code
a VoiceConnection is not a VoiceChannel object
you could've said so in the first place ๐
hello, how do i give presence to my bot?
you mean like a status?
yep
which library?
discord.js
okay ty
does anyone know why my meta tags arent showing in discord
I try too many to make a command that turns on and off by another Command
which meta tags
<meta name="title" content="Discord Webhook Sender">
<meta name="theme-color" content="#dbdbdb">
this is in the head tag
you need opengraph meta tags
these are the ones you need i think
Wich is best sqlite or mongodb
realistically, you're comparing a fork to spoon
both are eating utensil
but each have their perks
theres no best db
even though i keep saying postgres is the ultimate db
i havent tried mongodb but i found sqlite easy to work with
i use heroku postgres for my bot
my im biased on postgres, try not to eat too much what i feed you on postgres
havent heard of fauna
Fauna is like all db schemes together
you need document based db? relational? scalable? light?
scalable or light?
hmmmm
keydb or sqlite might be best for you, i assume you're going for something light
Mmmmh whats the difference between scalable and light
scalable is high performance db
light is a db thats quick but its meant for low traffic
its not meant for slow traffic, dont get me wrong, but its usable in lower traffic ends
Its an RPG discord bot that stores quite a bit of data per user
where you wont eb doing thousands of queries a minute
storing data isnt the issue
i mean more like, how many queries a second do you do
Not that much its mainly 1 query when a command gets executed and then another one if I need to save more data
But lets say u have multiple users
hmmm you might wanna stick with sqlite then
Right and say iโd need a scalable one wich one would be your recommendation
sqlite can easily handle hundreds of queries per second
tim bout to swoop in and call me out for biased
if you're writing a lot, enable WAL mode and turn synchronous off
most of the time i see sqlite being used as a choice db is when there are few queries
specially with high volume data
Alright but sqlite is a good pick here right?
but i doubt they'd be using that much data
Also whats the best compression algorithm I should use
I looked into lzjs what about that one?
depends, you want it to be fast or to have high compression?
it would be better for you to do your own research instead of asking every db you know of here

see what each db offers
I did but Iโm really not sure what I should pick thats the thing
one or two is fine, but it feels like you're googling random db's and just asking it in here instead of reading about them
Iโd want it to be fast but also compress quite a bit
are you gonna use built-in compression in the database level? or are you gonna compress stuff yourself before writing to the database?
I just watched a 30 min video of database shit and I still dont know wich to pick
Iโll compress before writing
in that case, benchmark it yourself
but you cant really go wrong with the built in zlib
Is zlib built in sqlite?
inside a string?
Wait but zlib uses deflate right? So whats the difference between deflate and zlib or is zlib deflate Iโm fucking confused
ayo, I was just working on my bot page and now removed entity-header__short-description
I wasn't sure if that's allowed since it was only mentioned that it's not allowed to hide vital objects
I have no short description tho and I wasn't sure what to put there then
(https://top.gg/bot/701905927363756112) this is how it's looking like now
Nope that shouldnโt be an issue, you arenโt removing site content, ads etc.
How do I remove duplicate value in an object in an array while having to count how many is the duplicates?
[
{
"name": "Steve",
"voter": "b9k4tx56g"
},
{
"name": "Bill",
"voter": "es49fs3jf"
},
{
"name": "Adam",
"voter": "v8k79de56"
},
{
"name": "Bill",
"voter": "d34svrj"
},
{
"name": "Bill",
"voter": "lm8h76f"
},
{
"name": "Robert",
"voter": "l8s5v6q7b"
},
{
"name": "Adam",
"voter": "f7er43k"
}
]
I wanted something that looks like:
[
{
"name": "Steve",
"votes": "1"
},
{
"name": "Bill",
"votes": "3"
},
{
"name": "Adam",
"votes": "2"
},
{
"name": "Robert",
"votes": "1"
}
]
should I just make a loop, and make a new array, then start with the first one, then put it into the new array, then check the next one. check the new array for duplicates, then if it is a duplicate, delete it, then add 1 to the new array?
What language?
Javascript
Youโre still on that thing lol
nope, I am done with the other thing
I just need a data on how many is the duplicates
You can try lodash
There is native way too
This is what I'd dojs array.sort((prev, next) => Number(prev.votes) - Number(next.votes)).reduce((acc, cur) => (!acc.find(entry => entry.name === cur.name) && acc.push(cur), acc), []);
Sort the array by little amount of votes to most amount of votes, and remove duplicates using reduce()
^the native way, reducer
couldn't you accumulate first then sort second so you have a smaller array to sort
Yeah, I guess, if you know which one is the smallest amount
They want an array of unique items, all are lowest price from the original array
If I recall correctly?
You'd want to read more on reduce(), it's a really neat method: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce
code it
I don't know much
we dont spoonfeed here
if you got a specific question, we are happy to help you
otherwise if you truly want pre-made codes, use discord bot maker or some other sort of bot maker
I just looked at the result you wanted, seems like you also need to calculate how many votes that user had, reduce() can also do that
I'm assuming that one is different from yesterday?
it is the same, but I just need another data which is on how many duplicates.
ok
That's much simpler though, using reduce, you check if the user is already inside the array. If they are, just increment their voter count or if not, create a new entry with 1 voter
You don't need to sort it too
no code = no help
@pale vessel also if its a db you can just sql GROUP BY id
SQL moment
ss or should I write
up to you
You're not doing anything if the user voted
Do you want it to send the embed if the user voted?
i know
If so, move all the embed code to that if block
How so else and do I delete the one below?
Do you want to send the user this embed if they have voted?
No, if he didn't vote, send it
ok
- use @quasi shale-gg/sdkinstead since dblapi.js is deprecated
npm i @quasi shale-gg ?
ok thnks
Look at the example here: https://www.npmjs.com/package/@top-gg/sdk
Your problem can be fixed by putting the embed code inside the else block, since that will only be triggered if the user has not voted
https://topggjs.readthedocs.io/en/latest/Api.html It should be similar to use, the methods are the same
{
name: "Steve",
voter: "b9k4tx56g",
},
{
name: "Bill",
voter: "es49fs3jf",
},
{
name: "Adam",
voter: "v8k79de56",
},
{
name: "Bill",
voter: "d34svrj",
},
{
name: "Bill",
voter: "lm8h76f",
},
{
name: "Robert",
voter: "l8s5v6q7b",
},
{
name: "Adam",
voter: "f7er43k",
},
];
let newArray = [];
for (i = 0; i < array.length; i++) {
let name = array[i].name;
let newObject = newArray.find((arr) => arr.name == name);
console.log(name);
console.log(newObject);
if (!newObject) {
console.log("Creating");
newArray.push({ name: name, votes: 1 });
} else {
console.log("Modifying");
let votes = newObject.votes + 1;
newObject.votes = votes;
}
}```

Can you help me mostly when I don't know much?
It's crazy that one method and shorten your code to one line
You can ask your question here, others can help too
what is the other method?
Now what am I going to write instead of the old one?
reduce((acc, cur) => (acc has current's name ? <find acc by name and increment the voter count> : <else, acc.push(an object with name and voter count 1>, <return back acc>), [] (start with an empty array))
my brain too small to understand reduce
am I going to write this?
Naw
no 
What part are you having trouble at? @vast garnet
ok sorry i m turkish i need the translate ๐
I don't know what to replace my old code
Try replacing require("dblapi.js") to require("@top-gg/sdk")
ok
can someone check something in dms
const dbl = new DBL('dbl token', client)
dbl.hasVoted(message.author.id).then(voted => {
if(voted) {
} else {
message.channel.send("Bu komutu kullanabilmek iรงin botumuza oy vermelisin! https://discordbots.org/bot/813015311199633418/vote/n%60%60Onaylanmasฤฑ birkaรง dakika sรผrebilir")
}
})
it is a correct?```
Yeah
but error
:/
Can you show your code?
@pale vessel This is what I got if single brain cell didnt fail me:
array.reduce((acc, cur) => ( acc.includes(array.name) ?array.find(arr => arr.name == acc).votes = array.find(arr => arr.name == acc).votes + 1: acc.push({name:acc.name, votes: 1}), return acc), [])
Remove that duplicate new
ok
You're close, acc.includes() only works if the array is full of strings, but in this case it's full of object so you'd have to use .find(entry => entry.name === cur.name)
For votes, use .votes++ to increment it, you don't need to reassign the whole object that way
Yeah but you still hasn't fixed your original issue
You want to send the embed if the user hasn't voted right?
is it acc.find, or cur.find?
acc is like the object itself
Yeah
pls
You can share it here if it's related to development
this doesn't work
is acc or cur the element inside the array?
Delete that jesus 
yeah If the user did not vote, send my vote message
thats why i said dms
It's cur, acc is the final result, you can push/modify elements from it, as long as you return the value back
frick
Don't
Code
Like
This
I don't
Hence why there is , acc at the end
it's like that when I pasted
Pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
use that
if I remember correctly, cur is like the {name, voter}. While acc is the final result, {name, votes}
So how do I write "voted === true" instead of "vote"?
Naw that's just what voted is
All you have to do is move your code to the correct scope
Yeah
also,
Cur is the element from the original array
where am I going to move?
you won't need return, , acc is enough since it's inline (no {})
@pale vessel alright thanks, I think I am getting the hang of it now.
I sent you the image
Move embed to else {}, and the channel.send to if
r u making a bal command in js
hey dude i m turkish not u understand
This is what I got so far.
nvm
if (voted) channel.send("Voted");
else {
// your embed code
channel.send(embed);
}```
cannot import name 'web' from partially initialized module 'aiohttp'
I don't want to send embed
any ideas?
Send whatever you want
but that if-else should be self explanatory
How did you import aiohttp?
Not at all
from aiohttp import web
tough
as doc example
Are there Arabs here to communicate?
nope
I am Turkish and I do not understand anything, please can you put the code ready (provide translate)
@vast garnet step 1 learn english
@pale vessel
is that python
yes
its an aiohttp class
ImportError: cannot import name 'web' from partially initialized module 'aiohttp' (most likely due to a circular import)
full error
meant to say where is aiohttp
im using prettier in vscode, and it always makes a newline everytime a code is getting too long. I want to disable it. What settings is it related to?
you say from aiohttp
Are there Arabs?
what happened
@drifting wedge ur importing 2 modiles frkm each other
spelling๐
non no
ููู ุนุฑุจ ููุง ุ
Yes
please
Duh
bru
U fixed!?
from keep_alive import keep_alive
from discord.ext import commands
||pov you clicked||
@drifting wedge google: python circular import
it took you that. long to say that
Coreh Schaefer has really good explanation
@earnest phoenix i am slow af
What is the "vote" "BOTUU" here for?
View -> Text Wrapping
"Toggle word wrap"
Hey flapze
You know any python?
Basically is there a way to setup a webserver that doesn't stop other processes?
Like for example, if you run your bot it goes forever technically
Webservers too
hey look at me ss
Is there a way to make it still process requests but not stop everything else?
Do you have a file called web by any chance
I cant find it
.
uuuuuuu
my cod
so my codes under this DBL
Yeah, everything after var down there
this is a fun code she needs to vote for it to use it and if she doesn't send a message send a fun code in the code below
anyone good with heroku?
You 'd want to else return channel.send(), add return
ok ok
return stops unvoted users from executing that command
stop, I accidentally said ok ok I did not understand. Can you directly throw the code or can you tell?
I can only tell
You also still have to put your code inside that .then(voted => {}) or use await
I'll give you an example
const voted = await dbl.hasVoted(author.id);
if (!voted) return channel.send("Oy verilmedi"); // not voted, return with a message asking them to vote
// Embed code
channel.send(embed1);```
It will only run the embed code IF the user has voted
So you have to change your code since this makes it way simpler
OK, but am I going to type that fun command below into "// embed command"?
Yes
It will only continue if the user voted otherwise, it will send "Oy verilmedi" and stop
ok i m try
wym it brings to code
In what way does it not work? Does it give you any error messages?
You should also remove this, it doesn't do anything
Also, why do you have two open_account methods?
It should be defined, that's weird
Oh
@vast garnet Remove this for now
it workie?



