#development
1 messages Β· Page 394 of 1
oh
ok
my favourite command
that apparently works in #development π€
Ah, I'm not getting to actually develop when I hang around in this Discord all the time
wym
why can bots talk here
RIP
same
welcome to the club
they cant

i was using my bot for an example with the eval command earlier
i just haven't changed it back yet
pls
Talking of improving this Discord server, how do you review suggestions?
And why do you often never hear back? π
did you leave some feedback, there's a lot we may or may not have missed
generally i look at them but i cant guarantee remembering them
hey guys, in Discord.js, how can i tell where a "missing permissions" error is occuring?
Can you not try/catch?
In other libraries you actually NEED to do that because Discord doesn't provide an API to find out whether you can DM a user or not
just as an example
Generally try to not rely on try catch though and check by yourself beforehand
How to display a number between 100 and 1000 ?
You mean choosing by random?
If you mean that, please utilize the search engine of your choice.
@hardy moon what coding language
JS
(node:41728) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send messages to this user
are you banning the user and then getting the user after you banned him
@languid dragon Stahp, he is just being a lazy piece of.. :S
because you can't send a message to a user that doesn't exist
ik that lol
well show code
@earnest phoenix if there is an error, send a message that his dm isnβt open or whatever
the dms are open
im using an alt
Is dat lizard?
no
]]ev -s (function(){ let user = m.client.users.get('330325177151913984'); user.send('nice meme').then(()=> { /* ban user here */ }) })()
@earnest phoenix still there?
i didnt use any awaits
Well, either await or promises
1 sec

ignore the //here
:reeee:
let member = m.guild.members.get('286166184402092042');
member.user.send('nice meme').then(()=> {
member.ban()
})
what Brian said
i dont know how to use promises but i'll read the docs
DoThingA().then(() => DoThingB());
ill walk myself out the channel now
I know, wrong syntax
Alright then, Seems that promises are really useful
Thanks for the help guys
it worked
thank god
xddd
doThingA().then(doThingB);
Ah, didn't think it would be that similar to C# π€
mhm, you can do that in that specific example
Because of the parameterless lambda
Does it actually have a result?
it can
Well, figured that, but I meant in the way you wrote it there.
function doThingA () {
return Promise.resolve('ass');
}
const doThingB = console.log;
doThingA().then(doThingB); // logs 'ass'
which part of it
Oh, bad phrasing, I'm not confused
but I would imagine code readability suffers
if you do that with a lot of things
i love resolving ass
how long does it usually take for a bot to get its certificate application reviewed?
const doThingA = async () => "ass";
const doThingB = console.log;
doThingA().then(doThingB);
π
@barren valve Oliy does them himself so it can take a while
it's the same thing, they might not know async functions return promises
because you're mixing async and .then
it can be done in even more ways
ik
const doThingA = () => new Promise(r => r('ass'));
oh ok thx @quiet bobcat
np
and if you get too reliant on awaits, you'll end up having blocking code
so if you do multiple awaits after another you are waiting for a promise to be resolved one after another, it's best to understand Promises before async/await
because you can do Promise.all to do them in parallel
(as of right now) async/await is nothing but syntactic sugar anyhows, so yeah, better to understand the basics first
just like classes

Object.prototype syntactic sugar
but classes are so much easier to understand
henlo jacz
yaaaa
I'm trying to update server count. Is the token the same as the token used to login the bot?
lmfao no
Thanks!
yukine i will definitely add that
Anyone know why I cannot get the total amount of members in a single guild with Discord.js?
Like it always gives me undefined
how can i make my bot send help?
like for a example
gameset (watching etc.) (text) changes the game
if i do >gameset help it gives help
Wdym?
ik that its simple but im dumb lol
@cunning oxide try message.guild.memberCount
it doesnt work for some reason
If it doesnt work too try message.guild.members.size
i get undefined message
t!eval message.guild.memberCount
@cunning karma can you help me?
@drowsy falcon yeah grekxx
look what i sent
Did you define message event as msg @cunning oxide
@drowsy falcon help for what?
how can i make my bot send help?
like for a example
gameset (watching etc.) (text) changes the game
if i do >gameset help it gives help
It should give help but for what the command or what??
like
if i do >poll (message)
it creates the poll
if i do >poll help it gives help, how to use this command
Oh π€¦
lol
if(args[0 === help]) return message.channel.send("Your help message") @drowsy falcon
Simple
And if that not work too try if(args[0] === help) return message.channel.send("your message") @drowsy falcon
Did it work??
Try the second one
Show me your code in my server
kk
Anybody who could check my queue mechanism to see what i am doing wrong
since its something with the mechanism
?
Nvm I went up higher
i got this
if(wUser.hasPermission("MANAGE_MESSAGES")) return message.reply("That user cannot be warned! :warning: ");
but
As a higher rank
I cannot warn lower ranks with that power
is it possible to change that?
Seems like you are making it so you cannot warn a person who has manage messages
I mean i could change the manage messages perm to something else
but for instance if i change it to manage_server mods will be able to warn eachother
and thas not what i want
What ranks have manage messages, that's what you need to find out
Alright
Make sure your person your trying to warn doesn't have it
I gtg now, bye
Got it, Bye
Thanks for the help
https://hastebin.com/uviqexoxuh.java image manip utils for java beginners
I use them so I thought I should share
yes
faster? what's the difference?
okhttp doesn't have a retarded api
supports http/2.0 (j9 does too, but i'm not sure if it does by default for url connections it doesn't)
can someone recommend a vps?
Ovh
Digital ocean
Aws, digital ocean
Search Google
thanks
can anyone help me here
what do you need help with
bots dont respond in here
when i do it


