#development
1 messages · Page 540 of 1
ye exactly
not a different timer for each person
I did
store the time they run it or something
No not for each person.
For each server using it say they have like 3 going on
say i have 1000 servers running that code? is that bad?
think about this
im a plumber
a shitty one
i fix my pipes in the worst way
literally with cloth
how well will that work
lmao i love that analogy
ikr
whar if time = 240 not 1500
so it would actually be 240 minutes not seconds
let timeInterval = setInterval(() => {
}, 240 * 60000)
-=15 sorry
boom
no no no
because it is
js
let time = 240
let timeInterval = setInterval(() => {
if (time === 1){
clearInterval(timeInterval)
}else {
time -=15;
}
}, 900000)
Is that acceptable?
With say like 2200 people using at same time.
So you're using an interval to countdown a time and once it's passed you'll end the interval?
setTimeout ❓
Okay so! I am creating a giveaway command, however, the bot is able to win sometimes. I don't want that to happen but even when I specify that in the filter, it still picks the bot!
client.channels.get(config.channels.giveawayChannelID).send({embed}).then(msg => {
msg.react("🎉");
const filter = (reaction, user) => reaction.emoji.name === '🎉' && user.id !== client.user.id;
const collector = msg.createReactionCollector(filter, { time: 10000 });
collector.on('collect', r => console.log(`Collected ${r.users}`));
collector.on('end', collected => console.log(collected.map(r => r.users.random().tag)));
})
``` JavaScript
Ping me when you respond to this kthxbai
@inner jewel So, does it help in any way with gathering scattered data?
@earnest phoenix filter the bot

Anyone else?

undefined
(node:4632) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'run' of undefined
at Client.client.on (C:\Users\Aj\Desktop\Senpai\senpai.js:44:33)
at Client.emit (events.js:182:13)
at MessageCreateHandler.handle (C:\Users\Aj\Desktop\Senpai\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
at WebSocketPacketManager.handle (C:\Users\Aj\Desktop\Senpai\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:103:65)
at WebSocketConnection.onPacket (C:\Users\Aj\Desktop\Senpai\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:333:35) at WebSocketConnection.onMessage (C:\Users\Aj\Desktop\Senpai\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:296:17)
at WebSocket.onMessage (C:\Users\Aj\Desktop\Senpai\node_modules\ws\lib\event-target.js:120:16)
at WebSocket.emit (events.js:182:13)
at Receiver._receiver.onmessage (C:\Users\Aj\Desktop\Senpai\node_modules\ws\lib\websocket.js:137:47)
at Receiver.dataMessage (C:\Users\Aj\Desktop\Senpai\node_modules\ws\lib\receiver.js:409:14)
(node:4632) 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: 1)
(node:4632) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Error
client.on("message", async message => {
if(message.author.bot) return;
if(message.content.startsWith(`@ripe burrow `) || client_settings.prefix){
let command = message.content.slice((message.content.startsWith(client_settings.prefix) ? client_settings.prefix : `@525815816411676673`).length)
let cmd = command.split(" ")[0];
let args = command.replace(cmd+" ", "");
let commandfile = commands.get(cmd);
console.log(commandfile)
console.log(commandfile.run)
if(commandfile) {
commandfile.run(client, message, args).catch((e)=>console.error(e));
}
}
});
Code
It worked fine when using the prefix
but when I tried doing @ bottest
It threw that error above
I fixed the error but the mention still doesn't work
well my bot is c#
but idk how else to store the queue because litedb (the db i use) won't serialize the song class, and so when trying to restore the saved queue the queue is null
so i get an exception/error
anyone with discordjs regularly getting this
{ DiscordAPIError: Invalid Form Body
avatar: File cannot be larger than 10240 kb.
at item.request.gen.end (/app/node modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:79:15),
at then (/app/node modules/snekfetch/src/index.js:215:21)
at process. tickCallback (internal/process/next_tick.js:68:7)
name: 'DiscordAPIError',
message:
"Invalid Form Body\navatar: File cannot be larger than 10240 kb.',
path:
"/api/v7/webhooks/525859688873721867/cXW2uhlKJØjI1A2A46Z1pMZY3Uuggm8wTdwtJWvIfeyin21cgKpVnwgaA0b2wWLI26UT',
code: 50035,
method: 'PATCH' }
the only things i am using for webhook avatars are the avatars from actual users themselves
so i didn't assume it would be an issue
oh
oh god oh fuck
it's that guy with the 30 minute GIF avatar
shit
@fervent oyster do u know how i do this "streaming" status in eris ?
Eris, a NodeJS Discord library
i already red this
but where do i have to set the "game.type"
ay
i think i know
lmao uhtred
hayyyyyyyy whats going on

i fixed it
i uploading the image to imgur and then i am sending the message
@topaz fjord it was an normal embed where i wanted to provide an image
like
client.createMessage(msg.channel.id, embed: {})
One of you can help me for sharding ? With JDA
@modest shore you need to load the image into an embed attachement before you can use it in embeds
so do i have to do this ?
embed: {
attachFile: "ok.png",
image: {
url: "attachment://ok.png"
}
}
@quartz kindle `
no, you have to use discord's richembed builder
yeah i am trying not to use djs
for this time
i am redoing my bot in another lib. the version which is now up and running is in djs
idk if you can do it in an embed literal, have you tried using Discord.attachment?
i try some things now
if you plan to use another lib, then that other lib should tell you how to upload files
the docs are really shitty tbh
rip
yeah
yes @sick cloud
yeah embeds only support http urls or attachments, and to send an attachment you need to upload it via multipart/form-data, which should be handled by the lib
yeah so i am using imgur atm to upload the image to send an embed lmao
that sounds disturbingly inefficient lmao
what are you trying to do
if you have a set of static images why not just upload them all beforehand
Anyone use JDA ?
or are you uploading images you dont have yet
@last ferry i have to edit an image and then upload it
@earnest phoenix just ask the question, don't ask to ask
@last ferry which lib are u uing?
C#
oof
just ask your question
Discord.Net to be precise
my problem is that the docs of the lib that i use are so shitty
How do you get an information about a shard ?
i dont see anything about attachments in eris docs, maybe it isnt supported
what kind of information?
is it possible for you to just send the image alone or does it have to be embeded
or maybe it uses the same file as the message.file
numbers of users and guild
cause that may be your only option
And you create shard manager with ?
@quartz kindle there is this in the docs https://i.imgur.com/VmdkR6T.png
new DefaultShardManagerBuilder().setToken(...).setWhatever(...).build()
nothing else
A DefaultShardManager work ?
DefaultShardManagerBuilder
use the builder
the DefaultShardManager constructor is huge
can someone explain how to use this, i am not understanding it tbh https://i.imgur.com/VmdkR6T.png ?
createMessage(channel.id, "this is my file", {
file: Buffer.from("this is my text"),
name: "buffer"
});```
is that eris?
yes
if you're a beginner u should probably be using d.js
its way better/easier and much more people can help
im not a beginner my current version of the bot is djs but i dont want to use it anymore
and the docs from eris are way worse than the docs from djs
why are you switching?
want to see which lib is perfoming better on my vps
Hey
How can I do two .setActivity (ex: "Look everyone" 2 seconds later "On 4 servers") on discord js
set activity => setTimeout(function(){ set activity }, time to wait)
if 2 people have the same avatar will the hash of both be the same?
i dont think so
thx @quartz kindle
u can test it
@inner jewel ok its working but it was the wrong thing oof
did it just put the image outside of the embed?
thats because the buffer type is wrong
the setGame not working
Buffer.from doesn't read files
what do i have to provide there
you need to use fs.readFile
also if you're generating an image, don't write to disk
i'm pretty sure most image manipulation libs allow you to export the result to a buffer
fs.readFile can read a file into a buffer, so if you have any static images such as backgrounds, etc that you use in manipulation, load them and keep them in memory for future uses
How can I do two .setGame (ex: "Look everyone" 2 seconds later "On 4 servers"), not the .setActivity
For get the shard where I am it's ShardManager#getShardsQueued() ?
@quartz kindle when i want to read the file what parameter do i have to give instead of "utf8" to get the buffer
ok
yeah buffer should be the default if nothing is specified
I did not think about it é_è
did it upload inside the embed? or outside?
Thank's Natan it work
if you do any file reading make sure it's async

also there's lots of modules that can do compression for you
@quartz kindle atm just as an image
without anything
but i am going to sleep now 2AM for me atm
I'm confused on why my Beta version of my bot has more delay then the release version, there isn't any code differences besides adding a few more commands, which aren't big.
Is there any option to get compressed versions of images from the CDN
like a size parameter/query in the url
the discord CDN ofc
hey, i have installed ffmpeg in my node_modules but when i use my play command, the console write that ffmpeg is not found
download the binaries
Yes I found before, thanks anyway
k
For oauth I'm trying to receive the access token, i already have the access code. When I tried following the directions, porting it to js and I even tried using postman to send a request. I still was getting errors saying method not allowed.
Ex from discord: https://discordapp.com/developers/docs/topics/oauth2#authorization-code-grant-access-token-exchange-example
Sending request to: https://discordapp.com/api/oauth2/token
Step up your game with a modern voice & text chat app. Crystal clear voice, multiple server and channel support, mobile apps, and more. Get your free server now!
.addField('Moves (incl. possible moves)', `${pokemon.moves.slice(0, 16).map(m => m.move.name).join(', ')}, and ${pokemon.moves.slice(16, pokemon.moves.length)} other${pokemon.moves.slice(16, pokemon.moves.length) > 1 ? 's' : ''}`)
still being thrown Must be 1024 or fewer in length., any ideas here
i've cut off loads
how is making it inline going to help lul
looks nice
Hey, I have create a play command but this command not working and I don't why
thats the most important thing
the url format is wrong
show the whole code
hide keys
that is the most horrible play command ive seen in a while
ok first const voiceChannel = message.member.voiceChannel;
then you can remove this part of your code
it is
I see it now
simple args
const args = message.content.slice(prefix).trim().split(/ +/g);
const cmd = args.shift().toLowerCase();```
?
three, follow this guide https://www.youtube.com/watch?v=4LmY8VzUTBU
Ever wanted to know how a core developer of DISCORD.JS uses his own library? I don't really care what you think, but if you want to leave feedback do so in t...
after the like 4th episode the code is all wrong
but before that it is all fine
fourth, make a command hanlder
@bright spear thanks! you saved me a lot of time
yw
i was ready to programmatically resize
I want to know, the method ShareManager#restart is for ? Because when I use it, my uptime didn't change so it's not a real restart
Hmm ok I see
small update with the image thing. I have this sofar but the attachment is empty https://i.imgur.com/NvSsQPV.png https://i.imgur.com/jLGzTJX.png
has someone an idea what i did wrong ?
i dont know eris, but why is the url attachment://
because an image in an embed cannot have an local file so some guy told me to use the attachment thing
post the image in a private server and use its cdn.discordapp link
never tought about that
@mossy vine when i try to get the content of the message (the link) it returns undinfied. Code : https://i.imgur.com/IpgTKwb.png
and without channel it returns Promise<Message>
why tho
@topaz fjord Can you code using MongoDB?
What for?
Storing bot settings, votes, user data
dont do this lol
you are doubling the request and putting more work in
the attachment thing is just fine, you just need to figure out how your library handles it because the attachment protocol is built in discord
Or just store the file in /tmp/ and send it then delet it
exactly however youd need to send 2 requests
one to send the image in the private guild and the other to send an embed in desired channel with the first requests image url
you dont need to senf it in a private guild
send it once yourself, get the link, and send the link via code
If you plan to reuse it, it's prob better to use the link
even if you needed to keep the link, you could save the message object and later. access its attachments
Then there's no need to attach it per message later, just extra cost
I'm assuming we are talking about sending images
yeah...?
If you were to attach it per message, that's new upload per message
Link wise it just uses the existing resource instead of creating new ones
yeah, thats why i said if you want to reuse it, youd save the message object and access the attachments and grab the url from there
my point is optimization; use minimal requests you can
It's really the same if he supplies it manually
it is not 
is giving a pear then an apple to a person the same as giving them both at the same time? you could just give both the pear and the apple at the same time, saving time, would it be just a second.
the reusing process is the same in both cases, the initial request is not
something is telling me you jumped into the conversation before reading what was discussed 
The end result is still the same
Sure initial steps is different
But what's the outcome?
youd worry about the process, not the outcome
one process is saving time and resources, one is wasting them
This discussion is getting nowhere and is just repeating previously discussed points
dot dot dot
I'm going to get back to work, but C's method is undoubtedly the easiest for a single resource
it would also fall under api abuse 🤷
yall never heard of optimization and respecting ratelimits
How is using an image link api abuse
how do i make a bot 24/7 online
ok
@topaz fjord why should i know what i'm doing since i don't even code with this lang
i just tried to help the user who was looking for help
then don't try to help if you don't know the lang or the lib
it will lead to nothing
wasn't it to just add .then after the getMessage() ?
okay so im quite new to fs and all that stuff, but how can i get a list of subdirectories in a directory
node.js, right?
Ok, i need an example of what to do in js when making a token exchange. I've tried a few ways including postmaster and I still need help. Link to what I'm talking about https://discordapp.com/developers/docs/topics/oauth2#authorization-code-grant-access-token-exchange-example
Step up your game with a modern voice & text chat app. Crystal clear voice, multiple server and channel support, mobile apps, and more. Get your free server now!
can anyone help me with discord.js-lavalink
this is what i have atm
if (!msg.member || !msg.member.voiceChannel) return msg.reply("Must be in a voice channel");
let [...track] = args[1]
track = track.join(" ");
const [song] = await getSong(track);
const player = await client.player.join({
guild: msg.guild.id,
channel: msg.member.voiceChannel.id,
host: getIdealHost(msg.guild.region)
}, { selfdeaf: true });
if (!player) throw "No player found...";
player.play(song.track);
player.once("error", console.error);
player.once("end", data => {
if (data.reason === "REPLACED") return;
msg.channel.send("Song has ended...");
});
return msg.reply(`Now playing: **${song.info.title}** by *${song.info.author}*`);
but every time i play a link it says "no track found
(node:15944) UnhandledPromiseRejectionWarning: No tracks found
(node:15944) 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: 1)
(node:15944) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
what's getSong
Someone know how to check with discord.js if a player is into the discord? (To remove @ with numbers)
async function getSong(string) {
const res = await snekfetch.get(`http://${config.restnode.host}:${config.restnode.port}/loadtracks`)
.query({ identifier: string })
.set("Authorization", config.restnode.password)
.catch(err => {
console.error(err);
return null;
});
if (!res) throw "There was an error, try again";
if (!res.body.length) throw `No tracks found`;
return res.body;
}
wdym if player is into the discord?
oh to remove the mention?
but only a specific type?
umm
So only actual members cqn be added
Check #265156322012561408 pls
@west raptor this is getSong
async function getSong(string) {
const res = await snekfetch.get(`http://${config.restnode.host}:${config.restnode.port}/loadtracks`)
.query({ identifier: string })
.set("Authorization", config.restnode.password)
.catch(err => {
console.error(err);
return null;
});
if (!res) throw "There was an error, try again";
if (!res.body.length) throw `No tracks found`;
return res.body;
}
(node.js) is there any way to define a variable in one file and use it in another one? (global.x doesnt work)
make it in a module
im reading a directory with fs so i dont want to do it every single time i need to work with it
hmm thats big sad
how are you doing it
i read the dir in index.js and save the output to a variable
i need to use the same variable in ./src/hi.js
global.thing = thing
yes, that doesnt work
hold on lemme just
okay im actually stupid
global.loadedModules = 'hi'
fs.readdir('./src/modules', (e, f) => {
loadedModules = f
console.log(`Loaded modules:\n${f}`)
})```
i was doing it totally wrong
now it works lmao
lmao
What is the code for displaying all emojis? [Eval]
Ok, i need an example of what to do in js when making a token exchange. I've tried a few ways including postmaster and I still need help.
UPDATE
All I've just realized that I need a header like such but I'm still getting errors saying method not allowed. ```js
'Authorization': Bearer ${code}
Link to what I'm talking about https://discordapp.com/developers/docs/topics/oauth2#authorization-code-grant-access-token-exchange-example
Step up your game with a modern voice & text chat app. Crystal clear voice, multiple server and channel support, mobile apps, and more. Get your free server now!
When I try to bump my server as a test, it comes out like this when it should be on seperate lines, anyone know how to fix this. JavaScript and I'm using SQLite
is this an issue with the bot?
if so go to the bots support server
if not, \n for seperate lines
I am the owner of the bot
oh, then \n
But I don't want them to have to do \n every new line
iirc they cant even do that lmao
You can. Partner Bot has it
then break all the data up
into let staments
then compile it
happy? its pretty simple
Still unsure of how I do it 😦
omg
break up all the data in the response
because your making a api call right?
then it will give it to you in sperate sections already
then you can output it how you like
I'm not using an API call LUL
OMG
😂
then how you pulling data from a server list?
SQLite DB

