#development
1 messages · Page 654 of 1
what would be the simplest way to do that, aside from regular sweeping? since it doesnt offer a client option for that
I run a task that clears emoji, guildMember, user, channel, messages, presences (these eat SO MUCH) every 10 minutes
Its so good
I just delete the entire collections
Heres an example on github https://raw.githubusercontent.com/dirigeants/klasa-pieces/master/tasks/cleanup.js
Deletes everything that eats memory
You gotta have ur own task system to make it run though
interesting, thanks for that
Np
It brings down memory to like 20-50mb depending on the amount your bot constantly caches
actually on d.js master
its easy
just enable partials
then you can actually not cache users and members
¯_(ツ)_/¯
just do a fetch on your events if you work with those then voila
d.js also provide a way to do that
if (message.member.partial) await message.member.fetch()
yes, but it doesnt have an option to automatically prevent caching in the first place, does it?
you can disable message caching, but not user/member/other
yes, that is what we are discussing, so the only thing we can do is regular sweeping
the partials just enables us to do it easier to recache those things
actually I have a technique myself so that I dont need to loop on those although I don't really uncache my members
Im on master and i only need the cache (members/users) like once a day :/
Useless to store 190k users for only 5 to be used on one day
Lmao
in 2 days uptime my bot only eats around 6.5gb at 2 mil user and member caches
In 2 days uptime my bot crashes because it reaches memory limit
3gb on 190k users
its not just members and user cache you are caching on d.js
Where presences of the users are eating up half of it
Ye but users are the most eating
in my experience d.js cache "tons" of things
Like holy shit
when I say tons yes tons of it
if you disable presence websocket events, does it prevent them to be cached as well?
I used heapdumps from 5s uptime vs 2 day
I dont think so, you need to modify the lib to prevent it to cache the presence at the first place
And users was 79% of everything in the heapdump
which I do
My d.js is forked to prevent the FF
- Emoji Caches
- Presence Caches
- Message Edit cache is always 1 only
Hmm
by default message edit cache is unlimited
imagine editing the same message for 100 times
OF THE PRESENCE CACHING
where is that cache even stored?
message._edits
jeez
But is there a way to not sweep them, just never cache them UNLESS you ask them and get rid after
edits or precense?
Like something in my bot needs presences, but thats the only thing
In the entire bot
That uses those presences
just fork the library on where it store the presence
And its only when a guildmember executes that thing
like just remove the .set() part
And only the guild's members presences get used
can you extend/overwrite some classes during runtime instead of modifying the lib files?
but how do you fetch the presences when you need it?
there is, Structures.extend but thats so limited
it doesnt allow you to change how d.js cache
you can just change the data cached
not how it caches
what we want is on how it caches
not the data cached
cant you replace the entire extension with your own clone lul
Is there a way to ask the API for presences when i need them
yes but you are replacing the "data cached"
If not then im stuck with auto caching of all presences..
not where it is being set
thats why I run my fork and just maintain it on par with d.js master
i see
Structures.extend is good in something like, modifying the original message cache
to add your things
it doesnt let you modify the stores
Sigh im being ignored
^I saiid you can avoid it being .set() at the first place
But i need the cache sometimes
I asked like 5 times now
How do you fetch them
When i need them
And theyre not cached
https://discord.js.org/#/docs/main/master/class/PresenceStore unfortunately you cant
So you cant ever get a user's presence if its not in the cache?
What the fuck is this bs
if discord sends their presence update they will be on cache again
What do you use presence for first?
there are a lot of alternatives
depends on what you want
Guild member info
online offline playing?
If thats the case you need to cache the presence
just uncache members and users to reduce ram
So i can format commands based on device they use
but if I were you I would just drop presence cause its just horrible in ram
2 mil presence eats 2 - 4gb of ram
It works but i cant seem to get any of the deleted cached things back when they are gone
before I use presence for what you are doing and Im at 10gb at 1.5mil
user and member caches
but now Im sitting at 6gb
Like when i fetch an user from the API it doesnt return activity
thats almost 4gb of savings
presence is on more on WS I believe so
Discord will be sending presence when a user presence got changed or something like that
if you are insistent on keeping your presence
then you need to do a major overhaul on presence store
So i guess i should get rid of online, dnd statusses in my commands?
Meh
as I said forking the presence store is the better solution
If it saves memory, i should then
Yeah no im not gonna waste my db on presences tbh
190k data stores on a db, changing probably every second is terrible
cant you refactor presences into saving only the data you need? it probably saves a lot of stuff you dont need
Unless RethinkDB is capable of storing it every second
you can flush to db on an interval
I even dropped support for presence things updates like username profile pic etc changes
due to how resource taxing and blocking it is on javascript
Well either way, does your fork only disable presence caching and it runs on master branch when theres updates too?
Oh i see but i need the user's own name change whenever they change but i think fetching the user updates that?
Can i use your fork maybe then
the fork is kinda modified to the bot
its not fit for public usage
Ill stay with my sweeping task then lol
It wipes like 20k presences every time it sweeps
well one thing you can do is modify ._edits cache in messages
Along with emojis and others
if you disable message cache, does it also disable message edits cache?
Meh i have a client option that gets rid of old cached messages
it disables edits, deletes, events as well
it also affects the bulk delete for some reason
you can used the fetched messages
thats why its weird
I can fetch 100 messages manually myself but it only deletes 50 which is my max cache on messages
get cached for 7 days?
d.js default message cache is 200 per channel
it will be forever on 200 and replace the old messages with new ones if you dont sweep
for small bots thats not noticable
but on big bots, imagine having 1mil text channels with 200 messages cached
that doesnt sound so feasable
Mem Usage :: 61.51 MB
Uptime :: 7D, 20H, 39M
Users :: 8,898
Guilds :: 5
Channels :: 150
My bots stats (my beta bot which im testing it on, not in 220 guilds lol)
Its currently 4 minutes away from next sweep i think
export a channel messages?
What would be the impact on RAM usage with 22k channels
even its not on your cache as long as the messages is not deleted you can fetch them back on api via its id
and cache are all in ram
depends on your cache
22k channels isnt that big but the messages can
if its deleted and you didnt store it
bye bye
you cant fetch a deleted message
My bot cached 8k channels
And 190k users
On 230 guilds
Along with like 2k emojis
A dozen of roles
and idk what else
sweepers is fine if you dont use cluster sharding
I cant shard with 230 guilds lol
im gonna run some tests on my bot thats in 1.2k guilds
the performance impact on sweepers gets bigger the more guilds on a single shard
and you will have big problems when it goes overboard
My bot wont reach 1k anyways
Its been online for 2 years now
And it has 230 guilds
230 in 2 fucken years
You can store messages unless the user asks to have it removed
But why would you need to store messages anyways? What kind of command would you need it for?
"useless logging" is not allowed
like you are spying on your users
or selling their info
something like that
You can't store what is not needed and/or the user doesn't know you store basically
That's why I have a rules screen before the user even uses my bot
They have to accept or decline
You still can’t be logging info unless it’s so important that your app won’t work without it
Well if Discord finds out, your bot will get deleted from Discord I bet
And honestly I see no point in storing unnecessary data without telling the users unless you are an asshole
2.4 End User Data. “End User Data” means all data associated with the content within the functionality enabled by the API or SDK, including but not limited to message content, message metadata, voice data and voice metadata. You acknowledge and agree that Discord and its end users, as applicable, retain all worldwide right, title and interest in and to the End User Data. If you have access to End User Data through the API or the SDK, you shall ensure that your Applications do not collect, use and/or disclose End User Data except (a) as necessary to exercise your rights under this Agreement, (b) in accordance with Discord’s Privacy Policy. If you have access to End User Data through the SDK, you additionally agree to get express permission from the End Users.
You shall not sell, license or otherwise commercialize any End User Data. You may not use End User Data to target End Users for marketing or advertising purposes. You may not disclose End User Data to any ad network, data broker or other advertising or monetization related service.
You shall delete all End User Data upon Discord’s or the End User’s request and within seven (7) days following the End User’s termination of the End User’s account. You may only retain chat logs as necessary for the operation of your Applications. Discord’s offering of an API or SDK that allows you to reproduce or display End User message content is not an express or implied license to such content from Discord.
tfw you copy part of the discord api’s tos
Yes
Because when you link it, barely anybody will honestly read it
Yes
Hey I find it fun to read legal documents
And when you copy a whole section and paste it to a channel, it’s very hard to miss 
I find it boring
And painful
But you do you
One should not create a bot when they dont even read Legal
you will get lawsuited for that
can you pay the lawsuit
I’m using the code:
dbl.webhook.on('ready', hook => {
console.log(Webhook online! http://${hook.hostname}:${hook.port}${hook.path});
});
dbl.webhook.on('vote', vote => {
console.log(O membro com o ID ${vote.user} votou em mim ;w;!);
});
And every time i’will start my bot, i have the error:
dbl.webhook.on('ready', hook => {
^
TypeError: Cannot read property 'on' of undefined
lol
dbl.webhook is undefined
But its the code of the API page
const dbl = require('dbl-api')
I think its that
I have that @earnest phoenix
I cant see you responsible on big things
I didn’t
you need to know what is yes and no
nsfw channel exist for those although somethin that is illegal is red area
ask the bot dev
probably they are lazy
At the first place why even require Administrator, I would question the bot developer's code in this
Anyone can help me ?
try posting the whole code
instead of that part only
.on of undefined means dbl.weebhook is undefined
I would look on how dbl.webhook is defined if I were you
What is the Webhook password?
is it a good idea to enable ws compression?
@earnest phoenix a random password
You can put "test123" or idk
@earnest phoenix and the url?
http://serverip/dblwebhook
@slender thistle I only store data like user ID and user name, command times ran to log possible cheating/macros/transfering to another alt
Should be fine then
@earnest phoenix needs to have something on the page?
??
@earnest phoenix can i use glitch to host that page?
Yes
And at /dblwebhook
I need to write something on the page?
@earnest phoenix ^
No pls stop ping me every time
Ok
Sorry
lmao no
did you install it through the "add package" button?
does glitch give you a ip for where your bot is hosted on
Yes
?
m = 0
while True:
f = input('Write Anything')
m = (m+100)
if f == '/money':
print (m)
else:
print('+100')
```
```Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module> start(fakepyfile,mainpyfile) File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start exec(open(mainpyfile).read(), __main__.__dict__) File "<string>", line 7 else: ^ IndentationError: unindent does not match any outer indentation level [Program finished]``` i think this is a Pydroid problem right?
m = 0
while True:
f = input('Write Anything')
m = (m+100)
if f == '/money':
print (m)
else:
print('+100')
@indigo geyser
who codes in python
a lot of people here
Python is the #5 (2 according to other research) most used language
lazy i already have a bot
What approach do you guys use to keep track of command usage on your bots (count for how many times each command is getting used)
Also I use discord.py, what's wrong with it
i dont keep track, but a database would work fine for that purpose, since its just incrementing a value
@mossy vine Yeah, thought there might be a different approach that I haven't thought of
Thanks
Don't use it
Whatever line it says it has a error on, backspace the beginning of the command to the previous line and press enter
were would i put this message.content.split("#=help",1)[1]
in this
for x in range():
await message.channel.send("")
*my code, hes using my help command as a base
idk what a base is
im trying make it so when u type !hello the bot ask you want you want to type then it types that
so what do i do
for x in range(20):
await channel.send("something")
I would suggest against that
im not going put it in this server
This server or not, you can still get ratelimited unless you are sure it doesn't hit it or put delay inbetween the iterations
Does anyone know how to use modules for commands?
which library
Sorry DJS
Guys i use this javascript var channel = message.channel channel.overwritePermissions(channel.guild.defaultRole, { VIEW_CHANNEL: true }, { SEND_MESSAGES: true } );
but it does only do VIEW_CHANNEL
I think it should be { VIEW_CHANNEL: true, SEND_MESSAGES: true }
yeah, you have 2 objects
I may be wrong though
the second one is ignored because the method only has 1 parameter
@abstract crow i think i have tried that but it didn't work
it's just ignoring the second one
how can i fix it ?
.overwritePermissions(guild.member {
'VIEW_CHANNEL': true
'SEND_MESSAGES': true
'READ_MESSAGE_HISTORY': true
})
Base it off of that
So change some things around
Wait I was actually right for once 🤣
So yeah try , { perm1: value, perm2: value })
ok thanks i'll try it
how to let the bot check that an channel has nsfw turned on?
Lang?
Google is very neat. https://discord.js.org/#/docs/main/stable/class/TextChannel?scrollTo=nsfw
For DJS ^
For python async I have a work-around
d.js @west spoke
ok
Hey guys, I have a question, my userinfo command keeps having an error pop-up it says "cannot send an empty message"
I use node.js / discord.js
can anyone help me?
I'm not sure if I follow, the message is supposed to send the embed
no need for that neko
its a richembed
it does have quite a few typos tho
the error seems to be originating from your index.js file
and that does not look like an index.js file
wait nvm
that was snekfetch
should I do a try catch then?
try logging infoEmbed
I just logged I tried it with the try catch first
it looks like the "nickname" is undefined
i reccommend you read the docs
what d.js version
also try message.channel.send({ embed: infoEmbed })
@obtuse wind
Or you can use npm ls discord.js
did the thing work
my npm version is 6.9.0
ok
it works thanks 👍
np
Yeah because in order to not have an object and send an embed, the variable needs to be named embed
^
Since message.channel.send(embed) is just a shortcut to message.channel.send({ embed: embed })
do you think I should do message.channel.send({embed: embeds}) for all my commands?
Only if it's an embed use that
k
Also 1 more question, why doesn't my clear/prune command send an error message saying that the message is over 14 days old?
npm ERR! code ENOENT
npm ERR! errno ENOENT
npm ERR! syscall spawn git
npm ERR! enoent Error while executing:
npm ERR! enoent undefined ls-remote -h -t ssh://git@github.com/discordjs/discord.js.git
npm ERR! enoent
npm ERR! enoent
npm ERR! enoent spawn git ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Aj\AppData\Roaming\npm-cache\_logs\2019-07-13T20_02_19_301Z-debug.log```
I keep getting this error
But I never have gotten it before when trying to install discord.js master
use the https link
with node . >log-File.txt 2>error-File.txt i can run my bot logs (errors) in a file but on the normal logs how can i log the normale console.logs in my console ?
use a process manager to actually run it
In which location should the vps server be located?
I do not think vps should be closer to the discord API.
discord servers*
discord has servers all around the world
so it doesn't really matter
Voice servers have, and api is only one
if you host the bot in the US you're going to have a small difference between usage in US and EU, isn't anything significant though
I host mine as close as I can to discord servers
if you want low rest/ws ping, us east
I'm sorry for ping
if you want low voice ping to a specific region, in that region
@inner jewel so VPS located in Poland should be good?
wrong continent
it'll work, but if you want low ws/rest pings, you need to be in US east, not europe east
chodzi o mały ping
a my pewnie mamy z 50/60
wiec wiesz
no one can understand you
speak english
@hollow saddle I didn't have git installed when I first downloaded it
But I'll try
Thanks
@earnest phoenix eh nie
discrd api jest w US east wiec komunikacja miedzy tym serwerem a srwerem jest dłuższa
na polskie ping wynosi okolo 200ms
albo 150ms
dla europy zachodniej 120ms
Why limit yourself to only one person helping you when you can have multiple in a channel
That’s fair
@rotund canopy, OP tell you ask here your question If it's a Code Question
It is
I’ve set up almost all of my bot on my own but there’s one feature I’m having trouble with. I need a way for a bot to send a picture and then for people to guess what that picture is (having the bot recognize they guessed right).
I haven’t found anyone able to help me yet
So it’s appreciated if u can help
You could set up an array and inside it, use objects for the pictures url and correct answer and go from there
And then await messages and if the message equals the answer, it’s correct
I’m speaking in terms of discord.js since I’m only experiencing in that
Lol
I can do most of tht. Thanks
This is with Python (not all of this is correct, but the concept is this) ```python
@client.event
async def on_message(message):
if message.content == '$random':
emb = discord.Embed(title='Guess The Image')
emb.set_image(url=your link image here)
await message.channel.send(content=None, embed=emb)
if message.content == 'correct answer':
await message.channel.send('correct')
else:
await message.channel.send('Nope')
Oh thank you
Ik
Like no args for on_message
Specifying content isn't necessary but explicit > implicit ig
I guess that conversation ended but I had to look up "Poland" to know where it was
RIP my history teachers
hi
Not 100% sure if this the right channel, but off-topic is insane atm so seemed better here lol
I am trying to get a small team of BETA testers to test my new bot, I really want to make sure its as good as can be, if you'd like to help out and test my bot, DM and I'll link you to a form 😃
What kind of bot is it
RPG style loot em up bot, I don't wanna give away too much and thats the best way to describe it I think lol
@hollow saddle
Ah I see
I'm trying to push code to a GitLab repository that's under a group that I don't own, but I'm a dev in the group... ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'https://gitlab.com/groupname/reponame.git'
For those who dev on Java, is there a have the same function of
https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Executors.html#newCachedThreadPool()
but with the ability to submit tasks and return a Completable Future instead of Future?
@opaque eagle iirc gitlab “developer” only can submit PRs. Only managers can push straight to it and accept prs
jshell> var e = Executors.newCachedThreadPool()
e ==> java.util.concurrent.ThreadPoolExecutor@26a1ab54[ ... = 0, completed tasks = 0]
jshell> CompletableFuture.supplyAsync(() -> "some async value", e)
$4 ==> java.util.concurrent.CompletableFuture@2b71fc7e[Not completed]
jshell> $4.join()
$5 ==> "some async value"```
@sinful lotus
@inner jewel supplyAsync?
so that wraps the threadpool to CompletableFuture hence not block my code?
you dont
y
heroku is not made for bot hosting
why you want a bot if there is tons of bots already tho
My friend loves calum Scott so I’m trying to send this embed for them, why do I get an unexpected or invalid token?
`!e const discord = require(“discord.js”)
const calum = new discord.RichEmbed();
.setTitle(“Calum is hot”)
.setDescription(“Matt loves calum more than he does his jull”)
.setImage(“https://cdn.discordapp.com/attachments/598700186125991936/599831998537924608/image0.png”)
.setColor(“RANDOM”)
message.channel.send(calum)`
Get rid of the ; after new discord.RichEmbed()
Same thing
Use proper quotes
You’re using the iPhone “”
I believe right?
I’d suggest either making ur eval command auto replace them (there’s variants for single quotes too) or using the proper quotes, by holding down the “ button until it pops up the variation menu and just letting go should give you the proper quote "
or use gboard
oh actually, you get invalid token since if that's your eval command, you are requiring discord without defining the client, logging it in, etc.
if your eval command sends back the output directly you could just eval the richembed without having to call message.channel.send
@valid frigate no wrong, invalid token means invalid character which would be “
YES JUST SEND YOUR QUESTIONS AND WE WILL TRY TO HELP YOU
I HAVE MAKED A HTML REGISTRATION FORM AND I WANNA INPUT A PICTURE HIW WILL I INPUT A PICTURE
Calm down on the caps lock
<img src="image.jpg"> command is not working
CALM DOWN WITH THE CAPS LOCK, AGAIN
AND YES, JUST ASK YOUR QUESTION. YOU AREN'T HELPING ANYONE BY ASKING IF YOU CAN ASK A QUESTION
CALM DOWN WITH THE CAPS LOCK, AGAIN
AND YES, JUST ASK YOUR QUESTION. YOU AREN'T HELPING ANYONE BY ASKING IF YOU CAN ASK A QUESTION
CAPS +BOLD
By asking if you can ask a question, you have already asked a question so simply just ask the actual question. State exactly what the problem is so someone can help you as soon as possible.
All shards are online and the bot is responding in one server but not another. What could be the reason?
how can i public my html project so any 1 can see it
@copper crystal check your ws status
if ws is fine
probably your code is blocked of some sort
when somone spam a command
is that also api abuse ?
more like they are abusing your bot
TypeError: (intermediate value).setTitle(...).setDescritpion is not a function I keep getting this error .
Oh wait
Just noticed what is wrong
Anyone know what the rate limits on webhooks are? (Discord webhooks if anyone needs any clarification)
Anyone know how to also do @frank blaze help but also keep the /help command?
for people who dont know the prefix
Read my last message 
discord.js
how are you checking for prefix right now
wdym 
@tulip wave 30 msg per min
i want it to be @frank blaze help but also for ppl who know the prefix to be /help
@slender thistle discord.py @bot.command
yes
how are you checking for the prefix
you likely have an if statement with something like message.content.startsWith
I'm asking you "which user you want to mention", not "what do you use for your commands"
in all the commands i just add `:usage:"/example",
what command handler are you using
where do i check that
do you have a message event anywhere
can you send the contents of the message.js file
in dms or here
@twilit rapids thx
like tokens or passwords
ill sent that on dms to be more safe tbh
@tulip wave its sent on headers
Oh yeahhhh never checked them
who knows how i could make my bot count this server aswell and his playing thing to then be 50k ?
dont mind the playing thing just how i aalso count this server
what

I need a little help :/. I am trying to add this to my git repo. But it wouldn't show up? It just looks blank like I didn't add anything.
(https://discordbots.org/bot/598431937035763713)```
i dont think you can put a link in a link title
hello, i have a possibly easy problem here
using discord.js i'm trying to split a message's rows in an array of strings
like so
let text = message.content
text.split('n/')
but it doesn't actually split it into rows
New line is \n 
hmmm
i'm trying to see what happens with
console.log(text.length)
for(let i = 0; i < text.length; i++){
console.log(text[i])
}
but the result still is in individual letters even with \n
7
a
s
d
a
s
d
when i write asd asd
Correct me if I misunderstood something, but you're currently printing every character in the string without checking for line breaks or anything
You want it to print "asd" "asd", right?
yes
message.content.split(/ +/g);
so am i doing just
the console logging wrong and it actually does what it's supposed to
When doing text.split("\n") you need to set a new variable or use text
as in let text = message.content.split('/n')
yes but \n not /n
yes frick
It's okay, you'll get used to it ;P
oof
Hello, for my question I'll make an example: the bot asks me for an iD of a random user on discord and he answers me with his nickname and his tag of the genre username#0000. How do I get the bot to give me the username#0000 format but not the mention?
still not good with let text = message.content.split('\n')
I mean if you're typing asd asd there's no new line
@earnest phoenix In Java, I'd simply do member.getUser().getName() + "#" + member.getUser().getDiscriminator()
in javascript ?
getDiscriminator*
<>.user.tag
@uneven rover thx
Thanks Shea 
or you could use User#getAsTag either works
thankss guyss

or member.tag actually depends on how you define member
and what lib youre using...
I do this and isn't work
t/eval let id = "546968486606536706"
message.channel.send(${id.user.tag})
oh discord.js?
That would be a string
yeah
you can define member by client.users.get(id);
then do .send
String doesn't have a property of user
wait im dumb
You'd want to use discord.js to find the user by id, it'll have a function for that somewhere
but if the user is not in one of the bot's servers
If the user is not in the server, discord has a request you can make to find them which discord.js will have implemented somewhere
/eval var id = client.users.get("546968486606536706");
message.channel.send(id.user.tag);
try that maybe
ok
if it doesnt work, try removing user from id.user.tag
and if that doesnt work then replace id.user.tag to id.username + "#" + id.discriminator
@weary lark
t/eval const client = bot
let id = "546968486606536706"
let memberid = client.users.get(`${id}`)
message.channel.send(id.user.tag)```
TypeError: Cannot read property 'tag' of undefined```
Yeah cause it’s a string
okay
okkk
I think
Just get the member by doing message.guild.members.get(“id” or client.user.get(“id”)
Then use .id
Or .tag
you should already be getting the client
in the eval
without requiring it
so what are you trying to get exactly @earnest phoenix?
the discriminator (4 numbers after username), the username (username) or both?
I try to retrieve a user's user's nickname and tag via their ID without going through the mention
okay
try javascript t/eval let id = message.author.id; let memberid = bot.users.get(id) message.channel.send(memberid.tag)
oh feck nickname
XD
Lmao
@uneven rover you'r best
Poor Pie just wants to help
thx u
ima just focus on working on my website now lol
will do
@weary lark
let id = args.join(" ")
let userid = id
let memberid = bot.users.get(userid);
.addField("⛔ Utilisateur gban :", memberid.tag)```
anyone know any good random image apis
i dont sadly
ok
ur using discord.js right?
yes
ok
I just warn on The args ID join the bot doesn't have it in its list of users, I try with client?
im so confused rn, idk why, ill give it to someone else lol
sorry but i cant help you with that one
Did you console.log those values to see if they are correct?
the console say me Cannot read property 'tag' of undefined @quartz kindle
try console.log(args)
i want learn to code but i don't know what for a program is good for a newcomer
php storm or something like taht, i dont know
Visual studio code
One message removed from a suspended account.
One message removed from a suspended account.
^
It's all a preference, but knowing how visual studio code works is a good thing
Yeah
One message removed from a suspended account.
same
One message removed from a suspended account.
word (wait you can code in that?), notepad, notepad++, atom (but can be buggy/laggy), vsc + theres a lot more out there lol but yeah
One message removed from a suspended account.
i went from notepad to notepad++ to atom and now vsc
And what kind of programming language should i start? or what programming language did you start with?
^
One message removed from a suspended account.
okay 😄
One message removed from a suspended account.
i started with js
then went to html, css, and now kinda learning/not learning python
Python and JavaScript are labeled simple programming languages
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
I started with html and css
One message removed from a suspended account.
If you end up going for js, check this out: https://www.tutorialspoint.com/javascript/javascript_tutorial.pdf
But yeah I’d start with js
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
i am a german person, i don't understand all what you write, but some programm languages i hear befor
One message removed from a suspended account.
One message removed from a suspended account.

One message removed from a suspended account.

a friend say to me it's important to learn first the grounding and than the many programm languages, i think you hear i'm really newcomer 😅
One message removed from a suspended account.
Yeah that's fine
😅
Once you know the base of js for example, understanding the base of other programming languages will become easier
I started out knowing nothing lmao and I started JS, the community is helpful and overtime you'll get the hang of it
It's pretty much the same, just in a different syntax
There's obviously more than that to it, but you get the idea
okay, thanks guys for the much help
😅 🙃
One message removed from a suspended account.
👌
so I wanted to use jwt to create auth tokens for my api.
but how can I revoke tokens?
save every generated token in a db and deleting them when revoked?
So I'm trying to make my code randomly select four lines from words.txt and combine them, all separated by dashes
I got the random word part working, but I'm struggling on getting four words
I thought about making an vector and pushback the vector, like in C++
This is the code
https://throwbin.io/uWGXk4m
Ping me if you can help
Throwbin is a website where you can store text online for a set period of time.
it isn't exactly a bot question, but whatever, there are lots of devs here
Is that node/javascript?
“C++”
You dont need an http request to open a local file
Wait no nvrm
Oh youre working on a website, not node
Also, your funcions are creating an infinite loop
Combine calls wordgen and wordgen calls combine
!DOCKTYPE>
<html>
<head>
<title> Creating fOrms </title>
</head>
<body bgcolor="lightblue"><center>
<form>
<h1>Online registration Form </h1>
<b>First Name :</b>\t<input type="text" name="first_name" size="25"><br><br>
<b>Last Name :</b><input type="text" name="last_name" size="25"><br><br>
<b>Age :</b><input type="text" name="age" size="25"><br><br>
<b>Phone-NO :</b><input type="text" name="phonenumber" size="25"><br><br>
<b>E-mail :</b><input type="text" name="email" size="25"><br><br>
<b>Password :</b><input type="text" name="password" maxlength="10"><br><br>
<b>Date of Birth :</b>
<select name="moths">
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
<option value="7">July</option>
<option value="8">August</option>
<option value="9">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select><br><br>
<b>Years :</b>
<select name="years">
<option value="1">1999</option>
<option value="2">2000</option>
<option value="3">2001</option>
<option value="4">2002</option>
<option value="5">2003</option>
<option value="6">2004</option>
<option value="7">2005</option>
<option value="8">2006</option>
<option value="9">2007</option>
<option value="10">2008</option>
<option value="11">2009</option>
<option value="12">2010</option>
<option value="13">2011</option>
<option value="14">2012</option>
<option value="15">2013</option>
<option value="16">2014</option>
<option value="17">2015</option>
<option value="18">2016</option>
<option value="19">2017</option>
<option value="20">2018</option>
<option value="21">2019</option>
</select><br><br>
<b>Dates :</b>
<select name="dates">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select><br><br>
Please use http://pastebin.com
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.
^
also explain what you’re doing, what’s wrong, etc
first thing i see: !DOCKTYPE>
doctype
It should start with <!DOCTYPE html> @near igloo
Other than that, what's the issue?
PieToday at 19:17
first thing i see: !DOCKTYPE> REPLY=>could not select the bracket
Still not dock and you didn’t supply a type
OKOK
THX
MY HTML
is it ok?
i wanna insert a picture
and how do i make footer menue
hwlloooooooooo????
i think you should learn html right from the beginning
Is that notepad
yummy
yup
?
maybe learn the very basics of general coding 
yeah
And for an online registration form you'll need to know PHP too
HTML is coding 
“Code”
you dont need php
well you're clearly new to programming, If you want to learn HTML from the beginning I suggest w3schools. Also get an IDE while you're at it
Plus 2, if all you need is some basic info, why not use smth like a Google Form instead?
Cuz people feel sPeCiAl when they say they made it themself
Ok a slight upgrade
Even cuter but whatever
Still need formatting and a better ide
i started coding on notepad++
@slim heart I don't think that's the problem here.
Ok cool you’re not gonna end there
@near igloo try w3 schools
google search issues
it's good for basic HTML
ok...
do your own research and learn new things
Or just find an online course
and yeah w3 schools is amazing
You won't get anywhere if you keep asking questions without trying
who can give me a link for downloading css
you dont download css
You don't download css, you create css
^
tiana i dont need w3 school i just wanna download css
You can't download css
possibly a troll
You have to code it just like your html file
y?
Because you have to
@earnest phoenix not everyone new to coding is a troll
they're ignoring what they've been told to do for the second time
Perhaps he doesn't understand the concept of it yet, no sweat
and continue using their point despite it being debunked by two people
And what is easy to program or what should I program first?
an app or a discord bot... idk
- Learn a programming language
- Practice the programming language
- Pick which one your interested
- Code
Hello world
hi
Although with apps its a bit different
If you're talking about mobile ones
There are certain langs
yeah mobile
Hi
I have a problmem
if (!req.query.code) throw new Error('NoCodeProvided');
const code = req.query.code;
const creds = btoa(`${CLIENT_ID}:${CLIENT_SECRET}`);
const response = await fetch(`https://discordapp.com/api/oauth2/token?grant_type=authorization_code&code=${code}&redirect_uri=${redirect}`,
{
method: 'POST',
headers: {
Authorization: `Basic ${creds}`,
},
});
const json = await response.json();
fetch('https://discordapp.com/api/oauth2/token', {
method: 'POST',
body: json,
})
.then(res => res.json())
.then(info => request({
url: 'https//discordapp.com/api/users/@me',
method: "GET",
headers: {
authorization: `${info.token_type} ${info.access_token}`,
},
}), function (error, response, body) {
if (!error)
console.log(body);
})
.then(console.log);
res.redirect(`/?token=${json.access_token}`);```
Does not work :/
Invalid URI "https//discordapp.com/api/users/@me"
Android: Java, Kotlin, Dart, React Native
iOS: Dart, Object C, Swift, React Native
Those are the langs for mobile
I put it cyber
Lol
but can i program an mobile app on the PC ? or i have to code on the mobile when i want a mobile app?
@solid hull you can program a mobile app from a pc
You pretty much have to program a mobile app on pc
^
okay, 👌
Android Studio: https://developer.android.com/studio
(iOS) XCode: https://developer.apple.com/xcode/
@lofty hamlet where does the error occur
@earnest phoenix no does he work so with my code how i can take the id of user ? :
if (!req.query.code) throw new Error('NoCodeProvided');
const code = req.query.code;
const creds = btoa(`${CLIENT_ID}:${CLIENT_SECRET}`);
const response = await fetch(`https://discordapp.com/api/oauth2/token?grant_type=authorization_code&code=${code}&redirect_uri=${redirect}`,
{
method: 'POST',
headers: {
Authorization: `Basic ${creds}`,
},
});
const json = await response.json();
fetch('https://discordapp.com/api/oauth2/token', {
method: 'POST',
body: json,
})
.then(res => res.json())
.then(info => fetch('https://discordapp.com/api/users/@me', {
headers: {
authorization: `${info.token_type} ${info.access_token}`,
},
}))
.then(function (data) {
console.log(data.id)
});
res.redirect(`/?token=${json.access_token}`);
}));```
what did you just ask
I want take the id of user
Yeah but i d'ont have the user idd when i console.log this
because it's returned in json
oh geez
log the body
🤔
Body is :
access_token: 'XXXX',
scope: 'identify',
token_type: 'Bearer',
expires_in: XXXX,
refresh_token: 'XXXX'
}
@topaz fjord
Hello, how can I reinvite my bot on this server :-?
Ask one moderator
uhm, you are a moderator, right :?
Judging by my roles, I think 
i have used nginx as a reverse proxy several times now, but this time its giving me the apache2 default page on / and nginx 404 on any other paths
it works fine with ip:port
@pulsar mango 👌
How to do an Command that replies with an Random answer in an Embed?
Choose a random thing from a array
Ok
example:
const poop = ["lol", "no u", "etc"];
message.channel.send(`${poop[~~(Math.random() * poop.length)]}`);
lol
and how to do it in an embed?
you're using discord.js?
yes
gud
RichEmbed Example:
const poop = ["lol", "no u", "etc"];
const random = new Discord.RichEmbed()
.addField('Randomizer', `${poop[~~(Math.random() * poop.length)]}`)
message.channel.send({embed: random});
i dont think ~~ is valid js
lol
Refer to this for embed as well: https://anidiots.guide/first-bot/using-embeds-in-messages
@stray garnet
~~X is basically Math.floor but limited to 32 bits
~ is the bitwise not operator
running it twice yields the original value back, but js converts numbers to 32 bit integers (and truncates decimals) before applying that operator
wow
i dont think that is good...
thats fine
ok i hope so
Sorry for intrerupting, but can this be turned into an async function cuz the await can only be used as such, and my brain couldn't come to a logical solution```
if(!muterole) {
try{
muterole = await message.guild.createRole({
name: "flex taped",
color: "#514f48",
permissions: []
})
how can i check the uptime of another bot, kind of like this http://prntscr.com/oevb6w
@earnest phoenix Deutsch?
@soft cove if they dont have the command I dont think you can
oh wait
let me see
who is "they"
@stray garnet nope
@earnest phoenix rly?
what do you mean? I'm seeking for an advice
how could i check the uptime of a different bot through a command like this: http://prntscr.com/oevgvl
When the bot comes online, you want to log that somewhere. Then upon command, compare that time to now and you'll have your uptime
Obv. reset when it goes offline and such
Im not going to log hundreds of bots at a time
i want it to be in a command where it checks it on the spot
Might be another solution somewhere, can't think of one as of now
@waxen meteor version?
There isn't?
I'm using the rewrite version
I thought there was, my bad
With discord.ext.commands
Perhaps check this out? https://discordpy.readthedocs.io/en/latest/api.html#discord.User.bot
#normal code
if message.author.bot:
return```
You only need the second part
Replace message with whatever handler you use
Or just return if message.author.bot is True
Ah ok turtle
So I'll need to put that in each command class?
It's useless to have if not
Honestly, yes you do
Unless you have a "global" way of checking it before each command
Depending on how you handle your commands, that is
so i asked around and the only way to do that is to check when the bot goes online, then store that in a db and then when it goes offline reset the value
uh
at the top of your message event
If you have a function which handles the base of each command class, you can put it in there
that's the global place before commands
@soft cove That's what I told you
Almost, if not, everyone has a message event
because that's where you put a command handler
Well, I have Discord.py's built-in command handling function, so would I have to go in and edit the library itself?
True true
Commands extension
If you didn't override on_message, your bot will default other bots by default
And if you did override it, well, you just need a if message.author.bot: return in the very beginning of it and that's it
I didn't override anything
You want your bot to ignore other bots, right? Am I following the topic here?
Eh you're good
I ran the help command from another bot and my bot responded to it