i want it to play the gif in the embed how i do that.
google it
set the embed image to the direct link
ah ok
i dont know what to put
to get it to work
@inner jewel help
soz for mention btw
how can u check a specific guild then run this
bot.on('guildMemberAdd', member => {
var role = member.guild.roles.find('name', 'Supporter');
member.addRole(role)
});```
```javascript
try that
@earnest phoenix add the guild parameter in the function + check through ID
@earnest phoenix actually nvm I think the guild parameter is useless in this since it's for a specific guild
hint on searching guilds through id: bot.guilds.get
ππ»
i tried js bot.on('guildMemberAdd', member => { if(bot.guilds.get("396459465093939222")); var role = member.guild.roles.find('name', 'Supporter'); member.addRole(role) });
why are you using an if statement with that
Β―_(γ)_/Β―
if you want to use if, easy way to do it:
if (guild.id === "some guild id") {
// do some stuffs
}
``` you'd also need to add the guild parameter to the function
@earnest phoenix
alright then, thats fine
bot.guilds.get returns a collection
@topaz fjord no
<Client>.guilds is a Collection which extend map, Map#get returns the value for that key if present, and if not null
@restive silo cucc outta here
so no matter how many times i use bot.login, it always said, ""bot" is null or not an object." What do i do?
i am LOST
sounds like you lack of basic knowledge about your choosen programming language
π
That i do
then why not reading stuff up and try to understand the basics first, before actuall making a bot?
thats the easier way
looks like i dont have a choice. Hopefully my laziness wont get the best of me during that timeπ
thanks for the help though
how do you fix this? https://some.government-database.info/IzzVvNTU.png it was sent 3 times
send it once π€
I am.
some code would be nice
ok
maybe you have more than one instance of the bot running
@night imp ```js
exports.run = async (bot, msg, args) => {
await msg.guild.members.fetch();
msg.channel.send(There are **${msg.guild.members.filter(m => !m.user.bot).size}** users. There are **${msg.guild.members.filter(m => m.user.bot).size}** bot${msg.guild.members.filter(m => m.user.bot).size == 1 ? '' : 's'}. In total there are **${msg.guild.members.size}** members.)
};
exports.info = {
name: 'members',
usage: 'members',
description: 'Shows member count.'
};```
if your shit is sending more than one time then you should do a lot more than put return at the end of your command functions 
find actual problemo
isnt this a problem? https://some.government-database.info/IzzVvNTU.png
yes but find the meme that is causing it
meme
meme
wow
How do you get an emoji's ID?
click open link

thank!
yee
send an emoji?
yes
for animated emoji you can do 
oh
and for regular emoji you can do <loading:393670580232257538>
ohhh i get it
sorry my discord app crashed just now
imma try it right now
thank you!
Whats the better alternative to Opusscript
There is one that works better I can't remember the name of it
JS
node-opus
i have a tag/autoresponse system in my bot, and it has variables (such as %{user} and %{displayname}) which will get the current users name/displayname, im using an object for this and it works fine so far
but i want to extend this functionality further from simple %{user} and %{tag} variables to something like %{random}, which i want to have a syntax like %{random:this is a string|here is another string|this has a 1/3 chance of being chosen}, but i don't know how to implement a syntax like that
and obviously the %{random} would be replaced with the randomly chosen response out of those 3 options (or however many the user decides to put)
I mean, use a regex to capture groups from : group 1| group 2 | so on
im pretty shit at regex and i had a go at it myself but didn't really get much success
this is what i ended up with https://please.zbot.me/Fpocz5EE.png
plus there's a lot of issues doing it like this (unless theres some solid regexp that i can create), like only being able to use one %{random} tag, and not being able to use other variables inside the random variable
my console keeps throwing this:
at item.request.gen.end (/rbd/pnpm-volume/768faaa2-1c53-4031-b548-770885ea090a/node_modules/.registry.npmjs.org/discord.js/11.3.2/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:71:65)
at then (/rbd/pnpm-volume/768faaa2-1c53-4031-b548-770885ea090a/node_modules/.registry.npmjs.org/snekfetch/3.6.4/node_modules/snekfetch/src/index.js:215:21)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:118:7)
(node:7936) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 342)```
what could this be?
i know somewhere it misses permissions, but i don't see the cause
@steel tinsel if it can read messages but cant send message in the channel can cause missing access, if ur help command dms and the person has dms closed also can cause that, if u have music and a person ask it to join the voice channel and it doesnt have access to talk/join it also sends that error
What is the context? Send the code
(node:92084) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.``` Why do i get this error when my bot have **role managing** perm
probably your bot doesn't have some other perm that it needs
try to put ur bot role above the other role
@spring ember i don't know context, i just know it kwwps throwing that error
how do i fetch an invite for each one of the guilds the bot is in?
yes
try to learn how to use .createInvite
Also, you might want to think about .catch in your promises
uh, so i tired to kick the user then send him the dm and log the message in the moderation channel but if his dms are closed the user cannot be banned
so i tried this
await kUser.send(kickEmbed).then(()=> {
kickChannel.send(kickEmbed);
})
}catch(e){
kickChannel.send(kickEmbed);
message.guild.member(kUser).kick(kReason);
}
}```
I run it and it doesnt do anything
nor kick the user or even give a error
help?
π€¦
u are supose to console.log(e)
and see wats the error

