#development
1 messages · Page 1692 of 1
const bla = require(`locatedSchema`)```
the thing about it is that where do i put it?
at the beginning
t
do you know how modules work? youre already using them, you should know
module.exports makes the file importable
require imports the file
// file1.js
module.exports = something
// file2.js
something = require("./file1.js")
like this? const mutemodel = require ('schema file')
yes
how someone say what this practicly means:
.then(result1 => {
console.log(result1.id)
return result1.id
})
is it a function?
a promise
Is there a way to store a var in a .then() like 20times?
so my mutemodel
yes
wat
I have like twenty times in a row .then
is there a way to store a var in that code then.
you mean an other file?
no
Then i dont
/model/muteModel?
./model/mutemodel

yes, but you need a relative path
./ means same folder
../ means previous folder
relative path is a way to store, got it
really?
i thought ./ went outside of the folder
so if you are in folder commands and the file is in folder models then you need to go to the previous folder
no that will look for the file in the base folder of your computer
oh
I totally knew that
and your folder is named models, not model
the names of the folders and files need to be correct
show what you mean because you're not making much sense
why the capital S
lol my bad
fetch('https://discord.com/api/oauth2/token', {
method: 'POST',
body: new URLSearchParams(data),
})
.then(res => res.json())
.then(info => {
b = info
return info
})
.then(info => fetch('https://discord.com/api/users/@me', {
headers: {
authorization: `${info.token_type} ${info.access_token}`,
},
}))
.then(userRes => userRes.json())
.then(result1 => {
console.log(result1.id)
id1 = result1.id
return result1.id
})
.then(console.log)
.then(id => fetch("https://discord.com/api/guilds/828624028456583190/members/" + id1), {
headers: {
authorization: `${b.access_token}`,
}
}).then(result2 => {
return result2})
.then(console.log)
should work
why
just put everything in one then
ow, is that a thing to
Because i love cntrl c and cntrl v
https://github.com/discordjs/guide/blob/master/code-samples/oauth/simple-oauth-webserver/index.js
dafuq
it fixed it but the mute still doesnt work heres the error
only the last part i typed myself and that part wont work
how
this is why you never copy n paste big code you dont know
Havent thought of that, but still how
okay thx for your help
try understanding what each step is doing
can i jsut have one .then(var1 => {
all code
})
?
- send request
- get result, convert result to json
- ??? what is info doing? this is not really doing anything
- use the info from the previous one (that you could have gotten from step 2) and make a new request
- convert the new request into json
- console.log the result then return the result again? what for?
- console.log it again and do nothing?
- now you have invalid data here
...
-
b = var outside the chain so i can store it. -
that last one i understand
im getting really annoyed with this, what part of the message.mentions.members.first() is undefined? this has been getting on my nervs for atleast 5 hrs now i see 0 problems, the bots sees a bajillion
TypeError: Cannot read property 'members' of undefined
const Discord = require("discord.js");
const { stripIndents } = require("common-tags");
exports.run = async (message, args) => {
if (message.deletable) message.delete();
let Member = message.mentions.members.first() || message.guild.user.cache.get(args[0])
if (!Member)
return message.reply("Couldn't find that person?").then(m => m.delete(5000));
if (Member.hasPermission("BAN_MEMBERS") || Member.user.bot)
return message.channel.send("Can't report that member").then(m => m.delete(5000));
if (!args[1])
return message.channel.send("Please provide a reason for the report").then(m => m.delete(5000));
const channel = message.guild.channels.find(c => c.name === "reports")
if (!channel)
return message.channel.send("Couldn't find a `#reports` channel").then(m => m.delete(5000));
const embed = new MessageEmbed()
.setColor("#E74C3C")
.setTimestamp()
.setFooter(message.guild.name, message.guild.iconURL)
.setAuthor("Reported member", Member.user.displayAvatarURL)
.setDescription(stripIndents`**- Member:** ${Member} (${Member.user.id})
**- Reported by:** ${message.author}
**- Reported in:** ${message.channel}
**- Reason:** ${args.slice(1).join(" ")}`);
return channel.send(embed);
}
the outside doesnt exist anymore
if you want to interact with variables outside you need to use async/await instead
But it kidna worked
http.createServer((req, res) => {
}
let responseCode = 404;
let content = '404 Error';
const urlObj = url.parse(req.url, true);
if (urlObj.query.code) {
const accessCode = urlObj.query.code;
console.log(`The access code is: ${accessCode}`);
var b = "";
var id1 = "";
// ...
const data = {
client_id: '757161884528148500',
client_secret: 'xxxx',
grant_type: 'authorization_code',
redirect_uri: 'xxxxx',
code: accessCode,
scope: 'identify guilds.join bot',
};
fetch('https://discord.com/api/oauth2/token', {
method: 'POST',
body: new URLSearchParams(data),
})
.then(res => res.json())
.then(info => {
b = info
return info
})
.then(info => fetch('https://discord.com/api/users/@me', {
headers: {
authorization: `${info.token_type} ${info.access_token}`,
},
}))
.then(userRes => userRes.json())
.then(result1 => {
console.log(result1.id)
id1 = result1.id
return result1.id
})
.then(console.log)
.then(id => fetch("https://discord.com/api/guilds/828624028456583190/members/" + id1), {
headers: {
authorization: `${b.access_token}`,
}
}).then(result2 => {
return result2})
.then(console.log)
}
if (urlObj.pathname === '/') {
responseCode = 200;
content = fs.readFileSync('./index.html');
it will only work if you dont need those variables anywhere in your code during the same function
because once you start a .then() without awaiting, the outside code doesnt exist anymore, its long gone
the variables will work if you only access them after some time
but they will not work if you try to access them immediately
so i should put "await"?
it would be way easier if you make everything into async/await
const info = await fetch(..., {...}).then(res => res.json());
const user = await fetch(..., {use info here}).then(res => res.json());
etc...
thats really smart
if you did it without await, like this, it would not work ```js
let info;
fetch(..., {...}).then(res => res.json()).then(i => info = i);
console.log(info)
because by the time the .then() finishes, the console.log doesnt exist anymore
so i should use wait. got it
that code is basically the definition of es4 code or callback hell
how many .then()'s did u add there

personly 4, but github already has 10 or more
rewrite it with callbacks :^)
you using var and then()
you can ditch both of those
also, isnt fetch() callback based?

idk, i think it accepts both
fetch returns a promise
can anyone here help me with this error?
you cut off the error, right
if (urlObj.pathname === '/') {
responseCode = 200;
content = fs.readFileSync('./index.html');```
Reading files every request?
ye its promise only
thats the error
are you connected to the database?
yes
imagine if fetch had callbacks, let me rewrite it
don't
lets not go there again. please

how did you call the database?
https://pastebin.com/SNMA66Fv lets not do this again TIm
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
var current1 = result1[0].current;
var location = result1[0].location;
var current2 = result2[0].current;
var location = result2[0].location;
var current3 = result3[0].current;
var current4 = result4[0].current;
var current5 = result5[0].current;
var current6 = result6[0].current;
var current7 = result7[0].current;
var current8 = result8[0].current;
var current9 = result9[0].current;
var current10 = result10[0].current;
var current11 = result11[0].current;
var current12 = result12[0].current;
var current13 = result13[0].current;
var current14 = result14[0].current;
var current15 = result15[0].current;
var current16 = result16[0].current;
var current17 = result17[0].current;
var current18 = result18[0].current;
var current19 = result19[0].current;
var current20 = result20[0].current;
var current21 = result21[0].current;
var current22 = result22[0].current;
var current23 = result23[0].current;
var current24 = result24[0].current;
var current25 = result25[0].current;```
LOL
yes
omfg
I saw someone do it actually
people not knowing loops exist is the best shit ever
better I mean

not how you connect, how you query it
for loops are for the weak, smart people use while()
if (args == '1 + 1') return '1 + 1 = 2'
if (args == '1 + 2') return '1 + 2 = 3'
if (args == '1 + 3') return '1 + 3 = 4'
...```
fetch('https://discord.com/api/oauth2/token', {
method: 'POST',
body: new URLSearchParams(data),
}, res => {
res.json(info => {
fetch(..., {...}, res => {
res.json(result1 => {
console.log(result1);
fetch(..., {...}, res => {
res.json(result2 => {
console.log(result2);
})
})
})
})
})
})
``` :^)
const info = await fetch('https://discord.com/api/oauth2/token', {
^^^^^
SyntaxError: await is only valid in async functions and the top level bodies of modules
←[90m at Object.compileFunction (node:vm:355:18)←[39m
←[90m at wrapSafe (node:internal/modules/cjs/loader:1021:15)←[39m
←[90m at Module._compile (node:internal/modules/cjs/loader:1055:27)←[39m
←[90m at Object.Module._extensions..js (node:internal/modules/cjs/loader:1120:10)←[39m
←[90m at Module.load (node:internal/modules/cjs/loader:971:32)←[39m
←[90m at Function.Module._load (node:internal/modules/cjs/loader:812:14)←[39m
←[90m at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)←[39m
←[90m at node:internal/main/run_main_module:17:47←[39m
no
atVeld please ban tim
should i make the function asunc
another amazing example of the pyramid
someone in general asked a better way to do essentially this
fibonacci pyramid
1 1 2 3 5 8
i love that code
callback hell
you can safely put fibonacci's pyramid in those callback hells
like this?
no where did you send the request to the database to call findOne on the model
how do people make function async
add async to it
but putting async to it
where
infront of it
fuck whats another name for this
umm
infront of the function
pascal triangle
function Sync() {}
async function Async() {}
http.createServer ((req, res) => {}
Where accectly
ngl im confused
we told you
async (req, res)
thx
the error is one a different position, it says mute.findOne not muteModel
did you uploaded the code to your VPS before running it again?
uhhhhhhh
or saved it before running
si
can you send your code here
its hard to understand the issue
at least the const parts
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
thats the mute command
this is why i ask if he properly saved it
arent you supposed to name the schema
like
MuteSchema.js
or no
i mean i dont think its required
why?
idk i just saw most examples having Schema at the end
you can call the file donkey and export it as muteschema
no bcs i guess he forgot to save the file or forgot to upload it
the error says mute.findOne but the code he provided says now mutemodel.finone
i saved it
try running it again
ight
and see if the error persists
did you call the model somewhere else?
Ehm, any idea?
[Symbol(Response internals)]: {
url: 'https://discord.com/api/guilds/828624028456583190/members/372063501755088896',
status: 401,
statusText: 'Unauthorized',
headers: Headers { [Symbol(map)]: [Object: null prototype] },
counter: 0
}
}
const mongoose = require('mongoose')
const mute = mongoose.Schema({
guildID: String,
memberID: String,
length: Date,
memberRoles: Array,
})
module.exports = mongoose.model('mute', mute)
how did you import it?
const http = require('http');
const fs = require('fs');
const port = 25565;
const url = require('url');
const fetch = require('node-fetch');
const { userInfo } = require('os');
http.createServer (async(req, res) => {
let responseCode = 404;
let content = '404 Error';
const urlObj = url.parse(req.url, true);
if (urlObj.query.code) {
const accessCode = urlObj.query.code;
console.log(`The access code is: ${accessCode}`);
var b = "";
var id1 = "";
// ...
const data = {
client_id: '757161884528148500',
client_secret: 'xxxxxxxx',
grant_type: 'authorization_code',
redirect_uri: 'xxxxxxxxx',
code: accessCode,
scope: 'identify guilds.join bot',
};
const info = await fetch('https://discord.com/api/oauth2/token', {
method: 'POST',
body: new URLSearchParams(data),
}).then(res => res.json());
const user = await fetch('https://discord.com/api/users/@me', {
headers: {
authorization: `${info.token_type} ${info.access_token}`,
},
}).then(userRes => userRes.json())
const join = await fetch('https://discord.com/api/guilds/828624028456583190/members/' + user.id, {
headers: {
authorization: `${info.token_type} ${info.access_token}`,
},
}).then(console.log)
}
if (urlObj.pathname === '/') {
responseCode = 200;
content = fs.readFileSync('./index.html');
}
if (req.url === '/') {
responseCode = 200;
content = fs.readFileSync('./index.html');
}
res.writeHead(responseCode, {
'content-type': 'text/html;charset=utf-8',
});
res.write(content);
res.end();
})
.listen(port);
console.log("I am listening on port " + port)
bcs its all over the place
the mute.js yes there is
did you send your bot token for authentification?
did you use VSC as editor?
What is the best way to get Year Month Day Hours Minutes?
if you use js look into the ms lib
idk how to code so idk what that is 😛
did you want to use oauth to create a server?
then i cant help you
idk
No, i want to force people to join a specific server
you should know what you use for coding lol
it is probably vsc
sounds TOS violationish
actually it isnt
Wdym
when you auth an app
it tells you what it does
one says
"Join servers on your behalf"
happened to me
yeah
scope: 'identify guilds.join bot',
if you use VSC hover over the import value of your model, does it show a part of your model
If people are giving me permission, how is that against theTOS?
how did you import the model? it should be the same as the one you export, otherwise you wont find it
yea nvm, but as a fair warning, some people will nope out of it if they are forced to join a discord server.
idk
im just so confused
what is muteModel defined as
???
whatever is before join is undefined
const muteModel = require('../models/mute.js')
is there a way to make typedoc link to types rather than telling them as their name
** i know this isnt a development quesiton but people in my other servers are useless**
So im not very good with linux but i was following a tut and I am having trouble starting pu my ts3 server
so i have these files in which i need to start in order to begin using the server but when i type the name and then start nothing happens
i get a error saying the file isnt a command
nothing happened
chmod is to change a file's permissions
has nothing to do with running
remove it
so you have a problem in your file
i dont see why i would?
show the contents of the file
yes
then thats the problem
Ayeeeee
try googling for one that runs on arm
Kimi no nawa ?
ie
so this worked for the bots perms to show but when its set for message.author it throws ```
props += ${me.hasPermission(permName) ? yes : no} ${perm}\n
^
TypeError: me.hasPermission is not a function```
permissions.sort();
const me = message.author;
const yes = ":greentick:"
const no = ":redtick:"
let props = '';
const permEmbed = new MessageEmbed()
.setTitle(`${client.user.tag}'s Permissions`)
.setThumbnail(`https://cdn.discordapp.com/avatars/${client.user.id}/${client.user.avatar}`)
.setColor(`RANDOM`)
permissions.forEach(perm => {
let permName = perm.toUpperCase().replace(/ /g, "_");
props += `${me.hasPermission(permName) ? yes : no} ${perm}\n`
});
permEmbed.setDescription(props);
if (me.hasPermission('EMBED_LINKS')) message.channel.send(permEmbed)
message.delete({timeout:10});
}
const me = message.author;
yes
What should be the authorizaiton for PUT/guilds/{guild.id}/members/{user.id}
I have now this, but it only says unauthorized
[Symbol(Response internals)]: {
url: 'https://discord.com/api/guilds/828624028456583190/members/372063501755088896',
status: 401,
statusText: 'Unauthorized',
headers: Headers { [Symbol(map)]: [Object: null prototype] },
counter: 0
}
const join = await fetch('https://discord.com/api/guilds/828624028456583190/members/' + user.id, {
method:'PUT',
headers: {
authorization: info.token_type + " " + info.access_token,
},
}).then(console.log)
What should be the authorization?
Because this isnt working
so
what the heck that Symbol() do?
ive seen it every now and again
but i've never once used it
iterateable ?
can someone give me the website that can run my bot?
website
Look my status
no but 24/7
is that code to run 24/7
what the do you mean
nothing
if your bot is running, then its not that hard to keep that running.
how do I repleace " from a string
python?
like say the string had ""dfd"" in java
java
nvm I got it
lol k
Anyone? from the docs it doesnt say directly
https://discord.com/developers/docs/resources/guild#add-guild-member
Lel K
Any idea what I'm doing wrong here?
your indent is wrong
There's a comma at the end of line 392, not sure if that's supposed to be there

what you want ```js
if bla
something
await something
else
something else
await something else
what you have ```js
if bla
something
await something
else
something else
await something else
A 429 on /gateway/bot means your bot has been blocked I believe.
You can check the header returned to see the remaining time in seconds.
message.awaitReactions()
(if you're using discord.js)
lol
you didnt even read how to use it
scroll value?
you mean the position of the scroll?
you can't with css/html
you have to do it with js
oh
The Element.scrollTop property gets or sets the number of pixels that an element's content is scrolled vertically.
guild.members is undefined even though the guild has members when logged. Since guild.members is undefined, logging guild.members.cache crashes the bot with no error log, as does trying to fetch any members.
I don't know what could be causing this since it worked before the update. Is there some sort of initializing I'm supposed to do? My bot has the Server Member Intent so it's not that.
did you enable the intents in your code though
"enable"
are you using the intents in your code*
You have to enable the intent in your code?
Can you give an example please?
My bot messed with members before they added the intent.
After they added it, it worked again after I enabled the intents on its page.
Now I'm having the aforementioned issue after the v12 update.
Oh, my issue definitely falls into the symptoms.
Weird that guild is an intent but I can interact with that fine without specifying it...
because it isn't a privileged intent
it's treated as on by default (if you don't specify any intents in the code)
Yeah, I understand now.
I'm working on getting it working.
It may seem rude, but I always wait for things to work/the issue to be resolved before I thank anyone. >_>
oh no don't worry about it
Mmm.
I'm guessing you want an automatic way to do it.
You could force it manually via string manipulation. I don't know how to do it automatically.
umm
shoot
I forgot
I KNOW IT
i just forgot
How do I go from folder to folder in powershel?
cd
var img = new Discord.MessageAttachment('blahblah');
Error: Discord is not defined.
I go and declare Discord.
var img = new Discord.MessageAttachment('blahblah');
Error: Cannot read property .MessageAttachment of undefined.
I think this is the first time it's told me "the same" error in a different way.
how did you declare discord
I used to just have:
const Discord = require('discord.js');
but because of intents stuff that doesn't fully work how I expect, I now have it as:
const {Client, Intents, Discord} = require('discord.js');
Yeah, I figured.
what you're doing right now is object destructuring
go back to what you had
i don't see how intents correlate to this
the intents class lives under the discord namespace
the docs also tell you this
Instead of explaining myself I'll write this off as me not understanding hwo that declaration works.
I tried Discord.Inte--
Oh.
I didn't capitalize it earlier...
Do you know how to turn strings into arrays? Do you know how to manipulate strings?
I can explain it but I want to check first that you're okay with just using string manipulation instead of looking for a function to do it for you.
Sorting it would be another complicated matter unrelated to changing the format.
Then you can make a function to turn a fed date into an array, use a temp variable to swap the position of the first two items, then send it back after placing a / between each array item.
You can use a different function to turn a fed date array into a sorted array of dates. It'd compare the years, then the months, then the days to sort them, checking everything over again with each following date.
Not the most efficient sorting algorithm but it's something that would work.
There's other ways to do the first function too since each day/month item is two characters in length. So you don't even need to turn them into arrays.
Wait, sort works for dates?
no, it isn't aware that this is a date, but it orders it alphabetically
nevermind
it orders based on the beginning of the string, aka the day
Then I don't see how it's useful. If you compare--
Actually, I see how using .sort() would make it more efficient with some cleverness.
Thanks for all your help.
Despite thanking you, I'm back to the same error (that being a lack of) I had earlier before I started messing with intents.
what are the intents you declared in your code
copypasting from SO 🙄
hm, if you have GUILD_MEMBERS declared in your intents it should work
var myintents = new Discord.Intents();
myintents.add(['GUILDS', 'GUILD_MEMBERS', 'GUILD_MESSAGES', 'DIRECT_MESSAGES']);
const client = new Discord.Client({ws: {intents: myintents}});
Uhh.
It's undefined...
Exactly.
console.log("It got here!8");
console.log(guildNTABot.available);
console.log(guildNTABot);
let tag = guildNTABot.members.fetch(vlnangie.id);
console.log("It got here!9");
I've already checked that the id is being provided. I even tried replacing it with the id directly.
Every time it crashes on that line, before logging "It got here!9".
This code is in ready.
Ah.
you're saying members is undefined
make your handler async
it would be nice if you could provide your entire code
otherwise i have no context of what you're doing
I'm going to spare you +17,000 lines.
In this context, I'm just trying to fetch a member so I can get their tag.
i have a huge feeling this is an http://xyproblem.info
Asking about your attempted solution rather than your actual problem
I've barely ever used fetch, promises, and await. The new update is making me use them.
I don't think I'm making that mistake.
I'm trying to do something that I used to know how to do before v12. I'm pretty sure this line is the problem since the bot crashes before reaching the next line.
Unfortunately making ready async and awaiting it has changed nothing results-wise.
well, i can't really help you without the code in the ready handler at least
What usually causes a crash with no error?
To make sure, I'm going to comment out the code that happens before this likely-suspect line to make sure that you are getting the full picture.
please do not
not omitting code is the whole reason i'm asking for it in the first place
an analogy - imagine going to the doctor and complaining you have a really bad cough but what you didn't mention to the doctor is that you smoke 2 packs of cigs a day
That's under the assumption that the patient thinks that smoking is unrelated.
In my case, at least.
I'll post the code in a moment.
Should I do multiple messages since it's over 2,000 or multiple screenshots?
you can either bin it or just paste the code in here
discord will automatically convert it to a text file and show a preview
there is your issue
fetch is a promise
await it
guildNTABot is a Promise<Guild>
not a Guild
Then why the heck does it log the guild?
what does it log exactly
Oh.
Promise {
Guild {
etc.
For the record, I was going to leave that line in when I proposed commenting out unnecessary lines to test.
so it was a xyproblem! and it would've been mitigated if you just told us all of this in the first place :)
It wasn't an XY problem because I didn't realize that line was the problem.
In the XY examples they have a goal and hide it.
It was my mistake to not check for other fetches.
And not realizing the logged guild was a promise.
It's crashing without error again, but I'll only come back here if it's not because of fetch and there's no error.
Or if I still really struggle to understand how to use promises.
Thanks again for your help, cry.
oh also
now that you handler is async and you're awaiting your promises
you can try catch the entire handler
and log the error in case it happens
the entire program shouldn't be crashing like this
Hmm. Noted.
Actually, I'm going to try to get that working before focusing on the code more.
You mean put a try catch in the handler?
yup
Okay.
...on(..., async () => {
try {
//code
}
catch (err) {
console.error(err);
}
});
Hi, I tried to upload a bot and they haven't rejected it yet but they will do it because I forgot to put a nsfw command for a nsfw channelxd, how do I do that?
im noob
dx
I'm glad you posted that because I did it wrong and it wasn't working.
It's giving me errors now, thanks!
(Though I wouldn't have fully understood this particular error without your earlier help)
on a serious note, can't help you much if you don't state the library you're using
How can I dm all guild owners
you don't
?
you don't dm all owners
that's an idiotic idea
why would you want to do that
it's api abuse and a bothersome to other people
To tell them the bot will not be online
create a support server and announce things there instead
people who care will join the support server
Ok thx
guys..
I mean..
its not about BOTS specificly..
but
How do I know my router version?
It is related to development... because I got to use that for something in my development
I tryed searching up stuff like.. "router", "my router", "Whats my router" and stuff on google but it didnt help.
?
You what?
Just type 192.168.0.1 in your browser
Or look below your router for the config address
but then Ill need password and stuff... and.. like.. I mean..
I need my version it self
to select from there
o
Default is admin admin
below...
Any advice on what I'm doing wrong here?
alr.
Not all routers use that one
There IS a "with" keyword, you just need to check if you're using it right
I'm no python guy, so idk
I dont understand it.. 😐
I got this:
tg1682g
and thats like..
the model name or smth
This?
Does default gateway work for all routers?
if they have gateway exposed yes
ya
I did.. Now I cant find the password/username to put in. I tryed admin admin and it isnt it..
See that link
ye I just saw it im on it
try admin password
Router passwords are less than nothing lul
are you sure there is no password written on it?
No
did you try admin password?
Admin password
how should it look like?
Login: admin
Pass: password
Had to be smug smh
o
facts..
my bus droped me 2 miles from my bus station and I had to walk back few weeks ago.
Btw, be careful with what you change
I will. 😏
Unless you want some private time with your isp
isp?
(unless you know how to revert obviously)
revert?
Internet service provider
o
Tech support
ye... Kinda not the best.
isnt that standard for adsl?
Not when you use both a router and a modem
well i did the same thing
i had a modem in bridge mode
and the router as the auth
Some routers lag a bit when in authing
Like, don't expect much from 15-year old brazillian tech
yep.
for me it was the opposite, the modem would randomly disconnect/deauth
how many modems did you get burnt by lightning?
xD
Lul
i always had 2, one for backup
the burnt one would get replaced by the isp
sometimes i swapped them
gave them my own burnt one instead of the isp-supplied one
lol never even thought about that ngl..
btw, ever had ants inside your modem?
i had a tp-link router with an ant colony inside
yep.
wasnt really nice.
also..
damn it
I need more help.
Idk how to open a port.
says to go there
and so I did
then it shows this
idk how to open the port it self...
Select the Connect tab.
Select See Network under your WiFi name.
Select Advanced Settings under More Options.
Select Port Forwarding from the menu.
Select Add Port Forward.
also
what in the fuck is that
configuring port forwarding through your isp's website/app?
thats the stupidest thing i've ever seen
thats like... instead of you opening your door, you drive to a construction company and tell them to come open your door
no, a normal router software will have everything built in
oh...
your isp is an abomination
locking the router down and forcing you to login into their website
i literally never seen that before
yeah you basically have 0 control over your router with american ISPs
can't even set DNS settings
wtf
that's why you never rent routers from your isp and just buy your own
i haven't seen the port forwarding thing before I feel like you might be doing something wrong there but they don't want you not using their ISP DNS
?
also who changed my nickname
I think it was veld becuase he was on the channel I where I started streaming while someone else was streaming lol
did you change your username to something with symbols or special characters?
Hi
iirc they don't actually force you to use the website, there is a webserver on the router that gives you more advanced settings such as dns blocks so im pretty sure there is port forwarding
its just super easy for the average person to use a website rather than logging on to the router and configuring everything there
so i need help with my set lenguage command he keeps saying that the guild is not defined
client.translate = async (text, message) => {
let a = await db.ref(`guild/${message.guild.id}/config/lang`).once("value")
let lang = a.val()
if(lang === null) lang = "pt"
const translated = await translate(text, {from:"pt", to:lang})
return translated.text;
}
message.guild will not be defined if the message was sent in a DM
if i want to create a new channel and put that into a channel category do i need to create the channel first and then move it into the category?
using discord.js
You can specify in the create channel options a parent ID which will be the category channel's ID
thanks! that sounds easier. looking into that now
(node:4929) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'queue' of undefined
at module.exports.run (/app/src/Commands/Utilities/24.js:25:26)
at MusicClient.<anonymous> (/app/src/Structures/MusicClient.js:60:13)
at MusicClient.emit (events.js:327:22)
seems the queue instance was never set
Umm
what is client.queue supposed to be
also, you need to pass your client instance to the run method in your command handler
not unheard of to implement a queue system to let a secondary thread do the messages/commands processing
i have it too
it does make a difference in responsiveness
@earnest phoenix
Okay
problem with multithreading is, if u handle resource/db's , u must implement also a mutex or similar thread limiting code, coz u cant have multiple threads touch resource like that
creates a race condition, deadlocks
thats nasty
a thread dedicated for command/message processing would be useless, because then the main thread loses it's use. Having a thread pool to execute commands would be a good idea
require('dotnev').config();
const { Client } = require(discord.js);
const Client = new Client();
Client.login(process.env.DISCORDJS_BOT_TOKEN); What did i do wrong here?
what's the error
i am doing node .src/bot.js and trying to get it online but it wont work
well... uhm... what's the rest of the code?
require('dotnev').config();
const { Client } = require(discord.js);
const Client = new Client();
Client.login(process.env.DISCORDJS_BOT_TOKEN);
ok but
that does nothing
it literally logs in and does nothing
What are you expecting it to do?
duplicate constant identifiers for Client might be a start. Doesn't an error occur if multiple constants with the same identifier are declared
I mean yeah that's one possible issue but it doesn't even error, so clearly, the issue is there is no code written
idk i am watching a video how to do this so i dont know how this works
Your bot literally isn't written to do anything lol
Ok so keep watching
and keep writing
basically replace anything that uses Map in js would be a good example, its a key/value db basically, if your bot goes down, it stays up with the data previously put in it
you've got step 1, now you need to do step 2, 3, 45, 15135. One after the other.
i have but the step i am on is getting the bot online
Isn't it?
its not
ok what happens when you run node index.js (or wahtever filename you have)?
like when you run it, what happens
an error
... can you be more precise or do I have to guess?
Error: Cannot find module 'C:\Users\jackh\discordjs-tutorial-bot\index.js'
[90m at Function.Module._resolveFilename (node:internal/modules/cjs/loader:925:15)[39m
[90m at Function.Module._load (node:internal/modules/cjs/loader:769:27)[39m
[90m at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)[39m
[90m at node:internal/main/run_main_module:17:47[39m {
code: [32m'MODULE_NOT_FOUND'[39m,
requireStack: []
}
so... you didn't create your index.js file? 
Ok but getting the bot online literally requires the creation of a javascript file
you can't get the bot online without creating that file
Are you not paying attention to the tutorial or what?
idk know this stuff
the main file is usually called index.js just as a standard naming convention. You may have called your main file something else, which they specified that you should try to run the main file (whatever you called it)
maybe i should stop
Stop making a bot? Yes. Stop learning? No. You should keep learning, but learn the right thing.
Which is the programming language first.
I am using Visual Studio Code
that's an editor not a programming language
If you really want to do what you envisioned, you shouldn't give up on it. At least, not entirely. You can always come back to things at a later time. Some things just can't be done as a beginner which is acceptable
oh
That's like saying you want to write a book, I say you need to learn english and you say "I'm using a typewritter"
JavaScript or python or java
they're doing javascript, you're late to the conversation, you should scroll up instead of asking things that were already answered.
ok
const Embed = new MessageEmbed()
.setColor("#d4b1ff")
.setTitle("Joining")
.setDescription("${args[0]} I successfully joined voice channel")
return message.channel.send(Embed).catch(() => message.channel.send("I successfully joined voice channel"));
},
};```
help
thi is code for embed
but it says embed not define
where is the problem
the problem is you're trying to send embed and it's not defined.
... because you didn't define it?
where
why are you trying to send 2 different embedS?
no
This embed isn't defined.
uh... how about just... delete it...
since you only want to send one embed and I presume it's the second one you actually defined.
dn
lemme check
(node:612) UnhandledPromiseRejectionWarning: ReferenceError: MessageEmbed is not defined
at Object.run (/home/runner/Test-oke/commands/setprefix.js:18:23)
at Client.<anonymous> (/home/runner/Test-oke/index.js:56:42)
at processTicksAndRejections (internal/process/task_queues.js:97:5)```
error

probably you forgot to import MessageEmbed from discord.js?
or try Discord. before MessageEmbed?
m
gotta love it when people just blindly button mash and copy random stuff instead of learning javascript
i didn't catch that
Ok lemme check
haha i love how you have to reiterate the message everytime haha
It's been a common theme for the last 5 years
i need dashboard creator dm me
why my bot sending this
An unexpected error has occurred.
Possible type Error: Status code: 429
i just added uptime
and
429 means rate limited
i need dashboard creator dm me
Make sure your bot doesn't spam the Discord API
so how can i check it
Do you have any code that could potentially spam it?
yeah that doesn't tell me a whole lot. I have no clue what uptime.js is
lemme show u
name: "uptime",
aliases: ["u"],
description: "Check the uptime",
execute(message) {
let seconds = Math.floor(message.client.uptime / 1000);
let minutes = Math.floor(seconds / 60);
let hours = Math.floor(minutes / 60);
let days = Math.floor(hours / 24);
seconds %= 60;
minutes %= 60;
hours %= 24;
return message
.reply(`Uptime: \`${days} day(s),${hours} hours, ${minutes} minutes, ${seconds} seconds\``)
.catch(console.error);
}
};
Well none of the should cause a rate limit, so it's some other part of your bot
hm
i need dashboard creator dm me
No need to spam
Also this isn't the place to look for a developer, go to a freelance website like Fiverr
const fs = require("fs");
const { Collection, Client } = require("discord.js");
const client = new Client();//Making a discord bot client
client.commands = new Collection();//Making client.commands as a Discord.js Collection
client.queue = new Map()
client.config = {
prefix: process.env.PREFIX,
YOUTUBE: process.env.YOUTUBE_API_KEY
}
//Loading Events
fs.readdir(__dirname + "/events/", (err, files) => {
if (err) return console.error(err);
files.forEach((file) => {
const event = require(__dirname + `/events/${file}`);
let eventName = file.split(".")[0];
client.on(eventName, event.bind(null, client));
console.log("Loading Event: " + eventName)
});
});
//Loading Commands
fs.readdir("./commands/", (err, files) => {
if (err) return console.error(err);
files.forEach((file) => {
if (!file.endsWith(".js")) return;
let props = require(`./commands/${file}`);
let commandName = file.split(".")[0];
client.commands.set(commandName, props);
console.log("Loading Command: " + commandName)
});
});
//Logging in to discord
client.login(process.env.TOKEN)```
index.js file
and play.js
hello
@dusky sundial
Hi
So first of all, do you actually know any JavaScript or have you just copied this from the internet?
Me?
No
Im learing bro
i tried first to do it , now im coding it myself
Well the issue with copying code you don't understand is exactly this, when an error occurs you have no clue why it happens or how to fix it
My best guess is that you're being rate limited by YouTube because of your play command
can't help you any further as I'm not a js dev
I've just heard that YouTube has some pretty strict rate limits. So again, I'm not saying that it is the issue. It's just a guess from me
all I know is that 429 means that your bot is being rate limited, I have no clue from where though
:)
Maybe this is the issue im using sma e api key
to use two bots
@dusky sundial
If you’re doing a music bot for a bunch of servers you’ll need to proxy
honestly just don't make a music bot, the market is oversaturated and it's unlikely that your bot will be as good as Rhythm or other popular music bots
no
Y
In order to bypass the rate limits you need several different IP addresses which you can rotate
using music from youtube is super difficult when starting out
you need a large amount of infrastructure just to get a few plays
There isn't a ton of mainstream music on soundcloud
large bots use what fued said, they buy out like 1 million esc IPs and rotate them on each request so they can never get blocked
find a provider and pay a shit ton of money to them lmao
lol
IP Brokers
lamoo
if you're at the point where you don't even understand how to rotate the requests best bet is to drop the idea because it won't be worth the investment
but a music bot called Preo
And it built using a bunch of codes
which are available on internet for free
and it works well
idk why

Help me Im depressed
Do you run the code yourself? A local instance might not get rate limited cause it's not being used too much
yes
And how often did you use it? How many songs did you play
I don't think we're on the same page but ok
and the bot its not even verified
this means
my bot blocked by youtube

Hahahaha
i have a solution
does anyone here know how to use the patreon API?
use the client they provide (if aviable for your language) or make http requests
as a fair warning the api is deprecated
it must be https sadly
the other problem, it's terrible
then just send a http request and add you api key to the header
i dont agree with you on that
depends on the context i would say, if you do a lot of thread heavy stuff having a pool would be better than a single dedicated thread for all commands, like rendering or ML stuff (even tho i would run this in a seperate instance on its own thread)
the client listens for messages (api/lib) and then i have a sep thread that applies the modules (filters, commands)
thats how ive set it up
imagine your bot being on a lot of servers, assume you get messages every split second, the main thread would have to deal with a lot
if you separate these two things with a queue in between
makes more breath space
and few of my commands are a bit on the heavy side, being 2d drawing routines
one thing i do wanna make yet is a crontab module
any suggestions?
@lusty quest
this might help https://bit.ly/2PvfShP
why does this keep happening now 😔 I am literally using manager.spawn(manager.totalShards, 5500, -1) this shouldn't happen
lol np
I thought I was on coding den
thanks
an interface isnt exactly an instance, is it?
just the structure
or am i crazy ?
as far as i know, a class can abide by an interface
because i have classes that implements that interface
yes
and does the constructor code setup the 'parent' so to speak of manager
Try this
but then classes that implmement this will throw error
i mean the interface works just fine when i run it but eslint is the problem
im not sure if i want to disable that rule
the first error told that there wasnt anything set on the manager field, right?
basically null reference
'this' under laying class could be different , might have the same interface fields
so im just shooting up balls here, can you cast it ?
just disable the eslint rule, typescript itself should report on not defined errors
Summon() will call another Manager instance so this will definitely be different
there are so many compromises in rules now i don't know if this is good
this doesn't make sense
what are you exporting
okay
also you can try using export interface, maybe the rule won't break
but then it throws Module "..." has no default export
export default interface
so i just tried to use curl today and it says this:
aatif@aatifpc:~$ curl https://google.com
Command 'curl' not found, but can be installed with:
sudo apt install curl
i tried to install the command but it says another error:
aatif@aatifpc:~$ sudo apt install curl
[sudo] password for aatif:
E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
aatif@aatifpc:~$
wdym another process is using it, i just turned on my computer and didn't open any other program???
probably auto-update thing
hm
i would say wait for it? but the thing is there's no way of knowing exactly how long it's gonna last.






