#development
1 messages · Page 1581 of 1
can embed be replaced? Is it the name of embed? Or is it has to be embed?
message.channel.send(new Discord.MessageEmbed())
embed can be whatever
Pinned messages has some info about free VPSs, I recommend Vultr or GalaxyGate as they're both pretty cheap
alr.
alr, thanks.
It's better to declare embed outside of the send function just to keep it clean
Hmm
You're gonna need some experience with Linux to set up a working VPS though
Something like this
this makes me crazy
There are plenty of tutorials so it's not that hard
- reading the documentation helps

You'd be surprised how little people actually use docs :)
M-microsoft edge?
Yep
But why?
intent?
are these open
open is by looking to the right.... or to the left?
just turned it to the right..
listing or listening?
does it matter.... ?
open now
||(Changing it...)||
to left?

renew and try your token
is it that hard to type left?
If it doesn't work the code has an error
yes
all?
does quick.db allow for more than one connection
const officialServer = bot.guilds.cache.get('738540548305977366');
```Am I getting right? Cuz `roles.cache` is undefined
you want the disable to persist across restarts?
I use my DB for that xD
and then cache the option
well, editing the original js file sounds like a dumb thing to do
sure it works
but so many things can go wrong
just make a json file or something to keep track of disabled commands
That’s right
I have a collection in firebase called 'settings', then I cache the settings at startup, or if changes are made
in settings I have the prefix, automessages and language
hmm maybe it's a problem with exporting
WOOOHOOO! I after a whole fucking week of fixing and rewriting my whole bot, I AM READY to upload it to top.gg!
...
The question now... is how I do that.
Why? What’s wrong?
go to top.gg and click on add bot?
Go the website and upload
alright. Thanks,.
roles.cache is undefined, inside another command file
How are you doing roles.cache?
First make sure roles is defined
Check what output you get when you console log roles
yeah, I was about to do that
just found officialServer has another variable's value, cuz I didn't update the dev version

yeah, execute() problems
F
wow, still a problem. Now execute() is right, but it passes undefined to the command
What are you trying to pass?
officialServer
try {
command.execute(bot, message, command, db, lang, language, prefix, args, officialServer, serverSettings);
}
catch (err) {
console.error(err);
return message.reply(lang.error.cmd);
}
```I have this in the main file
execute(bot, message, command, db, lang, language, prefix, args, officialServer)
```and this in the command
Have you tried to log officialServer before command.execute()
gonna do it
See if it's actually defined
Search on all shards and have the shard that has it return what shard it is
const officialServer = bot.guilds.cache.get('738540548305977366');
console.log(officialServer);
```instant undefined
you can also use the equation: (guild_id >> 22) % num_shards == shard_id
so you dont have to send a request to every shard
Was gonna mention that but I missplaced the equation
probably isn't in cache
@outer perch have you made sure you copied the right id
hm
You don't need to await to get the value
So other than the bot not being in the server I have no idea
the fact i figured out the issue without realising i did, jesus im tired
Lmao
not that
Go to sleep then Luke
wait a min
Ah that's a F
maybe it's L
const bot = new Client();
const officialServer = bot.guilds.cache.get('738540548305977366');
bot.once('ready', async () => { 'whatever is here doesn\'t matter' });
```🤣
look at the order
the bot doesn't even have time to cache
xD
big F
When the issue is so simple we overlook it
mhm
lmfao
We just take for granted that the code we run will be run after it's ready
laughing hard af ✅
rolling on the floor ❎ (almost there)
Let me kick you off ur chair to get the last one
🤣
cya 👋🏻
oh wow, now I can't add a role to a member, cuz the intents were disabled at 100 servers
So i don't think this is about development but i think so
Someone knows how add ssl to subdomain?
const tip = ['bru', 'hgfsdr', 'dasgrg']
yes, i copied all the letters and i don't know why
oh, nice, thanks!
You can do: ```let tip = [
"bru",
"hgfsdr",
"dasgrg"
];```
So replace { } with [ ]
Also let is better than const as you can change the value of a let variable
hey
hi
do any of you use express for making an http server
if you say wanted a long list of things
or is that just me
a json file can be like
"tip": [
"bru",
"list 2"
]
}```
and you can access that array by doing: let tip = require("./jsonName.json").tip
Thats package.json
Do npm init -y in the terminal
i mean that's what it should do xd
ah yes windows user
let guild = await client.guilds.fetch(guildID)
let guildMembers = await guild.memberCount
let guildName = await guild.name;
joinlogID.send(`Bot has been invited to **${guildName}**. This guild has ${guildMembers}.`)
})
Is there anything wrong with this?
No error but doesnt work
global.joinlogID = joinlog.channels.cache.get("809622829322600490")``` is how I defined joinlogID
dont use await for things that dont need it
only fetch needs await
and guildCreate gives you a full guild object
not an ID
Oh so I can just do guild.name not all the extra?
yes
what if I want await instead of then?
😎
true
go slep
"joinlogID is not defined"
well i go, kthxbye
Defined it previously
global.joinlogID = joinlog.channels.cache.get("809622829322600490")```
you dont need any of that either
just do client.channels.cache.get("809622829322600490")
I need to fetch the log in my server though for it to log it
do guilds stay cached after a reboot?
kthxbye (for real now)
hey umm
returned undefined for guild name ...resolved
what does unknown message error mean? discordapi error
I got this...
well you can't send an array to a channel
not icons
wait a minute.... I dont remember putting icons..
the error says icon_url
you could also just join your array by comma, tip.join(", ")
anyone?
it means that the message is deleted/you're looking for a message in the wrong channel
makes sense
also
i keep seeing the internal server error too often while editing embeds
even tho the embed is there
is discord outage that bad?
that's weird
ikr
internal server errors are usually server side
my whole error log file is filled with internal server error from discordAPI
once or twice is acceptable
but
this
like wtf
Is this the correct code?
if(!message.member.hasPermission("MANAGE_MESSAGES")) return message.reply("Sorry, you don't have permissions to use this!");
const deleteCount = parseInt(args[0], 10);
if(!deleteCount || deleteCount < 2 || deleteCount > 100) return message.reply("Please provide a number between 2 and 100 for the number of messages to delete");
const fetched = await message.channel.fetchMessages({limit: deleteCount}); message.channel.bulkDelete(fetched) .catch(error => message.reply(`Couldn't delete messages because of: ${error}`)); }```
how do i make a bot that sends a message every minute as me?
i think have an idea idk tho
Wdym
i want to be able to send a message every minute without actually typing it yk?
That is possible actually,But idk how
Yw
You don't need to fetch messages. Just provide amount directly to bulkDelete()
Ok
What will be the error message if any error occurs?
ok
Kick/Ban command code is similar to this code with some changes?
how long does it take to get a verified bot after releasing the bot on top.gg
Depends
My help command dosent show up anymore i get a empty box ?
how do you make the bot DM the message author? message.author.send doesn't work anymore
bruuhhhh... My bot is going to be reviwed soon and I just bought my VPS.. well.. in proces of buying it. They are checking it..
It should work unless the user had their DMs disabled
ayt ty
You need to list all the commands in Help
i did
uh... Is there a way... for me to create a command that will clear the terminal in VSC?
I did this...
What is the error?
module.exports = {
name: 'BrHfsvh',
execute(client, message, args) {
clearImmediate.console.log
console.log("cleared the terminal..")
}
}```
wait
wtf
auto correct.
ill brb
You are JS?
Screenshot the code and send me in DM.I will check that
Im sending a POST request using axios with discord API to send a message. Im getting a 200 response but its not sending the message
anyone know what could be happening
Check your response body
If it sent properly then it should return a message object
Otherwise an error
Hey i want to code a chat with bot,But idk how?
i am getting a 401 now
not good but at least a clear answer
yes in header
Can you show?
ok
const messageContents2 = { "content": content, "tts": false }
axios.post('https://www.discord.com/api/v8/channels/' + channel + '/messages', JSON.stringify(messageContents2), headers2
).then((response) => {
console.log(response);
});```
@pale vessel
Authorization, not Authentication
oh boy i am stupid
Hello
Mmmm hotdogs
Sorry
About that
But how do I get my bot online
Yes it’s anti spam
Sorry
I’m new to this
Man just dropped his hotdogs accidentally
you code it
you run the code
and it magically goes online
How

can I walk the code? 
Answer me Please
use nodejs or something
Use discord.brainfuck
what do you mean by dat
kekw
It’s showing me weird stuff I need major help 😔
Like a chat bot bro
No
How do I code the bot
they just send a link for you https://discordjs.guide/creating-your-bot/
why don't you check it
I’m on mobile not pc I wish I had a pc
Aren’t you a bot dev?
Iam
look for some random api and start using that
lol
Can you help me in that?
nope no idea
Can somebody help me I’m on mobile not pc so it’s not that ez
It will be fun for some users BTW
i keep getting 401s on a POST request with discord (using axios) to send a message
You can code in glitch.com from Mobile
Thanks
sadly its very hard to code on mobile and on pc its like 4x times better
wider screens are just better
that vertical height with the small width it doesn't help much
Well everyone don’t have the money for a pc and stuff like that
But it is very hard to code in Mobile
yeah but just sayibg
I hate my life
the experience on mobile is gonna be a lot worse
You did any course in Bot development?
did you ever code before
You need to know basics of development
You need to understand the JS Tutorial by yourself
you don't have to do everything at once
but this is still development related
yes,But iam scared of Mods will warn us
im pretty sure they wont
ok
its not
Where do I even start it’s nothing but slot of links
I started coding by Learning from YOUTUBE
youtube is not always the best place to learn
Yes,I learnt from YT and other bot devs
most tutorials are just never up to date
Now i bet that coding is very easy
thats the problem
lol
@slow lichen also look at https://discordjs.guide
Bruh
If you love to code,It will be very easy to understand
Bro where am I supposed to start reading
just pick a guide and start reading
im not reading it for you
lol
ur supposed to be reading it
Just tell me why do you want to develop a bot?
Because I want my own bot
For your server?
Yes
you can also try this
if you want to
this time its big ass button
impossible to miss
Do you know how long it usually takes to get a bot approved
Ah, thanks
Then maybe don't buy nitro with boosts?
Well depending on for how long you plan to have nitro, your pc will be paid quite fast
iPhone can't boost
Then you have a pc
If you can't boost on iphone and own an iphone

No
its litterally an apple product
No
you could even make a pc for 400$
So, how do you explain your boost? Since you said you can't boost on iphone
lol
Lol
you can make a pc for the price of a ps4 and you would get even better perfomance

saying that you need 1k dollars is just dumb
not true at all
You have nitro
No you don't
I don’t have nitro
omfg
you can buy boosts individually
fine
That’s nice idc
Fake
I don't have nitro

Now stop lying and being cringe
💀
I think you will once you realise they are a moderator
anyways going to general chat now
does anyone know what event I need to get member role updates
in discord.js
lol
I forgot
please use the channels according to their purpose
distortion == funny? smh
And you have to realize that this isn't a meme channel
OOOOF
I smell a mute coming
I have a string like <@_valid_role_id>.I know that there is a function in the <discord.js>.Util module that canvobvert it to a role object, but I forgot it's name. Anyone remembers it?
const { MessageEmbed } = require("discord.js");
module.exports = {
config: {
name: "balance",
aliases: ["bal", "money"],
category: "economy",
usage: "!balance",
description: "View your money balance!",
accessableby: "Members"
},
run: async (bot, message, args) => {
console.log("Hello!")
} // <--- Why does it not allow me to put an ; as it errors.
};
Why does it not allow me to put an ; as it errors.
Is it supposed to be a ,?
it must be an , lol, thats the syntax
Because it's inside an object (wrong reply, meant for @feral aspen)
const ms = require("parse-ms");
let time = ms(timeout - (Date.now() - data.daily));
It's not an assignment
Usually, in discord.js, I can require part of the package like MessageEmbed, but how can I do it at ms?
Yea, I guess.
I thought I can just require part of the ms to do things for me but since it is ms(), I don't think things can work as I expected.
Yeah
Unfortunate.
I wouldn't call it unfortunate
You just don't need to do it ig
Unless there's ms.parse() for example where you could use const { parse } = require("ms");
Yes.
but there's none of that
Yes. 🤷♂️
Yeah, and I'm still trying to figure out why my client is having a memory leak where it is doubling in ram.
I am not sure what I am supposed to do to fix this.
discord.js - How to convert <@&ROLEID> into role object?
ig that works
i want to do my bots site like chance the prefix see all the commands who can help me :c
So you want to make a dashboard? That's not easy to make - you need to have knowledge of HTTP servers/requests, HTML, CSS, JS, oauth2. You also need to buy a domain for your site and use nginx/Apache to reverse proxy requests to your server. It's definitely not a beginner project and you should learn each technology on it's own before you start working on a dashboard.
Hi, Can anyone here help me code a bot easily as I’m having trouble coding mine
@wise cave
can you please help?
You don't need to ping others, just ask what you need and I'm sure you'll get an answer
Okay sure!
In which language?
why do i keep getting fucked up errors why meeeeee TWT
fyi you should probably use something like sentry so you don't have to ssh into the server everytime you want to see errors
its fine, im on windows and lazy xd if i was on my ubuntu machine i would just ssh from terminal
but the errors TWT
making me cry yowwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
I mean it doesnt help that the terminal is escaping \n making the error pretty un-readable
how can i make vote command
well, i download the error logs anyway... but most of the errors are those "internal server error" and "user aborted request" nothing else.. its frustrating ughhhh as it doesnt occur when i test it out and try to recreate this shit.. its causing embeds to stop editing
i know this
how fix
it's somehow sending too many requests but I don't know what is sending too many requests
is there a way I can get any console output as an event in nodejs
for example if there happens to be something new in the console an event would be triggered
this is for development support
oh sorry
I tried restarting, and then I just got the first screenshot
i made command for ownership server only
and i put on permission
if(!message.member.hasPermission(message.guild.owner)) return message.reply("** You Don't have OwnerShip Permission **");
Is message.guild.owner defined or not?
anyone help
no, that's ownerID
it still wouldn't work in his context
so?
message.guild.owner is not a permission
I think there is a property to check if they are the guild owner
check the docs
maybe
compare author's id with owner's id
grr
member.owner
or member.isOwner
if (message.guild.ownerID !== message.author.id) {
//code
}```
it is option in permission check iirc
actually
is that only for ownership?
yeah
yes
was about to say you don't need to check permissions
l9l
but there he sent it
well whatever
now, @summer torrent
uhm
and then on the dedi, it still has this
found in discord.js server
looks like your connection is getting reset when attempting to connect to the api
reset token
I don't have access to the config.json file editing because I don't have sftp or ssh access
well, it's a private repo
time to make a temporary file that will hold the token
i do it but everyone can access to command not only ownership
show code
if (message.content.startsWith(prefix + "antibots off")) {
if (!message.channel.guild) return;
antibots[message.guild.id] = {
onoff: 'Off',
}
message.channel.send(`** ⛔ AntiBots Off**`)
fs.writeFile("./antibots.json", JSON.stringify(antibots), (err) => {
if (err) console.error(err)
.catch(err => {
console.error(err);
});
});
}
}
})
here it is
you don't check it
premium subscription count
will that work?
what lib
djs
guild.premiumSubscriptionCount
check what
look at Guild class
one moment
message author is owner or not
!s
thanks
I JUST FOUND THE REASON TO THE ENTIRE ISSUE KEKW
I literally had an idea this might've been the issue earlier but thought "nah probably not"

