#development
1 messages · Page 1945 of 1
Would look something like this:
Array(...).fill("naga");
... is the number of times naga should be present in the array. You can determine that by the rarity @earnest phoenix
Follow up to Klay
if (chss.rarity == 'Common') chr = Array(19).fill('nada');
if (chss.rarity == 'Rare') chr = Array(30).fill('nada');
if (chss.rarity == 'Epic') chr = Array(46).fill('nada');
if (chss.rarity == 'Legendary' || chss.rarity == 'Champion') chr = Array(103).fill('nada');
chr.push('chr');
An even simpler solution would be to assign each rarity a number then make one call to Array fill
So if it picks nada they don't get it, if it is chr they get it. There will never be any other it wants to pick from?
Would something like this work?
const isWin = (type) => {
switch (type) {
case 'COMMON':
return Math.random() >= 0.5
case 'RARE':
return Math.random() >= 0.6
case 'EPIC':
return Math.random() >= 0.7
case 'LEGENDARY':
return Math.random() >= 0.8
case 'CHAMPION':
return Math.random() >= 0.9
default:
return false
}
}
Would need the chances tweaked tho, in this example COMMON would have a 50% win rate.
Just something from the top of my head, could probably be done better.
thx
let array = ["chr"]
//AFTER FILLING
["chr", "nada","nada","nada","nada","nada","nada","nada","nada","nada"]
``` so there will be more chance of getting "chr", right? Or the order isn't important?
or the fill works different?
Is it possible to select 100 random users with a certain role in a discord server and put them in a txt file and send it? I feel like there's some sort of JS function for it but I can't find any 
if you're selecting by random index, then order doesn't matter
Maybe Math.Random an array
index? i use the math.random ```js
chr[Math.floor(Math.random() * chr.length)]
Yes
You're selecting an index of the array randomly
So it doesn't matter where it is
ok
I don't see why you wouldn't just select the character if Math.random() is lower than a certain number, and select nada if it's not though
Like ```js
if(Math.random() < 0.1) {
return "chr";
} else {
return "nada";
}
probably a lot less computationally expensive but idk
Sound extremely inefficient filling an array just to then randomly pick out a value
Try this: #development message
Pass in the rarity type, COMMON , RARE etc, and it will return true if a person won, false if they lost.
^^
won?
what they won?
they will be winning chr randomly
if you wanted to be fancy and avoid errors you could use an enum 😉
they haven't already won it
the point is that you don't have to fill an array and select a random index
it accomplishes the same thing
but with less work
Didn’t want to put too much on the table yet xD
You want a random sample of users from a collection. The easiest way would be to assign each user a random number and compare it against 0.5.
users.sort((_) => Math.random() > 0.5);
Then you can just grab a subset of the array, like with .slice.
I mean
I just want to do
message.guild.members.fetch() (which gets all the IDs)
and then just get 100 of them
theres abt 300 ppl in the server
Do you still want to filter by their role ID and get a random sample of them, or something else.
Fetching is what you just wrote.
So basically just fetch the members, make sure they have a certain role, then pick them
About 300 people have that role
let guildMembers = await message.guild.members.fetch()
How would I get just the user ID from here
user.id i assume
const isWin = (type) => {
switch (type) {
case 'COMMON':
return Math.random() >= 0.5
case 'RARE':
return Math.random() >= 0.6
case 'EPIC':
return Math.random() >= 0.7
case 'LEGENDARY':
return Math.random() >= 0.8
case 'CHAMPION':
return Math.random() >= 0.9
default:
return false
}
}
``` finally I understood it
thx
You could just use map.
guildMembers.map((member) => member.id);
Oh yeah, ty
np, The higher the number, the max is 1(it will never actually return 1), the less likely it is to return true
If you also want to filter by if they have a role, just use filter.
guildMembers.filter((member) => member.roles.has(...));
And you can compose that with map and sort like I showed above.
0.5% is 50% win rate. So 0.1 they would win 90% of the time
oh
now you can't read it
Hmm, so how would I only make it get 100 of those only
Like I write it all to a txt file
With only 100 IDs
how do i check if the card is common, rare, etc..? before i used "card.rarity === "Common"
okk
You can use first(100) on the collection.
ohh ok ty
Of course, most of this stuff is documented (https://discord.js.org/#/docs/collection/main/class/Collection), so you can manipulate the collection however you need it.
That's weird. It should.
For reference I'm still using Discord.js 12.5.3 bc im lazy ;-;
It's an old bot so I didn't bother to rewrite most of it
It should still work in that version.
Can you verify what member is.
guildMembers.filter((member)
Can you show more of your code
const g = guildMembers.filter((member) => member.roles.has("Verified"));```
Ah now I see
You said that member.roles.cache.has doesn't work, but that should be the solution.
And .has takes a snowflake/role ID
Not the name of the role
Oh ic
Hmm it doesn't seem to work
Just prints []
Let me check my intents one secc
Yeah my intents are on
Weird
g.map((member) => member.id);
Would this work
After I filter out the members w/ the role, then I get their ID?
Because rn it doesn't write anything to the txt file
ah wait nvm got it
Okay so now i have a txt file of all the users like this
(1,2,3) etc
How can I make it so it adds a role for every user in the txt file
Im thinking of for x in the array something like that
for (let userId of <that txt>.split(",")) {
// get the member first from userId, then add the role
}
forEach do thing in the same time, but for loop, not. (if you use await)
example:
forEach
request 1, request 2, request 1 done, request 2 done
but for loop
request 1, request 1 done, request 2, request 2 done
CMIIW
also forEach will execute the code below it even the Promises is not yet resolved
Hey, just got a question in my mind, looked into the python library of topgg(for sending guild count and these stuff), and if I'm not wrong, the bot sends the guild count, it means the bot also can send fake guild count to topgg servers right?
this code is like forEach but it waits until all the promises resolved
Promise.all(<the text>.split(",").map(async id => /* add role here */))
Adding to that, forEach is considerably more expensive than a normal for due to it not being as optimized during runtime
For smaller tasks it's fine, but for larger datasets or heavy processing you'll want to use normal for
So it's like int(time.time())?
So is it like this?
e = discord.Embed(title="", description='{}'.format(int(time.time() + time)))
await channel.send(embed=e)```
It's showing me this error
remove int and try
do some basic debugging
like printing
and you can also make a variable for it and then use it in the description
So like this?
await channel.send(embed=e)```
yes try
worked?
sorry for ping i just wanted to know
You should pinged me actually or I didn't see your reply
Let me try
btw you can use other discord wrappers because discord.py is discontinued
Yeah but I am used to python
you can use nextcord,pycord etc
Btw, how is carl-bot going to do
they'll probably shift like I'm doing
Now you are using pycord?
I'm using nextcord
they literally add every new feature
it's not been a week since discord added timeout feature and nextcord already added it
oh ok
while discord.py just shut down
python3 -m pip install -U nextcord Installation?
yes
you'll have to do some changes though
everything which was discord you'll have to change them to nextcord
try it
its kinda fast too
ok
Is there buttons and buttons actions?
yes
they have literally everything
buttons,dropdowns
but buttons in nextcord are really a lot different from discord_component buttons
How to use webhooks ?
They literally said this.
k thx
You can't. You're shadowing the time module with a variable. Also that's just for the unix time part, you need the whole format <t:UNIX_TIME:R>
Can you give me full coding?
That's needed, I don't think you can have floating point
No, spoonfeeding is no good for ya. Besides, it's against the rule. The most I can do is give you directions. First off, take a look at https://docs.python.org/3/library/time.html#time.time. It returns the UNIX timestamp in seconds as you can see, so you can just add up the user input which also in seconds to get the "giveaway end timestamp." Then just cast it to int to remove the floating point and format it to a string so it becomes <t:THE_TIMESTAMP:R>
Why tf does something returns unix as a float?
Precision You tell me
Really, I can't see a single upside to that 
Like, if u need more precision use millis
If u need even more use nano
But tf floating timestamp?
sounds like a js timestamp divided by 1000
Someone forgot to floor the result probably
Or maybe someone pushed the code as a joke
but realized they couldn't undo it later due to breaking changes
That code is very alien
Are those pointers I see there?
Ah nvm, sometimes I forget python is backed by c
Yeah, CPython is the ref impl
The curly braces should've thrown you off.
Yeah, my brain basically stopped the moment I read the code
C is alien enough, mix that with pointers and lodash and u get me hanging
define HAVE_CLOCK_GETTIME_RUNTIME __builtin_available(macOS 10.12, iOS 10.0, tvOS 10.0, watchOS 3.0, *)
bruh
Enough C for today
Lmao, you're still reading it?
that's enough C for the rest of my life
just write in D
or torture yourself with C++
Hey guys, currently doing a survey for frameworks and libraries developers prefer to use. Please try to fill it out if you can it is only 5 questions. https://forms.gle/PQdtFGAaGqUbGGocA
@solemn latch eh?
That's enough C
Idk if that's against the rules, it's just odd to ask like that
Plus all that data was already gathered by someone and probably available online, so a little search would yield results with a sample way bigger than he'd ever be able to get
hello i have an afk command and it stores the user's id and afk in db but as soon as it use it says welcome back
how do i prevent the bot from removing the data for sometime
after the command is used
Store in db
it is stored in db i just mistakenly typed "not in db"
Then what's the issue exactly
Cuz data in db won't simply "vanish" after a while
UNLESS
inb4 cachedb
That's exactly what you're supposed to store in the db
I don't get how it'd be deleting unless you're purposely doing so
idk
...you're the dev, how don't u know?
as soon as I type -afk it gives me a message that I'm afk and another message that welcome back
Show the code where u send welcome message
ok wait
Hey so Im having this issue with webhook decoding
@commands.Cog.listener()
async def on_message(self , message):
keys = db.keys()
id = f"{message.author.id}"
if id in keys:
del db[f"{message.author.id}"]
await message.reply(f"Welcome back **{message.author.name}** ,I removed your afk")
for member in message.mentions:
if member != message.author:
mid = f"{member.id}"
if mid in keys:
reasonf = db[f"{member.id}"]
await message.reply(f"Mentioned user is afk right now | Reason : **{reasonf}**")
this code
Decoding, yes
Ok, what's the desired result vs current result?
So I have a webhook sending json to discord, is there an easy way to decode it into human readable text or do I have to make a custom bot for that?
Also merry christmas ^^
desired result is i don't want it to delete the id and reason from the db as soon as i use it and current result is it deletes the id and reason as soon as i use it
First, you don't decode a json cuz it's not encoded
Second, depends on what data we're talking about
Merry xmas
You're calling del db
Remove that line and it'll no longer delete
this is what i meant
Its pretty basic stuff
"dispatchTimestamp": "2021-12-25T04:42:54.703Z",
"value": "10"
}```
My original thought was to make an autoresponder but I would need the autoresponder to read one channel and respond in another channel.
Usually you'd have a third column holding a boolean value for whether the user is afk or not
i do not want this to happen
Remove del db
then how will it delete the data when a message is sent
Json is a data structure, if using js simply access it like you'd do with any other object
Then u can get the data and process however u want
You won't
^
huh
Don't delete, simply flip the switch off
let data = JSON.parse(result) garrett
Did u add a value to toggle off the afk?
it's a key-value database
And did u filter results to show only values with enabled afk?
For god's sake, tell me it's not a json database
nope
Mongo?
replit database
just a simple database which stores key and the value not more than that
kinda fast
so I used it
Pretty sure it'll fail fast later on due to increased amount of required data per key
But whatever, time will make u switch eventually
hm so should I be using mongo db
Well, given the lack of info, try using a json structure as value
i know how to use it
Up to you, I prefer sql
Nobody knows until learning
i tried googling
Not that you need a degree in CS, but database stuff is not THAT straightforward for first timers
And while mongo feels easier, you can equally mess everything up if u don't know what you're doing
Depends on what you're storing
Sqlite can run in a microchip without trouble
Research about database types, don't simply go for sql because I said
Different needs, different databases
Baeldung covers a lot abt sql in general
W3schools too iirc
Idk where to find about mongo, but probably w3schools talk abt it too
async def get_prefix(client,message):
try:
with open("prefixes.json","r") as f:
prefixes = json.load(f)
return (*prefixes[str(message.guild.id)],"grabe ")
except:
return (*"-","grabe ")
intents = nextcord.Intents.default()
intents.members = True
client = commands.Bot(command_prefix = "-",intents = intents)
client.remove_command("help")
I have this code when i type return commands.when_mentioned_or(*prefixes[str(message.guild.id)],"grabe ") i get an error
more than one prefix
And what error are u getting?
that it cannot take a function
?
not working
I dont think I can format my questions to the point where I'd be able to not sound like an idiot so Im gunna have to look into this another time.
Goodnight guys
Are u using js?
Error command_prefix must be a plain string,iterable of strings or callable returning either of these not function
Show where u define command_prefix
command_prefix is a way for adding a prefix to discord py bot
But where u define it
i didn't define
Hm
I feel like its kind of odd that there isnt a prebuilt bot that reads json and replies with a well formatted embed.
There is probably, but not as easy as simply plug n play
Alright
Log prefixes
print it's working
{"guild id":"+"
"guild id":"-"}
,
Read from #webhook
"dispatchTimestamp": "2021-12-25T04:42:54.703Z",
"value": "10"
}
auto reply #generaI:
"Something occured"
I'm not a javascript guy, obviously. I dont know where to start for this.
It's not that hard, but quite lengthy to explain it
ok
Print prefixes[str(message.guild.id)]
yes i did this
What did it show?
And this?
wait I'm doing
isn't () required?
Printing it causes a crash?
in print prefixes[str(message.guild.id)]
Put parentheses then
working
What did it print
You have an issue there then
You didn't remove the old print
Oh my
lmao
gn
use linux
Hey @sly sierra would you be able to lend a hand?
"dispatchTimestamp": "2021-12-25T04:42:54.703Z",
"value": "10"
}
I have this webhook output from a website. All Im looking to do is make the output human readable
When a response comes in trying to make it say "Something Happened @ this time"
its not a json file, its a json response. I added the webhook to discord using integrations
I want to take the json responses from one channel and automatically reply to another channel with "something happened @ timestamp"
The way you would do this really depends on the programming language you're using
- Listen to the responses containing JSON input
- Validate if it's a valid JSON and cast to JSON
- Take the timestamp from the JSON input and convert it into an actual date instance
- Use date/time functions to make the date instance into a human readable form
If you're using JavaScript:
- Get JSON input
- Validate and cast the JSON input by parsing using the
JSON.parse()method - Convert the timestamp into a date instance using the global
Dateconstructor - get the human readable form of the date instance using the
<Date>.toTimeString()method
You can take the same approach in other programming languages based on the features they provide
Unpack a list
Give me your output of prefixes, full-on copied. You are trying to unpack a string apparently
You don't need the asterisk in that case
The command prefix could also be an iterable of strings indicating that multiple checks for the prefix should be used and the first one to match will be the invocation prefix.
I'm thinking about making a channel that is private and all the hook messages go there. Call it Hooks
Then a bot that reads each hook and translates it to a message and posts it into a public channel.
No need to verify cus every message will be JSON and same format
I'm not entirely sure how to get started
I see what you're trying to do
- Listen to messages of that private channel with the bot (Make sure the bot has permissions to view and read the messages of that private channel)
- Get the contents of the message and translate it the way I said in my previous message or with your own logic if you will
- Then send the result to the said public channel(s)
Pretty simple and easy to implement
If you tell me the Discord API library you're using for your bot, I can show an example of how you can achieve that in code
huh
Mm?
Hey guys, how do i add 4 shards to my bot in v12?
const bot = new Discord.Client({ partials: ["MESSAGE", "CHANNEL", "REACTION"] });``` this is how i currently define the client
how many guilds?
shardCount:4 ig for max 10k guilds
- Tim knows better
2k
3k* sorry
but the commands are really intensive and the bot is overall performing really slow
so i wanted to shard it
if you have 3k guilds you already have some kind of sharding
its not possible to have more than 2500 without sharding
do you use the ShardingManager?
I need it to give "chr" or otherwise "nothing"
like i'm using ```js
if(functioned === "chr") {
....
...
..
.
} else {
....
...
..
.
}
I am looking wrong. I was looking at my own made dashboard, and all my bots have 5k in total, 3k of which are actively being used. My biggest bot that i am trying to shard, is actually in 2022 servers
if you wanna try using the sharding manager, check the docs
you need to create a new file
this file will start the sharding manager, then the manager will run your bot file once for each shard
{"player":[{"id":"1","name":"11"},{"id":"2","name":"22"}] how i can get id by name? im trying to make command !search name and want to give result as id
for now it's working better than before with only a few lines of code
before there were like 20+ lines
<object>.player.find(item => item.name === searchNameHere)?.id
why isnt it recommended to shard ur bot before 1k servers?
servers* and every shard you create means more mem usage and cpu usage
and its useless to shard when your bot isnt even in 1k server
Generally speaking I reccomend waiting until 2k guilds, not 1k
that's what i was about to ask
Excluding cases the bot is growing extremely fast. Which is uncommon
^
ight, ty
anyone help me pls
discord recommends sharding at 1500
oh ok
it's far away for me so I can rest until 1500 servers
This is v13, i run v12. Would that make a difference in sharding
or didn't they change anything
the basics should be the same
one of the things that changed is broadcastEval, but you only need to worry about if if you need to use it
Is there a way to make it more difficult? (check picture above)
I learned that 0.1 and 0.10 are the same thing
yes 0.1 and 0.10 are the same thing
Hey, people that have both SFW and NSFW commands to your bots, how are you handling the transition to slash commands?
Is there a way to only display some commands in NSFW channels?
then I can make it more difficult with 1.9? or There can be more numbers like 100, 1000
oh
idk too but johand said that 0.5 is 50%
and 0.1 is 90%
so 0.9 is 10% maybe
function isWin(type){
const h={"Common":0.5,"Rare":0.6,"Epic":0.7,"Legendary":0.8,"Champion":0.9}
return (h[type]<=Math.random())?"chr":"nada"
}
let chra = isWin(chss.rarity)
Math.random() gives you a random number between 0 and 1
including decimals
meaning it can be 0.000000001 for example
or 0.04816487263874
you are checking if your number is smaller or equal to Math.random()
meaning if your number is 0.5, then you have pretty much a 50% chance that Math.random() gives you a number smaller than that
because it can only generate numbers between 0 and 1
and 0.5 is right in the middle
if you give it 0.1, that means you only have a 10% change of getting a number smaller than that
because 0.0 to 0.1 is only 0.1, while from 0.1 to 1 there is 0.9 possibilities
oh
you can give it as many decimals you want
for example if your number is 0.001
what are the chances Math.random() gives you a number smaller than 0.001?
0.009?
oh yeah
so from 0 to 0.001 there are 0.001 possibilities
meaning 0.1%
one in one thousand
1 in 1000 of getting a card?
yes
so yes, in your current code, 0.1 does equal 10%
so if you do 0.01 it becomes 1%
0.05 would be 5%
etc
ty
I know a better random number generator
women
aha aha get it
because they're unpredictable at times

$ touch woman
fatal: cannot touch woman
fuck you
dug me i check my bot?
what?
db.set(`giantt_${author.id}`, true);
db.set(`archers_${author.id}`, true);
db.set(`minions_${author.id}`, true);
db.set(`arrows_${author.id}`, true);
``` Can I do the same thing in another and less lines code?
Yes
I'm changing my whole code to a more smoother one
Thanks :)
so I'm wondering if there is a way
Put each string (giantt, archers, etc.) in an array and iterate over it doing the same operation
or an even smarter approach
don't use 4 entries to save a bool
instead have something like flags_USERID and use bit flags
saves much more space and performance
function massUpdateUserData(tables, user, value) {
return tables.forEach(t => db.set(`${t}_${user.id}`, value));
}
massUpdateUserData(["giantt", "archers", "minions", "arrows"], message.author, true);
oh thx
im going to have to agree with the bit flags approach
ok so
const check = await database.find({ userid: userid, "data.primary":req.user.id })
that would work wouldn't it?
what database
mongo
shouldn't it be findOne
well yes and no
i'm doing this so it checks if the data exists
it then does js if (check > 0) { // does shit }
put an !! on there to make it a bool
where
!!(await database.delete(/* ... */))
i'm not deleting tho 
null
Sweet. Just check for that with findOne and you're good, no?
If no data exists that matches your filter, then why bother with .find?
Wat
Pointless
Non null is already truey
It's just unnecessary converting
I don’t mean that
I mean it’s not retuning anything even tho it exists
I think I did the selection but wrong
Bit*
Are you sure you're searching in the right collection?
Yes
yo! i have a discord bot hosted on heroku currently, and the way i test the bot is by scaling the dynos down to 0, and then i can test locally. this makes the bot go down, though. is there a way to keep the production bot up while testing a different version locally?
You should create a new bot used for beta testing and push updates to your main bot when you’ve rolled out new features
And only host the beta bot locally, since it only needs to be up during testing
testing on live sites is always the answer
saves time

Why the db restarts for some users? (it restarts for random users) like they got 100 cards and a few hours or days later they don't have anything (coins, cards, etc..)
That's pretty much unanswerable without more info on your setup
ok
my first guess is: you're using heroku + file-based db
then give more info
the db is quick.db
...and why would I suggest mongo?
why?
quick.db is shit indeed, but any db will suffice
all it changes is how quick the bottleneck will come
but that's not the point
where is the bot running?
replit
you can't use file-based dbs on replit probably
so you recommend me passing to mongo?
idk
there is no obsession
i just thought mongo wasn't file-based
Mongoose 
The db works fine though
thing is
yeah that
file-based dbs arent persisted on replit
so you'll always return to the earlier state of it upon restart
You can use MongoDB atlas
that'll work?
anything outside of replit will work
damn you could even use github as database holder
it'll yell at u due to constant pushes tho
but general rule is, you want to get a vps asap
it's not expensive, and will solve 99% of the issues you have
Yes but i dont like mongoose, You can find a better alternative on js or not use odm
Atlas 512 MB free
use atlas to store a serialized sqlite db 
then unserialize on startup and use in-memo
Am I allowed to use apple emojis on my website? And will they get also displayed right on windows/android devices? 🧐
that's an unicode thing that you need to check each device's catalogue
nothin guarantees an emoji will be in all 3 devices
I mean, unless you compare the palettes
Okay, but don't I get trouble if I use them? For any use like personal, commercial etc.
don't think so, since they'll show different for each device
emojis are unicode, the device just fancify it
like \😄
this is how it shows for me (w11 version)
for u it could be different
yes for me it looks like the apple smile emoji since I'm on a MacBook
alright^^ thanks 🤝
yw
just note that if the emoji is not present for the viewer it'll appear as a square
quick question, how does this site look to you? https://aliabdaal.com/ does it also show apple emojis or windows ones?
I’m Ali. I’m a doctor, YouTuber and podcaster. On this site we explore the strategies and tools that help us live happier, healthier, more productive lives.
I get Apple emojis
you're on an iPhone, iPad, MacBook etc. right?
MacBook
@low orbit it's because it's getting your hour (24 hour format) on your computer.
It's 6:30pm for me so it returns 18, etc.
Cool. 🙂
getTime uses UTC
the date is transforming it to your time isn't it? (yes)
Passing the time to the date constructor will make it be in your timezone.
Right.
Um
Dylan has stopped working.
You can create a UTC date object by passing the year/month/day/hour/minute (lol) to Date.UTC() and then setMinutes on the date object.
I would just use a library like moment (which they've stopped developing) and do the like 1 line solution
I really would suggest reading the djs guide from beginning to end before trying to move to v13
thats the guild you want non global commands to go to
for example if you want eval, you can have eval only show in one server.
I think its covered on that page
or the next one
(also you dont want global commands for testing, they can take an hour to update)
so I register all my commands once in a test server for development.
it can be
Slash commands along with components
fast
if (interaction.member.roles.cache.has('847248675389702204' || '896044829438533673')) {
Is || not a thing?
Cause it only reads the first role.
djs v13
Not as you intended though.
So it's evaluating the first string and the second string
But that's clearly not what you wanted.
o-o I wanted it to look if they have both roles
I also tried && but 🤷
or like one of the roles I mean*
You should check the general .has twice
hm
e.g. ```js
if (cache.has(...) || cache.has(...)) {
// ...
}
if (interaction.member.roles.cache.has('847248675389702204') interation.member.roles.cache.has'896044829438533673')) {
ah
with the ||
alr
If you want to check if the member has both roles, you should use && instead of ||.
There are other methods of achieving this.
For example, instead of using .has(...), you could use .hasAll(...).
Which accepts an array of IDs.
Which would accomplish the && part.
do i need GUILD_PRESENCES to check for total members of a guild? wth?
No.
Well, it depends.
Do you want all the members, or just the number of members in a guild?
You can get an approximate without guild presences.
do I need to enable any privileged for my bot to fetch audit logs?
I don't believe so.
@sudden geyser yea, i was able to get just the total members without it, thats all i needed really 🙂
hullo
its says 'npm' is not recognized as an internal or external command,
operable program or batch file.
did you install node/npm?
so ```js
guildMember.timeout(0, reason)
should be work, right?
i got node
i couldn't get it exactly
do i got to get npm/
did you restart the terminal after installing node?
i opened it after i got the node
0 probably doesnt work does it? 👀
NaN and null removes the timeout, are you trying to remove a timeout or set one?
i want to remove timeout
does your bot have that permission?
yes
try restarting your pc, then running it. if that fails check node is properly installed
strange 👀
any errors?
Error: val is not a non-empty string or a valid number. val=null
when i tried null i got this ^
Genuinely why do people shit on d.js caching system, real answers only.
?
because it was bad... in v12
100x better
Do you have any comparisons?
i might just give up
tim would be able to explain it kek
node -v
you didnt install node
might just need to set it to an empty string for some reason 👀
should i do current version
LTS
ok
nah 
i tried already
lemme check the github issues then
i can't find anything 
I couldn't either
might be best to re-ask the question so someone who knows can help
What permission should I use for mute command?
depends
If you're using a role, how about checking if the user can manage that role?
And if they can apply it to the target?
manage_roles?
more specific
I believe the recommended permission for most commands is the permission it would require for the user to do it manually
If using timeouts, how about that new permission Discord added
Hmm
MODERATE_USERS I don’t think is right necessarily
MANAGE_ROLES or that is probably fine
idk does it added to discord.py
add_reactions
administrator
attach_files
ban_members
change_nickname
connect
create_instant_invite
deafen_members
embed_links
external_emojis
kick_members
manage_channels
manage_emojis
manage_guild
manage_messages
manage_nicknames
manage_permissions
manage_roles
manage_webhooks
mention_everyone
move_members
mute_members
priority_speaker
read_message_history
read_messages
request_to_speak
send_messages
send_tts_messages
speak
stream
use_external_emojis
use_slash_commands
use_voice_activation
value
view_audit_log
view_channel
view_guild_insights
Value is my favorite permission
I found all of permission in Discord.py Docs
I found this in another bot have been declined
Should I follow this?
Are you using Discord.py or a fork of it?
Then you should consider migrating to a fork like Nextcord or Pycord
Hmm
As they've probably added the permission
And added support for other stuff, like slash commands
I will think about it cause it will change the full code
For this time I will use manage_roles but maybe I will change
@solemn latch ahh my bad... i fixed it thank you for ur patience
my bot is not comming online when i do node .
const Discord = require('discord.js');
const bot = new Discord.Client();
const token = 'no';
const PREFIX ='';
bot.on("ready", () => {
console.log('i am online!')
})
bot.login(token)
is it logging anything?
?
alot of stuff
well, show that stuff
am i supposed to past it here?
yes
Is there a way to play an audio buffer using lavacord?
probably yes
the problem being connection.play() expects a string as a parameter
so obviously I've gotta do it some other way
you have to check the source code and see what .play() does internally
somewhere in there is a function that plays audio from a stream
so you can call that function directly instead
agh
for sql should i store discord ids as varchar or BIGINT?
i feel like a type of int is better cause a id is a number
but id have to use bigint cause the numbers too large?
perhaps I should just not use lavacord since my only intention is to play mp3 files
if you're using a library that uses bigint ids, yes
if the library uses string ids, then you're gonna have to convert them back and forth all the time
which honestly isnt that bad
my brain is completely fried
I hate discord audio
My goal is to take an mp3 file as an attachment and play it in a vc which is proving to be much more difficult than I thought
I wonder if there’s a way to save the buffer of the attachment into memory without having to download the file through a request. I’m probably missing something here but I’m going to go to bed instead of doing more of this
i forgot lavalink is an audio server
meaning lavacord is just a client for lavalink, it does not actually play any audio
it only sends instructions for lavalink to do it
so you will need to either stream the audio buffer to lavalink somehow, or save it as a file and tell lavalink to play it
if you are on linux, you can write the audio files to /tmpfs
which is basically a ram disk, writing and reading on it should be as fast as ram
Yeah I think I’m going to move away from lavalink and just use my own stuff for this
Since I’m not by any means intending to do anything other than stream audio from a given mp3 file
If I was getting audio from YouTube or something like that then I’d use lavalink but I think it’s better to just throw together some spaghetti code and improve it over time
If you were using Java, there's lavaplayer
Which is made by the same lavalink guy, and basically a standalone (well, kinda) lib
i need a help
No, you need to ask it first
I don't think LP was made by the same person who made LL
L
Request.post(authOptions, async (error, response, body) => {
if (!error && response.statusCode === 200) {
this.token = body.access_token;
}
});
if (this.token) return this.token;
Any one have clue how I can wait for the request?
because it just return undefined
if (this.token) return this.token; needs to be inside the callback
You need to make sure that the check is done after the token assignment
but it still return undefined in the function
the the request in a function
like the function return undefined
That means that either it errored/the status code wasn't 200 or access_token isn't a property inside body
Use promises and resolve when the token is available:
new Promise((resolve) => {
Request.post(authOptions, async (error, response, body) => {
if (!error && response.statusCode === 200) {
this.token = body.access_token;
resolve();
}
});
}).then(() => {
// Code to run after the promise is resolved and the token is available.
});
You can also use the reject method the promises provide to reject the promise if the token wasn't available
will it return the token, if I put whole thing in Function?
You can return the promise as the value of the function and resolve the token with the resolve() method provided, then the token will be directly returned as the value of the function after you resolve it's promise
Quick Question, I recently informed myself about NextJS and I'm wondering if I can use the same server for frontend and backend. Because like there's the /api folder etc. 🤔
how do i check if a bot has slash commands registered for a specific guild using discord.js? is that even possible?
I want a span with </ as content, how do I do that?
like
literally "</"
as the visible content
<span></</span>
maybe with space? 🤔
Not what I want...
Going to use < instead
Is there a way to get the date of when a document in a model, in MongoDB, was created?
Like the date of when this document was created?
you could add a date field
i don't think mongo has a way of tracking when a document was created
Unfortunately, I can't update 600 documents. :/
Oh, thanks. 👍 I'll try figuring out how I can get the objectID.
Ohh, makes sense.
Hey, so it returned the _id, common sense, although, how do I convert it to a date, again?
i'll have a look
lemme do some testing rq
console.log(data[0]._id.getTimestamp()) worked for me
in my instance, i did js const data = await accounts.find({username:username}).toArray(); console.log(data[0]._id.getTimestamp())
so <object>._id.getTimestamp()
Alright, I'll check it out now, Discord currently lagging. Thanks, though. 🙂
Except that you actually can. Create a script which adds a createdAt property to each document, and for future documents create a createdAt when you create the document
but then that won't really work
because they won't have the actual dates of the signup saved
with the ID, you can get the time stamp
They can get the original date with the ID...
then save it another property so they don't always get it from the ID
i mean thats true
Is there a function to convert 2021-08-17T07:55:58.000Z to a human readable time?
Nevermind, found it.
new Date().ToString()
Is there a way to convert 1st to first with st small up.
what language?
Javascript.
I have this function.
function ordinal_suffix_of(i) {
var j = i % 10, k = i % 100;
if (j == 1 && k != 11) {
return i.toLocaleString() + "st";
} else if (j == 2 && k != 12) {
return i.toLocaleString() + "nd";
} else if (j == 3 && k != 13) {
return i.toLocaleString() + "rd";
};
return i.toLocaleString() + "th";
};
const nth = function(d) {
if (d > 3 && d < 21) return 'th';
switch (d % 10) {
case 1: return "st";
case 2: return "nd";
case 3: return "rd";
default: return "th";
}
}
found that
lmao that variable naming
wait thats probably not helpful 
oh the symbol?
OHH
Indeed.
Subscript
2 secs
what are yo using it in?
:))
Leaderboard. 
Yes, can't be something else. 
i mean it could be a website 😳
At this case, nope.
well 90% ppl here are bot devs tho :))
1ˢᵗ
damm
How, which website.
90% here are devs in general
...
Huh, what's your problem?
I appreciate it, though. 😂
Thank youuu.

Same. 
hey how do i attach these 2 avatars next to each other?
var images = [`https://cdn.discordapp.com/avatars/${user1[1].user.id}/${user1[1].user.avatar}.png`, `https://cdn.discordapp.com/avatars/${user2[1].user.id}/${user2[1].user.avatar}.png`];```
I cannot use jimp or anything as it's a link to a file. not the file itself
Tryna get the profile pics next to each other, but it's not working out for me
i don't think you can do that
unless you use canvas or something to put the images next to eachother
as the images are both going to be square, you could technically do a 512x256 image and have both images together
Guys! Is it possible to convert an image URL to emoji for embed message directly through code using dpy?
You mean get the image url and make it an emoji?
Yes
Yeah that should be possible.
#save the image first
with open("saved image name", 'rb') as fd:
await ctx.guild.create_custom_emoji(name='emoji name', image=fd.read())```
I'm getting the icon URL as response, i wanna use that like an emoji on the embed message
You would ideally make it validate that the message contained an attachment
if it did, get the attachment url, save the image from that, then open image and add emoji like i did above
keep the discord emoji image size limit in mind tho
Is it possible to do without saving it first tho ?
it is but not the easiest
the easiest way is to save the image and then remove at the end
after adding the emoji you would do os.remove("image name")
os.remove("Windows/System32")
mac gang
you could just load the image from memory instead of saving it
also is an upgrade from a GeForce GTX 1050Ti 4 GB to a GeForce GTX 1650 4 GB worth it?
hashing
depends on how much that upgrade will cost
its £150 for the 1650
bcypt and salt the password. Try between 10-12 rounds
Don’t use outdated hashing algorithms like md5 or sha1 etc
how much is a 1070 instead of 1650?
i'll have a look
also Argon2
By comparing the hash
ah ok thanks
thanks
bcrypt.compare(myPlaintextPassword, hash, function(err, result) {
// result == true
});
i'll have a go later
Personally never tried it. Would you recommend it over bcrypt?
its not that scary if you know how things work
its newer and won a couple security competitions, but otherwise its pretty much on equal terms with bcrypt
its recommended if available and convenient to use
Ah, any performance benefits? Or basically user controllable?
not recommended if you need to go overboard to make it work
user controllable, same as bcrypt
whats likely to be the best for my login system
whichever of the three is easiest for you to implement and use: bcrypt, scrypt, argon2

