#development
1 messages · Page 778 of 1
@regal saddle how are you getting client
what you mean?
How are you defineing client
How are you getting your Client class?
@eternal adder bUT iTs aN oBJeCt
im kinda confused sorry 
ShUdDuP @modest maple
yeah
Then you can't use commands
That's for the old async branch right?
Ah
Fucking autocorrect please
soo i need to use if message startswith?
If your using discord.client() yup
I know commands is rewrite only..? I've only used client() in async I believe though?
thats how it looks
async version had commands extension but it was not documented
Oof
Bot has the command extension and built in command handler
Client is more bare bones
Wait, if Lukas is using commands (permissions check) shouldn't they just use it to mark a command aswell? @modest maple
I mean if they're using discord.client() they can't use it at all
Client doesnt have anything like that
Client literally just has the bare bones and the bare events
You have to handle everything yourself
oof
hey bois so if i want to make a web frontend for my bot, should i put the server code with the bot code or keep em seperate?
thats hard
Well, they've got commands has_permissions() there, so I would've thought commands.command() would be fine? Either that or the permissions check doesn't work aha
Keep seperate
If they're using client it will never work
Cuz you're trying to call a class and a decorator that doesn't exist
how should is use it then?
You may find it easier to swap to the commands extension? And yeah, get the bot object instead
Clientdiscord = discord.Client() would work?
Otherwise it's either making a command handler or doing .startswith
And no not if you want to use the built in extensions
ok, the startswith and an permissions check?
like message.author.permissions_in(message.channel).kick_members:

If you're new to python I can't advise doing a discord bot till you know the basics well
What you're trying to use is the extension stuff
That's uses bot
Because it uses a command handler
What you are actually using is client
That is a very basic class that just gets you the discord stuff not any command handling or context manager stuff
ah okey, i undertand.
@eternal adder I see, but i'm new in Discord API coding, but i just dont see how to make it easier, i really tought about an forEach with the member.user.id that checks if is in the file or not.
If you're unsure then my method would work, store them exactly how you already have? You don't want to loop over all members as that can become extremely slow, especially with larger guilds
I'm still stuck on the invites thing
have you actually done anything
I did try put in a code for it but it is not working
I got the bot online
I just need it to track invites just like invite manager
have you actually done anything
A question you ask DBL and don't get a proper response to
I will show you what I have done in a min
I'm not on my pc at the moment
But I only started all this yesterday
go check an idiots guide, and find tracking invites section there @earnest phoenix
Okay
lul
What the
hey how tp get a role by bot in server by eval command
i have this code in my bot, and it works fine, but my linter says "guild is defined but not used"
bot.on('guildCreate', guild => {
console.log(`${bot.users.size} sailors have boarded the Golden Barge—now servicing ${bot.guilds.size} spheres.`);
});
is there something i can do with guild to make my linter stfu? this is like a compulsive thing
Don't you think you should use guild.memberCount?
or am I missing something?
If you don't need guild, rename it to _
_guild
Doesn't _ work easier?
true
i am more interested in the total number of folks with access than the individual guild size; i am not monitoring the logs much
@slender thistle does JavaScript play well with that tho
the linter does not play well with it
first of all change ```js
${bot.users.size} to ${guild.users.size}
I think it does.
it does
You mean guild.members?
Yeah I think so.
I thought it was guild.members yeah
the code works exactly as expected and intended
I'm half asleep right now so I might not get the name right.
rtfd ftw
Cecil you don't want to do bot.users.size because that will count every single user across every single guild the bot is in as well.
that's what i want
You sure?
${bot.users.size} sailors have boarded the Golden Barge—now servicing ${bot.guilds.size} spheres.
instead of
guild_count_users sailors have boarded the Golden Barge—now servicing ${bot.guilds.size} spheres.
@manic terrace you can tell eslint to shut the fuck up with either // eslint-disable-line or // eslint-disable-next-line
Iirc
Been a long time since I've used a linter in js
lol eslint gives me the option to turn guild into _guild and then tells me _guild isn't being used
lol I'm surprised
(also the reason i want to know the total users is because the whole reason i am learning how to make bots is to show up a competitor in my industry. so the total number of users and servers is turbo useful data)
/eval client.guild.role (member) I like this
@earnest phoenix that's easy...
in eval it should be like this:
message.guild.roles.forEach(role => message.channel.send(role.name + role.id));
that's just to print all the role names with the id's.
could just map it
true...
also Client#users only caches online users iirc
lol
I would recommend using Collection#reduce (I don't think discord.js has a reduce method)
/eval message.guild.roles.forEach(role => message.channel.send(+));
why + in the message content?
^
You aren't adding anything
/eval message.guild.roles.forEach(role => message.channel.send(`${role.name} : ${role.id}`));
But that's now how it works...
Try that
seems like you're spoonfeeding at this point
/eval message.guild.roles.forEach(role => message.channel.send(${role.name} Admin));
like this
yes
ohk thx
that would just send a channel message with every role in the guild and admin for example:
test role 2 Admin```
wait if you want the guild member roles from the bot then try GuildMember#roles
https://discord.js.org/#/docs/main/stable/class/GuildMember?scrollTo=roles
(stated in the beginning of this conversation by April)
True ^
<clientuser>#roles#filter probably will work
Does ClientUser#roles even exist
ClientUser is not a guild user though 🤔
ClientUser#Me#User or smh to get guildmember object of it
Why isnt that working
cause it's diagonal
True
Bruh. Have someone an idea why my vot crashes out any errors?
@earnest phoenix delete that you just leaked a password
hmm
The password regenerates every restart
Mkay
Can anyone help me for pass a checkbox data from ejs to js ?
I need a example
:3
{ Error: 401 Unauthorized
at IncomingMessage.res.on (/rbd/pnpm-volume/53d7f4af-4cfe-4738-ba4f-43cd500e21bf/node_modules/.registry.npmjs.org/dblapi.js/2.3.0/node_modules/dblapi.js/src/index.js:118:25)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:139:11)
at process._tickCallback (internal/process/next_tick.js:181:9)
raw: '{"error":"Unauthorized"}',
body: { error: 'Unauthorized' },
status: 401,
headers:
{ date: 'Wed, 29 Jan 2020 06:53:39 GMT',
'content-type': 'application/json; charset=utf-8',
'content-length': '24',
connection: 'close',
'set-cookie':
[ '__cfduid=d4d7067eec3c36664ee951243bd19ec841580280819; expires=Fri, 28-Feb-20 06:53:39 GMT; path=/; domain=.discordbots.org; HttpOnly; SameSite=Lax; Secure' ],
'x-powered-by': 'Express',
'access-control-allow-origin': '*',
'access-control-allow-headers': 'Authorization',
etag: 'W/"18-XPDV80vbMk4yY1/PADG4jYM4rSI"',
'cf-cache-status': 'DYNAMIC',
'expect-ct': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"',
'strict-transport-security': 'max-age=15552000; includeSubDomains; preload',
'x-content-type-options': 'nosniff',
server: 'cloudflare',
'cf-ray': '55c94a503d3ef0dd-IAD' },
ok: false,
statusText: 'Unauthorized' }
Why this error? can anyone explain me please?
Unauthorized means your api token is not set or invalid
Cloudflare block
👀
@quasi stirrup you want to make a request on what website ??
He is trying to post server stats to dbl
Really weird why cloudflare respond to this i dont have this personaly
Unauthorized means your api token is not set or invalid