you can have differents section is a sqlite db right?
English please mate...
im done
Your sentence does not even make sense
like in a json
Yes
then do it like that
xp[message.author.id] = {
xp: 0,
level: 1
};```
nice json example
Wait no, I didn't understand. Sorry. It isn't like JSON lol
Want me to send you doc link?
for SQLite?
i know sqlite basics
you can have "sections" or what ever
name then what you will
I just have different columns in the table
Yes
Okay
@formal agate This is how I done it. Is this right? :o
sql.run(`UPDATE guildConfig SET description = "${description.replace(/\r\n/, "\n").split("\n")}" WHERE guildID = ${message.guild.id}`).catch(console.error);
i only know sqlite basics
I done that, but still nothing unfortunately
from web devolvement
hmm okay 😦
use google
Already tried. Have not came upon anything
show the embed code
tim
var embed = new Discord.RichEmbed()
.setAuthor(`${message.guild.name} | Server Bumped (Preview)`, message.guild.iconURL)
.setDescription(`${row.description}\n**[Click here to join the Server!](${row.invite})**`)
.setImage(row.banner)
.setColor(row.color)
return message.channel.send({embed}).catch(console.error);
}).catch(console.error);
so basically row.description is a single string
do you ever update it? or it is always the same
do you customize it or can people also do it?
then you need to check how you receive the data, im not sure how discord gets messages that contain new lines
or you can make a special character act as a separator for new lines, and tell people to use it
Would this code work with \n
sql.run(`UPDATE guildConfig SET description = "${description.replace(/\r\n/, "\n").split("\n")}" WHERE guildID = ${message.guild.id}`).catch(console.error);
setdescription this is a test description line 2 description line 3
what happens if someone types that, does discord show new lines in the message content?
Have not tried it. I'm not sure how I would actually make that happen
let me test actually
it should work, the message should contain \n in it
what happens if you update the database with a description that contains new lines?
why isnt this working with eris ? https://i.imgur.com/SL27mlY.png
that seems like somthing for discord js
its not
idk eris
can someone tell me how to get it working ?
i try to switch from djs to eris
in djs i would know it but in eris dik
try type 1 instead of type streaming
okay
No need to specify game
@quartz kindle nope doesnt work either
did you do 1 or "1"
then idk
already rad this
Maybe you should set status to online?
client.setStatus({gameprop})
it seems to me that nothing is updateing
Ok because this place is active again I'm gonna ask this question. Ik this code is wrong, but idk why. The errors say basically nothing as to why. (I basically just changed a few things from the ex from discord.) js const exchange = await fetch(`https://discordapp.com/api/oauth2/token`, { data = { 'client_id': process.env.CLIENT_ID, 'client_secret': process.env.CLIENT_SECRET, 'grant_type': 'authorization_code', 'code': code, 'redirect_uri': `MY CRAZY URL HERE`, 'scope': 'identify guilds' }, headers = { 'Authorization': `Bearer ${code}` } });
that's not valid js
Don't use template literals if you are not templating
why? it doesnt break anything
i no nothing of oauth
its not oauth its invalid js
ik that
you dont need to know oauth to see issues there
This is basic js object stuff
you just need to know js
im stupid
did u read wot natan said?

