#development
1 messages · Page 1519 of 1
hmm gotcha
lmao
base64 encode the image and put it in the css directly
Interesting... Won't decoding slow stuff down?
it makes the image a bigger file size. it saves making another http request though
And does that even out, or are there significant advantages either way?
it's going to be slower
the end user ends up downloading the same amount of data
for small images it could make sense
image sprites are good way to reduce http connections without base64 encoding
g
Hello I have a problem I have a welcome message with 0 errors but when the members join the discord nothing happens
const Discord = require('discord.js')
module.exports = async(bot, guild, member, message, args) => {
// création du embed.
let embed = new Discord.MessageEmbed()
.setColor('#ca0137')
.setAuthor(`📥 — <@${member.id}> nous a rejoint`, member.user.avatarURL())
.addField("Création", moment(member.user.createdTimestamp).format('ll') ,true)
.addField("Jour(s)", checkDays(member.user.createdAt) ,true)
.setDescription(`Concernant ${member.user}`)
.setThumbnail(member.user.displayAvatarURL())
.setFooter(`ID : ${member.user.id}`)
.setTimestamp(new Date())
bot.channels.cache.get("792435358368792607").send(embed) // Id du channel. [ALT + 8]
};
did you enable guild_members intent
https://discord.com/developers/applications/****BOT_ID****/bot
I do not change the name of guildmemberadd afterwards?
I have activated SERVER MEMBERS INTENT but nothing is still happening
did you restart your bot after you activated it?
Can I learn typescript without needing to learn JS first
Do you pass the proper intent to the client websocket options
sure
you will learn a lot of js in the process, but typescript will make it easier to learn if you have experience with java/C#
You're pretty much learning JS at the same time as TypeScript. I'd encourage TS first since it helps you understand types which is really key in languages
more like, to move from ts to js, you have to "unlearn" a bunch of stuff
Aren't key words like public and private coming in newer revisions?
Right
Any good resource you can share to learn typescript?
you dont use the keyword "private", you prefix it with a hash
#this.abc = "private"
in js that is
I'll try doing something simple but I haven't found anything worth while yet
in typescript you use the keywords like normal
I don't know any good resources off the top of my head, no. I learned TS after I learned JS so the transition was super natural
do you use the "intents" option in your client? like new Client({ws:{intents:"something here"}})
const Discord = require('discord.js')
module.exports = async(bot, guild, member, message, args) => {
// création du embed.
let embed = new Discord.MessageEmbed()
.setColor('#ca0137')
.setAuthor(`📥 — <@${member.id}> nous a rejoint`, member.user.avatarURL())
.addField("Création", moment(member.user.createdTimestamp).format('ll') ,true)
.addField("Jour(s)", checkDays(member.user.createdAt) ,true)
.setDescription(`Concernant ${member.user}`)
.setThumbnail(member.user.displayAvatarURL())
.setFooter(`ID : ${member.user.id}`)
.setTimestamp(new Date())
bot.channels.cache.get("792435358368792607").send(embed) // Id du channel. [ALT + 8]
};
his question was about your client options
show the code where you create your client
the part where you have bot = new Discord.Client
I don't understand or can I find what you are asking for
in your code
in your index.js file
at the beginning of the file
you have this const bot = new Discord.Client()
show me this
should i make a fun bot or utility bot?
i was working on something until i hit a wall then had to stop
you need to enable the intent in your client.
yes in put const bot = new Discord.Client('intents');
that doesn't make any sense.
you dont need to enable them
if none is specified, it defaults to all
so thats fine
oh, i thought it was all non privileged intents.
show your guildmemberadd.js file
how did you name the file?
guildmemberadd.js or guildMemberAdd.js?
const Discord = require('discord.js')
module.exports = async(bot, guild, member, message, args) => {
// création du embed.
let embed = new Discord.MessageEmbed()
.setColor('#ca0137')
.setAuthor(`📥 — <@${member.id}> nous a rejoint`, member.user.avatarURL())
.addField("Création", moment(member.user.createdTimestamp).format('ll') ,true)
.addField("Jour(s)", checkDays(member.user.createdAt) ,true)
.setDescription(`Concernant ${member.user}`)
.setThumbnail(member.user.displayAvatarURL())
.setFooter(`ID : ${member.user.id}`)
.setTimestamp(new Date())
bot.channels.cache.get("792435358368792607").send(embed) // Id du channel. [ALT + 8]
};
guildMemberAdd.js
cuz guildMemberAdd only passes a member argument
here I just did it
add const moment = require("moment") to the beginning of the file
and what is checkDays?
do you have a checkDays function in the file?
here I just did it
I put const moment = require("moment")
whats the difference between let var and const ???
var declarations are globally scoped or function scoped while let and const are block scoped.
var variables can be updated and re-declared within its scope; let variables can be updated but not re-declared; const variables can neither be updated nor re-declared.
They are all hoisted to the top of their scope. But while var variables are initialized with undefined, let and const variables are not initialized.
While var and let can be declared without being initialized, const must be initialized during declaration.
https://www.freecodecamp.org/news/var-let-and-const-whats-the-difference/
any recommendations for cheap us-based VPS? i'm using google cloud right now
thinking of OVH or digitalocean
VersatileNode, it has amazing prices
@manic cairn hey, do you mind running a general purpose speed test if you have a VersatileNode vps?
i can get the command, just gotta find it lol
curl -sS https://raw.githubusercontent.com/jgillich/nixbench/master/nixbench.sh | sh
Hey
For what reason?
i want to compare to my host
every time i find a host with better pricing than GG, and better cpu's they always have worse performance. no idea how
and exactly what is curl -sS https://raw.githubusercontent.com/jgillich/nixbench/master/nixbench.sh | sh gonna do?
it runs a series of tests, cpu tests, network tests, and log the hardware you have.
woo thats kinda sus ngl
itll also tell us the various cpu features enabled which some hosts
its an extremely commonly used set of tests.
why 🤔
yea
its like running a exe file from freeboobsnotascamtotalylololol.com lmfao
🤷♂️ i mean ive been using it for years, pretty sure most people use it.
still sketch
just i wouldnt, but u do u
🤷♂️
they have okay hardware, the big benefits are the drives, and unlimited bandwidth.
any other way to run a test without that thing?
i mean, all benchmarks require running a command
how much r u paying?
& what specs r u getting?
their cheap plans are a 6700k or a 7700k
As there's the native package in JavaScript called events, it provides an EventEmitter class, is it possible to know the exact name of the event that was emitted on <EventEmitter>.emit()?
the more expensive ones are 9900k's i think?
if i have like if arg1 == True or arg2 == True if theyre both true
what happens?
does it happen or not?
its true, so it happens
yep, your looking for exclusive or(one or the other)
24 USD with 2 vCore, 8GB DDR4 2666MHz, 60GB NVMe SSD Storage and i9-9900k @4.7GHz with other benefits
yeah
alr ty woo
@slim void editing is generally better.
deleting and resending is two requests
editing is one
galaxygate seems pretty priced up
new york is expensive
i wanna see the nixbench for that versatilenode thingy
yeah 
i might have to buy one for testing
i just dont want to buy a vps AGAIN and not use it
Up to you but to me that thing seems pretty sketchy
🤷♂️ if you dont want to dont.
hehe i have an uptime of 913h43m38s
whats sketchy about an open source piece of code lol
you can literally open it and see what it does
you want to do like .emit("bla") and detect that a bla was emited without having any listener to it?
something like a catch all listener?
I mean, events are emitted using the <EventEmitter>.emit() method, so if i have an event listener for example, <EventEmitter>.on('message', () => { ... }), is it possible to know for example when the message event is emitted, get the name of the emitted event
Hello guys, I have an issue, I want to list an array of emojis that is too long to fit in a single embed so Im trying to do a pagination to list them all. My question here is, how can I split a big array in pieces that will fit in different embeds?
Chunk the array
name of the emitted event? the event name is "message", if you have a listener for it, you already know its name
Chunk? 
if your looking to make your own events, you could also make a variable with the name of the event passed along with that event.
Oh wait nvm, i was planning to do some kind of iterations through them but then i realized <EventEmitter>._events exists that also includes their name 
theres also .eventNames()
(T, L) => Array.from({ length: L }, (_, i) => T.slice(i * L, i * L + L))```
Chunk the array and iterate through them, first parameter takes an array, second the length of every subarray
@solemn latch can a bot get rate limited for sending/deleting? If its a feature.
if you do it too much yeah.
and it will get you closer to your total ratelimit
you should be ratelimiting users from spamming commands
otherwise any command could result in a ratelimit
@sand dome Discord trims it.
It's not good to rely on spacing like that since it may appear differently.
Discord doesn't trim spaces for bots
@solemn latch but my bot has a feature where you set the counting channel. Then the bit deletes any message sent to that channel, and converts it to a sent msg. How do I rate limit a delete msg?
It does.
in that case, i would let your bot's lib handle the ratelimits tbh.
wdym converts it to a sent message?
do you resend the deleted message to another channel?
Tim no
So I have a counting feature
Let me just ss
You send the next number. Then it makes a new msg with the next number.
If u send an invalid num/text. It just deletes it.
ah so if you post a message, it deletes it and edits the original one?
if the number is correct
wait wut
Dms
anyway, the rate limit for deletes is much higher than send/edit, so you should be fine
while I was testing my play command for my bot
I got this error:
ReferenceError: Cannot access 'bot' before initialization
// PLAY COMMAND
if(command === 'play'){
bot.player.play(message, args[0]);
// As we registered the event above, no need to send a success message here
}
this is the command
You're using the variable bot before even defining it
so what should i change it to?
starting the long road of updating my codebase and api wrapper 😭
What reason are you updating it for
make sure your definition of bot is before you use it.
hey
@solemn latch
does anyone here use macos? cause i need help
Can u join my server or test a feature on my bot and tell me if its ok?
And not rate limited
typically no, but whatever i got a minute dm the invite
i need help
how to open port on macos? like i need my app to listen to a port but idk how to open
i turned off firewall
but no work
Depending on where you're tying to access the app from, you may need to port forward in your router
i turned off firewall
so
it should be able to allow incoming connections
from anywhere
That's not how it works
Your router also denies connections to a specific port unless the port is open
forwarded, that is. You need to go into your router admin panel and find port forwarding and configure the port
yep in order to be accessible from outside you need to tell your router that
If you're trying to access from within the same network, there is no need to port forward
keep in mind that random people may try to break into your systems. I set up a home security system once and someone tried to exploit the fact that the port was open. There was authentication for the web server listening on that port though.
how? do i login to cox or something and allow it?
I mean its better to search online to see an article telling you how to on your router, with a good warning explaining why you shouldn't
@drowsy crag
want to get updated to discord.js v12 so transitioning is easier in the future once new bot integrations are released, like slash commands and the stuff discord teased a while ago
v11 has been deprecated for awhile now too, so a real good reason to move off it
yup for sure
What are you actually trying to do?
I get the port thing, but for what purpose?
im stupid. the port opens upp when i node app.js..
Right
bot dashboard
Yeah, I'd heavily advise against opening a port to your router from the internet ... lol
What are some good ways to minimize the bandwidth usage of a discord bot?
The only reason it'd be applicable is if you're running a server and you want people to connect from the outside to it (ie. Plex)
When you say bandwidth, are you referring to a bandwidth server metric? If so, how much bandwidth is your bot reporting?
It’s just using a whole load of data I dunno if it’s all at once or just over time and specifically upload
For my bot, which is in 131 servers, there's like little to no bandwidth going on 😄
Yeah I think it might have to do with channel.stop typing being called too much?
I do call it twice for no reason
Idk if that’s the cause of it but my bot barely gets used either which is strange
@sturdy gazelle using intents?
No I don’t think so
I only go so far as to set the bots status
Indirectly ig cuz I do set typing
I really don’t need to it honestly works terrible
express deprecated res.send(status): Use res.sendStatus(status) instead dashboard/routes/discord.js:4:9
help por favor
The error is right there lmao
do res.sendStatus(status)
ah all good
Your client might need to be apart of the guild for the role data. If it sends you the interaction initiator, you can just get the Member by ID and check their roles
Role data is usually only sent on GUILD_CREATE
But how would i implement the restriction
Are you not allowed to just not respond to the webhook?
webhooks are generally not things you respond to.
But I want to restrict it to role-only members
And I don’t have any prompts it’s just in the cmd
I meant you could just return and end processing of the interaction if a condition isn't met
ah
Yeah but I want it to say like “restricted u can’t use this”
If the user doesn’t meet the permission
If the docs don't mention anything about restrictions they process on their side, I don't think there is anything like that. Does the interaction allow you to send messages only the user can see similar to clyde?
Because trying to do stuff like /nick causes clyde to send you a message
Hmm
Well it shows for everyone
Not just the user
So maybe I’ll make it only show to the user
hey what do i use for finding the time of an utc offset?
Assuming you're using JavaScript
The getTimezoneOffset() method returns the time zone
difference, in minutes, from current locale (host system settings) to UTC.
sorry should've specifed
Did discord js have an update around the 3rd of this month?
Discord.js v13 is still in development, and there's no ETA so we don't know
Did discord have an update around the 3rd?
Cuz that’s when my bot started acting all funny
A d s lol
@coral trellis
Adums
owo
@oblique robin you arent getting far with them ads 
Aw gone
It's probably a logical issue on your end. Dependencies wouldn't auto update unless you specified you wanted a newer version.
I don't believe Discord's API/Gateway has received any updates recently
Hm yeah it could easily be me
https://hastebin.com/idejifuxay.typescript
I'm getting an error that says :
"unexpected token } " on line 21
Why tho
I don't think anything is wrong there
there's a trailing comma inside the brackets
function meme() {
const url = "https://meme-api.herokuapp.com/gimme/1";
let value;
axios.get(url).then(function (response) {
value = response.data.memes[0].url;
});
return value;
};
Why is this returning nothing?
you're returning in a callback
that returned nothing too
make the func async and use promises
learn how promises work
that code instantly returns value
it doesnt wait for the promise to resolve
the callback in then does
is there a way you can make a bot advertise your server? or is there any out there can do one?
what about just like general advertising?
via an http post request
@earnest phoenix Dont get it
what exactly don't you get
I returned the promise still empty
show your code
function meme() {
return new Promise((resolve, reject) => {
setTimeout(() => {
axios.get("https://meme-api.herokuapp.com/gimme/1")
.then(function (response) {
resolve(response.data.memes[0].url)
})
.catch(reject(new Error("Failed getting")))
}, 1000);
})
};
what in the literal fuck
idk dud
axios.get is already a promise
Okay
what in the fuck
why are you wrapping it inside of another one
LOOOL
1 min
Promisify the promise shall we?

(await axios.get()).shit[number]
yeah the thing it it trys sending the message before I have the fucntion returning the link
at this point Idk
async function meme() {
await axios.get(
SyntaxError: await is only valid in async function
isnt that function asynced?
you either didn't save your code or one of your callback functions weren't async
@client.event
async def on_ready():
await client.change_presence(activity=discord.Game(name=f"playing {client.guilds} servers | .help"))
# await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=f"looking over {len(client.guilds)} server | ?help"))
print("yeah")
status = cycle(['{0} servers | >help', '{1} users'])
@tasks.loop(seconds=5)
async def change_status():
await client.wait_until_ready()
content = next(status)
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=content.format(len(client.guilds), len(client.users))))```
File "c:\Users\schwt\OneDrive\Desktop\Projects\py projects\bot but with cog\main.py", line 20, in <module>
status = cycle(['{0} servers | >help', '{1} users'])
NameError: name 'cycle' is not defined
please help
you probably don't have any function named cycle
@client.event
async def on_ready():
await client.change_presence(activity=discord.Game(name=f"playing {client.guilds} servers | .help"))
# await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=f"looking over {len(client.guilds)} server | ?help"))
print("yeah")
async def ch_pr():
await client.wait_until_ready()
statuses = [f"on {len(client.guilds)} servers | .help"]
while not client.is_closed():
status = random.choice(statuses)
await client.change_presence(activity=discord.Game(name=status))
await asyncio.sleep(5)
client.loop.create_task(ch_pr())
```i had this previously then changed to that
yeah np
5 seconds is too fast imo
you never started the loop as well, and why do you need to cycle an iterable that only contains 1 element
Anyone Know How To Make It So The Bot Command Only Works In 1 Specific Server?
I Need The Code
spoonfeeding not allowed
use if statement
the server id the message id was in, vs the server id you want.
if its the same, do it.
message server id == server id
just do
if(message.guild.id != "your server id") return
!==, i really don't like seeing !=
that'll be much better
oh
:v
inb4 message is not defined
its the same so yeah
how did you know he is using js smh
mind reading powers
no no

they just have a crystal ball
oh the crystal ball! it was found!
:v
well no
inb4 bdfd
if(!message.guild.id = 'server id'){
nO
No not =
Right?
no
oh
!message.guild.id is flase
oh
feck you
fuck me then
:clarksonsad:

==
ok
learn some basic js please

why not != bruh
wh?
oh wait i htought you were same person
:V
5am is getting to me
welp
generally inside the command i do {} only do returns like that in the command handler
if(message.guild.id == 'server id'){
}else{}
yeah that'll work
tha'll do. tha'll do.
Huh
<User>.discriminator
You guys are champs for taking these questions and responding 😄
how do i have my bot join a vc? it says i need the PyNaCl library but idk how to get it
You use repl.it?
eww
Anyways,
its easy to keep stuff running
you have to search in the packages PyNaCl
how do i do that?
wait..
im kinda new to this
and install
yes
Almost everything
like...?
if you have no issue with it, its fine.
It only runs the repl for 30m
not if i keep pinging it with uptime robot
But.. then your token will be leaked
not if i have it in a env
you can hide your token with env variables
and to make repls private you need hacker plan (which i have)
expensive
private repls are un-needed if you use env variables
message.channel.send('link 1', 'link 2', 'link 3')
Will The Bot Rotate Throught The Links?
Or Send Firts One Only
no
rotate?
is the event guildMemberAdd a Presence Intent or a Server Members Intent?
dont turn on presence intents if you dont need them
i mean my presence intent got declined when whitelisting and i want to reappeal
oh
guildmemberadd is guild_members intent
i use it for a good reason, but i want to show everything i use it for
it will not rotate.
Then How Do I Make It Rotate
a loop
message.channel.send('link 1')
message.channel.send('link 2')
message.channel.send('link 3')
depends what you define as rotate, as in it edits every few seconds to the next link, or every time the commands run a different link is sent?
nearly
0-0
When the command runs again, it shows a diff link
in the dashboard?
put the links in the array, have an int that goes up each time the command is run, if the int is higher than the length of the array reset it to 0.
use said int to get the current link from the array
ok thanks
whats a DM channel called?
Hey so, i was trying to make my own bot but while following the tutorial it didnt work...
it worked from to the coding part but then it did'nt work.. Btw i'm on mac so that might be the reason idk
the given link in #502193464054644737
i cant download from steam cause my software denies it
the steam one is a really bad one imo.
I'm trying to display the total shards for my bot on top.gg and this is my code
I'm not sure why it isnt working
im also not a huge fan of "anidiotsguide"
i prefer. https://discordjs.guide/
Ok thanks
i'll try it later
that would set the guild count to your shard count. .postStats(serverCount, [shardId], [shardCount])
also, dont think you can post stats before being approved due to the lack of a token.
oh i see, ill try that out. I have 2 discord accounts, im just logged into this account on my laptop. the bot is owned under the main
anyone know py?
even that doesn't work
yes
what errors or issues are you having?
the bot is not responding
have you done any of the code yet?
yes
#general-int for turkish
what does your code look like? please remove your token.
wait i need to find the code again
Great.. i cant find it
ah. well lmk when you do.
you will need to do atleast all of these for your bot to go online and give a response.
https://i.imgur.com/ETyIIKT.png
every one of them. skipping steps, or parts of steps and it wont work.
The language is JavaScript right?
yep.
ok
How do you find the amount of users across all guilds? Like a total sum
easiest way, probably mapping all guilds by their memberCount and reducing it.
^
Well you don't need to map first. Lol
oh shoot you are right
What language, though?
js
1 sec
So like bot.guilds.cache.reduce
client.guilds.cache.reduce((x, y) => x + y.memberCount, 0)
yo this is not an easy one to explain aight
interesting
took me a while to grasp reduce() in all its glory
ok fair
So first paramter is function
its hard because everyone x y's it
i also have another question.. How do i restart my bot?
And second parameter is the initial value
"accumulator, currentValue, currentKey, and collection", would this be collection?
for now, while developing you can just cmd + c while clicked on the terminal
ok
so it's reduce( (accumulator, currentValue, currentID, collection) => { return accumulator }, defaultValue) essentially
the guide goes into pm2 and stuff later.
you always have to make sure to return the accumulator which, well, "accumulates" data through the loop - it's passed down to the next iteration loop
It may take my a while to grasp this 😅 I'll read the docs online and research it, ty!
Sure, and in the meantime what I sent earlier is the literal answer, for discord.js 😂
Thanks 🤟
I use it in many places, myself, so I made a util function for it ```js
client.getAllMembers = () => client.guilds.cache.reduce((x, y) => x + y.memberCount, 0);
so i've put all the code to get the !Ping command working but it still isn't online
did you run the code?
i cant
why
the bot is offline
the bot is offline unless you run the code
how can i run it?
the guide covers this, please dont skip parts.
i'm not thats the thing
the guide covers it.
uhhh.. whats this?
code: 'MODULE_NOT_FOUND'
did you install discord.js?
yep
while it was installing did it give any errors?
it should say somewhere in the error stack what module is missing
throw err;
^
Error: Cannot find module 'discord.js'
Require stack:
- /Users/apple/mybot.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/Users/apple/mybot.js:1:17)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/Users/apple/mybot.js' ]```
thats what it shows
As a sidenote your code shouldn't be directly in your user's folder Make a new folder in your Document or something
because now you're mixing system files and bot files and it's going to get messy real quick
what if his bot is called apple?
now it shows this:
at WebSocketManager.connect (/Users/apple/node_modules/discord.js/src/client/websocket/WebSocketManager.js:133:26)
at Client.login (/Users/apple/node_modules/discord.js/src/client/Client.js:223:21)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:1652) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1652) [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.```
Yeah no that's now how file systems work 😂
nvm
its not called apple
yea just saw the path
it's not that hard to follow the tutorial, it tells you how to get the proper token
yep
skipping parts of the guide wont work.
i copy pasted the token
maybe you should go through a few javascript tutorials as well before trying to write bots.
youll do this for litterally days when it could take 20 minutes if you dont skip parts.

just skipping the text and reading only the codeblocks wont help
and the main prob it shows invalid token
Also, again, skipping the part about "learning javascript before making a bots" won't help at all
the guide expects you to at least have the basics, which you clearly don't have
i learn JS ok
done it for a year

but you didnt know about installing a module?
or starting your project
i'm new to making bots ok
dont judge me
Or, in this case, probably, just copy/pasting a single string in the right place
pretty much everything you make in node.js requires some external modules
This has nothing to do with "bots", it has to do with the basics of nodejs.
not just bots
i know
There are links to nodejs tutorials and courses here :
#development message
fALse
how do i get the message.mentions.members.first() id?
message.mentions.members.first().id
Remove the .members at the end
i'll prob get a better guide here:
https://discord.js.org/#/docs/main/stable/general/welcome
That's a guide to discord.js not node.js
yes
i know there are cases where its not true, but most stuff usually depend on some external Modules.
i can prove it by doing a whole discord bot without external modules, not even ws, just the built-in fearures
they're languages
i did, and it says the the id is undefined
Good for you, nobody cares.
that wasn't the point
well yeah
i want to see this bot though
also using modules make developing faster, with no need to make your own methods for certain stuff
do it open source, i actually am curious
Yes please do go ahead and make it without any external dependency
Literally no use of require or import, go ahead
if its only message.mentions.members.first().id it says that the id is undefined
message.mentions.members.first().id not message.mentions.members.first().members.id
the latter makes no sense
you could make it in a single file, but it would be horrendous to read and to keep track of stuff
you don't get the members of a member
Also it wouldn't say id is undefined
would it maybe say cannot get property id of undefined ?
If I make the dbl vote webhook be one of my websites thing
How do I get what the webhook is sending?
you.... receive it through the http address the webhook is sending to.
it's a simple POST message.
Like the webhook sends it thru the url?
I dont understand lmao
Me no smart lmfao
A webhook is literally just an HTTP POST request to a specific URL that usually includes a secret or a token
So first off, what do you mean by If I make the dbl vote webhook be one of my websites thing
because... I'm not sure I fully undrestand what you're saying here
https://repl.it/@takipsizAD/dblwebhook#.replit well it is example to dbl webhook
your webhook receiver is just an http server, same as one that would host a website, just specialized for receiving inter-server data.
yes.
I don't know what I'm saying
I don't understand http too well
Members can be undefined if you haven't fetched them
you might want to get message.mentions.users.first().id instead.
that one's always available
did you even mention anyone in your message
1s
How can i make a forEach to deny the send messages permissions to a Muted role on every channel the guild has
guild.channels.cache.forEach()
ok so I'm completely brain dead...should this console log the given guild's name? It's straight from the docs
client.guilds.fetch('797555277146357792')
.then(guild => console.log(guild.name))
.catch(console.error);``` and the error is ```js
client.guilds.fetch is not a function```
oof
client.guilds.cache.get("id")
try client.guilds.cache.get(id)
you don't need to Fetch a guild. Guilds are always cached
Then why tf is the docs telling me different...also I tried the .get method
and what happens when you use get
the docs provide a fetch method just in case its ever needed, as guilds can be removed from cache if dev's force them to be.
I don't remember ever seeing a guild not be already fetched, that would be an extreme edge case, tbh.
didn't know that...and of course it works when I go to show you what happens 🙃
I use discord.js-light so my understanding might not be quite right, but surely if you fetch a guild that is already cached it will just use the cached one without fetching?
yep
Oh right some people use that thing. smh
It does look through the cache first yes
So surely their code should work?
Depends what the client variable is
True
so when do I use this way of defining things? I have always used it in d.js v12
const bleh = client.guilds.cache.find/get(u => u.id === `123`)```
No but it's the same with djs
get("id") , get doesn't take a function
That's for find, .get just requires the id
It's client.guilds.cache.get("264445053596991498") for example
Also make sure you're inside an event handler, if you're not inside an event, the cache doesn't exist yet
then why wouldn't it work when I used .find? It was getting an error at .cache
What error
Has the bot ready event happened before this?
Some functions can't be used until the bot readies
Inb4 v11
That would be funny
I hate my computer...why isn't it throwing the errors anymore 😅 either way it's all good and working lol
I use djs v10, why doesn't my bot start?
ok then why won't this work? I've never ever had this issue 🙃
const mainGuild = client.guilds.cache.get(`797555277146357792`);
const devOne = mainGuild.members.cache.get(`495702607982231586`);```
The second one might not work, if the member isn't cached.
But the first one, yes it should always work as long as you're inside an event handler.
so I need to fetch the member? the member is going to be the owner of the guild and bot so it better be cached lol
I appreciate the help...it's 3:30 am and I need sleep lol
Yes you do bye goodnight sleep well don't respond
It won't let me send a message to them...it's saying devOne.send isn't a function when I try to send a message to myself
I need to get this done or I honestly won't be able to go to bed because it should be simple
Tired programmers are dumbass programmers.
Alright so I've been toying around with slash commands... and I definitely like them way more than normal commands
they work even if the bot can't see the channel, and the bot can reply to them even if they don't have the SEND_MESSAGES permission, you don't need a websocket connection to use them
im currently using this code but idk why total shards isnt showing up on top.gg
client.on('ready', () => {
setInterval(() => {
dbl.postStats(client.guilds.cache.size, client.shards.Id, client.shards.total);
}, 3600000);
});
const wyr = new Discord.MessageEmbed()
.setTitle(`Would You Rather`)
.setAuthor(message.author.tag, message.author.displayAvatarURL())
.addField(`${response}`, `What would you rather?`)
.setColor(`RANDOM`)
.setFooter(`React below with A or B`)
.setTimestamp```Why if i try to send this embed it says "cannot send an empty message
Well that's part of the code. what's the rest of it?
@umbral zealot https://hastebin.com/meralaqaju.typescript
Ok and... does it work now?
Are you sure that's the right command that's causing the error?
And this is discord.js v12, right?
if you do npm ls discord.js in your project folder
I don't see how this code could cause that error then
oof
Like, that's... correct code...
i had this a time ago and then i fixed it but i tried same thing again and it doesnt work
and how i fixed it was gjust changing thename to embed
im just gonna try to write a new embed
Honestly though, that code looks fine.
other than the fact that you're using the same variable for message inside the callback
but that's... still scoped so it should work even if it's confusing
@umbral zealot its the embed i tried to make it send js message.channel.send(`What would you rather`, embed) and it sends What would you rather and it reacts but it doesn't send the embed
try doing message.channel.send({ embed }) instead
honestly I dont see anything wrong with it
Could also be message.channel.send("What would you rather", { embed }) if you want both message + embed
https://tinyurl.com/y6bbtpnr works fine for me
i hate my life
okay will try
nah the messsage was only a test
I did what was shown in the hastebin file and it worked so idk what is wrong with it for you
which line does it direct to when it shows the error
oh nvm
xD
with {embed}
thanks
but without {} in my other commands it works fine so dumb command
but it works so i will nvm it
Hi one question
Is there any way to create timer which stops a fucntion after 10 seconds in js
pls ping me
setTimeout
wrong it executes after sec
and not stops
because you did it wrong
show your code
thats why i asked how to do it
it's simple setTimeout syntax
...show your code
setTimeout(function(){ alert("Hello"); }, 3000);
this executes after 3 seconds
correct
but i want a timer xD
like after 3 seconds it will stop the function
...so why would you want a timer
a timer is for repeating actions
a timeout is for delayed actions
to terminate a code
i still don't see why you would need a timer for that
you can execute anything and everything in a setTimeout callback
i am making a custom command bot and if a user ues a while loop i could stop it with a timer
what's it going to do for 3 seconds
like
while(!a){
//endless loop
}```
are you sure custom commands which execute code directly are a good idea
la can stop it with the timer
in the first place
because attackers can do actual proper harm
yes because there are function like Send
u cant use your own function
someone could just make your bot delete every channel in every server its in
or just leave everything
no because u cant acess it
that's what you think
u can only acess message object
not client
i am not a dump xD
client is under message
so how would you block accessing client
checking for it as a string?
function executecc(ccstring,message){
try{
function SEND(stringmessage,channelid){
channelid = String(channelid);
if(!stringmessage) return "No Message provided!";
if(channelid) channelid = message.guild.channels.cache.get(channelid);
if(!channelid) channelid = message.channel
channelid.send(stringmessage);
}
return //execute function
}
catch(error){
return clean(error);
}
see this is a function
if use client it will throw undefinded
Stopping a while loop? Okay, I'll just spawn million child processes. Or, maybe, DM every user the bot sees a thousand times.
since it is over the scope
String(channelid); what are you doing
that code formatting tho
stolen
probably
no
i can code bruh
you might not have an improted client in that file
but attackers can still access it
i wouldn't steal that if i was starting out tbh
just as a ref
how?
message.client is the client object
M e m o r y 🤩
lol let me try
you can also require/import everything, find where client is used
use fs
do tons of more harm
It all comes back to... oh look, public eval being a bad idea! :o
this is the reason why custom commands are not executed directly but rather often have their own language which is then preprocessed into actual code
nope undefinded
anyone use puppeteer for web scraping?
i have a problem here
so when i try to scrape from my local computer its working
but when on host its not working
that is not eval i use a lexer for it,i did not send my code bacause it is too big
If this doesn't scream "public eval", I'm not sure I'm understanding this right, then
like if(token=Send)
get args
function send
like this
eval is never good
how can u excute client when u have only acess to message
you could run a Public Eval command on a Express server that got no connection to your Bot and then limit certain stuff, But i dont think this is worth the efford
why
bcs its stupid, like a public eval command
a custom command bot + multi purpose is on hype
i forgot what to put there:
i wanna do that if args 2 isnt a number it will return
and i forgot what define the number
like if(args[2] != ??)
!Number(args[2]) @tardy hornet
k ty
how does getting invite info work?
let invite = message.guild.fetchInvites(args[0])
message.channel.send(invite.channel)```
this doesn't seem to work
does not work!
thats kindaweird cause the documentation says message.client returns the actual client
collector.on('collect', m => {
let tradepokemon = m.content
console.log(m.content)
});
const exampleEmbed = new Discord.RichEmbed()
.setColor("RANDOM")
.setDescription('Trade request.' + "@<"+firstmember+">" + "'s " + found.name + " for " + targetMember + "'s " + tradepokemon)
.setImage('')
.setTimestamp()
.setFooter('Made for your server!');
message.channel.send(exampleEmbed);
const reactionEmoji1 = "❌";
const reactionEmoji2 = "✅";
let msg = await message.channel.send();``` hey is there any way how i can define tradepokemon outside the scope of the collector?
let tradepokemon;
tradepokemon = 'dawudhawd'
aha and let tradepokemon; is defined inside the collector scope?
or outside?
Outside of course
anywhere lol
Before calling your collector
If you wanna change the var inside the collector to use it later again
yeah i know
thanks!
how would i actually check whether the m.content contains any type of text?
m.content.includes()
How to make Python bot
...
https://sourceb.in/378Rt9CxX1
I'm getting : Invalid Token: 'const' on line 17
(Javascript)
Why tho
Can anyone check for errors and correct me?
take a look at the discord.py library
bruh are u copy and pasting that code
the command code is should be inside the run function
module.exports = {
name: "lockdown",
category: "owner",
run: async (client, message, args) => {
///the code
}
}
@earnest phoenix ur putting the code outside of the { } 
@sacred aurora I'm not
I mean I copy pasted from another code in my bot
Since I'm a lazy ass
WAIT
I'm so dumb
I didn't notice
This
Thing
Bruh
brrruhh
How to delete an already sent ticket to the discord support?
Did you threaten a staff
{"code": 0, "message": "You are being blocked from accessing our API temporarily due to exceeding our rate limits frequently. Please read our docs at https://discord.com/developers/docs/topics/rate-limits to prevent this moving forward."}
when i try to open my bot i am getting rate limit error i have 3,200 servers i have 3 shards thats weird I'm using v12.5.1
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
congratz you got ratelimited
I can open the bot on my own computer but vds also does not work
check through your code and make sure it follows the ratelimit guidelines from the link mentioned
You won't be able to start it
you got ratelimited
does that show up when starting your bot?
yes "sharding ready timeout shard 2 client took to long to do"
const Discord = require('discord.js')
const { ShardingManager } = require('discord.js')
const manager = new ShardingManager('./bot.js', {
token: ayarlar.token,
totalShards: 3
});
manager.on('shardCreate', shard => {
console.log(`[${shard.id+1}/3] Numaralı Shard Discord'a Yeniden Bağlandı ve Aktif.`);
});
manager.spawn();
manager.on('message', (shard, message) => {
console.log(`Shard[${shard.id}] : ${message._eval} : ${message._result}`);
});``` this is a my sharding manager
i have 3,200 servers
yeah you got ratelimited, re-read how to shard properly
can someone explain how it works, nothing is wrong with it, I just dont know how it works
client.guilds.cache.reduce((a, g) => a + g.memberCount, 0)
@drowsy crag get some beaning here
b e a n
tsk
do you see any error @rustic nova
oop
i can't help you, i can only say you got ratelimited from logging in
check the ratelimiting guidelines
Thats so weird because the bot is running on my computer but vds also does not work
When do you need to start sharding?
If I remember correctly , there is something in dpy to reset all the cache . Do you know what it is? There is something I am pretty sure , I just don't remember what its called.
Note: I don't want to restart
Ping me if you know something
sharding is required around 250,000
i suggest you to start sharding with 20k servers or so
thankss
what
or is it not? https://i.imgur.com/s2PT54y.png
thats for "very large bots", which have special sharding requirements
sharding is required at 2500 and recommended at 1500
Can confirm, you need to start at 2500 and add a new shard every 2500 after that
explain
why
msg.guild.members.forEach(member => {
member.setNickname(e- + member.user.username)
})
that
when the bot has every permission
and i the owner
use this command
it returns missing permissions in the console log
is your name above the bots?
uhh
why
its below it
also
im using it to change other peoples nicknames
everyones nickname*
and idk why it wont change them
makes no sense
@earnest phoenix make sure that the bot's role is above all the roles of whoever you're trying to nick


