#development
1 messages · Page 1869 of 1
'-'
'-'
https://github.com/apenasigordev/FailBot/blob/a05cac6f692d38c1fc4e931258684c9c61c9556f/index.js#L74
@sick fable use this handler
👍
K
Little question, is Cassandra use JSON/BSON database like MongoDB? (ik Cassandra supports JSON, but idk if it is stored in BSON like mongodb) If not, what does it use? (ping me pls)
CQL ok
wtf is bson
binary json
and what is a binary json?
BSON (/ˈbiːsən/) is a computer data interchange format. ... It is a binary form for representing simple or complex data structures including associative arrays (also known as name-value pairs), integer indexed arrays, and a suite of fundamental scalar types. BSON originated in 2009 at MongoDB.
BSON has a published specification.[4][5] The topmost element in the structure must be of type BSON object and contains 1 or more elements, where an element consists of a field name, a type, and a value. Field names are strings. Types include:
Unicode string (using the UTF-8 encoding)
32 bit integer
64 bit integer
double (64-bit IEEE 754 floating point number)
decimal128 (128-bit IEEE 754-2008 floating point number; Binary Integer Decimal (BID) variant), suitable as a carrier for decimal-place sensitive financial data and arbitrary precision numerics with 34 decimal digits of precision, a max value of approximately 106145
datetime w/o time zone (long integer number of milliseconds since the Unix epoch)
byte array (for arbitrary binary data)
boolean (true and false)
null
BSON object
BSON array
JavaScript code
MD5 binary data
Regular expression (Perl compatible regular expressions ("PCRE") version 8.41 with UTF-8 support)[6]An important differentiator to JSON is that BSON contains types not present in JSON (e.g. datetime and byte array) and offers type-strict handling for several numeric types instead of a universal "number" type. For situations where these additional types need to be represented in a textual way, MongoDB's Extended JSON format[7] can be used.
so basically a json but encoded in binary?
is there any advantage over json at all?
smaller size
ic
I smell Wikipedia… somewhere
tim has wikipedia downloaded on his pocket hdd
lel
Wikipedia downloaded tims knowledge
tfw v8 engine is on v9.4
wtf
Is there a way define multiple embeds
like
let x && y = new Discord.MessageEmbed()
let x = { description: "embed" };
let y = x;
assuming you just want to make an alias since js by default will reference objects
do you want y to be a reference or a completely new instance
let help = new Discord.MessageEmbed()
let mod = new Discord.MessageEmbed()
let info = new Discord.MessageEmbed()
let fun = new Discord.MessageEmbed()
let giveaway = new Discord.MessageEmbed()
let music = new Discord.MessageEmbed()
let cs = new Discord.MessageEmbed()
let embeds = [help, mod, info, fun, giveaway, music, cs]
embeds.forEach(x => x.setColor(client.color.green) && x.setThumbnail(client.user.displayAvatarURL({dynamic: true})) && x.setTimestamp())
Wey not create the embed inside .map()
It works so op
slow
map wasn't even designed to be a standalone iterator
I just want to point out that x y and z are embed
Hi, I'm trying to check if the user who reacted to a message doesn't have a specific role, I've got this
!user.member.roles.cache.has(votesRole) but I get an error in the console saying that it can't read property roles of undefined
Could someone tell me how should I set up my code, please?
d.js btw
message.member.roles
let a, b, c, d, e, f;
a = b = c = d = e = f = new Discord.MessageEmbed();
actually no, do this instead: ```js
let [a, b, c, d, e, f] = Array(6).fill().map(() => new Discord.MessageEmbed())
oh, all those are different instances?
didn't know it works like that
actually no they arent
Thought one references the other
yeah you're right
These dont work
This one doesnt define embed
The other is just merging all embeds
wdym doesnt define
A.setTitle is not funciton bc this isnt defined as embed
?
let a = something
a.setTitle("Some Title")
setTitle() is not function
Did you understand?
Hmm
poor embed
Thanks for the heads up, I've fixed it 
my bot isn't responding when I'm reacting
const embed = new discord.MessageEmbed()
.setTitle('Are you sure about that ?')
const messg = message.channel.send(embed).then((messg) => {
messg.react('❌').then(reaction => reaction.message.react('✅'))
const filter = (reaction, user) => (reaction.emoji.name === '✅' || reaction.emoji.name === '❌') && user.id === message.author.id;
const collector = messg.createReactionCollector(filter, {time: 10000});
collector.on('collect', r => {
if(r.name === '✅'){
message.channel.send('✅')
} else if(r.name === '❌'){
message.channel.send('❌')
}
});})```
reaction collectors are fine, but I'm pretty sure your problem lies in the fact that you didn't await sending the embed
You have to resolve promises
the collector is created after the message is sent though
Oh
how?
Still, isn't the value of messg Promise { <pending> }?
now I'm starting to wonder why they assigned it to a variable
Actually nvm, it's executing the if statement regardless I've the role or not
if (!user.member.roles.cache.has(votesRole)) {
reaction.users.remove(user.id);
message.channel.send(`<@${user.id}> You must get the **${message.guild.roles.cache.get(votesRole).name}** before participating in this vote.`).then(message => message.delete({ timeout: 10000 }));
}``` This code is inside a Reaction Collector btw, so "user" is actually referring to the user who added the reaction to the message
can u attach videos on MessageAttachment?
no
Am I being dumb here? https://i.callumdev.xyz/r7ey8.png
wdym
Good one @crimson vapor 
you saw nothing
🤐
if(!message.guild.me.hasPermission("EMBED_LINKS")) {
return message.channel.send('oh no looks like i dont have embed permission :<, for commands to work right please give me \`EMBED_LINKS\` permission to continue to use the bot')
the bots not checking if it has embed perms
how does one do it
that only checks for role permissions
channel permission overwrites can disable it on specific channels
use message.channel.permissionsFor(message.guild.me).has("EMBED_LINKS")
thank you
try{
data = await schema.findOne({
userID: message.author.id
})
cuser = await schema.findOne({
userID: mentionsuser.id
})
if(!data) {
data = await schema.create({
userID: message.author.id
})
}
} catch(err) {
console.log(err)
}
data.credits -= credits
cuser.credits += credits
It's not editing for cuser
mentionsuser
How can I use user from a reaction collector to know if they have a specific role
Basically, I want to know if the user who adds a reaction to a message has a specific role
d.js
how do i wait for a function to finish, without using setTimout ot .then
await it
how
await <stuff>
so just await myFunction()
if it is async, yes
if it isn't async you don't even need to wait since it'll block execution until it finishes
its not working
Just tried this
if (!reaction.member.roles.cache.has(votesRole)) {```
and got "Cannot read property 'roles' of undefined" in the console
check the docs to see how to properly get member object from it
you have to get the member object from the guild using the user's id
when using baseUrl to import files without ../../ I get this error message. It also loads the scss file correctly but not all the css loads?
nextjs ^
you have many files with the same name but different casing
well, I dont, there is just the one
does that file contain same-name stuff?
what
multiple modules with same name
nope
idk then, did u try running at debug level?
no, I mean, inside the file
just good ol scss https://i.callumdev.xyz/0l4jv.png
try running at debug level to see if anything useful appear in the log
next:jsconfig-paths-plugin moduleName did not match any paths pattern styles/Pages/Auth.module.scss +224ms
next:jsconfig-paths-plugin moduleName did not match any paths pattern styles/Pages/Auth.module.scss +1ms
warn - ./src/styles/Pages/Auth.module.scss
There are multiple modules with names that only differ in casing.
we'll need tim