I have a question if i use spaces in a switch will it work? / how do i bypass it if it dosent
like this case T r e a s u r y:
string tags?
let guildRole = realmeye[message.author.id].guild
switch guildRole: { ```
@earnest phoenix theres no error
@low owl they are actually names not ideas because im making a verification bot that uses a api
@earnest phoenix ok so it works?
switch(x) {
case "a": a(); break;
case "b": b(); break;
default: stuff();
}```
@austere meadow for your random thing you'd need an actual parser
loop through the chars, keeping track of them
fuck i dont know how to use a parser and im using javascript so that doesn't help my case 
ill have to look into it but thanks
@fleet mason But you use Discord API guild roles right?
@low owl i give them roles and the roles i know how to find but the guild roles is a game
I got this so far
kickChannel.send(kickEmbed);
kUser.send(kickEmbed).then(()=> {
})
message.guild.member(kUser).kick(kReason);
what is kickChannel and kUser?
Your formatting is a bit off and you should also await or promise the actual kick but ah
Otherwise looks right I guess
Wait, you delete the message and expect an exception?
message.delete().catch(O_o=>{})
kickChannel.send(kickEmbed);
kUser.send(kickEmbed)
//why do u have this but dont have anything here :/
/*.then(()=> {
})*/
message.guild.member(kUser).kick(kReason);```
if ur kUser is message.mentions.members.first() then i know where u f up
uhh
kickChannel is let kickChannel = message.guild.channels.find(name, "moderation_logs");
and k user is
let kUser = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
ah
just do kUser.kick(the-mods-shitty-reason)
Dude you use catching of errors wrong though :(
That's just being lazy. You can before even executing the command tell if you will get an exception or not, why still use the catch?
i have a bot that runs on "python" does anyone have an idea how do bot do run on a VPS?
alright
or is there any site?
@earnest phoenix are u using google translate?
I'm from another country, helping me translate google ..
well most vps are paid
I already have a paid one
Then you need to decide what kind of workflow you want to have
do you want to manually update your bot? Do you want to use a Ci/Cd etc.?
@earnest phoenix then pretend ur on ur computer and host it on the vps without closing the console/terminal whatever u call it
Well I do not need a start.sh?
to run bot in vps screen
I do not believe
im trying to make sure that when a user is kicked or banned from my server that
it doesnt show a "goodbye message"
but rather just "user kicked"
can anyone help? I'm using discord.js
no
like within my bot
i have a welcome / leave message
that runs on "guildMemberRemove"
i'm trying to make it so that when i run a kick command
Well, where exactly is your problem then?
it doesnt show that goodbye message
i dont want the bot to run that function when a user is kicked
Try to describe your situation a bit and what you are stuck on
ok
one minute
so, i run this command, and it still sends the goodbye message
but all i want it to send
is the kicked embed in a channel
one minute
this^
i dont want the "Goodbye message"
how to not get it to send that i guess
yeah
this thing is being weird
i will use the audit logs then
didnt think of that i guess
lol
thanks guys
I bought a root

what do I select from here?
You won't learn anything with that "behavior". You need to try things by yourself or research on your own.
^
Always asking others won't help you
But to answer your question, any of these. I don't know what desktop/applications is though.
@earnest phoenix, yes, the kick i did.
@earnest phoenix its a private bot anyway. I'm not using it in any way for my profit or anything + he has been credited and has been asked if i can fork it.
thats fine
Hey
hi
Any Discord4J people in here? My bot is running into major issues atm and I can't really tell what exactly is going on. It seems like it is failing to connect to Discord because I keep seeing websocket errors like "Connection reset by peer" and stuff like that. Restarting doesn't seem to fix anything. Anyone have issues similar to this before?
reset by peer makes me thing you're trying to connect to discord with 2.5K guilds but not sharding
The bot has about 940 guilds
:blobhmmm:
TBH I haven't done much with regard to sharding other than turning it on with the recommended shards method
Yeah im not sure, Do they have a discord api channel?
(probably best to ask there)
I asked on their server as well
afaik reset by peer is a network error
I should add that connections to other apis have not been affected, it seems to only be a discord issue
switch guildRole : {
case Friendzoned :
message.member.addRole(Friendzoned);
break;
case Naknoemo:
messag.member.addRole(Naknoem);
break;
case Red Ice:
message.member.addRole(redI)
break;
case nutty:
message.member.addRole(nutt)
break;
case Destructive Dragons:
message.member.addrole(DestructiveD)
break;
case Amigoz:
message.member.addrole(Amigo)
break;
case DOOM:
message.member.addRole(Doo)
break;
case Semii:
message.member.addRole(Semi)
break;
case Mini Nut:
message.member.addRole(MiniN)
break;
case Fairy Tail:
message.member.addRole(FairyT)
break;
case T r e a s u r y:
message.member.addRole(Tres)
break;
case Konoha:
message.member.addRole(Konoh)
break;
default:
message.channel.send("XD")
}
}``` what did i do wrong?
^^^^^^^^^
SyntaxError: Unexpected identifier
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:607:28)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Client.client.on.message (C:\Users\sande\OneDrive\Bot\EUW Bot\index.js:31:23)```
i need help :/
error:
^^^^^
SyntaxError: missing ) after argument list
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:383:7)
at startup (bootstrap_node.js:149:9)
logout
[Process completed]```
code:
```js
client.on("message", async message => {
//cant even do anything
})```
I thought it was async (message)
it doesnt matter
O
Lol
update node
i think my node is updated
node -v
lemme see
v6.11.4
doesnt support async/await
yeah you need 7.6+
ok
get current
9.11
9.11 or 8?
recomended is 8
I said above
9.11
ok
@spring ember ok thx but now i got this error ``` case Red Ice:
^^^
SyntaxError: Unexpected identifier
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:607:28)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Client.client.on.message (C:\Users\sande\OneDrive\Bot\EUW Bot\index.js:31:23)``` How do i fix it?
case "Red Ice"
string tags
ok i have a stupid question ``` if(djksajd) {
}else {
jdsakjds}
Commands only work in testing channels
client.on('message', function() {
const duration = moment.duration(client.uptime).format(" D [days], H [hrs], m [mins], s [secs]");
let replies = ["im in beta!", `im up for ${duration`];
var interval = setInterval (function () {
client.user.setActivity(replies)
}, 1 * 1000);
})
doesnt seem to be changing after a while :v
some1 help :vvvvvv
You can't set activity as an array
o
You should check out d.js docs
a so thats what im doing wrong :v
@neon root #312614469819826177
Hey, can someone help me set up a cooldown for a specific cooldown... I'm having some trouble. I'm using discord.js.
Thanks. Where do I even set that cooldown... its weird.
Now in the command event add this
@earnest phoenix u broke https://media.turtle-bot.com/f/r621X.png
@topaz fjord then wot
quick question for anyone using a Command class for commands
is there any significant different between doing
exports.settings = {command: 'help', description: 'Displays all available information about commands and help for zBot.', usage: 'help [command]', throttle: {usages: 3, duration: 10}}
and creating a command class, extending it through all of my commands and creating a constructor for all of them? is there any reason i'd actually want to do that compared to just making a settings variable and exporting that
Depends, More personal preference
Not really
ok cheers
idk i just see a lot more people using command classes these days and i was just wondering if theres anything to it
there isn't anything too special about command classes expect being nicer + more work at some points

lots of people like using them for no reason when an object would be faster and simpler instead
same goes for maps
it keeps the code tidy
people like using maps for storage where an object would do the exact same thing but faster
also it depends on the structure
it does, hence "lots"
I'm talking about (arguably ig) the majority, not everyone
not saying classes are useless, they aren't
@clever yew Maps vs Objects
What about it
Write a big essay about how Objects are faster but Maps are more functional
Map is a collection, you must use it when you want a dynamic keyed collection of key-value
You should always avoid plain objects for this feature, since every property you add/remove to/from it, it makes V8 re-compile the entire object from scratch, which is slow
Also, Maps are faster than objects, what are you talking about Jacz?
540M vs 527M ops/sec respectively
Maps don't have the overhead of looking the prototype and parents if a key is missing, as it looks in an internal map which has been optimized in V8 6.4+
Map#get: https://vgy.me/aczq5s.png
Object Accessment in JS is kinda spreaded
But yeah, from Benedikt Meurer (V8 developer): https://vgy.me/XEMdMF.png
You can check the slideshow here about why plain objects is a bad idea for this kind of things: https://t.co/ZDH1Uld5CF
cc @uncut slate
is there a better way to iterate over the users collection than this or is this the fastest
const users = client.users;
for (const [snowflake, user] of users) { ... }
Sorry, I couldn't find the exact part from the specification as it's 827 pages long
@austere meadow depends on what you wanna do
(About Object Property Accessment)
i have a Find class and im basically iterating over all users to find different things based on the query (like id, username, tag, discriminator, etc)
I'd say usejs for (const user of client.users.values()) { /* ... */ }
the user object
If you need the id, you can access to it via user.id
okay ill give that a try
y const?
You don't need to cache client.users, the left hand expression of of creates an Iterator instance, therefore it creates the iterator, and for each yielded value from it, run the block
var is better for most things
Nope
ive just read that its faster to cache it
var should be avoided at all costs
No var is not better for most things, var should never be used in ES6+
oh I guess things are different now, it's been years since I used js
and var hoists so it can be really fucky
I thought the only difference is the scope
nope
Variable declaration with let and const are faster post V8 6.2 (Node.js 8.3.0 and newer)
nice to know
@austere meadow POJOs used to be faster than Maps, yes, but it got a speed boost with TurboFan (which outdates the information from many StackOverflow pages), and lately in V8 6.4, it got another speed boost
(think you mean Aeth
)
Node.js 10.x will ship V8 6.5, but they're bumping to V8 6.6 once node-sass fixes the issues (which they already did, yesterday)
And the release date for Node.js 10.0.0 is set to 24th April
oh good to know
One small step for nodejs
According to Myles Borins, Node.js' TSC Director
tries to reference "one small step for man kind" but fails
(Pretty much who manages it all)
interesting stuff, I had no idea @clever yew @earnest phoenix

I have been studying V8's internals to comprehend many stuff that is under the hood in V8, so I could optimize my applications specially for it
also, I was surprised to see you suggest a for..of
I use them myself but I everyone I know gives me shit for it π
for..of is actually very performant
Its performance in the great majority of things is either as fast or faster than a for loop
Since in the primitive for loop, you do:
1. Declare a variable
2. Check the condition
3. Accesses to a position from the array, having to re-calculate the shift position from scratch
4. Run things with it
5. Call third statement
6. Go back to 2.
In a for..of loop you do:
1. Initialize the iterator
2. Check if iterator is done
3. Accesses to the current position from the array, being optimized as the position doesn't shift from 0 but by the current position
4. Run things with it
5. Go back to 2.
There's some overhead in both, but basically the for loop is optimized by nature (it's very easy to compile to Assembly), the for-of loop is optimized by the V8 engine and is able to skip some things
Things such as in a for loop, V8 has to check you're always accessing to numeric properties and it's between 0 and the arrays length (otherwise it checks the prototype chain), which is quite bad. Of course, in some scenarios, this could be optimized (or is already optimized) to avoid the checks, V8 already has this functionality, and I believe it's doing this since TurboFan
In a for-of, V8 knows that by nature it'll never access the prototype chain but to each %Element% in the internal array slot, so it doesn't need those checks
Both end up with some overhead:
The first needs all those checks plus accessing the internal array slot -> Gets optimized to use the internal array slot directly and shift the position smartly
The for-of has the Iterator overhead, doesn't need to check anything but %Iterator.done% -> Gets optimized like 
Conclusion: They're equally fast, main difference is that for-of is way cleaner
But if you need index aswell, for is the best solution
As I mentioned before, for-of is equally or faster than for in arrays, the reason is because most of us do this:js for (let i = 0; i < arr.length; i++) console.log(arr[i]);Where V8 has to access to arr.length in every iteration (which has some overhead), instead of this:js const arrLength = arr.length; for (let i = 0; i < arrLength; i++) console.log(arr[i]);Which comes to be noticeably faster than the previous. However, this is much readable:js for (const elem of arr) console.log(elem);Isn't it? π
And it's as fast as the second code
Also much shorter 
is that so 
Another upside of for-of, it works with any iterator, whereas for doesn't
You can get completely consistent code with it 
>>> for x in range(5):
... if x/4 == 1:
... break
... else:
... print('error')
...
>>> for x in range(5):
... if x/5 == 1:
... break
... else:
... print('error')
...
error
thats really cool :3
@clever yew What do you mean by works with any iterator exactly?
One moment
generators right?
I understand how Symbol.iterator works, but I don't think that's what kyra is referring to
not completely sure
pretty sure he means generators
Generator functions return iterators, @earnest phoenix @uncut slate
I know...
yeah, but how does that tie into "using any iterator"
Map.entries(), Map.values(), Map.keys() are Map's iterators
You can do for (const key of myMap.keys()) {} and key will be every key from the Map instance
or values and it'll be every value
Ohhh, that's what you're referring to
Or entries and it will be a tuple key-value
Same thing for Set, which has all 3 iterators with the same value
const myArr = [1, 2, 3];
for (const element of myArr) {}
for (const element of new Set(myArr)) {}```
if you put a console.log(element) in both for-of bodies
It'll print 1, 2, 3
That is, their iterator works the same
As they both have Symbol.iterator which yields each element from it
gotcha
No matter what, as long as it has a generator function, you can get each yielded element from it with the for-of
wdym by "which yields each element from it"
That's why for-of is very consistent
It can iterate over anything that is an iterator
Map, Set, Array... they're iterables, you can iterate over all three in the same way
Array.prototype[Symbol.iterator] is a generator that yields every value
that's why I think he meant
I know what Symbol.iterator is and all that but like what do you mean when you say yield each element from it
aka im confused what yield actually does
generators yield
generator.next 
function* test() {
yield 1;
yield 2;
}
for (const el of test()) console.log(el); // 1, 2```
generators are great
they are
Also thisjs function* test() { yield 1; yield 2; } console.log([...test()]); // [1, 2]
Yeah i just read the whole Iterators and Generators guide
tho i'll forget it in 5 seconds
if (msg.includes("help") && message.mentions.users.has(bot.user.id)) why does that not work?
and msg = message.content
@earnest phoenix why dont u just use .startsWith?
Or a framework that handles that for you
if (msg.startsWith("<@bot.id> help"))
There are a couple of bot frameworks that support prefix mention
Also, that won't work very well, Speak
When the user has a nickname, you'd do <@!userid>
I want to point out that you should not 1) rewrite your code to check prefix for every command 2) check prefix for every command
hmm
no dw
(msg.includes("help") && message.isMentioned(bot.user)))
ill try that
i think the second part is wrong
not sure and too lazy to check rn
just in case someone does help @cold summit
@cold summit help
wrong channel
nope
oh
Only works in testing
this is about bot development, don't tell me to argue about python and js in here.
@low owl
Well, it is kind of bot development related.. in the end you use the tools to make a product and before you do that you should know which tool to use
Anyways, seems like you don't want to have a good discussion. Then might as well not do it.
What discussion @earnest phoenix
he was shitting on python
and saying js was better
@floral stone
didn't want to make more sparks
That doesn't mean it's bot development related. Yes, if you are talking about it in a way related to bot development then yeah but a general conversation about superior languages isn't really bot development, more just coding.
Anyways, it's just a coding language. It's just a preference. Who cares!
pat thief