running 2 functions in a message event was a nono, checking at the start of the message event if the message starts with the prefix, boom, issue fixed
I am stupid

🤔
var prefix = prefixes[message.guild.id].prefix;
var error = ":x:";
var success = ":white_check_mark:";
var loading = ":thinking:";
var user = message.mentions.users.first() || client.users.cache.get(message.content.split(' ')[1]);
if (message.author.bot) return;
if (message.channel.type == "dm") return message.channel.send(new Discord.MessageEmbed().setTitle(error + " **You Can't Use This Command In DM!**"));
if (message.content.startsWith(prefix + 'unban')) {
if (!message.guild.me.hasPermission('BAN_MEMBERS')) return message.channel.send(new Discord.MessageEmbed().setTitle(error + " **I Can't unban members because i don't have Permission!**"));
if (user === message.author) return message.reply('you cant unban ur self ');
if (!message.member.hasPermission('BAN_MEMBERS')) return message.channel.send(new Discord.MessageEmbed().setTitle(error + " ** You need ban permission to use this command!**"));
if (!user) return message.channel.send(new Discord.MessageEmbed().setTitle(error + " **Please type a user ID !**"));
message.guild.owner.send(success + `**${user} Has been unbanned By **<@!${message.author.id}>`)
message.channel.send(success + `**${user} Has been unbanned by** : <@!${message.author.id}>`)
message.guild.members.unban(user).catch(err => message.channel.send(`Sorry There's a Error`) )
}
})
Problem is
like me on server and someone try unban me he send i got unbanned
Wheres problem i want say this user didnt banned sorry for bad english
help if you can
example
and me already on server and he unbanned me
anyone?
.-.