I'm having an issue with external emoji and slash commands. My bot has external emoji permissions and can use external emoji outside of a slash command. Inside a slash command, however, the emoji just show up as :emoji_name:s. Is this a known issue? Is there any workaround?
can you show us your source code
(node:25) UnhandledPromiseRejectionWarning: ReferenceError: guild is not defined
let member = guild.members.cache.get(user.id);
if (!member.roles.cache.has(votesRole)) {```
Emoji IDs are being converted to emoji here:
https://github.com/tiltowait/inconnu/blob/c6b848e01a913749ff0704b52a1e4ffa07fbc0ac/inconnu/display/trackmoji.py#L84
Array turned into a string here: https://github.com/tiltowait/inconnu/blob/c6b848e01a913749ff0704b52a1e4ffa07fbc0ac/inconnu/display/trackmoji.py#L33
can someone end my suffering and help me with a cmd handler that doesnt hurt replits feelings
whatever i use gives it more errors then people on this planet
In __hungermoji, you're modifying the dictionary where you're storing the emoji IDs.
But you save the ID to a variable before altering it
Which is weird
So you end up with a situation where the value will be the ID if it's never been touched before or the string to render on Discord if it has
I don't think it was intentional
oh something I missed
you reassign emoji to the actual emoji and return that
I do need to change this function to just hardcode the values (I did it this way because of a mistaken assumption on my part originally). However, making that change doesn't actually fix it
If I change it to "no_hunger": "\:no_hunger:", I still get the bug
bleh, Discord messed up my formatting
If I change it to that, the bug still occurs
you need to get the guild from somewhere
for example message.guild or channel.guild
its not a free floating global variable
can someone end my suffering and help me with a cmd handler djs v12 compatible
Yk v12 is deprecated right?
i miss the time when they didnt instantly kill their older library
if it's deprecated why can we still use it
deprecated means you can use it but not recommended
and they wont support it anymore
oh I see
Which means "it MIGHT work, but expect sudden death at any moment"
uh bruh so should I yes or yes start working on a rewrite of my bots
Ye, better while you're still small
The later you start the more work you'll have
and isn't there some kind of automatic converter like that one that turns everything from some old types of js into ES6 for example?
Nope
you wish
Yeah it definitely makes sense
discordjs wouldnt be that kind
Btw, do you plan adding different languages on ur bot?
I don't, I'll stay with JS, it's the one I'm most familiar with (as I haven't coded in any other language in the past) even though I'm still a total amateur in programming in general
...languages as in english, spanish, german, etc
i18n
Just say yes or no 
ah lmao sorry
Nah, the current bots I program are made for very specific servers & purposes. Some years ago my dream was to create an actual cool bot and submit it to top.gg but I gave up
Ok, you're fine then
if anyone knows are javascript objects just hash maps under the hood
So no, they'll keep English as main and only language
I asked because for i18n stuff you need to start at the very beginning
i18n is annoying as fuck
You can't simply change your mind later
It's not humanely possible to implement i18n in an old project
It is the kind of thing that you wanna make sure you're going to support multiple languages from the very beginning as it can be as KuuHaKu said quite challenging to implement later on
Not to mention implementing it properly can be rather annoying
I see lol
I'd argue there are many things you won't implement now but will later because there comes a time where you need it—just like i18n
But then it's too late 😩
Implementing i18n late is annoying as fuck
It is something i'd much rather do from the beginning
At least have some basic implementation that can be built upon later
Me too, wish someone told me when I started
Implementing i18n is going to be annoying no matter what time you chose to adopt it
Klay you it is 10x more annoying doing it in a project that is already built up
And adopting it early may just lead you to walk in the dark thinking "yeah this works!" only to realize it doesn't (or very poorly) when you add another language
But I don't see myself collecting all the 3 thousand strings in near future
I don't have any major project going on right now that requires i18n
Nor do I have the patience to implement or work on a project that could use it
Is i18n the only option for implementing translations to your bot though?
i18n stands for internationalization (often with localization added), so it is the way to translate a bot
Yea
that sucks
It’s not like it would be complex to create language files in the ini or JSON format, load a default language file, parse the file into vars (or a language obj), then load an additional language and overwrite all existing language vars to prevent incomplete language files from missing anything
Just a few functions to load the files and parse the content, that’s it
But you really need to be consequent to not use any text to output in your code
not exactly
js Map is a hashmap, but objects can be a bunch of different things depending on how many items and what type of items it holds
yes its complicated
Btw, how can I check how many reactions have the collector collected?
I tried with console.log(<Collector>.collected.size) but it doesn't display anything in the console
its optimized for performance, not for memory usage
From the language that treats every number as a float
also vastly depends on the js engine, thats how v8 does it
it has maps that are massive complicated structures lol
and yeah
whats the general lookup time on a JS map?
also fun fact, v8 stores 32 bit ints as actual 32 bit ints, even though js treats them as doubles
generally its o(1)
sorry i mean in actual timing
like in nanoseconds?
idk, a few hundred nanoseconds i guess? lmao
Im just curious because if they do it for performance you'd expect it to be faster than things like Python for actual access time
otherwise it be needless complication
pls ping when replying
microbenchmarking in v8 is hell
"oh you're benchmarking this piece of code? here let me precalculate, predict and compile the outcome and give you the result instead of running your code :)"
http://img.extreme-is.me/YxYEmwujY07f0LOB I don't see what the issue is
apparently your server no work
Well
It works
Then randomly
On no interval or a set way
It just sends a 520 back
Could it be I am calling too many times?
Ask the server
It's my VPS 
is this http status codes
looks like it yup
module.exports = {
name: 'error',
async execute(client, error) {
try {
throw new Error('Whoops!')
} catch (error) {
const embed = new Discord.MessageEmbed()
.setAuthor(client.user.username, client.user.displayAvatarURL({dynamic: true, size: 2048}))
.setTitle(error.name)
.setDescription(`\`\`\`${error.message}\`\`\``)
.setFooter('Error!')
.setTimestamp()
}
How to make it send error from any code in the bot ?
then in that cases webserver is committing http genocide
Why are you throwing an error inside the try
Idk
also you just send the embed to the channel
Yes i didn't sent this line
It's not sending
anything
It's only happening on this bot, maybe its just because its being hosted locally
Oh
nvm
how would I make a cli have commands like npm init not npm --init
they are??
also, is the only way to make custom cmds, to use bin?
you can make cli apps with any language
tbf, they are the first kind you learn when starting
I'm trying to make a cli for a npm package to help users manage, so they can do commands like "ch help" and it will log a help message
you can do with node if you're used to it
ty
np
Okay, I stripped out the bot.get_emoji() code and hard-coded the emoji strings into my code. Verified once again the bot has permission to post external emojis. Verified the @everyone role has external emoji permissions.
Bot still won't display external emojis using slash commands. It uses them just fine in non-slash-command interactions
Okay! Finally figured it out. Turns out the channel we have for bot testing didn't have the permission set, but every other channel did. 🤦♂️ But it works now
can i change the True False text for booleans?
but they are
tank u
np
Yes, delete my profile
No, don't delete my profile
i might need to use choices
do I have to have the options with - infront or can I do it without them
you can make it however you want, the syntax is totally up to you
just like a normal bot
oh alr,
they use - or -- because grabbing params is somewhat easier if they all contain a common prefix
ohhh okay,
dose it only work with 1 cmd??
then do it
literally treat the cli app as a bot
use a command manager
good way to practice making command managers I'd say since you'll only have a single param
which is the message itself
think as if you were making a bot, how would you process that message?
like, I sent ch -n blabla
how would you execute that command?
as in with a cmd handler?
ye
yes
then i would get cmds folder
in that case, you didn't define a command at all, only the params
ohhhh
so you'd need something like ch setname -n something
the cmd is -n
can be, sure
lol i am confused
normally params are the ones with - prefix
but it's exactly as you were saying
check if message has prefix ch
if yes, find command with name -n
if found, pass args to it and execute the code
but how do i check when a cmd was sent
you don't need to
actually, yes you do, but it's simpler than discord
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', text => {
console.log(text);
if (text.trim() === 'quit') {
done();
}
});
function done() {
console.log('Now that process.stdin is paused, there is nothing more to do.');
process.exit();
}
very similar to d.js
to keep process alive just put it on an infinite loop
although I guess stdin will already do it
im so confused lol
process.stdin.on('data', text => {
console.log(text);
if (text.trim() === 'quit') {
done();
}
});
imagine this is a d.js event
like client.on('message'
yes
but instead of an event object all you'll have is a string
text will be whatever the user typed
ok
so this is just in a normal js file?
ye
and i use a bin file to execute?
can someone help me out with a command handler? v12?
You know v12 is deprecated right.
And please don't ask to ask.
Just explain your problem.
help
if (fields[key].$elemMatch) {
^
TypeError: Cannot read property '$elemMatch' of undefined
at model.Query._castFields (/home/runner/tbz/node_modules/mongoose/lib/query.js:5008:23)
at model.Query.<anonymous> (/home/runner/tbz/node_modules/mongoose/lib/query.js:2341:23)
at model.Query._wrappedThunk [as _findOne] (/home/runner/tbz/node_modules/mongoose/lib/helpers/query/wrapThunk.js:27:8)
at /home/runner/tbz/node_modules/kareem/index.js:370:33
at processTicksA
what... lol
@thorny flume is this useful? https://stackoverflow.com/a/68566867/14695788
Hi, I've a question
So I'd like to store a role's members.size value to use it later, the problem is that if I define it this way: js const role = message.guild.roles.cache.get("id").members.sizerole's value may vary, as people may get that role added/removed in the meantime
So how could I store it so that it's a non-editable value?
Uhm just dont change the value after storing it?
But it's not possible - People might get that role added/removed from themselves while the code is running, and it may affect the final result
Is that line of code being run multiple times?
the value should only be assigned once the client reaches a ready state
^^
yes
if at 7am I run the code, role's value might be "5", for example, however, at 10am it might be "7" (so +2 users got the role), however, I would like to keep having "5" as role's value
maybe I could put the value into a string and call it later?
So you want it to run once, get the value, then never run again?
No, run it once, get the value, and stay with that value even if role's value is different later
You should do what I suggested.
let amount = 0;
client.once("ready", () => {
amount = getRoleCountHere();
});
maybe even store the value in a database so that it's persistent if you need it to be
Alright, thanks! 
I've another idea, what if I update the message embed where role's value is each 1 hour?
Would this code be a good idea?
do {setTimeout(function(){m.edit(embedNameHere)}, 3600000)} while (gameVoteCollector.ended === false);```
Every time it edits the message, role's value will get updated
setInterval may be better lol
Is there any link shortner for bot invite url
K ty
how do i make my own oauth2 handler?
🎉
ohh ok
Follow these steps
(I wrote this for someone else tho)
- The user goes to Frontend React app (/login)
- You redirect to Discord Oauth2 api (discord.com/oauth2/....)
- The user clicks accept
- The user gets forwarded to your Front-end React with a code (3000/login?code=THE_CODE)
- You get the code inside react and send a request to the backend (The user stays on /login page and watches a loading screen)
Meanwhile in Backend - The express app receives the request with code
- It authorizes using the discord api
- It generates a random token
- It saves the data and token to database
- It sends the user data and token to Frontend (React) as a response to the request.
Now in Frontend (React) - The app receives the response containing user data and token
- Stop the loading screen and show the data you received
- Save token in cookies / localStorage for future use
wait so u mean if a user authenticates through discord then discord does a request from the link ive provided?
if so that kinda makes sense 
huh ?
When you set up oauth2 you get a code / token in your redirect uri/url
ah
You set a redirect uri (let's say top.gg/login)
When the user authorizes you you get the code as get parameter at that uri (eg top.gg/login?code=THE_CODE_IS_HERE)
yes
how about this?
const oauthData = await fetch("https://discord.com/api/oauth2/token",
{
method: "POST",
body: new URLSearchParams({
client_id: clientID,
client_secret: clientSecret,
code: code,
grant_type: "authorization_code",
redirect_uri: URL,
scope: "identify guilds",
}),
headers: {
"Content-Type": "application/x-www-form-urlencoded",
}
})
The uri you've used for redirection
in the example (top.gg/login)
uri / url
and whats URLSearchParams is that something i need to worry about or it's just a NodeJS/Js thing
Yes
That's the thing you should worry the most about

People (like me) literally spent hours just to find out the data type isn't json and URLSearchparams
Thus making it the most complicated process of the oauth2
so how do i prevent that from happening/what do i do about it
Discord interactions are dumb, try and change my mind
URLSearchParams is literally ?param=value¶m2=value
use URLSearchparams and not json or js object
It's probably built in

are they safe?
yes
Kk tenks
Even uptime robot works right?
idk, try it
Kk
inb4
how do i check that its a real code
cuz someone can just type the url then add ?code=idk
Yeah
You have to verify the coe3
Nothing on the web from the client side can be taken as valid or correct
so how do i check if its a real one?
you generate the code server-side, and after the user gets redirected you compared the generated server-side value with the search parameter value
"generate the code server-side"
wdym 
oop I'm confusing code with state
Just make the request for the user's access token and if you get an error then it's not valid
you should also use the session property for extra security https://discord.com/developers/docs/topics/oauth2#state-and-security
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
ah
and if i want more scopes i can just do this right?
"identify guilds guilds.join etc."
yeah
Why my bot doesn't found commands folder at line 7 ?
he say me - no such filee or directory -
lol what
"illegal request"
:iara_saywhat:
help
code
const express = require(`express`)
const axios = require(`axios`)
const app = express()
const client = {
id: "884689851272810497",
secret: process.env.client_secret,
scopes: ["identify"],
url: "https://oauth2-handler.slay098.repl.co/login"
}
function getToken(code) {
axios.request({
url: `https://discord.com/api/v9/oauth2/token`,
data: new URLSearchParams({
clientID: client.id,
client_secret: client.secret,
code: code,
grant_type: "authorization_code",
redirect_uri: client.url,
scope: client.scopes.join(" ")
}),
headers: {
"Content-Type": "application/x-www-form-url-encoded"
}
}).then(res=>{
console.log(res)
}).catch(res=>console.log(res.toJSON()))
}
app.use(express.json())
app.get(`/`,(req,res)=>{
res.redirect(`/login`)
})
app.get(`/login`,(req,res)=>{
if (!req.query.code) return res.redirect(`https://discord.com/api/oauth2/authorize?client_id=884689851272810497&redirect_uri=https%3A%2F%2Foauth2-handler.slay098.repl.co%2Flogin&response_type=code&scope=identify`)
getToken(req.query.code)
})
app.listen(2000)
is there any way to make a collection with plain js?
wdym by "collection"
Yes, by extending Map
thonk
That's what a Collection is
can someone help me
hi can anyone help me out
this is coming when i made a new file for invite cmd
and this shows me when i run the cmd
@drowsy crag please see this
its a phising
link
const express = require(`express`)
const axios = require(`axios`)
const app = express()
const client = {
id: "884689851272810497",
secret: process.env.client_secret,
scopes: ["identify"],
url: "https://oauth2-handler.slay098.repl.co/login"
}
function getToken(code) {
axios.request({
url: `https://discord.com/api/v9/oauth2/token`,
data: new URLSearchParams({
clientID: client.id,
client_secret: client.secret,
code: code,
grant_type: "authorization_code",
redirect_uri: client.url,
scope: client.scopes.join(" ")
}),
headers: {
"Content-Type": "application/x-www-form-url-encoded"
}
}).then(res=>{
console.log(res)
}).catch(res=>console.log(res.toJSON()))
}
app.use(express.json())
app.get(`/`,(req,res)=>{
res.redirect(`/login`)
})
app.get(`/login`,(req,res)=>{
if (!req.query.code) return res.redirect(`https://discord.com/api/oauth2/authorize?client_id=884689851272810497&redirect_uri=https%3A%2F%2Foauth2-handler.slay098.repl.co%2Flogin&response_type=code&scope=identify`)
getToken(req.query.code)
})
app.listen(2000)
Its saying its a "Bad Request" and sending a status code 400
"Do not @mention people randomly"
k
code?
Please provide the code and error so we can help easier