i'd recommend not copy pasting discord's example python code and learn the language properly instead
you should learn it before trying to make something complex
That was a bad idea
if you don't even know the syntax you can't expect to make something that works
w3schools.org and sololearn have some good js tutorials
managed to get the token so far so
wait
well if you know then it shouldnt be surprising that it doesnt work
because you did a GET instead of POST

now it's go-read-the-docs-for-whatever-fetch-library-you-use-to-find-out-how-to-make-an-url-encoded-post-request
fish enjoy this show
if its your first time working with oauth you should probably read this => https://aaronparecki.com/oauth-2-simplified/
This post describes OAuth 2.0 in a simplified format to help developers and service providers implement the protocol.
its real "fun"
not skim read over it, actually read it with understanding
are you just blinding trying out things until you accidentally do something that works?
what do I do if I need to contact someone who turned down my bot wrongly but they don't answer my DMs?
what you mean
Well the same mod declined my bot twice because he said my help command sucked
but it works and explains everything there is to explain
contact support
can we see the help command
we have been over this
I thought you said to just message the guy who declined it, I dodn't realize there was actual support
then you said you where gonna message him
@tall gyro did you say in the long description or short description that your help command was token what can you do?
yeah in the long one, and it also says that when the bot is added to the server, if a text channel named "general" exists
why dont you switch them around?
make token help the main help command
and use something else for your support server link
like token support
token what can you do is not a very intuitive help menu
does anyone here use discord.py?
I could switch it around if something like
if message.endswith == 'more':
exists - I know the startswith is a thing but is ending too?
it exists in js, idk about python
but anyway you shouldnt rely on that, because it can more easily be triggered by long sentences who randomly end with that keyword
unless you check for both start and end
message.endswith("more")
yeah it's check if it included "token help" and if it ends in more then it'd send the support link
what library
discord.js
Thx Tim
omg
omg
idk what i did
but i got a response
YES!!!!
oh
wait no
it still is broken
how about learning the language/fetch library first 🙃
i was logging the wrong thing
lol
Natan, why learn, when you can try for hours and hours of changing little amounts of code in hopes of it working?
ok every single thing I've basically says this is correct for oauth, but it still says 'BAD REQUEST' and idk why. ```js
let exchange = await fetch(https://discordapp.com/api/oauth2/token, {
method: 'POST',
data: {
'client_id': process.env.CLIENT_ID,
'client_secret': process.env.CLIENT_SECRET,
'grant_type': 'authorization_code',
'code': code,
'redirect_uri': `http://kool.kool/api/discord/callback`,
'scope': 'identify guilds'
},
headers: {
'Authorization': `Bearer ${code}`
}
});```
did you use edit?
What
also what lang
No
that is why
try google https://stackoverflow.com/questions/45292707/editing-messages-using-discord-js-not-working
wait whats the problem?
use google
its simple
My problem isn’t what you are assuming it is
I’m not editing anything
It’s obviously how to edit messages
Clearly what your saying is not what his problem is.
Hold on
what are you trying to do then?
"Why does my bot add on logs instead of replacing them?"
thats what you said
This is the problem https://vimeo.com/308018869
what's your code?
I’m on mobile and it’s too hard
you are probably reusing the same embed
making it duplicate fields
retake a good look at your code and fix any loopers
also you should probably explain your problem instead of giving us little to no context and expecting us to understand it
It’s basically this and the definitions
I have it as new Discord.RichEmbed()

that means nothing
if there are other named that
they would need to be in other files
REPOST:
ok every single thing I've basically says this is correct for oauth, but it still says 'BAD REQUEST' and idk why. ```js
let exchange = await fetch(https://discordapp.com/api/oauth2/token, {
method: 'POST',
data: {
'client_id': process.env.CLIENT_ID,
'client_secret': process.env.CLIENT_SECRET,
'grant_type': 'authorization_code',
'code': code,
'redirect_uri': `http://kool.kool/api/discord/callback`,
'scope': 'identify guilds'
},
headers: {
'Authorization': `Bearer ${code}`
}
});```
is the code even defined?
i mean, where are you getting the code from? do you get it from a page where you have to click authorize?
it doesnt say anything about authorization headers being needed, but they do have 'Content-Type': 'application/x-www-form-urlencoded'
so try adding that to your headers
hmm ok
i thought you replaced content-type with Authorization
error (same as before): ```error
Response {
size: 0,
timeout: 0,
[Symbol(Body internals)]:
{ body:
PassThrough {
_readableState: [Object],
readable: true,
domain: null,
_events: [Object],
_eventsCount: 3,
_maxListeners: undefined,
_writableState: [Object],
writable: false,
allowHalfOpen: true,
_transformState: [Object] },
disturbed: false,
error: null },
[Symbol(Response internals)]:
{ url: 'https://discordapp.com/api/oauth2/token',
status: 400,
statusText: 'BAD REQUEST',
headers: Headers { [Symbol(map)]: [Object] } } }```
you dont need authorization
ok
bad request
omg
i think i was using the wrong redirect
and still a bad request
idk then, i need to go sleep
discord.js
trying to finish my addrole command and its telling me "find" is depreciated. Not sure where to find what im supposed to use
use a function
.find(u => u.thing === anotherThing)
find takes a function, not the old 2 parameter way
I'll see what I can do.
@wise plume what @sick cloud said. but basically in english;
When you do like .find('type', 'string') is deprecated meaning it's not supposed to be like that anymore i gues lol, not supported.
So now what you have to do is .find(thing => , thing represents the object that has whatever type you're trying to find so when you do like .find('name', 'namehere') you needa do .find(objWithName => objWithName.name === "namehere")
basically in English, cool
Big english
oof let google be my friend lol im still very new to both js and bot dev
that does point me in the right direction though so thank you
thank you 0.0
can anyone help with oauth in js?
oauth 2 for disocrd
i'll assume you're using node-fetch
2 minutes in the readme
that's the solution for your issue
doing it with arrow notation is literally just over doing it, making it harder tbh
no
also Natan, your solution to fixing the code for my oauth token exchange does not work
s/find\((\S+), (\S+)\)/find(x=>x[$1] == $2)
its something in this ```js
let exchange = await fetch(https://discordapp.com/api/oauth2/token, {
method: 'POST',
data: {
'client_id': process.env.CLIENT_ID,
'client_secret': process.env.CLIENT_SECRET,
'grant_type': 'authorization_code',
'code': code,
'redirect_uri': `http://fdasdfg/api/discord/callback`,
'scope': 'identify'
},
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
});```
ooops
i did
data is ignored
tim had me change part
don't expect code copy pasted from a python example into a js thing will work
yet you're doing exactly that
Wait were you not talking about discord.js @sick cloud ?
tim told me the auth in header was pointless
@amber fractal no i am, it's being removed from js
Because in https://discord.js.org/#/docs/main/stable/class/Collection?scrollTo=find its not marked as deprecated
aka everything
Oh
so you use a function
find(key, value) isn't even a js thing
it's a discord.js thing
Array#find always required a function
with js its a function anyways https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find#Find_an_object_in_an_array_by_one_of_its_properties talks about arrow notation, I don't think it's being removed. If it were discord.js would mark it as deprecated, no?
Either way I gtg
that's just a function
array.find(x => ...)/array.find(function(x) {}) are the only things JS has
collection.find("somekey", "somevalue") is something discord.js has
in it's collection class
how would i detect upvotes for my bot (in discord.py)
hm
How do I make the bot check if the channel is NSFW? (Discord.NET 1.0.2)
<Channel>.IsNsfw
Okay Thanks
Not IChannel though
what is the channel type?
I think it makes the command be for nsfw channels only, I’m not so sure tho
But it doesn't work in NSFW channels
hmm
@upper tundra why are you on v1 thats the very old version you need to be on v2
lol
How much do I need to change when I switch to v2?
How i can customize my page on DBL...
put valid css in the style tag
this looks ridiculous https://i.imgur.com/BWnXGPz.png
Error: https://paste.tscforum.com/uqupjnagzt.coffeescript (I understand it, just let me explain)
Code: https://paste.tscforum.com/ndijzkbefm.js (I did this off of an idea, so basically experimenting)
Alright so, I want to be able to give a reason and time, but it just doesn't take either and it mutes the person until i manually unmute them
Doesn't even send the message *Person has been muted for xxx amount of time and for reason
await(mMember) isnt valid code, not sure what you're trying to do there
args isnt an array
might need to look at your command handler setup
.join only works for arrays
args isn't an array?
yes it must not be because it's saying that join isnt a function
can anyone tell me what to set limit to when i want to get all the logs from a channel. seems to max out at 500 for some reason. if i dont set limit it maxes at 100
You should go to the discord.py server for this stuff
Debatable, we have plenty of other lang peps
js is just the cool kid of the moment, so everyone here is basically a wannabe js coder
how can a bot list server focus on js
yes lots of people know js but i wouldnt say dbl is js focused lol
How can I remove a person from channel permissions after they have been unmuted?
My mute command changes the person channel permissions so when the person is muted the perms of all channels change for them so they have the send message perm removed but after being unmuted they stay on the list of people in channel permissions
I want them to be removed after being unmuted
How do I make my bot send gifs and custom emojis in a messages
depending on your programming language, there must be a way to send files to discord
and emojis can be sent by specifying the full emoji string
which is done by putting a \ in front of the emote/emoji name
emoji: \🐀
emote: !bingSip
iirc you can send files like {files: "urfile.png"}
or something like that
in discord.js
add that as an option on send()
or just use an embed and the image property
image: {
url: "https://this.is/my/image.png"
}```
@amber junco
you check the docs
no
....
So much for a help server
Smh
Im not even asking for code
just where I would look at on the docs
idk
donate
what
@lusty dew what lib
D.js
of course
Heh...
look at the docs, along the lines of channel overwrites
use eris kthx
or ask in the djs server
same
can anyone tell me why this isnt a valid markdown table? it doesnt render properly
**__Word bank:__**
| ---- | ---- | ---- | ---- | ---- |
| JQXZ | QEW | AC | ZNY | TJL |
| OKBV | DFW | YKQ | LXE | GS |
| VSI | PQJS | VCN | JR | IRNM |
| OP | QYDX | HDU | PKD | ARGF |```
tried putting text above the hyphens
and even tried removing them
still renders everything as one line D:
all fixes tell me to use 3 hyphens with text above them. it still doesnt work
After each line put 2 spaces (example: **__Word bank:__**[space][space])
this will tell Markdown that it should force a new line
@mossy vine
@bold dock that worked, thank you!
noice 😃
I've gotten far enough in the oauth flow of discord to get the following response from discord but idk why I'm not getting a token of any kind. I thought sending the code in the proper format would return a token to be used to access the user data. ``` [Symbol(Response internals)]:
status: 200,
statusText: 'OK',
headers: Headers { [Symbol(map)]: [Object] } } }```
you're misunderstanding the process
i'm going to quickly go over it from the beginning because i don't know where you got that from
okay, so first you are supposed to make a call to /api/oauth2/authorize with the required url parameters (client_id, redirect_uri, response_type and scope), if and when the authorization process is done, it will redirect the user to your redirect url with a url parameter named code.
Then in order to exchange for an access token, you need to make a POST call to /api/oauth2/token with these values in the body; grant_type, client_id, client_secret, redirect_uri and code, they need to match the values that were used in /api/oauth2/authorize, and for code you'd use the code you got in the url parameter.
If the request was successful, you'll get a JSON response which contains a access_token field, you need to cache that access token. access tokens last for a week, so i make my sessions last exactly a week so i don't have to bother with automatic token refreshes. anyways, you'd use that access token in the authorization headers now. for e.g, to get the info about your logged in user you'd call /api/users/@me with the Authorization header set to Bearer accesstoken
replace so first you are supposed to make a call to to so first you are supposed to redirect the user to
rip
i am just going to recode everything tomorrow
Hi
I have a problem
fonction.channellogs(message)
var args = message.content.split(' ').slice(1)
var achievement1 = args.slice(1).join(" ");
if (!Dresseurs[sender.id]) return message.channel.send("Erreur :Croix: : `Vous devez être un Dresseur pour effectuer cette commande : ?start`")
var user;
if (message.mentions.users.first()) {
user = message.mentions.users.first();
if (Dresseur.Pokedollars >= achievement1) {
if (Dresseurs[user.id]) {
Dresseur.Pokedollars -= achievement1
var DresseurPAY = Dresseurs[user.id]
message.channel.send(`__Vous avez envoyé :__ **${achievement1}** à **${user}**`)
DresseurPAY.Pokedollars += achievement1
message.channel.send(DresseurPAY.Pokedollars - achievement1)
} else return message.channel.send("Le membre n'est pas encore dresseur !")
}
else return message.channel.send("Vous n'avez pas assez d'argent !\n*Il vous manque " + (achievement1 - Dresseur.Pokedollars) + " P$.*")
}
else return message.channel.send("Vous devez mentionner un membre !")
}```
My code
My code is functional except for the addition of pokedollars to the person mentioned it's completely bored, it adds 0 etc ... Do you want screens?
Who can help me ?
Wish I could, but I dont even understand the language
:/