π
Really?

for js, how to you detect the amount of characters written
class NickCommand extends Command {
constructor() {
super('nick', {
aliases: ['nick'],
args: [
{
id: 'member',
type: 'member'
}
],
clientPermissions: ['MANAGE_NICKNAMES'],
userPermissions: ['MANAGE_NICKNAMES'],
channelRestriction: 'guild'
});
}
exec(message, finna) {
if (!finna.member) {
return message.channel.send("**MEMBER NOT FOUND**");
}
let args1 = message.content.split(' ').slice(2);
var argresult = args1.join(' ');
return finna.member.setNickname(`${argresult}`).then(() => {
if (argresult === `meme machine`) return message.channel.send('What is this?')
if (!argresult) return message.channel.send(`_${finna.member}\'s_ **nickname was successfully reset.**`)
return message.channel.send(`**User's nickname was successfully changed to \`${argresult}\`**.`)
})
}
}
module.exports = NickCommand;```
string.length?
How can i make a paid version of my bot
Paywall features people like, keep a database of paid user IDs (maybe hashed or something to make Discord happy), profit.
but how do i do that tho
@glossy mason
question!
how are the search results ordered? clearly not by the number of upvotes..
@earnest phoenix Depends. The basic idea is you need some way for people to send money and attach their ID with it (maybe Patreon? not sure how much you can do with their Discord integration). And then as I mentioned, a way to store those IDs so the bot can check against them when a user calls a paid command and only allow paid users to use it. I haven't done any work with payment APIs before, so I'm not fully sure what's out there that could possibly let you do it all automatically.
What kind
Sqlite, json, MySQL
what do you want to do @earnest phoenix ?
@spring ember wdym
with the database I mean
store user ids for a premium version of the bot
choosing database isn't obvious and what others use might not be good for you
umm
how do you plan to do that?
no one here is going to give you a full tutorial on how to make a premium bot
if you want it to be automatic, use patreon webhooks and their REST api
the easy way would be asking users to provide proof they donated
and manually give them permissions
"patreon web hooks", ah cool, TIL, thanks.
Ohh i want to kill my self irl now because of this bull crap
if !CheckMAC(body, request.Header.Get("X-Patreon-Signature"), hmacKey) {
http.Error(writer, "Invalid signature", http.StatusBadRequest)
return
}``` ```go
func CheckMAC(message []byte, messageMAC string, key string) bool {
mac := hmac.New(md5.New, []byte(key))
mac.Write(message)
expectedMAC := mac.Sum(nil)
return hex.EncodeToString(expectedMAC) == messageMAC
}```
@dire shell
How would I be able to make a command that checks if the user has voted. If they have then they have access to certain commands
heey
Hi?
lol
@dire shell if using js dbl.hasVoted("id")
Id being the members id?
yes
webhooks and dbs don't have anything to do with d.js fyi
D.js isn't related to patreon rest api and the implementation is up to you
You know let me explain this
I have patreon
someone gets the role
every 10 minutes the people get checked
they get added or removed to a premium version
clearly you aren't listening to us because we know what you want
you know fuck my life
im going to go find my knife
you're overreacting here
Don't please
then help me
Read first and think after about how do you want to implement it
I CANT READ I HAVE DYSLEXIA
then how did you just read his message 
i can barely read
@earnest phoenix clearly you just want to be spoonfed so just take the time to actually do things yourself and not expect the answer to be handed down to you.
guild.owner, the docs are your best friend.
https://discord.js.org/#/docs/main/stable/class/Guild?scrollTo=owner
kk
can anyone help me figure out how to create a bot??
scratch that. on my gfs laptop she wont let me download anything on it. is there anything associated with bosshunting and timers?
@signal peak if you're looking to create a bot, visit https://discordapp.com/developers to start
What language do you know
How do you find up time for a bot in JS, I tried but the command ended up breaking
Any bots for feedback? Where people can leave feedback in a server
@clear tiger client.uptime
@alpine lark You'll need to explain more, but there's a bunch of bots that do that
Lemme make sure I did it right
Or else I'll implement that in mine
So it was just an error in my command, thanks @clever yew
I had client.user.uptime lol
yw ^^
milliseconds afaik
Can anyone tell me how to do a youtube upload notif on discord.js?
how to detect if ur bot is nicked? d.js
member.nickname will return null if not nicked
ok
How to get info using Client ID? Discord.js
I said infomation
Like name
and this is worng
wrong
client.user
have fun from there
client.user
@earnest phoenix I have and I need to get the info
I don't want to see my bot info
I have my friend client id for test
and I want his bot name
How to get it
^^^^ Discord.js
Why do you have mee6's profile pic? π€
It's color altered tho
Well yea. I just have experienced way to many people that impersonate bots with a similar attitude.
Anyways to get back on topic, what do you want now? Be more specific and polite please.
If my understanding is correct, he's using his friend's bot and he has the client ID but not the name of the bot... And he wants to obtain the name?
@low owl
Sorry for the tag
Possibly, but I don't want to try and guess what he wants. Lilly he won't answer anymore anyways.
No worries :P
Likely*
Hehe maybe we should tag him...
Jesus, mobile typing is hard
client.users.get(the id)
Yeah ikr
or client.fetchUser(id)
Oh.. Good idea π
or for master client.users.fetch(id);
If he just wants the name can't he just look from the discord client
Much less hassle
I assume that is users.get, and fetch is actually downloading it into cache and the return.
But what do I know
why would get cache it?
I cannot get Fb Page feed using graph API
its already in a Collection
lmfao
@low owl ofc fetch would cache it
but i mean u can disable that
Sorry im confused what you are trying to tell me
Forgive me for my ignorance but what's the difference between get and fetch
Well
get gets it from the collection
aka its already in cache
fetch fetches the user from discord and set's it into cache
Ohh ok
fetch gets it from cache if its in there iirc
dont think it does for stable
in master it does tho
Oh no
You're comparing a NodeJS library to a Python library
?
just no.
How so?
Anyways, we just had that "discussion", more like stupid talk, yesterday
Lmao I'll just scroll up
Hehe I'll do my best
Nothing worth to read though. It comes down to what you want to use and what you are more experienced in with anyways.
Languages and libraries are tools and you have to treat them like that. Some are better for the job than others depending on your project.
Nicely phrased.
Thank you π
How do i make it so this discord wont get level up messages
Idk
client.on("message", message => {
if (message.author.bot) return;
if (message.channel.type !== "text") return;
if (guild.id === "264445053596991498") return;
// i put that there so this server wont get level up messages
sqlscore.get(`SELECT * FROM scores WHERE userId ="${message.author.id}"`).then(row => {
if (!row) {
sqlscore.run("INSERT INTO scores (userId, points, level) VALUES (?, ?, ?)", [message.author.id, 1, 0]);
} else {
let curLevel = Math.floor(0.1 * Math.sqrt(row.points + 1));
if (curLevel > row.level) {
row.level = curLevel;
sqlscore.run(`UPDATE scores SET points = ${row.points + 1}, level = ${row.level} WHERE userId = ${message.author.id}`);
message.reply(`You've leveled up to level **${curLevel}**! Ain't that dandy?`);
}
sqlscore.run(`UPDATE scores SET points = ${row.points + 1} WHERE userId = ${message.author.id}`);
}
}).catch(() => {
console.error;
sqlscore.run("CREATE TABLE IF NOT EXISTS scores (userId TEXT, points INTEGER, level INTEGER)").then(() => {
sqlscore.run("INSERT INTO scores (userId, points, level) VALUES (?, ?, ?)", [message.author.id, 1, 0]);
});
});
})
@earnest phoenix π€¦ do message.guild.id
ok
var args = commandbody.split(' ');
let cooldude;
if(!args.lenght < 1) {
cooldude = message.author;
} else if(message.mentions.size >= 0){
cooldude = message.mentions.members.first().user;
} else if (args[1].lenght == 18 && args[1].match(/^[0-9]+$/) !== null) {
cooldude = message.guild.members.find("id", args[1]).user;
}
let uiembed = {embed: {
color: 0x4A90E2,
title: "Profile for " + cooldude.username,
"thumbnail": {
"url": cooldude.avatarURL
},
fields: [{
name: ":tickets: Discriminator",
value: cooldude.tag
},
{
name: ":id: ID",
value: cooldude.id
},
{
name: ":battery: Status",
value: cooldude.presence.status !== null || cooldude.presence.status !== undefined ? statustags[cooldude.presence.status] : statustags['offline']
},
{
name: ":robot: Bot",
value: cooldude.bot
},
{
name: ":comet: Account created on:",
value: cooldude.createdAt
}
],
timestamp: new Date()
}
};
message.channel.send(uiembed);```
title: "Profile for " + cooldude.username,
^
TypeError: Cannot read property 'username' of undefined
at Client.client.on (/app/server.js:593:38)
at Client.emit (events.js:180:13)
at MessageCreateHandler.handle (/rbd/pnpm-volume/768faaa2-1c53-4031-b548-770885ea090a/node_modules/.registry.npmjs.org/discord.js/11.3.2/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
at WebSocketPacketManager.handle (/rbd/pnpm-volume/768faaa2-1c53-4031-b548-770885ea090a/node_modules/.registry.npmjs.org/discord.js/11.3.2/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:103:65)
at WebSocketConnection.onPacket (/rbd/pnpm-volume/768faaa2-1c53-4031-b548-770885ea090a/node_modules/.registry.npmjs.org/discord.js/11.3.2/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (/rbd/pnpm-volume/768faaa2-1c53-4031-b548-770885ea090a/node_modules/.registry.npmjs.org/discord.js/11.3.2/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:296:17)
at WebSocket.onMessage (/rbd/pnpm-volume/768faaa2-1c53-4031-b548-770885ea090a/node_modules/.registry.npmjs.org/ws/4.1.0/node_modules/ws/lib/event-target.js:120:16)
at WebSocket.emit (events.js:180:13)
at Receiver._receiver.onmessage (/rbd/pnpm-volume/768faaa2-1c53-4031-b548-770885ea090a/node_modules/.registry.npmjs.org/ws/4.1.0/node_modules/ws/lib/websocket.js:137:47)
at Receiver.dataMessage (/rbd/pnpm-volume/768faaa2-1c53-4031-b548-770885ea090a/node_modules/.registry.npmjs.org/ws/4.1.0/node_modules/ws/lib/receiver.js:409:14)```
it gives this error
the error is fairly obvious
oof
if(message.mentions.size >= 0){
cooldude = message.mentions.members.first().user;
} else if (args[1].lenght == 18 && args[1].match(/^[0-9]+$/) !== null) {
cooldude = message.guild.members.find("id", args[1]).user;
} else {
cooldude = message.author;
}``` this goes directly to the else
input: m:userinfo 403937044474232832
i facepalm
when does discord.js cache an user?
so ur memory doesnt break
if u understand what i mean
not a gud phrase but π€·
is there anyone thats willing to test the serverprefix change command from my bot
I just want to see if everything works well
at #commands
Hey, my bot got muted for saying "Unknown Command". I just removed it, but will my bot still get muted if it reacts to the message with a β ? If it does i'll just remove it
no
So β is allowed?
I mean maybe not on this server
Alright
e!
wat bot is it
Yeah that's fine
Going to build without the response just the β one sec
If it was something generic then no but e! is unique
done
Alright, thanks!
my help command doesn't have any permission checking, but for some reason whenever someone types help with whatever argument in DM it prints me this error:
AttributeError: 'User' object has no attribute 'guild_permissions'
Can someone help me?
I want to use that option to post the servercount ( #312614469819826177 example from duncte123#0001) but the part with Request request = new Request().Builder() gives me the error, that 'Request(okhttp3.Request.Builder)' is not public in 'okhttp3.Request'. Cannot be accessed from outside package
Any ideas on how to fix?
use the official libraries because those examples are outdated
Another (maybe even stupid) question: From where on the github do I get the latest version of the API?
It says latest version of commit. So 4b27930 or what would it be?
Or can I just use LATEST?
Alright. works. Thanks @trim plinth
Are there any limitationa about f.e. how many times you can change the servercount in a time-period (hour)?
so one per second.
even that can be considered spamming, it is recommended to do big enough intervals in posting your server count, especially if your bot is not joining that many servers
yeah.
I guess I juist update it every time I restart my bot, which is atm 2 or 3 times per day... (on average)
the best way in my oppinion is to make a background task that will update it like, lets say, every minute
I have mine on every 30 minutes
Β―_(γ)_/Β―
I update every guild create / delete
@misty pawn that'd be new Request.Builder()
you want to create the inner class Builder, not call a method named Builder in an instance of the outer class Request
@topaz fjord I first planned to update every Guild join/leave but meh....
My bot won't grow that fast I guess
only one guy needs to just spam 30 times join&leave event
anyone know the bot tatsumaki and its autorole feature? well i want to know how to make my bot get role ids by itself so it can assign roles no matter which server it is on
im using .js if you need to know
ping me if you can help
Lol, my bot got muted again for the same reason, i fixed the issue but i ran the wrong build of the bot. Could you help me? @uncut slate (you're the first mod i see)
my bot is @paper holly
It's running the correct build now
I'd suggest doing that in a different channel next time
Oh, sorry, where should I?
#general, #memes-and-media, #commands, #265156322012561408 or DMs