is this the part where everyone says
"its the hardest part of dealing with OAuth2"
replit lol
Let me see message.js
yea i got no free host

send the code in a pastebin or something
if you could provide one with bot hosting free it would help me alot
k
cuz were not gonna zoom in ur code
help
here
threadripper with 128gb ram only $480 monthly
I see. Just add userperms: [], below line 10
free i mentioned lol
i see that
k
const express = require(`express`)
const axios = require(`axios`)
const app = express()
const client = {
id: "884689851272810497",
secret: process.env.client_secret,
scopes: ["identify"],
url: "https://oauth2-handler.slay098.repl.co/login"
}
function getToken(code) {
axios.request({
url: `https://discord.com/api/v9/oauth2/token`,
data: new URLSearchParams({
clientID: client.id,
client_secret: client.secret,
code: code,
grant_type: "authorization_code",
redirect_uri: client.url,
scope: client.scopes.join(" ")
}),
headers: {
"Content-Type": "application/x-www-form-url-encoded"
}
}).then(res=>{
console.log(res)
}).catch(res=>console.log(res.toJSON()))
}
app.use(express.json())
app.get(`/`,(req,res)=>{
res.redirect(`/login`)
})
app.get(`/login`,(req,res)=>{
if (!req.query.code) return res.redirect(`https://discord.com/api/oauth2/authorize?client_id=884689851272810497&redirect_uri=https%3A%2F%2Foauth2-handler.slay098.repl.co%2Flogin&response_type=code&scope=identify`)
getToken(req.query.code)
})
app.listen(2000)

