#development
1 messages · Page 1850 of 1
I've been struggling with this for a week
you can check if its a network issue with the raw event
client.on("raw", r => r.t)
that should show you the guilds being received at login
if they are coming very slowly, its a network problem, or you have something heavy running in the script at the same time
if they come very fast but then get stuck for like 15 seconds on a single guild, then you have bugged guilds
bugged guilds can be caused by bot farms and guilds who abuse discord's limits
not much can be done about that, sometimes you cant even leave them
Can't leave them?
Guild.leave()
ye, like you send a guild delete request and it errors
Woah, why?
because discord is a good company :^)
👍
what abt me, receiving select menu events from other bots?
better yet, receiving select menu CREATION events
Lol
Oh and one more thing, is there anything I should know about when sharding?
Multiple connections to databases or something?
should be fine to have one connection per shard
Hosting api's/dashboards at a bot level is a concern.
if you write files you have to take special considerations
but dbs should do that for you
another thing is rate limits, each shard is only aware of its own rate limits, so if you do cross-shard operations, you have to take care of that
for example sending a message to a channel in shard 1, from shard 2
Ok
and message.channel seems to be null
or undefined
return null
}```
This seems to be triggering
Nevermind it wasn't that. I accidentally removed the await channel.send part
lel
Why can't we blacklist guilds?
I mean natively via Discord features
ask discord :^)

- blocking users only make it make them more visible
- discord doesn't have a native "mute" feature for text channels
- they changed a great color to an oversaturated one
- bots can't joing groups
Yis
there are many flaws, those are the ones I remember from the top of my head
Fuck that we want perks for boosters
we want perks for bot devs
Discord does
I want just something convenient from Discord
Even allowing customization would be greatful
congrats :)
lol
I remember Xetara was bitching around because I didn’t mark something I wrote as sarcasm
But calling discord a good company should be a banable offense 
How would I check whether a message has an attachment? Tried this:
if (!message.attachments) {
message.reply("Please attach an image to the message!");
} else {
// do stuff
}
But it doesn't seem to work. I don't get the message, "Please attach an image to the message."
The property attachments returns a collection.
If no attachment was send it’s an empty collection but still a collection
Therefore it’s always true
Check the collection size and there you go
ah i see thanks. mb didnt read the docs closely
Does anyone know how to make a leaderboard?
Using a database
It depends on what you want out of it.
Leaderboards are constructed from data.
Like scoring points / hours
You just store your points in the db and then get the top 10 or whatever for the leaderboard command
What Mac said pretty much still applies
I’m basically asking how can I make one? Do I need like to program everything or does the bot program most of it??
No you have to make it
Ik the commands are !slut !work and !crime
But i’m not sure where to find the boy
bot*
There might be some package you can use to do it depending on the lib your using
Also lets keep it sfw please
Sorry it was the commands
Still
Yeah I know once again sorry
Have you ever heard of any? Like any bot or is it a specific one
It depends on what lib you use
No. I don't use YouTube tutorials.
Ahh alright, Thanks though
Someone here know why tf my bot starts using tts without any reason? 
Is it possible to check whether the attachment an user posted is an image or not?
Ex.
if (!message.attachments.first()) {
message.reply("Please attach an image to the message!");
} else {
// do stuff
}
You could check the extension but it won't guaranteed to be a valid image
You can fetch the attachment as buffer and check the magic headers
Or maybe load the attachment in canvas and make sure it doesn't error, to name a way
if i did
while (condition) {
// code
}
console.log("a")
it will only log a if the loop is finished right?
yes
oh gud,
i can make like a repeat until statement kind of thing 
mhm
If I used PUT method onto api, the other property which is not used by PUT will be ignored by receiving end? For example, I'm sending data [{name, description, options, type, guildOnly, cooldown }] where here guildOnly, cooldown is not required by the server.
Yup. Just wanted some confirmation, since I'm registering them using map with the extras, not like others who use array.
[{name:string, description:string, options:?[object], guildOnly:boolean, slashcommand:?Promise, selectmenu:?Promise, button:?Promise}] This is what I'm sending to discord API to be exact, lol. Using name as the key
does anyone know how to make a box around my text on top.gg to look something like this using html or css https://cdn.discordapp.com/attachments/714045415707770900/878083827791179886/unknown.png
Looks like a code block, but not sure
Markdown code block iirc
Ok
anyone know how to track invite urls via a Ganalytics 4 property?
how to you make it that it requires mention then put into the embed
Requires you to mention someone?
yes
What language
then put into the mention and the user that used that command in and node.js
d.js?
discord.js
If so you can get the mention and use an if statement to see if they mentioned someone if not tell em to, if they do use it and put it in the embed
like for a hug command
Okay you can do this for any command
ok
Grab the mention and put it in a variable, use the variable to check if they didn't provide a mention in an if statement
something like
const member = <Message>.mentions.members.first()
if(!member) return <Message>.channel.reply('Provide a user you wanna hug')
ok
how to add the user mention to the embed?
const member = message.mentions.members.first()
if(!member) return message.channel.send
(${message.author} Provide a user you wanna hug)
i have this
just give it member
iirc it is a mention by default
const { MessageEmbed } = require("discord.js");
const { LOCALE } = require("../util/EvobotUtil");
const i18n = require("i18n");
const fetch = require('node-fetch');
const superagent = require('superagent')
const akaneko = require('akaneko');
const love = require("discord_love");
const { discord } = require("discord.js");
i18n.setLocale(LOCALE);
module.exports = {
name: "hug",
aliases: ["cuddle"],
description: i18n.__("Vote"),
async execute(message, args) {
let commands = message.client.commands.array();
const member = message.mentions.members.first()
if(!member) return message.channel.send
(${message.author} Provide a user you wanna hug)
const img = await love.hug()
let akanekoSan = new MessageEmbed()
.setTitle(${message.author} hugged ${message.guild.members.cache.get(args[0]) || message.mentions.members.first())})
.setColor("RANDOM")
.setImage(img)
.setFooter("yall look cute <3")
akanekoSan.setTimestamp();
return message.channel.send(akanekoSan);
}
}
here the code
@earnest phoenix
oh god
🤔
the error is the title
What is the error
Also use code blocks please
ok
.setTitle(`${message.author} hugged ${message.guild.members.cache.get(args[0]) || message.mentions.members.first())}`)
this the error
well you have an extra )
relly
yes
problem
You can't mention people in titles I dont think
Has to be a description
U cant mention ppl in titles
Make it to description
And it’ll work
ok
How do you create a table relation with pg sql queries
@earnest phoenix are you looking for foreign keys (with REFERENCES)?
Yes I am
I found an example on the internet
umm is this a thing
client.users.cache.find(user => user.id === "user-id")
help
or should i use get
idk
help pls
imma try get
if you are going to use an id
just use get
k
This function isn't working in reactions.
promptMessage: async function(interaction, author, time, validReactions) {
time *= 1000;
for (const reaction of validReactions) await interaction.react(reaction);
const filter = (reaction, user) => validReactions.includes(reaction.emoji.name) && user.id === author.id;
return interaction
.awaitReactions(filter, { max: 1, time: time})
.then(collected => collected.first() && collected.first().emoji.name)
}
It used to be message instead of interaction but I replaced them, but I didn't think it would be that easy.
This is the code I did:
const m = await interaction.channel.send({ embeds: [mainEmbed] });
const reacted = await run.promptMessage(m, interaction.member, 30, reaction);
await m.delete(mainEmbed);
.. and the problem is that when I react with the reaction I specified, it is not deleting the embed.
I couldn't solve the issue, here's the code: https://sourceb.in/cZW3o1Ldj1
would anyone know why /api/v9/applications/xxxx/guilds/xxxx/commands returns a 403 50001 Missing Access, when the application has access to the guild id provided
does it have the application.commands scope?
Ah thank you
pk
How do I store a OAuth2 refresh token in cookies securely? If I enable httpOnly, then I can't access the token through node.js/React.
Enabling httpOnly won't allow you to access it from the client-side, you will be able to access it from the server when the client makes a request, for example
I read a lot of guides yesterday but none of the described how to actually access a httpOnly cookie. How do I get it from the server?
Yea I'm using a cookie parser
its just like this then
So the cookie is being sent with the request, I just can't access it otherwise, right?
the cookie is stored on the client, and sent with the request, yes
I am trying to make context menus but i dont get the apps options and no error
Handler: https://srcb.in/AcqnI7Pymh
Event: https://srcb.in/uBF48suoLh
Command: https://srcb.in/xmRzWKwwmL
p.s. slash commands work
That's confusing
You're mixing sync methods with async
use a for loop
You can't use async in array.map()
forEach and async this never goes good 🤔
@drowsy crag
Got it
dblpy is deprecated?
It's topggpy now
I am trying to make context menus but i dont get the apps options and no error
Handler: https://srcb.in/AcqnI7Pymh
Event: https://srcb.in/uBF48suoLh
Command: https://srcb.in/xmRzWKwwmL
p.s. slash commands work
pls helpl
You posted that already
ik but my slash commands are working and ur giving a solution which i dont need
did you set the command type?
Bro clickyboys are sick
hey all!
i wanted to ask about that whenever I try to download one file from AWS S3 through console, I am getting following error:
can anyone help with it?
thanks in advance btw
Can anyone tell me what this means?
raise HTTPException(r, data) discord.errors.HTTPException: 429 Too Many Requests (error code: 0): 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.
you've been rate limited?
the error kinda explains it pretty well
very well actually
but i didnt do anything thats the problem
the bot just stopped working
because its been making too many requests, check your code maybe you have a loop which is always true or something. there are loads of possibilities
Check your code and console. They don't rate limit people for fun.
And read the link to the docs in the error message carefully.
did you try to mass dm people or mass assign roles for example?
rate limited basically
how long is this rate-limit?
You have to check the headers
The bot is back online
alr
the ban is usually 1 hour
is it ligal or like is it against the rules to have google ads on github pages?
ping in replies
Idk.. based of a template thats modified like a bunch but no one can see the modifications lol
would it make since to do it there ? or.. should I make like ads sections lol
"If you are found to do so still, and we find out, you WILL have to PAY us $20 " lmao
u can have ads there, u can do whatever as long as it follows their regulations
lol
qunsequences
I tryed my best spelling it
tryed
and too laze to search up every word that idk how to spell
tried...
lazy*
Is this grammer class... ?
grammer*
The grammar police is watching you!
yes this is grammar* class
I thought it spell grandma
anyone else having issues with shards launching? :/
Are you getting errors in your logs?
I get the 4th shard and it timesout
I check discord status for servers and they online
8.5k server 5 shard right? 1.5k per shard
Unavailable guild maybe? Anything in your code that checks for guilds on startup?
or is it 2,5k
I usually keep it around 1k per shard
Unavailable guild maybe? this is what I am thinking
900 - 1,200 to be safe
If you have anything that checks guild on startup just check if the guild is available before attempting to fetch the data.
Why didn't I think of that
thank you
Been there, done that, got the API ban to prove it 😂
Infinite error loop while I slept causing 1k reconnects and getting locked out for 72h.
Oooof. Lets hope I ain't API Banned 🤦♂️
why i am getting this error?
at RequestHandler.execute (/home/runner/Bot/node_modules/discord.js/src/rest/RequestHandler.js:172:15)```
You need to install latest version of node.js
I got told i could clone this: https://replit.com/@ConnorBrewster/Nodejs-16 and it would install it, i am using repl.
Hmm never used Repl. Sorry
that uses node 16.4
you need node 16.6
And, is there any way i can change it to 16.6 using it?
its nix
https://developer.mozilla.org/en-US/docs/Web/API/AbortController/AbortController AbortController is introduced in V15, v16.4 still should able to run it, just the warning will come out
error: creating directory '/tmp/nix-shell-67-0': Disk quota exceeded
sh: node: command not found
nix error: building nix env: exit status 1
error: creating directory '/tmp/nix-shell-73-0': Disk quota exceeded```
reload and try again
Ok.
i just realised
theres a new node version like every 6 months
meanwhile im still on node 13 lol
How can i give e a value? Everytime a message gets deleted, the bot crashes
import Discord from 'discord.js'
import { Command, CommandProps } from '../@types'
import { client, db } from '../index'
let e: CommandProps
export async function messageDelete() {
const {
message
} = e
let channel = await db.fetch(`modlog_${message.guild?.id}`)
if (!channel) return;
const deleteMessage = new Discord.MessageEmbed()
.setTimestamp()
.setFooter(message.member?.user.username as string, `${message.member?.user.avatarURL}`)
.setAuthor(`Message Deleted`)
.setColor("RED")
.addField("Deleted by", `${message.author} - (${message.author.id})`)
.addField(`Deleted in `, `${message.channel}`)
.addField("Content", message.content)
var sChannel = message.guild?.channels.cache.get(channel) as Discord.TextBasedChannels
if (!sChannel) return;
sChannel.send({ embeds: [deleteMessage]})
}
literally just message.e = whatever
what is that e supposed to do?
and what are the command props?
where are they defined?
right now your e is empty, it only has a type but no value
that's the type not value
Hmm
also, your messageDelete function has no aguments
how are you supposed to know which message it is about?
it doesn't take the time anymore ?
wow
I'm fucked
no it doesnt
also, you should never import from index, that creates circular dependencies
Hmm
Would this work?
export function getGuild(ID, client) {
return new Discord.Collection().concat(...botSharder.manager.getClientValues("guilds.cache")).get(ID)
}```
Thats the code I came up with to get a guild with sharding
You can concat a map/collection?
Yes
2021-08-20T13:36:03.402Z Preparing to connect to the gateway...
node:internal/process/promises:246
triggerUncaughtException(err, true /* fromPromise */);
^
[UnhandledPromiseRejection: 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(). The promise rejected with the reason "#<Response>".] {
code: 'ERR_UNHANDLED_REJECTION'
}
/home/evan/node_modules/discord.js/src/sharding/Shard.js:160
reject(new Error('SHARDING_READY_DIED', this.id));
^
Error [SHARDING_READY_DIED]: Shard 0's process exited before its Client became ready.
at Shard.onDeath (/home/evan/node_modules/discord.js/src/sharding/Shard.js:160:16)
at Object.onceWrapper (node:events:514:26)
at Shard.emit (node:events:394:28)
at Shard._handleExit (/home/evan/node_modules/discord.js/src/sharding/Shard.js:392:10)
at ChildProcess.emit (node:events:394:28)
at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12) {
[Symbol(code)]: 'SHARDING_READY_DIED'
I love sharding
First part is just the hashed client id
Anyone who can see the bot knows that part
ye but...why?
How would I check whether the channel a message was sent in is in a category?
Ex.
if (message.content === `${prefix}score`) {
if (!message.isInCategoryOrSomething() {
// do stuff
} else {
return;
}
}
Why cover it up when people know it?
why show it in first place, that's my question
alr ill take a look. thx
Ok, gone
Its still in your message though
yea its TextChannel#parent thanks
thats an extremely inefficient way of doing it, you're trying to transfer the entire guild cache to get only one value from it
btw, I meant in the log itself, not on the message
like, if you have access to the server you already have the token anyway, no need to add it to a log
Ohh
I didn't add it to the log
discord.js does it by default
When printing the debug event
djs is weird then
raid shadow legends > python
at least you don't get ads for one
I'm going to be honest, I switched to TS partly because I felt like I wasn't a "real" programmer if I programmed in Python
Programming in Python is 100% acceptable.
TypeScript doesn't make you a better programmer.
But it's great to learn new things
I'm probably just going to go back to internal sharding
So I don't have to change stuff
if you want to be a "real programmer" you have to go for C/C++/rust
According to whom?
begone seas and crabs
I code in html, I feel superior
😩 yes
https://srcb.in/hjzmc4CP9i why at the console log at line 18 they are both undefined? if i check in the database they are there fixed
The ts problem you had or what?
nah just problems with custom marked extensions but I finally figured it out
You're adding a lot of listener events somewhere (on process)
I'm not even adding listeners
Your program is somewhere.
process listeners are added by broacaslEval and fetchClientValues
Oh
Yeah I added fetchClientValues
But its in a function
export function getGuild(ID, client) {
return new Discord.Collection().concat(...client.shard.fetchClientValues("guilds.cache")).get(ID)
}```
So does that mean every time I call the function, a listener will be added?
yes but its removed afterwards, unless you call it too many times at once, or its crashing
also, that code doesnt make sense
How does it not make sense?
fetchClientValues returns a promise
Oh
you're using the spread operator on a promise?
I thought it would return an array
also, as i said before, thats a very inefficient way of doing it
you're transfering the full guild cache via ipc to get a single value from it every time
Whats a better way?
broadcastEval
also, what are you using the returned guild for?
js has terrible support for serializing complex types
its always better to work with primitives
Mute timer
Its run in a setInterval
When the time is up
It gets the member
and tries to unmute them
i know to to solve
where is this code running? manager or shard 0?
Hi
its normal discord.js problem
put client.maxlisteners(0) at end at below of client.login
for comment in reddit.multireddit('spez', 'fun').stream.comments():
print(comment)
thats not a solution, thats hiding the problem
wait its not exact
how can i generate this 'spez', 'fun' thing
thats not a solution, thats hiding the problem
u cant do anything else
it isn't complete string
yes you can
??
write correct code
dot posts are not allowed
umm.. can anyone help me?
ok
They're passed as different arguments
No idea. It's just in a file and I give it client
def multireddit(whatever_string_1, whatever_string_2):
...
In setInterval
u have badge
subs = [x.strip() for x in sub_file.readlines()]
print(subs)
for submission in reddit.multireddit(subs).stream.submissions():
print(submission)
i was doing something like this
if that code is running in all shards, then you dont need any of that, just use client.guilds.cache directly
What package are you using?
praw
since you said it's something like *kwargs do i need to make a generator?
Hold on
alr, i try what i can do for it
These docs are cancer at its finest
Ikr
But does this work?
https://praw.readthedocs.io/en/stable/code_overview/reddit/multireddit.html cuz idk chief it doesn't seem to be
Eugh. Time to read the source code
no this doesn't work
self.multireddit = models.MultiredditHelper(self, None)
Which dumbass does this?
self.multireddit = models.MultiredditHelper(self, None)
"""An instance of :class:`.MultiredditHelper`.
Provides the interface to working with :class:`.Multireddit` instances. For
example you can obtain a :class:`.Multireddit` instance via:
.. code-block:: python
reddit.multireddit("samuraisam", "programming")
"""```
ikr
the source code
reddit does
do "messageCreate" detect dm messages ?
imo it just creates the DMs
The event should listen to DMs too
on_message should detect messages
yeah i know
message was in discord.js v11 i think
What the hell is multireddit?
now its messageCreate and my bot now is not working with dm messages
Did you enable the DM messages intent?
go to developers portal
i hate v13
and enable intents
im gonnad add that intents
You can't enable the DM messages intent via dev portal
@worn sonnet anyhoo if you want multiple multireddit shits use a for loop on each element in subs
If that's what you need
i was trying to avoid it
but i think i will stick with it
That's what would happen under the hood anyway so
yea
So run the get() method on all of the shards?
if you are not doing any sort of shard check, then the code is running on all shards simultaneously
therefore you dont need broadcastEval nor fetchClientValues
just make a normal interval with normal code that checks if the guild exists and if member exists and do the job
I still need it for getChannel
i just added Intents.FLAGS.DIRECT_MESSAGES and still not getting dm messages !
I want to send a message in a channel when it joins and leaves a guild
So I still need it
a fixed channel?
Yes
that is not in the guild?
Not in the guild it's joining
then use it for that only
use broadcastEval after you finish the job
just to send the message
class Top(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.dbl_token = "token"
self.dblpy = topgg.DBLClient(self.bot, self.dbl_token)
self.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("path", "password")
@commands.Cog.listener()
async def on_ready(self):
await self.topgg_webhook.run(port)
self.update_stats.start()
print(f"TopGG Loaded")
@tasks.loop(minutes=30)
async def update_stats(self):
try:
await self.dblpy.post_guild_count()
logging.info(f'Posted server count ({self.dblpy.guild_count}), shard count ({self.bot.shard_count})')
except Exception as e:
logging.exception(f'Failed posting server count on top.gg: {e}')
wtf
guys my is not detecting dm messages
show the code
and yes i add that intent
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.DIRECT_MESSAGES] });
and
client.on('messageCreate', async message => {
console.log("HELLL")
.....
and its working with guild messages
@slender thistle can't use for loop since the stream is continious and it won't complete the iteration
@hot sleet ```css
client.on('message', message => {
message.member.user.send(message.content).catch(console.error);
})
i just copy pasted it fom here
https://stackoverflow.com/questions/62732491/my-discord-js-bot-gets-an-error-when-trying-to-send-dms
there is something like subreddits?
They didn't even care to mention it in PRAW models
you also need message and channel partials afaik
it returns the new subreddits that are created
partials were already in discord.js v11 and v12
intents were already in v12 as well
ok my dm code was working good with v11
because it used an old version of the discord api
when they didnt care about it yet
but now they do
so blame discord itself lul
eh i know
I honestly have no clue how Reddit API works
so i searched and found that
for submission in reddit.subreddit(learnpython+phonesarebad+anime).stream.submissions():
print(f"Title: {submission.title}. URL: {submission.url}")
something like this works
just need to add subreddit names and it works
I'm doing global slash commands, but everytime I update slash commands/add new slash commands it says this
If I do guild slash commands, it updates within seconds
But it's supposed to be public
Yes!
but you are the life saver man whenever i needed help you were there so thanks a lot
Are you reloading your discord every time you update a command?
I usually get that whenever I update a command and I don’t reload my discord
Doesn't make a difference
¯_(ツ)_/¯
That's normal.
Global commands don’t update instantly
There's a 1h cache
Guild/DM commands do
If you’re testing a bot, I recommend testing in DMs
(Or guild specific if the command requires type to use it in a guild)
it does update in dms yes
why my bot ignores me in Discord.py?
??
he ignores me
don't want to reply to my message

import os
import discord
class MyClient(discord.Client):
async def on_ready(self):
print('Logged on as', self.user)
async def on_message(self, message):
# we do not want the bot to reply to itself
if message.author.id == self.user.id:
return
if message.content.startswith('!hello'):
await message.reply('Hello!', mention_author=True)
client = MyClient()
client.run(os.environ['token'])```
Your indentation seems to be off.
when you talk to yourself and insert emojis it's a sign you're going insane from the bot
sorry, i'm new to python

he doesn't really answer me
you have to indent the message def to align with the ready def
with all the contents of the function
👍
that way it's inside the class and discordpy can detect you're adding an event listener
...
H.E.L.P.
firstly what line is that coming from
my intuition tells me you've messed up your json file somehow
does discord api allow u to get someones mail ID?
export function getChannel(ID, client) {
return client.shard.broadcastEval(() => return client.guild.cache.get(ID))
}```
I know this is not correct, but is this something like it?
no
dont transfer the channel
do the operation in the target instead
broadcastEval((client, context) => {
if(client.channels.cache.has(context)) {
client.channels.cache.get(context).send("something");
}
}, { context: ID });```
i'm in my command handler, i'm trying to make a help command that only takes a certain category. this is my code in the command:
const Discord = require('discord.js')
const fs = require('fs')
module.exports = {
name: "categories",
usage: "none",
description: '[...]',
aliases: [''],
run(client, message, args, guildprefix){
const funCommandFiles = fs.readdirSync('./fun').filter(file => file.endsWith('.js'));
const commandsArray = [];
for (const file of funCommandFiles) {
const commandFile = require(`../commands/fun/${file}`);
//my other code here, lol
};
}
};```
i'm getting this error: `Error: ENOENT: no such file or directory, scandir './fun'`
even when these are my files: (the code above is in the categories.js file)
anyone can help?
When i reply to a user with a button the emojis wont work, does someone know why?
Its only my client or is something with the bot?
Without sharing any code we'll have a hard time helping you
The code is ts button.reply.send(' OK')and the result is :success: OK and not
OK
do you have permissions for external emojis?
Does the bot need them when is a user interaction?
Cool tip: Webhooks can use any emoji without the bot needing to share that server (unrelated to this but still)
And api interactions too right?
Nope you need the perms Tim mentioned
Yes with auth2
does it work if you send it as a normal message instead of a button reply?
i cant try it
its only in one server
is the bot a member of the server where the emoji is from?
yup
you have to test with a normal message then
so see if the problem is the emoji or the reply function
sorry for insisting, can someone help?
fs with relative paths can be weird when called from functions in another file
you're better off using absolute paths with process.cwd()
how do i see who deleted a message/created a channel, ect with discord.js
You'd have to fetch the audit logs and search for a specific entry or just do that with the query
did that get updated with v13 or is it the same still?
Anyone know what this error means and how i can fix it?
Error: /app/node_modules/canvas/build/Release/canvas.node: invalid ELF header
the file was compiled in the wrong system
you cant copy-paste node_modules
you have to reinstall them
at this point
i think he ruined it
so he has to re initialize the package too
but try to npm install first then if it doesnt work then you should re init
guys
cant i just edit some modules
this one has an unhandled error that ends the entire nodejs proccess
@quartz kindleI just reinstalled all the packages and also dotenv but it still says it cant be found
Nvm
I fixed it
Still have this problem:
export async function getChannel(ID, client) {
const results = await client.shard.broadcastEval((client, ID) => {
if(client.channels.cache.has(ID)) {
return client.channels.cache.get(ID)
}
}, {context : ID})
return firstTrue(results)
}```
I know I'm technically not suppost to return the object, but it still works
does anyone know why when in an embed description, when i set it to a JSON.stringify(someObject.map()) and in that map i put a \n it does not breakline?
for reference, this is what i mean
did you increase the max listeners?
I shouldn't have to
You shouldn’t need to increase the maximum listeners if you’ve done everything right, that warning indicates a memory leak
How would you fix a memory leak?
how many times are you calling that function?
You’re creating too many listeners somewhere
i have a feeling you're using that more than needed
for(const item of x["entries"]) {
const guild = await functions.getGuild(item["guildID"], client)
if(guild) {
const member = await functions.getMember(item["memberID"], guild).catch()
if(item["time"] < new Date()) {
if(item["action"] === "unmute") {
if(member) {
if(await functions.unmuteMember(member)) {
await member.send(functions.createEmbed("You've been unmuted!", `You've been unmuted in ${guild.toString()}.`, variables.colors["green"], member.user, {name : "Reason", value : "Time out"}, null)).catch()
}
}
} ```
This is part of my code. The function is called every iteration, maybe thats why
json stringify outputs minified json by default
you have to add parameters for beautification
check the docs for json.stringify, i dont remember if its second or third parameter
thanks lol
is getGuild and getMember the same as getChannel?
all using broadcastEval?
getGuild is, getMember isn't
you have to rethink that, doing it like this is extremely inefficient
you're likely overloading the ipc connection
guys
Thats the cause, isn't it?
most likely yes
pls help
when you are sharding, you are splitting your bot into multiple processes
the command of the bot
each separate process cannot access each others data
so they rely on sending messages to each other, which is what broadcastEval does
sending too many messages too fast is gonna overload it, like a DDOS attack
👀
each broadcastEval sends a message to all shards
then waits for an answer from all shards
so each time you use broadcastEval you are already sending as many messages as the number of your shards times 2
if you use broadcastEval once on every shard, then you're sending shards x shards x 2 messages
How would I find a way to get the channel object without DDoSing my bot then?
thats what im saying
rethink it
dont do it like that
dont get objects from one to another
whatever you need the object for, you can do it in a different way
hmmm
What exactly are they trying to do
Get a guild object lots of times at one time
so fetching multiple guilds at a time?
again, why do you need the guilds
what are you doing with the guilds
whatever it is, you can do it without getting them
As long as you have their Ids you don't need anything else really
To unban the member, if its an unban
Store the mute timers with the guild id and just check if that guilds timer is up and unmute
then you can simply fetch the guild and unban
what triggers the unban
Timer
Users can set an amount of hours
Lets say 5
Yes
how do you retrieve it from the database
do you store the guild id in the database?
MongoDB's find method
so you are fetching all guilds
do you have the guild id in the database?
export async function add(collection, key, value, ID) {
return await collection.insertOne({"_id" : String(ID), [key] : value})
}
export async function remove(collection, key, value, ID) {
return await collection.updateOne({"_id" : String(ID)}, {"$pull" : {[key] : value}})
}
export async function find(collection, ID) {
return await collection.findOne({"_id" : String(ID)})
}
export async function update(collection, key, value, ID) {
await checkIfKeyExists(collection, key, ID)
return await collection.updateOne({"_id" : String(ID)}, {"$push" : {[key] : value}})
}
export async function erase(collection, ID) {
return await collection.deleteOne({"_id" : String(ID)})
}
export async function modify(collection, key, value, ID) {
await checkIfKeyExists(collection, key, ID)
return await collection.updateOne({"_id" : String(ID)}, {"$set" : {[key] : value}})
}```
These are the functions I use to store
And remove
From the database
but do you add the guild id with the entry
Yes
then problem solved
``` {"memberID" : member.id, "guildID" : guildID, "action" : "unban", "hours" : hours, "memberInfo" : ${member.username}#${member.discriminator}}
you'd wanna fetch by guild id then no?
fetch all items from the ban collection where the guild id exists in your shard's list of guilds
then unban them locally
done
without a single broadcastEval
omg
dismorse
morsecord
poggers
LmAo that’s good
You know u have to pay $5 to Tim each time somebody calls his name?
capitalism anywhere pfff
i am wolf of wallstreet

💰
you're the wall of wolfstreet
What the heck does this require other than having embed perm..
it has embed perms, and send messages perms, but does not respond and says missing permissions
Any idea why the node_modules doesn't grey out when it's in gitignore? Everytime i push it, it goes with node_modules in my repo
Possibly just need to restart your IDE.
Whats an IDE?
😦
Ahh
Indeed
Extensions and stuff
yea
It's p versatile
as I thought
you added the gitignore after you already published node_modules
just delete node_modules from the repo and from there on out it shouldn't push it
Ahh
also just a note, never add a gitignore file after running git add .
cause it won't register whats in it
idk if there is a way to fix that but I usually make sure I add a gitignore before running git add
I wonder if when translating morse code to normal english would I have issues? Cause the way I am defining the morse code letters there is a space between the dots and dashes, if someone were to not add a space would that cause issues since it wont find the letter in the map. Also I am wondering how I would go about making sure words are split up from each other so it doesn't look like a jumble up mess
Ok so i deleted node_modules from the repo and now trying to push with git push, but throws an errors saying Updates were rejected because the tip of your current branch is behind
if you edit the repo you have to pull first
Ahh
I am wondering if for my second issue I can just enforce them using / between words in morse code
np
make the words without spaces
..- -.. .- . --.
I'm just going to go back to internal sharding until I recode how the bot works
What does this mean again?
Could not find a declaration file for module 'node-fetch'.
Yes but what if they then put spaces, would I just trim off the spaces?
spaces would be the word separators
you dont need to enforce them
cause they could do . . -
you try to translate it anyway
and it wouldn't be found in the map
try npm install @types/node-fetch
Mmmm
How do I send HTTP requests? I'm trying to get an user's UUID from Mojang API, but the console says that "fetch" is not defined.
let uuidURL = "https://api.mojang.com/users/profiles/minecraft/" + args[1];
fetch(uuidURL)
.then(res => res.json())
.then(data => console.log(data))
.catch(error => console.log(error));
I could put a ? yea but hmmm, I really wanna make sure it translates the best it can
Which ig it really is their fault if they fuck up
well you could try some progressive combination checker but thats gonna be complicated
Yea
oh wait tahts what ur talking about LOL
mb sry
I don't know go enough to do that
doesnt discord fuck up sometimes when you try to send multiple spaces?
. . - - . .
eh it works sometimes
you could try multiple passes
for example try once without spaces, if any unknow character was found, try again with spaces
anywhere I see a / I can just replace it with a space when returning the translation
well its an option, just not very intuitive for the user
and anywhere they are going
"I like cats"
I can just put a / where the space is
true
I guess what I could do is just use spaces like you said, translate the letters and keep the spaces how they are
you can also do something like space counting
if number of spaces is bigger than number of non-spaces, assume the user put spaces between the dots and dashes
🤔
then try to use multiple spaces as a delimiter
is there a npm package that can help me making and use the dropdown menus
I do not quite understand this
it supports the two most common usage patterns
the user will either do this: ..- -.. .-. ...
or this . - . . . - - . . - -
if the user does the first, the number of non-space characters will always be bigger than the number of spaces
so you can go ahead and split by space
if the user does the second option, the number of spaces will always be bigger than the number of non-space characters
in that case, use a multi-space regex (2 or more spaces) as a delimiter
since you can safely assume the user wont think of putting more than 1 space between dots and dashes
that would be dumb
ye
But anyway, I don't know how I would even start with implementing that in go
so for now that will be a nice thought

it shouldnt be hard
you should have a way to count the number of specific characters in a string no?
Yea, Ima get the basis of it done and see about implementing that
I think we can use len
then you should also have a way of splitting a string into an array or tuple based on a delimiter
probably yes
specific characters?
I am not entirely sure
you need to count how many spaces there are
and compare it with how many non-spaces there are
Mmmm
Yea I will figure this out when it comes to it
I just wanna get the basis done
if go doesnt have a function to count instances of a pattern within a string, you can use a function to replace all instances of a pattern with nothing, and then use len() o that
👍
So first attempts didn't work
func Translate(text string) []string {
var chars = strings.Split(text, " ")
var translation []string
for _, letter := range characters {
for _, char := range chars {
if char == letter {
translation = append(translation, letter)
}
}
}
return translation
}
I was thinking this would work, but now that I think about it, it really wouldn't would it?
I get now why it won't work cause I am looping through my map of morse code characters so i am getting the values not the keys
How can i get my bots serving user count with the eval command?
Loop through server count and add member count to a variable..?
I'm trying to extract this specific part of a really long string so I can get an user's Discord from Hypixel API.
socialMedia: {
links: {
YOUTUBE: 'https://www.youtube.com/channel/UCKtEdr9JvK48QubxBu_vNiw',
DISCORD: 'Eltik#5776', <-----
HYPIXEL: 'https://hypixel.net/members/eltik.3776101/'
},
prompt: true
},
I can get the data, but extracting it stumps me. Since the string changes based on a player's stats, how would I check whether a player's Discord is set (whether it exists in the string) and if it does, get their Discord?
Code:
function getHypixel(uuid) {
(async () => {
const playerData = await hypixel.player.uuid(uuid);
var str = player.toString();
/*
look for:
"socialMedia": {
"links": {
"DISCORD": "Minikloon#0001"
},
*/
})();
}
Inb4, it's not feasible to track user count UNLESS you're retrieving row count from database
Like select count(1) from users
You'd parse the string into JSON/an object and access it like an object.
player is probably an object, so you could just do player?.socialMedia?.links?.DISCORD
Okay. Thanks!
of course
Yes
A linux VPS supports node
how? i buyed an ubuntu server from ionos and i don't know how to install node
yes
ok
thanks
Don't pick option 1, that version of Node.js is outdated
pm2 or some sort of other process manager
FUCK YOU MAN FUCK YOU
Ok
Rude!
if i close the SSH it goes off
He left the server after saying that lmao
how to let it on without the console opened
^^^
lmao
?
The average life cycle of someone too young for discord
@earnest phoenix I don’t see why you couldn’t host a bot and a website, but just make sure that your VPS has enough resources to support both
ok
in djsv13 client.voice.createBroadcast() is not a function... what can i do? found nothing online
sorry today i asked way too many things
@discordjs/voice
there is a whole separate docs for djs voice afaik
¯_(ツ)_/¯
it should work
Works fine for me
i installed it npm install pm2 -g
ah
You have to start it using pm2
how
pm2 start index.js
type the command
(or whatever your startup args are)
right?
pm2 start index.js --name bot :%^)
^^
pm2 start index.js --name uvuvwevwevwe-onyetenyevwe-ugwemubwem-ossas
node index.js
or node .
then its correct
ok thanks
try closing your terminal now
Thats a hot name
I downloaded it from GitHub the Jason file. For jokes
and what does the jason file contain
guys is there is any one help me ?
i have a problem ( The user aborted a request )
no error But this is bothering me and I want to solve it
i don't want to make a catch(err => 0) or else like this
i want to know Where does the error come from?
assuming you're discord jsing i think that means that an api request took too long to send back a response
detritusing
@quartz kindle found another issue with the morse code translator I am making 
Apparently you can use either _ or - for dashes
are you doing some leetcode problem
In my map I am only using _ for dashes so if I were to use - it would not detect that it is a dash and thus ignore any letters that match with the correct combination of dashes and dots
Idk, I am just doing something I thought of
I'm trying to create an error message for when the bot doesn't have permission to change an user's nickname, but since the docs are down for me I can't check to see what the new Discord.JS methods are (or whether what I'm doing is incorrect or not). Here's my code:
https://sourceb.in/PtNLXAA3zE
The documentation site is online.
Assuming you're on the stable branch, hasPermission is no longer a method. You can use .permissions.has(...) instead.
You don't need to find the role by ID either. You can just do .cache.get(...)
just tried it on edge it works
👍
sorry Sammy 😔 ✊
fiber is a web framework for go
static is static
i have this channel muted since all my js knowledge has just poofed
what does that mean 
actually why dont u just use linktree
ok
and i cant have a custom domain
anyhow u need some kind of webserver to serve that html
whats a good one of those?
idk
like ovh hosting?
@pale vessel backup
no a webserver is like express
koa, express, fastify those all create webservers
if your site is static just use GH pages lol
is that what i need the web hosting?
GitHub pages even supports static site generators like Jekyll
yea bro just use github pages
ok
Shall I post my awesome page on github page? 
ok?