achievement1 is not a number
its a string
you have to convert it into a number before you can do math
Number() or parseInt()
m e t h
Mmmmhh @quartz kindle i don't understand everythink
So ?
But achievement1 works for the - = but not for the + =
it's prob concating with the latter
strings can be concated with +=
We cant spoonfeed. but I think he means it needs to become a number before you do the math with it.
is it good my memory usage is consistent af
So ?
its like always 35mb
Idek how to check mine so I can say... Yes!
35mb ram for a bot 
Wait till it gets added here and cache breaks

@woeful saffron
I had to turn off my console logging for messages being deleted lol
i mean i use eris so 
How should I do it? @keen drift ?
How ?
Okay so! I am creating a giveaway command, however, the bot is able to win sometimes. I don't want that to happen but even when I specify that in the filter, it still picks the bot!
client.channels.get(config.channels.giveawayChannelID).send({embed}).then(msg => {
msg.react("🎉");
const filter = (reaction, user) => reaction.emoji.name === '🎉' && user.id !== client.user.id;
const collector = msg.createReactionCollector(filter, { time: 10000 });
collector.on('collect', r => console.log(`Collected ${r.users}`));
collector.on('end', collected => console.log(collected.map(r => r.users.random().tag)));
})
``` JavaScript
parseInt
I have never used a parseint @keen drift ...
parseInt(s: string, radix?: number): number
@faint junco You could just have it so i the winner is a bot to reroll, not the best way but a way
Hm, makes sense. Thanks!
He said even when it's filtered it doesnt work
rerolling if the winner is a bot would kill your cpu if all users are bots
users.filter(u => !u.bot).random()
parseInt(achievement1) is fonctionnaly
Thanks @keen drift ❤
And how i can verify if achievement1 is a number ?
npm install is-number
@inner jewel nooooooooooo
@lofty hamlet ```js
5 + 5 = 10 // number + number = number
5 + "5" = "55" // number + string = string
5 - 5 = 0 // number - number = number
5 - "5" = 0 // number - string = number


Hu ?
What is this ?
5 //this is a number
"5" // this is a string (text)```
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof is a good place to get info
Ah ok
I understand
How i can verify if achievement1 is a number also i return for write a error message
this is your friend https://developer.mozilla.org/en-US/
So : if (achievement1 != 'nuber') return ?
typeof(thing)
parseInt("5") // 5
Number("5") // 5
(5).toString() // "5"```
confuzz8led
typeof thing works too doesnt it?
he doesnt need to check if its a number, he needs to convert it to a number
because discord will always give you a string
he wants to make sure if the input isnt a number at all then it returns something
the input will never be a number
^
it will never be a number
someone explain to him in french lol
I understand
So ?
If a personn write ?gift @earnest phoenix NOTNUMBER my bot crash
i love that