@earnest phoenix i have fixed the issue, the token was invalid.
You got the big connection refused
How can I fix
Why do i get the following error: TypeError: Cannot read property 'members' of undefined
With this few lines of code:
const Discord = require('discord.js')
const client = new Discord.Client()
const list = client.guilds.get('GuildID');
list.members.forEach(member => console.log(member.user.username));
your client is not yet ready
client.on('ready', () => {
console.log("Bot Started!");
});
I used this before the list.members part
but your code there runs before that client.on ready those
also thats async
it wont block your code
so even you put that after client.on ready
nothing will change
put it inside client.on ready
where do you define your token?
Fixed it thanks was indeed like Saya-nyan said! thanks!
I'm checking with 2 loops if the user is in a JSON file, and if not he loses his role, but it kind of works, can someone learn me the right way with my code:
list.members.forEach(member => {
var ii;
for(ii = 0; ii < importedJSON.list.length; ii++){
var DID = importedJSON.list[ii].Discord;
var Side = importedJSON.list[ii].Side;
if (DID !== member.user.id){
//Watcher
member.removeRole('668050709375352843').catch()
console.log("Removed Watcher role from Discord ID: " + member.user.tag + "(" + member.user.id + ")");
//Player
member.removeRole('668050556404891668').catch()
console.log("Removed Player role from Discord ID: " + member.user.tag + "(" + member.user.id + ")");
} else{
if (Side == 0) {
if (message.guild.member(DID)) {
message.guild.members.get(DID).addRole('668050709375352843');
console.log("Added Player role to Discord ID: " + member.user.tag + "(" + member.user.id + ")");
}
} else{
if (message.guild.member(DID)) {
message.guild.members.get(DID).addRole('668050556404891668');
console.log("Added Player role to Discord ID: " + member.user.tag + "(" + member.user.id + ")");
}
}
}
}
})```
what's the problem
What I'm doing here is that i want to remove roles from a user if he isn't in the JSON file and if he is then i want to give him the role he has in the json file
I use 2 loops now for it, and it's terrible solution, cause it gives loads of errors.
For example:
(node:28352) LLgRi7cWeUUu5zpB7dekZFapB2XdRCvM4N: Possible EventEmitter memory leak detected. 11 guildMemberUpdate listeners added to [Client]. Use emitter.setMaxListeners() to increase limit
And:
(node:28352) UnhandledPromiseRejectionWarning: Error: Removing the role timed out. at /root/NERVE/Monitor/node_modules/discord.js/src/client/rest/RESTMethods.js:577:16 at Timeout._onTimeout (/root/NERVE/Monitor/node_modules/discord.js/src/client/Client.js:436:7) at listOnTimeout (internal/timers.js:531:17) at processTimers (internal/timers.js:475:7) (node:28352) 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: 7)
1st that’s the forEach
I am currently new in js so it's kinda tricky atm.
The bottom error is probably a timeout due to everything being overloaded as you added way too many listeners
You should solve the listeners issue first
JSON contents are an Array of Member IDs right ?
Which doesn't originate from the code you posted
Somewhere in your code you're doing something along the lines of client.on("guildMemberUpdate" ...
@valid holly Member Ids and the role they have
Instead of using forEach why don’t you throw everything inside a setInterval until condition is met
Array.prototype.length
If he doesn't fix the listener issue, nothing is going to work properly 
My command to create a new text channel is:
{"name":"new","permissions":"NONE","restriction":"0","actions":[{"channelName":"test","topic":"hi","position":"","storage":"0","varName":"","name":"Create Text Channel"}]}
Yet when it executes I get the error of:
Error with Event "Create Text Channel", Action #1: DiscordAPIError: Invalid Form Body type: Value "text" is not int. Where is the text that im meant to be putting an int in?
And what he's doing isn't time based at all so a setInterval makes no sense anyway
What he’s doing is looping through the whole JSON at once
then adding role to the members at the same time
resulting in both err
Make it the function execute at an interval to escape the limit
I believe it was 5 req/s
..
I'm testing it now with just typing a message untill it works
How about you don't run that code on every single message
So after all of it i want to make a timeinterval of 10 mins
10 mins would be too long
Well it's only me typing a message, so didn't think it wouldn't matter
All channels your bot has read permissions in will currently fire that on every messages
Yes but it's only me in that test server.
Is your client in other servers ?
ok
10 mins is to run that code everytime, to check.
Make sure to remove the forEach
But how do i get every member then?
map the members then i++ after addRole
Like every member needs to go through the check
<guild>.members
Done
<guild>.members.map(x => x.id)
you may not have all members cached
which could also be an issue
you also messed up your logs
because you put added player role for both of them
Yeah i did so i know what is added
Using an interval to prevent the ratelimits is alright but you rly shouldn't be waiting if you didn't do anything
I don't know if discord.js will check if the member has the role and automatically prevent you from sending useless requests
In case it doesn't, you should prevent that
No need to add a role they already have
No need to remove a role they don't have
Also interested in what exactly the json looks like
if Side will always be a number you should be using ===
Changed it to ===
You can also move the ii declaration into the for itself
You're only using it in the for
How you mean?
for (let i = 0; i < someNumber; i++) {}
Ah like that yeah got it.
But you say if it's always a number, does it mean this: DID !== member.user.id also needs to be !===
Ah okay good 🙂
But how can I run this code every 10 mins, instead of every message or memberupdate?
Have a loop
@late hill I added the checks if they have the role or not that it skips.
The first time the code runs everything is fine, but when it happends the second time, it goes wrong.
show code
member.roles.find(r => r.name !== "Watcher") this will match the first role in the role list regardless
because .find() tests one by one until it finds one that matches the condition, and your condition is not equal to, which means the first role it finds that is not "Watcher" will pass the condition, whatever that role may be
Stop with Node.JS/JS, it's very badd
js is not bad lol
false
@quartz kindle JS is not made for the back
JavaScript is an interpreted language, so very slow
originally no, but it was made possible, so why not use it? It is easy to use, which increases productivity and has a smaller learning curve
which is why so many companies are using it
because the cost of development is cheaper
which makes it not a bad language
its a good language for beginners and cheap/fast/easy development
Yes Node.JS is also very slow because it is coded in C ++ and python, in addition with its module layer
its not even that slow, the engine has a lot of optimization. its performance is on average equal to python
I suggest you do a speed test between Java & JavaScript, you will see the big difference
i suggest you stop talking nonsense lol
of course java is faster, its a compiled language
thats comparing apples to oranges
and is not the point here
Java is not a directly compiled language
Not to mention your code is probably alot slower and is probably the reason for a difference in performance
and javascript is not a directly interpreted language
Java is compiled in ByteCode which is itself read by the JVM
The difference is fractional and they're more than quick enough to do pretty much anything
javascript is compiled in the JIT
9/10 it will be down to poor optimisation as to limits of an interpreted language
JavaScript does not get MDR compiled
anyways, blatantly saying JS is bad is not accurate, specially when it does whats its supposed to do very well
JavaScript is "good" just for the client side
is a volkswagen a bad car compared to a mercedes?
maybe slower, yes, but its cheaper, and a good for a lot of purposes
and cheaper to fix
volkswagen is not trying to be on the territory of Mercedes
js is not trying to be java

lmao
both are multipurpose languages, both can be used for many things lol. just chose whatever language you like more
java is not strictly for servers
Js = JavaScript, ** Java ** Script, they did this to advertise themselves when the real name is emascript, and if they now want to be a language for the back
yes, and they did it 20 years ago
which yes, was stupid, but it has nothing to do with anything now
Without that JS would not be of this world anymore
they dont want it do be a backend language, they want it to be a multipurpose language. why? because its cheaper and easier to use, so better productivity
cheaper ?
they are different languages, you cant say one is better than the other, they both have pros and cons
Tim what you suggest to do there, cause i'm clueless at the moment,
what annoys me even more is the guys who only make Discord bots, they think they are developers while they follow tutorials and don't know anything except that! They don't even know the language
Cause you say find() will use the first role in the list, so it doesn't check the other one.
thats an entire different issue, and i agree there
That's actually wrong Dartagnou only half of those do that while bigger bot developers have been using a language for over a year now like me
but discord is for many people a first time experience, entry level programming
so its a good way to learn
so let them experiment
And reassure me, are you using object oriented programming?
i am
I'm using C# so screw your java vs javascript 
with a bot repo?
ok?
C isn't possible to view original code, @prime cliff c# we can find the original code or you've got the best encryptor/obfuscator

you mean unpack the executable?
just code your bot in asm
You can build it as an exe or a dll which supports linux too
Tim = Genius
Any program can be decompiled and unobfuscated
Tim > all
@earnest phoenix but the time depend of the level of security
Code your bot in binary ?
He'll yeh
Lol
True @earnest phoenix
I have view a big obfuscator litteraly too long to unobfuscate...
code your bot with brainfuck
0110010000100001000101000010001011111011111011111111111111110010110010011111100110111111001111100111100110001111111111001100110001111110011111110011100001110010001001100111000010001000100010001111001100011000010001111110011111111111111111111111110000011111111
``` this a code of my bot :kappa:
Imagine code 1 hello world in binary
Ho, shit !
Without any text to binary converger
Converter *