@summer torrent now it's only responding to commands locally but not on dedi :sad:

yes
Thank god
So I have a file bin.pgamerx.com just like my others in /etc/nginx/sites-available/
got it
This is the file's content
yo
have you reloaded nginx
any errors?
neither in nginx nor in my process
Everything is fine
No errors
or wait
is it because Of cache
that I can't
open the site
it could be
404
i got nginx 404
lol
close the editor
oop
👀
your nginx config is wrong
Why?
public
you're using an upstream
That's what I am using for everything else and it works Perfectly
so it should be proxy_pass http://app_yourdomain
and the ip should be localhost
or 127.0.0.1
I tried that as well didn't work either
why?
because its inside the same server
you have both nginx and node in the same server right?
so when you receive a connection in nginx
yes
you want to pass it to "same server, different port"
not another ip alltogether
if you use another ip, you're giving more work to nginx
it has to go check where that ip is
🤔
and validate it
That ip is of my vps
still
so just use localhost...
^
That doesn't change anything
using localhost or 127.0.0.1 is a fast path on the process
still use local host
So I will be using this
your code should be ```nginx
upstream somenamehere {
server 127.0.0.1:6969
}
server {
...
location / {
...
proxy_pass http://somenamehere
}
}
somenamehere is my domain?
somenamehere is your upstream name
Oh
you can give it whatever name you want
ok
wait
does host has to be a string
or a number
I mean usually in express
it's a string or no
what host? where?
It will automatically take localhost as the host?
nah
or thr 127.0...
0.0.0.0
which can be accessed using localhost
this only?
Why am I still getting 404
Linux?
i'm not sure but I think it's ufw
you can allow ports using ufw allow <port>
kk
Thank you very much my webhooks have finally worked
console.log config.port
why are you using a js file for you config and not a json one?
I mean
you're not exporting anything from the js file, so config is most likely just {}
oh
and port would be undefined
you're not in the snippet you sent
you probably want config.json not config.js
Alr, I renamed the file
also, do you even have any routes ?
like, an http server that doesnt have any routes will send 404 by default i think
how do we create routes
Also
I am using
Can webhooks ban or kick people?
no
Oh okay
Me?
yes
discord webhooks can only send messages to a single channel (the channel they were created in)
I saw a server get nuked yest they said it was a webhook and i got confused
wat
That's why i am asking lol
Probably just a cover up for staff abuse
no, that doesnt exist
a webhook is like "i allow this website to send messages on this channel"
thats all it can do, send messages to a channel
Yeah that's why i got confused
either a staff member or a bot did it all
bots can create webhooks 
In 10 mins
yeah. Bot
I got a little problem with my bot. Its coded in node js and i dont know how to fix it.
Whats the problem
How to get the coded stuff like this
wat
cmd: node bot.js
Bot is ready!
D:\path\New Bot Project\node_modules\scrape-yt\dist\index.js:108
if (query.trim().length === 0)
^
TypeError: Cannot read property 'trim' of undefined
at D:\aajie vps\dbm v2 met announcement\New Bot Project\node_modules\scrape-yt\dist\index.js:108:31
at step (D:\aajie vps\dbm v2 met announcement\New Bot Project\node_modules\scrape-yt\dist\index.js:54:23)
at Object.next (D:\aajie vps\dbm v2 met announcement\New Bot Project\node_modules\scrape-yt\dist\index.js:35:53)
at D:\aajie vps\dbm v2 met announcement\New Bot Project\node_modules\scrape-yt\dist\index.js:29:71
at new Promise (<anonymous>)
at __awaiter (D:\aajie vps\dbm v2 met announcement\New Bot Project\node_modules\scrape-yt\dist\index.js:25:12)
at Object.exports.search (D:\aajie vps\dbm v2 met announcement\New Bot Project\node_modules\scrape-yt\dist\index.js:103:12)
at eval (eval at Actions.eval (D:\aajie vps\dbm v2 met announcement\New Bot Project\bot.js:344:10), <anonymous>:5:33)
at eval (eval at Actions.eval (D:\aajie vps\dbm v2 met announcement\New Bot Project\bot.js:344:10), <anonymous>:9:3)
at Object.Actions.eval (D:\aajie vps\dbm v2 met announcement\New Bot Project\bot.js:344:10)
this is the problem
but it looks ugly now
Cannot read property 'trim' of undefined
you're trying to trim() something that doesnt exist
what does trim even mean

did you copy paste it?
its a node module so i just gave it a input and expected a output
var scrapeYt = require("scrape-yt");
const b = tempVars("input");
(async () => {
let videos = await scrapeYt.search(b);
const c = videos[0];
console.log(c);
Actions.storeValue(c, 1, "output", cache);
})();
this is my code
Most likely a copy and paste
😬
So i need to fix the input
Seems like it
Ok im going to try that
what is tempVars?
yes
do I need to do something else as well?
im looking at the source code
look at this
const configPath = process.argv.length <= 2 ? 'config.js' : process.argv[2];
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
so they are expecting config.js indeed, and processing it with fs.readFileSync lmao
what a stupid way to load a file
jesus christ
but rename it back to config.js
i did ?test 1 and then tempvar would be 1 but i forget that it is the third param for tempvar
so ?test 1 1
is working
and then it skipped the first 1 and only read the second 1
but its working now
so thx
But Why does it work on local ip but not on domani
that's what making me go freaking crazy
Hey how to make a top10 Leaderboard?Please tell me
where did you put your nginx config file?
/etc/nginx/sites-available/
did you copy it to sites-enabled?
I created a new file
how can i make a vote command?
/etc/nginx/sites-available/bin.pgamerx.com
In JS?
is the file's exact location
yes
copy /etc/nginx/sites-available/bin.pgamerx.com
to /etc/nginx/sites-enabled/bin.pgamerx.com
oh
Oh
OH
I AM FREAKING DUMBO
I MADE A FILE IN SITESAVAILABLE
instead of enabled
😩
dumfuk
ikr
xd
if(message.content === "vote") {
let embed = new discord.MessageEmbed()
.setTitle("VOTE")
.setDescription(`(VOTE)[Link]`)
message.channel.send(embed)
}```
replace with r!vote in message.content
like this ill send a screen shot
wdym
Ok
What is the meaning?
Can vote without going to the vote page when using the vote command
ok np
ctrl c
do nodejs got a inbuilt way to cache or do I need to install a package?
I need to cache cooldowns
will this cause a problem
I dont think making a cooldown a object isnt a good idea 
Objects are the native and best way to cache... why are you searching for a npm package for everything
Objects are trash
I asked if caching stuff has a already inbuilt feature or if I need a package for caching
no
Not you
ok
You should cache cooldowns in a Collection
It's way more efficient than Objects and accessibility is better than in objects
Definitely not more efficient
Definitely
imo it depends on your use-case
I just need to cache small cooldowns
Collections are a dumb-proof wrapper around the native Map class, so yeah
if it is a big cooldown will I just have it in a db
if you need lighter and more permanent cache with minimal effort, use an object, otherwise you can use a Map with a cooldown that altomatically removes things after being set/updated
Especially for something that changes a lot