tysm 
No problem :)
heroku or repl are the only free ones that I know at least
help 
k like a one where privacy of someone or code dont get leaked or something
You need to make a post request
you're making a get request rn
vps
as for me the imp this is members privacy and data
but vps are not free
yea
you can search for it
:((
Does someone know the discord sys req?
yup no issues and thx
ah shit
@cinder patio
const express = require(`express`)
const axios = require(`axios`)
const app = express()
const client = {
id: "884689851272810497",
secret: process.env.client_secret,
scopes: ["identify"],
url: "https://oauth2-handler.slay098.repl.co/login"
}
function getToken(code) {
axios.request({
url: `https://discord.com/api/v9/oauth2/token`,
method: "POST",
data: new URLSearchParams({
clientID: client.id,
client_secret: client.secret,
code: code,
grant_type: "authorization_code",
redirect_uri: client.url,
scope: client.scopes.join(" ")
}),
headers: {
"Content-Type": "application/x-www-form-url-encoded"
}
}).then(res=>{
console.log(res)
}).catch(res=>console.log(res.toJSON()))
}
app.use(express.json())
app.get(`/`,(req,res)=>{
res.redirect(`/login`)
})
app.get(`/login`,(req,res)=>{
if (!req.query.code) return res.redirect(`https://discord.com/api/oauth2/authorize?client_id=884689851272810497&redirect_uri=https%3A%2F%2Foauth2-handler.slay098.repl.co%2Flogin&response_type=code&scope=identify`)
getToken(req.query.code)
})
app.listen(2000)
That means bad request
yes ik but i can't find the error that causing this
There's nothing wrong with the code itself, the data you're sending to discord is not correct
It's client_id, not clientID
oh
Hello
still saying Bad Request
const express = require(`express`)
const axios = require(`axios`)
const app = express()
const client = {
id: "884689851272810497",
secret: process.env.client_secret,
scopes: ["identify"],
url: "https://oauth2-handler.slay098.repl.co/login"
}
function getToken(code) {
axios.request({
url: `https://discord.com/api/v9/oauth2/token`,
method: "POST",
data: new URLSearchParams({
client_id: client.id,
client_secret: client.secret,
code: code,
grant_type: "authorization_code",
redirect_uri: client.url,
scope: client.scopes.join(" ")
}),
headers: {
"Content-Type": "application/x-www-form-url-encoded"
}
}).then(res=>{
console.log(res)
}).catch(res=>console.log(res.toJSON()))
}
app.use(express.json())
app.get(`/`,(req,res)=>{
res.redirect(`/login`)
})
app.get(`/login`,(req,res)=>{
if (!req.query.code) return res.redirect(`https://discord.com/api/oauth2/authorize?client_id=884689851272810497&redirect_uri=https%3A%2F%2Foauth2-handler.slay098.repl.co%2Flogin&response_type=code&scope=identify`)
getToken(req.query.code)
})
app.listen(2000)
I not it English hehe
this is #development go to #general-int if u want to talk in diff language
:( what your from?
I dunno, check if process.env.client_secret is correct
k
and is there a docs on how to generate a token?
you mean a secret?
it can be whatever you want
or do you mean to regenerate an access token?
sorry, how do you change the language?
this thing: https://discord.com/api/v9/oauth2/token
like converting the code into a token
are you hackers?
haxta
ill ask in discord api server 
anyways thx for ur help
@errant flax try removing the scope
why?
What your from?
you got it working?
I can't speak English :(
still the same lmao
ah wait a sec
you need to make it a string
new URLSearchParams({...}).toString()
try it
What?
nvm its the same
or maybe you have a typo
@errant flax isn't it application/x-www-form-urlencoded
you write it application/x-www-form-url-encoded
I can't speak English. Help me :(

this solved it for me
Oky Thenks
sill an error
pOg it WoRkS
ive fixed it by:
fixing the typo on Content-Type
and making data a URLSearchParams class

Is there a max amount of slash commands a bot can have?
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
100 global
100 per guild
why dosent this work?
I have defined cmd and the file exists but it keeps telling me it cant find module .src/command/commandname.js
fs.access(`./src/commands/${cmd}.js`, (err) => {
if (err) {
console.log("The file does not exist.");
} else {
const command = require(`./src/commands/${cmd}.js`)
command()
}
});```
damn
100 global that's why I group complex but related commands into subcommand groups 
oh so subcommands are not counted?
Nah
ah ok I'm good then
It's still just one command
thx
hey umm
anyone use nestjs?
i just ran the basic nest new app and when i try to start the application it keeps throwing some "unexpected token in dist/app.controller.js" error
like bruh i haven't made any changes yet
just the basic boilerplate
Skill issue
It says that because typescript is java 2.0
okay i solved it myself
refreshToken(token){
return new Promise((resolve,reject)=>{
axios.request({
url: `https://discord.com/api/v9/oauth2/token/revoke`,
method: "POST",
data: new URLSearchParams({
client_id: this.client.id,
client_secret: this.client.token,
grant_type: "refresh_token",
refresh_token: token
}),
headers: {
"Content-Type": `application/x-www-form-urlencoded`
}
}).then(res=>{
resolve(res)
}).catch(res=>{
reject(res)
})
})
}
??
How can I make the collector listen just to the right interaction reply. So If I send 2 command where to bot replies with a message with components the collector listens to both.
I cant do like
let message = await interaction.reply()
message.createMessageComponentCollector({})
//message is always undefined
any help?
await it and make sure to add fetchReply
help?
await interaction.reply({ fetchReply: true }) if I recall correctly
thank you
is there anyone who is still studying in the IT field?
some are still in school majoring in tkj
i never finished school
last school what?
idk, 7th grade?
how old are you?
idk, 7th grade?. what is it?
i stopped going to school when i was 13. i am 30 now
School is overrated for some people / jobs. I wasted 2 years at college studying something I didn't really enjoy and dropped out.
agreed
why quit school?
i was introduced to html by someone when i was 16, it made me realize it was not rocket science as i previously thought
self taught from there on
Same lol
no i never went
Now I sell websites to small businesses 
in my case it was because my family started traveling, but i never liked school much anyway
we traveled for a few years in brazil, then i never joined school again
I dropped out of college because it wasn't what I wanted to do (studying Chinese and Spanish). And since I was already self-taught in development and graphic design and I already had that side hustle, I just didn't see the need for school at all.
nihao
Yeah that's the limit of my Chinese too 
lmao
It was interesting, but I just don't do well in a school environment
ye
for me, it still took me almost 10 years before i actually started working with programming
How do you add bot music to our discord?
i was more interested in tech and repair back then
my js skill was attrocious when i started working on discord bots in 2017 lmao
Same. I was more used to PHP from web dev. Making Discord bots has definitely helped my JS skills lol
Obviously there's a bit of JS in web dev but not a lot.
the only php i knew was from working with wordpress and i hated it lmao
watch this tutorial https://youtu.be/ii02ZfT3Pec
start at 0:50
i also didnt know how to use wordpress properly, so i did some horrendous things with it xD
meaning that i couldnt update wordpress because it would break my shit
and eventually i got hacked
because wordpress security is good™️
Lol
so what were talking
how...
wow is this real?
Lmao yeah I always bulk up the wp security a bit for clients
thank you
i was great at writing unmaintainable websites :^)
but i got tired of web dev, i dont do it professionally anymore
wordpress is famous for its bad security, so you have to always update it, otherwise you're vulnerable to exploits and shit
Yeah I don't know if I really like client work anymore. Making a Discord bot with a premium model has made me realise maybe SAAS is the way to go.
SAAS?
WordPress is like the #1 CMS so if people find an exploit you can bet they're gonna make money out of it.
Service/Software As A Subscription
can't open, why?
is the refresh_token for the OAuth2 app valid forever?
hello
Yeah some people say service, others subscription... All the same anyway 
hello
Do you have a code that makes my bot change the nickname of the new member automatically when he enters my server
wow seriously? teach me please, I want to hack the hacked account/server
By that do you mean you have an existing piece of code that you want help with, or you just want the code given to you @frigid solar
I just want the code
Why
In which channel
In #development
here
Having someone else write your code for you doesn’t teach you anything
Did you encode base64 ?
@arg {String} credentials Base64 encoding of the UTF-8 encoded credentials string of your application
We are in this rum
Search on Google / GitHub
This server doesn’t spoonfeed code
ok thx
Do you have a code that makes my bot change the nickname of the new member automatically when he enters my server
@near stratus
Either use Google like suggested, or we can offer help on how you can get started with that functionality
Search on Google
or see https://discord.js.org/#/docs/main/stable/class/GuildMember?scrollTo=setNickname
thx
how to add music bot
someone kill me
🔪
thank you
np*
Why are you laughing at me
To update the nickname like you want, you should set the user’s nickname on the guildMemberAdd event
I'm learning
You’re not learning if you’re expecting people to just give you code for you to copy paste
uh how do i check if my bot has permissions to ban, like i want to check all the guilds that my bot is in and make my bot leave all the servers that it doesn't have ban perms in
thank you
Why i have this error ? (the folder exists, see on the left) thx
[Error: ENOENT: no such file or directory, scandir '../commands/'] {
errno: -2,
code: 'ENOENT',
syscall: 'scandir',
path: '../commands/'
}
/moontest/events/ready.js:12
if(content.length < 1) return;
^
TypeError: Cannot read property 'length' of undefined
at /moontest/events/ready.js:12:20
at FSReqCallback.oncomplete (node:fs:185:23)```
using d.js 13
Can I ask for another help
Yes
const { Permissions } = require("discord.js");
if((bot).guild.me.permissions.has(Permissions.FLAGS.BANS_MEMBERS) console.log("Great, i have the perm !")```
try this
To get verified on top.gg, you have to submit a bot abiding by #rules-and-info
To get verified on discord, you’ll have to look at their requirements for bots, but you can start the verification process once your bot reaches 75 servers
how do you screenshot?
alrightys thx
np
Press a button on the keyboard
For you, when the guildMemberAdd is emit, do a action for the bot change her nickname.
Button name: Impr écran syst
ok ok
I have to give permission to change nickname
??
ye, logic
example: i don't have perm to change my nickname in this server because i don't have required perms. Is same for you
otherwise the perm change nickname will not exist
Can not
hey is refresh_token valid forever???
F1?, F2?
what is your windows??
how that ?
?
windows 7
i don't understand ur question @errant flax
@jaunty ore #general
please go to #general or #general-int and change ur keyboard pls
A quick google search can teach you how to take a screenshot
is refresh_token valid?
from the OAuth2 thing
Whereas a development channel is not the place to learn that
This keyboard is old, it's 10 years old
const guildIds = client.guilds.cache.map(g => {
return g.id
})
i am trying to make this select all the guilds that the bot has ban perms
is there a way i could do that
i don`t know
Or snipping tool 😎
anyone got any idea
.map(g => g.me.permissions.has("BAN_MEMBERS"))
aye thx
can not
try to join my discord
where do you come from?
can you teach me how to install music bot?
const guildIds = client.guilds.cache.map(g => {
return g.me.permissions.has("BAN_MEMBERS").id
})
ayo tim is this supposed to only get the guild ids that the bot has ban perms in?
has returns a boolean
You should use filter on the guild cache
And return the Boolean rather than trying to get out the id
Then you'll have a collection of guilds where your bot has permission to ban members
you can filter the collection after mapping
That's just logically more inefficient
client.guilds.cache.filter(g => g.me.permissions.has("BAN_MEMBERS"))
I still don't understand can you teach me again, sorry I still don't understand 😦
that will give you entire guild objects
not ids
if you want ids you can map it afterwards
.filter(...).map(g => g.id)
ohh alrightys
So I have two typescript files, and i want to get variables from file1 in file2, how can i do that?
export them
but i think it wont work, as file2 has an event listener, which is in a functionn. which is exported. but the variables will change over the time, so i want to get the variables when the event happens
show code
well its lot of code
ok wait
//file1.ts
import {func1} from "file2.ts";
let val1 = "something";
func1(val1);
val1 = "something else";
//event happens now
//file2.ts
export function func1(someVal){
event.addListener("event1",()=>{
//do Something with someVal
});
};
something like that
I have here an array with .mp3 files.
So how can I play the next song after the last song ends:
Sth like this (doesnt work of course)
let pathM = path.resolve('./music')
const playlist = fs.readdirSync(pathM).filter(file => file.endsWith('.mp3'));
console.log(playlist.length)
for (let i; i < playlist.length; i++) {
const resource = createAudioResource(path.resolve(`./music/${playlist[i]}`));
player.play(resource);
}
no you cant do that, you have to change the way you do it
one option is to have a separate function to update the value
another option is to put the listener in file1
listener is in file2
file1 sorry
Ask the gods who created React.useState
you can also export an object and modify its properties
How do they track the value of a variable
while running?
i will have multiple event varaibles (where i add the listener)
wait i have an idea
i mean, the proper way would be to have functions to update it
but an object should also work
for example
// file2
export {
prop: 10,
start: function() { event.addListener(/* do something with this.prop */) }
}
// file1
import * as obj from "file1"
obj.start()
obj.prop = 20
idk how typescript parses this, the object has to be imported as a reference and not destructured
but a more correct way would be to use functions
how could i do that with the functions ?
let prop = 10;
export function start() { ... }
export function update(val) { prop = val; }
// file1
import { start, update } from "file2"
start()
update(20)
yeah
Not on the last one though
ye, not needed in the functions method
yeah but I was talking about the first one
Me and my friend made a bot together. He gave me the file to add it for me and i downloaded it and added to my code sorce and this is what i got:
5Pm�B�l�G���}_�O�'�=�^6�i͘w%F��N�G�,�#�fH�Fq�Ɨ�"�b3?�Bz/%�.�,��!nc`Eʃh�%Mx�'ƭthI�2R�JG���?�7��rJhɹl3f�8��~�8�>�o�o֥9۴��A+ܮ^�G�6x|�H�D�@K~.�M:%.���Ϡ�gŅX�i�$2�*,���E�~�7��
nice
nice
coding?
Sorry, I'm still confused about what to do here
You know how to code right?
That looks like a compressed file
yes
Did you not read the message?
I can give the file is you need
like I said either it's a compressed file or your editor doesn't support that file extension
or is a binary file
true but I have no experience with that
botum compressed help @ mods
why did danny archive discord.py?
Read his gist
#toomanycomments
hosting my bot on aws but when i do node . the bot comes online but its status dosen't load and bot dosen't reply
also it stuck at ready.js
How can i skip to a specific second of a video with the new @discordjs/voice
RIP discord.py
You're just a few weeks late to celebrate
data = await schema.findOne({
^^^^^
SyntaxError: await is only valid in async functions and the top level bodies of modules
const schema = require('../schema/GuildSchema')
module.exports = {
name: 'guildMemberAdd',
execute(client, member) {
let data;
try{
data = await schema.findOne({
GuildID: member.guild.id
})
if(!data) return;
} catch(err) {
console.log(err)
}
let Channel = client.channels.cache.get(data.LogsChannel)
if(!Channel) return;
if(Channel.type !== 'GUILD_TEXT') return;
const Add = new Discord.MessageEmbed()
.setAuthor(member.user.username, member.user.displayAvatarURL({dynamic: true, size: 2048}))
.setTitle(' Member Join!')
.setDescription(` MemberTag: ${member.user.tag}\n MemberID: \`${member.user.id}\`\n Created At: ${moment.utc(member.user.createdAt).format('LT')} ${moment.utc(member.user.createdAt).format('LL')} (\`${moment.utc(member.user.createdAt).fromNow()}\`)\n Joined At: ${moment(member.joinedAt).format("LT")} ${moment(member.joinedAt).format('LL')} (\`${moment(member.joinedTimestamp).fromNow()}\`)`)
.setColor('GREEN')
.setFooter(member.guild.name, member.guild.iconURL({dynamic: true}))
.setTimestamp()
const botname = client.user.username;
Channel?.createWebhook(botname, {
avatar: client.user.displayAvatarURL({ format: 'png', dynamic: true, size: 128 })
})
.then(webhook => Promise.all([webhook.send({ embeds: [Add] }), webhook]))
.then(([_, webhook]) => webhook.delete())
.catch(() => {});
// add more functions on ready event callback function...
return;
}
}
Line
data = await schema.findOne({
and?
Your execute function isn't an async function
(as the error states)
plss
Function someFunction() { // opening bracket
Console.log("works!")//logging works
} // closing bracket
Hi 🙂 I'm report bot @tall vessel bot using to scam
bot using on discord scam nitro
Try #support if that's even related to topgg
thx
code
guild.members.fetch().then m
let bots = m.filter(x => x.bot)
console.log(bots.size)
Result
0
Problem
There are 3 bots in server
Do you have guild_members intent?
And is enabled during client start?
I enabled it on dev portal
Did you add the intent to the client?
Is that exactly how you wrote it?
No
Idk if fetch allows no-param retrieval
Did you try using the cache?
Or fetchAllMembers (something like that)
message.guild.members.fetch().then(m => {
let b = m.filter(x => x.bot)
message.channel.send(`
Total Users: ${m.size}
Bots: ${b.size}
`)
});
It removed on v13
Still, I'm not sure you can fetch like that, without any param
Doesn't the docs talk about doing that?
ClientOptions#fetchAllMembers
The ClientOptions#fetchAllMembers option has been removed.
Docs only talking fetching members and filter them if they online
I need to fetch bots
Probably fetching thing fetch all bots and users as same thing
What if i use users instead members
fetch undefined...
x.user.bot
x is a member, not a user
hello, i am trying to make a npm that has a cli and i am using a bin file and using package.json to exectue functions when messages are sent, but, when the user installs the package they can not use the commands, do i have to update their package.json to include the bin or do i have to do something els?e
if you want to use cli commands without node/npm the user has to install it as global
with the -g switch
so like npm i -g <package name>
yes
ok
I just restarted my bot (after literally changing a string's content) and now I'm only getting this error. My bot doesn't go online.
Is this a problem from my vps or Discord?
I mean I don't think it's my fault, I just changed a string's content before and restarted it so that it would show the string's updated content
Catch ur promises
Not only makes it a hell easier to debug but also allows error handling
Remember to throw early and catch late
just tried to start the project again right now (without changing anything in the code) and it worked out of nowhere lmao - I guess the fault was on Discord's end?
anyway thanks for the heads up
Probably connectivity issue
module.exports = {
name: 'channelDelete',
async execute(client, GuildChannel) {
if (!GuildChannel) {
return;
}
const { type, id, name } = GuildChannel;
How to know the user who deleted the channel ?
Can i know what is shard for and how to get it?
can i still have other packages if the user installs it global, and if so do they also have to install the used packages global aswell?
if the other packages have cli commands, yes
1 shard = 1 bot connection
discord only allows 2500 guilds on a single connection, so if you bot is in more than 2500 guilds, you have to use multiple bot connections, aka shards/sharding
Ouh
how can i disble maintenece mode
ummmmmmmmmmmm
pls help me
go ask where you got that sites code
not here
Main
const something = require(./something)
Something File
module.exports = client => {
console.log("Something is Ready")
}
Problem
something is ready not writing in console(restarted bot)
quotes around the ./something
oof
But console log is working when i type console.log on the first line
yea because it's not exported as a function
Hmm how do i it
wdym
Bc didnt understand it
export as a funciton
Then why itsnt working
async execute(client, channel) {
if (!channel) {
return;
}
const fetchedLogs = await channel.guild.fetchAuditLogs({
limit: 1,
type: 'CHANNEL_DELETE',
});
// Since there's only 1 audit log entry in this collection, grab the first one
const channelLog = fetchedLogs.entries.first();
const { executor, type, id, name } = channelLog;
const ChannelDeleted = new Discord.MessageEmbed()
.setDescription(` Channel Name: \`${name}\`\nChannel ID: \`${id}\``)
Channel Name: undefined
What is the problem ?
Hi! How can i fix this error pls ?
Source code : https://hastebin.com/ociwazinuk.coffeescript
Error : js DiscordAPIError[50035]: Invalid Form Body 10[APPLICATION_COMMANDS_DUPLICATE_NAME]: Application command names are unique at SequentialHandler.runRequest (/moontest/node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.js:198:23) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async SequentialHandler.queueRequest (/moontest/node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.js:99:20) at async /moontest/deployCommand.js:80:3 { rawError: { code: 50035, errors: { '10': [Object] }, message: 'Invalid Form Body' }, code: 50035, status: 400, method: 'put', url: 'https://discord.com/api/v9/applications/883621594877009921/guilds/834472071559512104/commands' }
PS: He say me exist duplicates command but i don't see :/
Fetch your commands then and you will see it
because you aren't calling it?
you've got to run the function
I'd say switch to d.py
ah yes, switch to an abandoned lib because of an error in another lang

any help ? i get this probleme only when i invite the bot to my own server but it works in other servers
Which intent is required to emit guildMemberRemove on discord.js?
thats not the full error
To emit an event nan intent is needed only for recieving an event from gateway the intent is needed
emit = receive
Hello.
Today I'm trying to send a attachment with interaction.reply function but he send me one error and i ask if someone can help me for fix this ?
Thanks you!
Error:
/moontest/node_modules/discord.js/src/util/DataResolver.js:125
throw new TypeError('REQ_RESOURCE_TYPE');
^
TypeError [REQ_RESOURCE_TYPE]: The resource must be a string, Buffer or a valid file stream.
at Function.resolveFile (/moontest/node_modules/discord.js/src/util/DataResolver.js:125:11)
at Function.resolveFile (/moontest/node_modules/discord.js/src/structures/MessagePayload.js:240:41)
at /moontest/node_modules/discord.js/src/structures/MessagePayload.js:205:85
at Array.map (<anonymous>)
at MessagePayload.resolveFiles (/moontest/node_modules/discord.js/src/structures/MessagePayload.js:205:56)
at CommandInteraction.reply (/moontest/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:97:64)
at Object.exports.run (/moontest/commands/Images/avatar.js:24:22)
at Query.onResult (/moontest/events/interactionCreate.js:28:41)
at /node_modules/mysql2/lib/commands/query.js:72:16
at processTicksAndRejections (node:internal/process/task_queues:78:11) {
[Symbol(code)]: 'REQ_RESOURCE_TYPE'```
data: new SlashCommandBuilder()
.setName('filter')
.setDescription('Adds filters to your avatar!')
.addBooleanOption(option => option.setName('blurpify').setDescription('Select the blurpify filter option'))
.addBooleanOption(option => option.setName('magik').setDescription('Select the magik filter option'))
.addBooleanOption(option => option.setName('deepfry').setDescription('Select the deepfry filter option')),
How to make that the required option is 1 option
If i set .setRequired(true) for all it will require all in same message
Your errors were:
- asking help about making a botlist
- not coding anything but stealing source code
- status 200 -> site unavailable, really?
how do i make a line of code run terminal commands for me with node?
exec
With Node, we can run shell commands and process their I/O using JavaScript, instead of the shell scripting language. This makes the application easier to maintain and develop as we stay in the same environment.
any solu?
so how i can fix it
btw
its just happened when i invite the bot to my own server
but it works when i kick em
is the code yours?
yes but i use some other codes
you are using a very old version of discord.js, which is no longer supported
so no
i need to update it ?
yes
You got'em
what no
be aware that updating discord.js requires updating a lot of your bot's code, because new versions are not compatible with code for old versions
you are using discord.js v11 from what i can guess, the latest version is v13
Lol
Never change a running system u know
how would i make a command that would run:
git commit -m "commit"
git push```

I would expect its generally O(1) otherwise it would be a yikes