Hard
Ho i'ts simple
because :
Not for me :(
the text (encoded in ANSII) is encoded in exadecimal format
Yeah
and transformed from hexadecimal to binary is very simple
This is a good thing
con.query(`SELECT * FROM prefix WHERE id = ('${message.guild.id}')`, (err, rows) => {
if(err) throw err;
var prefix = rows[0].prefix
if (message.author.bot) return undefined;
if (!message.content.startsWith(prefix)) return undefined;
});
const args = message.content.split(' ');
const searchString = args.slice(1).join(' ');
const url = args[1] ? args[1].replace(/<(.+)>/g, '$1') : '';
const serverQueue = queue.get(message.guild.id);
let command = message.content.toLowerCase().split(' ')[0];
command = command.slice(prefix.length)
if (command === 'play') {```
Oof
?
error info (node:21439) UnhandledPromiseRejectionWarning: ReferenceError: prefix is not defined
at Client.bot.on (/home/dcbot/dev/index.js:128:26)
Prefix is not defined
command = command.slice(prefix.length)```
@earnest phoenix var prefix = "."
Read the error please 😦
🤔
Or just
Oh common
Use an if
@earnest phoenix SQL Prefix
If your bot have
Yeah
not use var but let
Verify if the server have basic prefix or custom
In one var
And use this var
🤷♂️
Doesn't SQL give you a query as [(stuff, stuff)]
The code where you define the prefix
in fact a request for each message is not very good!
will most likely run after the rest of your code
Not Much u can rlly do for checking a prefix
Unless you check the guild I'd and see if it matches the last one
In fact a basic request like that every message doesn’t matter
Which is rare
@earnest phoenix
that
@quartz kindle So I changed it to: member.roles.has('0000')
also, the 1 request per message could easily be avoided
But the problem still occurs
even if it doesn't matter
Daniell an SQL request is very slow!
create an async thread for SQL request !
That gets pretty fucking big when you start chacheing thousands of guild ids and their prefixes
Or just cache everything when the bot starts
no need for async threads in js, just use callbacks and/or promises, and cache your prefixes
big
sits over here with my async SQL dB
with discord.js by default he's probably already caching many things per guild
the extra prefix won't even be noticable
it's 1 string
anyway he's probably not understanding any of this
@quartz kindle not working
Probably now confirmed
(node:30299) UnhandledPromiseRejectionWarning: Error: Adding the role timed out.
at /root/NERVE/Monitor/node_modules/discord.js/src/client/rest/RESTMethods.js:551:16
at Timeout._onTimeout (/root/NERVE/Monitor/node_modules/discord.js/src/client/Client.js:436:7)
at listOnTimeout (internal/timers.js:531:17)
at processTimers (internal/timers.js:475:7)
(node:30299) 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: 11)
How to solve this issues :/
Catch the timeout error
How @modest maple
@quartz kindle only music code https://pastebin.com/raw/Ejhz9vsQ
(node:30399) LLgRi7cWeUUu5zpB7dekZFapB2XdRCvM4N: Possible EventEmitter memory leak detected. 11 guildMemberUpdate listeners added to [Client]. Use emitter.setMaxListeners() to increase limit
11 wew
@quartz kindle since sql i ask for await youtube stops if i end it if not then else else ???
I try something new, cause new in js.
But how to make it work properly is a problem for me.
@earnest phoenix you need to learn about async programming
@pallid aspen the problem is most likely not there, and you still didnt change the .find() functions anyway
I did @quartz kindle i changed them to: member.roles.has('668050709375352843')
@quartz kindle please look at all the code I sent
oki
https://pastebin.com/mAhGYhfM new one
now, how many members are being changed there?
how many add/remove role operations are actually being sent to discord?
because this code is attempting to do EVERYTHING at once
meaning, sending to discord 100+ role operations in less than 1 second, if you have that many members passing the conditions
We have 10 members in the guild, and 8 members in the JSON file
im not sure what the current rate limit is, but its possible that its less than 8 per second
And they need to match if they have the role or not that they give it if they are in the JSON file.
If they're not in the JSON file but they have the role then remove it.
That's the idea.
how many times does your console log "added/removed role"
Let me run the bot in the first round.
but anyway if you want it to scale, you need to make some changes
Removed Player role from Discord ID: ThieMenPvPnOOb#8212(163663344429957120)
Removed Player role from Discord ID: ThieMenPvPnOOb#8212(163663344429957120)
Removed Player role from Discord ID: ThieMenPvPnOOb#8212(163663344429957120)
Removed Player role from Discord ID: ThieMenPvPnOOb#8212(163663344429957120)
Removed Player role from Discord ID: ThieMenPvPnOOb#8212(163663344429957120)
Removed Player role from Discord ID: ThieMenPvPnOOb#8212(163663344429957120)
Added Player role to Discord ID: Syntax#1337(204572389307187200)
Added Player role to Discord ID: Prizen#6384(276540506798948352)
Removed Player role from Discord ID: EncryptedWeb#0123(594520993507311651)
Removed Player role from Discord ID: EncryptedWeb#0123(594520993507311651)
Removed Player role from Discord ID: EncryptedWeb#0123(594520993507311651)
Removed Player role from Discord ID: EncryptedWeb#0123(594520993507311651)
Removed Player role from Discord ID: EncryptedWeb#0123(594520993507311651)
Removed Player role from Discord ID: EncryptedWeb#0123(594520993507311651)
Removed Player role from Discord ID: EncryptedWeb#0123(594520993507311651)
Removed Player role from Discord ID: EncryptedWeb#0123(594520993507311651)
And that's the problem...
yup
Because i have 2 for loops atm
API abuse
I'm sorry ;-;
so you need to carefully examine your logic, to avoid such situations
and if you want your code to scale, you will need to make some changes
you have to drop members.forEach in favor of a regular for loop, and make use of async/await
But if i drop forEach, how do i get every member seperate through my loop of checking in JSON file.
I don't understand, what you mean there, cause i already have a for loop.
because you can do this
for(...) {
await something();
}``` but doing this will not work ```js
a.forEach(async a => {
await something();
})```
a for loop will not continue until it awaits the async function, but a forEach loop will not wait
because the forEach loop is actually firing functions
like this ```js
a.forEach(a => {
something
})
is the same as
for(...) {
function() {
something
}()
}```
not my cup of tea either
@pallid aspen still didn't figure it out ?
.
Sadly still trying, but doing my best
That is a JSON format yesish
Sure or ask it here
[
{"Discord":"204572389307187200","Side":"1"},
{"Discord":"276540506798948352","Side":"0"},
{"Discord":"301673545639919616","Side":"0"},
{"Discord":"330050847360811013","Side":"0"},
{"Discord":"368361281587249153","Side":"0"},
{"Discord":"262213629796024320","Side":"0"},
{"Discord":"163663344429957120","Side":"1"},
{"Discord":"594520993507311651","Side":"0"},
{"Discord":"163663344429957120","Side":"1"}
]
@valid holly Mine atm.
There are other Py Devs here aswell
As I gtg for an hour for sports
Cuz school is oof
Why not get the member from id and check for role ?
Send it here and @ me so I can find it when I come back
Discord is the ID and Side is role 0 or 1
You mean to make it like this:
[
{"204572389307187200":"1"},
{"276540506798948352":"0"},
{"301673545639919616":"0"}
] ```
Etc.
If you have the member's ID, you can then check if they have a role
Don't do it like that
It's better to do so you don't need to update the JSON with new values.
JSON isn't the best to write/rewrite data..
Don't use the values as a key
'The JSON updates itself, from the website, because when people unlink from the webiste with their Discord, then they get out of the JSON list.
And then the role needs to be removed.
I still don't get why you need the "Side" when you can use the API
Side is 0 or 1 because they can select if they are a watcher or a player
in the website.
So if they have 0 they need the watcher role, do they have a 1 they are a player
So it serves other purposes than checking if he has the role ?
Side has the purpose to give them the right role
if member.id is in the JSON file then they need to give the right role (where i need the Side from)/
if the member.id isn't in the JSON file, then the role (watcher or player) needs to be removed from the member
but can't you do that in the code itself
^
Just map and check, then add accordingly
No const list = client.guilds.get('');
Yeah that's fine.
list.members.map prints:
'163663344429957120',
'204572389307187200',
'261125921958920204',
'276540506798948352',
'306797110643392512',
'329359548152414231',
'332155890532614144',
'594520993507311651',
'671335015468105740',
'671353409693024286'
]
So I think i'm going in the good way here
Keep only the ID's in the JSON, then check if the mapped member's id is in the JSON
if true add role else don't
Well you need to explain your situation a bit better.
Does your members choose wether or not to be a "Watcher" or "Player" in the website ?
They NEED to choose to be an Watcher or Player on the website.
But if they decide to give up their Discord ID, they get a role on the Discord server.
They need to choose on the registration form.
So in the database it says 0 = watcher, 1 = player
So if they choose watcher the value will be 0.
And then in the JSON will say: Side: 0
Good, thanks for the explanation. 👏
Keep the Side then and please clarify the situation from the getgo next time.
And the code where i am busy with needs to check if the players have the right role, and if they have a role but aren't in the JSON file their role will be removed.
I will sorry
Get the member's ID from the JSON, check if the mapped member's ID is in the JSON, get the Side part, store it, compare if 1/0, if 1 get the "Player" role ID else "Watcher" role ID, store them in var, look for mapped member's roles and check if they have the role.
array.prototype.includes(member.id) // mapped member not the actual djs object
Don't i have that already, Getting the member ID from JSON and check if mapped member id is in there?
list.members.map(member => {
for (let i = 0; i < importedJSON.list.length; i++){
var DID = importedJSON.list[i].Discord;
var Side = importedJSON.list[i].Side;
if (member.id !== DID){```
👍
list.members.map(member => {
for (let i = 0; i < importedJSON.list.length; i++){
var DID = importedJSON.list[i].Discord;
var Side = importedJSON.list[i].Side;
if (member.id !== DID){
if(member.roles.has('668050709375352843')){
//Watcher
member.removeRole('668050709375352843').catch(err => console.log(err));
console.log("Removed Watcher role from Discord ID: " + member.user.tag + "(" + member.user.id + ")");
}
if(member.roles.has('668050556404891668')){
//Player
member.removeRole('668050556404891668').catch(err => console.log(err));
console.log("Removed Player role from Discord ID: " + member.user.tag + "(" + member.user.id + ")");
}
}```
var DID = importedJSON.list[i].Discord;
Isn't this going to check for the i value in the array ?
It's the indicator of the for loop
Sadly I don't think the JSON's content [i] match the map's [i]
It's better to use includes()
if(importedJSON.Discord.includes(member.id) {
// Role check thread here
}
Still get:
Removed Player role from Discord ID: ThieMenPvPnOOb#8212(163663344429957120)
Removed Player role from Discord ID: ThieMenPvPnOOb#8212(163663344429957120)
Removed Player role from Discord ID: ThieMenPvPnOOb#8212(163663344429957120)
Removed Player role from Discord ID: ThieMenPvPnOOb#8212(163663344429957120)
Removed Player role from Discord ID: ThieMenPvPnOOb#8212(163663344429957120)
Removed Player role from Discord ID: ThieMenPvPnOOb#8212(163663344429957120)
Removed Player role from Discord ID: ThieMenPvPnOOb#8212(163663344429957120)
Removed Player role from Discord ID: Syntax#1337(204572389307187200)
Removed Player role from Discord ID: Syntax#1337(204572389307187200)
Removed Player role from Discord ID: Syntax#1337(204572389307187200)
Removed Player role from Discord ID: Syntax#1337(204572389307187200)
Removed Player role from Discord ID: Syntax#1337(204572389307187200)
Removed Player role from Discord ID: Syntax#1337(204572389307187200)
Removed Player role from Discord ID: Syntax#1337(204572389307187200)
Removed Player role from Discord ID: Syntax#1337(204572389307187200)
Added Player role to Discord ID: Prizen#6384(276540506798948352)
Removed Player role from Discord ID: EncryptedWeb#0123(594520993507311651)
Removed Player role from Discord ID: EncryptedWeb#0123(594520993507311651)
Removed Player role from Discord ID: EncryptedWeb#0123(594520993507311651)
Removed Player role from Discord ID: EncryptedWeb#0123(594520993507311651)
Removed Player role from Discord ID: EncryptedWeb#0123(594520993507311651)
Removed Player role from Discord ID: EncryptedWeb#0123(594520993507311651)
Removed Player role from Discord ID: EncryptedWeb#0123(594520993507311651)
Removed Player role from Discord ID: EncryptedWeb#0123(594520993507311651)
I don't undertand why that's still happening.
yayy!! ive managed to remove the "see what guilds youre a member of" permission from the oauth2 login of my dashboard 😄
logging into the dashboard no longer looks so spooky
@green kestrel nice
the only downside is its internally more spooky lol
as i have to store more data in mysql relating to the membership of a user on a guild and their permission bitmask, to replace that api call
but meh, its nothing the bot doesnt already know i guess
Also if i use the code TypeError: Cannot read property 'includes' of undefined is what i get/
Okay @valid holly I kinda got it working but there is one problem ><
Hi !

I have a problem, i'm coding a filter image but i have a error because avatar image link of User return an error (HTTP 403)
have you tried accessing the url yourself
403 = forbidden, so your bot token is changed while running/you simply dont have access into it from your bot
i hope you're aware that's a cdn link, also wrong token is 401
maximum number of characters GUARD.ID ??
what
GUARD.ID maximum character
pl:
👀
264445053596991498
19 character
what the maximum
There isn't one
Snowflakes can in theory be any number / length altho discord ranges from like 16 - 20 ISH?
snowflakes don't have a specific length
you're misunderstanding how snowflake ids work
^
No
Why do you need to know the max length?
a snowflake that has a value 100 isn't a valid snowflake
refer to the image above
because sQL must enter the maximum number
No you don't?
Hi guys I m back
Ok
VARCHAR have to give
What
The whole point of a dB is that you cans store data in it dynamically how pointless would it be if you had to limit the length of data you put in or the amount
for example, you cannot enter more than 10 characters in the password ...
How are you using Ur db
Hi
Because somthing seems massively wrong if your limited to X amount of characters per dB entry
id = GUARD ID
I think u all are studying something
id= guard id Varchart maximum 30 CHARACTER
@earnest phoenix you got any idea what theyre on about
@modest maple if you don't know what I'm talking about in SQL then why are you trying to help
varchar requires a specific length
however
why are you doing that
storing them as a string
INT ??
int is 32bit
bigint is 64bit
then set up BIGINT and it will be fine
yes
however
mark it as unsigned
snowflakes are unsigned 64bit ints
since there's no point in going into negatives with ids
and how can I give it to him?
what
how to set it up?
or is it good now?
Can U all answer me
@earnest phoenix fun fact, from that image you posted above, i just worked out there will be wrap-around of discords timestamp in 2154.... best hope nobody is still using discord in 130 years 😄
well we got 42 bits of time value, thats 2^42-1 max size which is 4,398,046,511,103... divide by 1000 because its milliseconds gives you 4,398,046,511 seconds, divide by 86400 (seconds in a day) gives you 50903 days, divide by 365 gives you approximately 139 years (didnt bother to account for leap years)... add 139 to 2015... and you get 2154
the 2038 problem stems from only having 32 bits in a time_t on 32 bit systems, discord added a fewwwww more bits to the timestamp
i really hope that discord arent using 32 bit machines and storing anything as time_t there. otherwise there are much bigger issues 😂
solved the problem I have Varchar a value of 500 that would be enough
enough for what Hedi
🤦
tfw you get told to use unsigned bigint and then you go ahead and use the most poorly performant solution instead
whats Hedi trying to do cry
oh, guild id should be: bigint(20) unsigned not null
i can tell you that for sure because thats what im using in mysql/mariadb 😄
so listen to cry, he knows what hes talking about
dont use varchar, because it will be dog slow when you have to index a bunch of them... get to 1000 or so guilds and 200,000 users and you will notice the issues
dont use int, because it will chop off 32 bits of the value
Imagine
can you imagine an imaginary manager, managing an imaginary menagerie?
then what exactly should I set now?
one sec
oki
Isn't snowflakes' maximum length 21?
@slender thistle 21 digits?
Yeah
not sure, if youre right i'll have to add a digit to all of mine
havent noticed a problem though 😄
Yeah for now they're 18 digits long
18,446,744,073,709,551,615
thats the max size of a 64bit unsigned integer
its 20 chars long not including the commas
Huh
Snowflakes can be big
thats as big as ones ever going to get in decimal
my id = 189759562910400512 (len=18)
biggest id = 18446744073709551615 (len=20)
so 20 is fine
but you had me checking... glad i dont have to worry :D
Time to unsign bigint my VARCHAR 
Sometimes I'm greatful for orm dhut
Dhit
Shit
Ree
Somehow somthing broke even more
when clicking a hyperlink for a message, does it always open in browser or is there a way to open in client
im assuming its possible to open in client
does it work in client when its not in a hyperlink?
I need help making a discord bot for my server I just got back into coding again im using c#
O Boi
so can someone help me plz
with what
No can do
making a bot is such a broad term to begin with
sorry broda
I don't know much about bot dev in c# but this seems somewhat reliable
@proud pebble I recommend Dsharpplus.
sooooo
when clicking a hyperlink for a message, does it always open in browser or is there a way to open in client lol
what do you mean
on desktop no
imagine the security risks if the app allowed to do that
it is possible cause electron but security
on mobile opening links respects the user's settings
How to add Rich Presence in c# tool but without using token??
What?
Hummm
How can i add Rich Presence for my tool
In c#
Without using token
what
This is possible
do you want rich presence on your bot or what
Lol no
@tiny tinsel it doesn't
Sublime text, vsc etc...
Can use rp without token
Or this is forbidden if he use token
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Ty
but like
ok so when i put an url in a title, it works normally (i think, i dont have a desktop but it doesnt open in a new tab), but when its an url from like RichEmbed.setUrl or something like that, it opens in a new tab
It's allowed to make a tool for manage the bot? Talk with him, manage sql, etc...
it entirely depends on your user settings
what @earnest phoenix
Bruh
on android this is what defines the behaviour @grizzled raven
I think he means links to messages
Finally got the system automatically generating the help command and paginate when needed
altho needs alot of optimisation
chilly fishu 8, that is beautiful
Ohhh
yeah i could use that hehe
i thought your Field Name by default was styling them!
i thought about doing each category in a new field but a hate the hard titles
altho that is a config setting on the handler
for(let i = 1; i < 20; i++)
{
for(let j = 1; j < v; j++)
{
console.log(" ")
}
v = v-1
for(let a = 1; a < i*2; a++)
{
console.log("*")
}
}```
I made a Tree Generater Code but somehow it gives me this as output, can anyone help?
@royal herald Math.random
i know
Would it be API abuse to change a message every 1 second? for 10 seconds?
but i mean
randomly putting a photo link in "setimage"
so it will put one of the links selected from "var"
are you getting the pictures by links?
I couldn't find any Pokemon api anywhere
I made it from my own list
Can I discard it if it doesn't appear as an "ads" @modest maple
Can anyone help me
whats up
@royal herald you cant actually access that image btw / i cant
but yh having it in an array would work
how can i do with "setimage"
like a random image from that?
What's the issue
@topaz fjord randomly putting a photo link in "setimage"
so it will put one of the links selected from "var"
yes I mean it, can I do it like that
yikes
indeed
One message removed from a suspended account.

@modest maple This is a port scanner ?
if you dont specify a port for a websocket to run on it will find a open port
and it means like optional arguments
that you can pre set if nothing is given
I think port scanner isn't really allowed by discord...
I don't think that's for discord
Yeah possible
its not
yh probably means yeah
But this isn't really legaly😂
Use for éducation only
for perfectly normal reasons 
Yeah yeah
there is nothing wrong with using a port scanner on a program that is literally for the server sided system to run a web socket
If you're running on your own vps there's no harm being done
anyone have a link or tutorial doc to how i can turn a user input into a channelID? i am trying to set this bot up so admins can change the welcome channel with a command
Your lib should have a method to get a channel by name/if
*id
What lib are u using
@manic terrace
discord js
i guess i can use collection for that, but i've never used collection so it's new territory
@earnest phoenix thats not it
can i get my bot to dm you embeds so you would know what i mean?
or nvm i could just take screenshots
.channels returns a collection and you can use .filter to find the channel by a specific parameter
Developer mode or the developer portal
The dev portal is at https://discordapp.com/developers
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
this is a message link in a title, set by using RichEmbed.setURL() or changing the url property in an embed object. this link opens in a new tab and i assume it opens in browser from client too
this is a hyperlink message link, in a richembed description. this doesnt open in a new tab
it always opens in browser on desktop
this is a normal link in a rich embed title, this doesnt open in a new tab either
you can't really do anything about it
it's how the client works
and mobile devs are retarded
it doesnt
testing with wews
windows
wewdos
wheres wewdo
Hiding behind those wews
wew
I may be stupid but why is this not working?
let userid = client.guilds.get("551070196958363648").members.find(user => user.username === query.id.split("////")[0]).id;
query.id.split("////")[0] is just Callum
@snow urchin just use
let mid = message.mentions.members.first() || message.author
let userid == client.users.get(mid.id)
can you do x || y and get something else than true or false back?
The value of y will be returned if x is falsey
Yeah
js right
Js is good for all begginers
I think this is bad to start with any langage need to be compiled
(Packed🤷♂️)
If you start with a C lang then go to js, you will be surprised by how easy it is
There are so many things that js does for you automatically lul
Nope, i cant C lang :D
Why ?
Too annoying to learn at this point
I have 0 experience with C# but i have some experience with C and C++
I had to work with C/C++ during my study for a few semesters, but it was hell
C# is the easier in the c family
Lul
But this is the best for me :)
(And c for linux)
I like js :D
I will stay with Java for my bots ^^
I have a bit of experience with C#
I've been doing Discord bots, windows apps and websites all in c# for 3 years now
You can see a preview of what i did on my gallery website i made in c# https://gallery.fluxpoint.dev
You know how i can start a js script with 1 Burton When the script is in the ressources ?
1 button*
Wut
At the start
We can use a picture in the ressource for example
But i cant start a script example for open a cmd and ask for name(use in the tool for the session
blazor is
eh
server side is still a fun idea
not performant
but client side blazor is a disaster
I dont get what youre trying Dany
Making a tool🤨
I want to make a more easier tool for making bot and free not like "discord bot maker" on steam
But at the start the name ask is for the bot
And youre using js? Or what are you building it with?
The js is for have the variable in the js script i think this is best way lol
And with the c# i take this name and placed it in botname var
And he can be view in a not éditable textbox
That makes no sense
Why are you mixing js with c#
js cant run without a js engine
i do it too
electron app with a .net core back component
Hmmm
This isn't a bad idea but not
This is for a future open-source project
Yeah, you can call native code from a js app, but calling js code from a C app needs a js engine
Well then yoi have two processes running

