#development
1 messages · Page 1952 of 1
I made fs read a sqlite file every 9s to save the file even when i'm not in replit and it's working, like a week passed and no corruption or anything...
Oh my
it's a test bot btw, the real one is safe
What's the influx of data?
influx of data?
You'll only face corruption when you have a steady IO flux
Like, many reads/writes per second
yeah I'm reading it every 9s and a week passed
For example, if the database is in the middle of an operation and you fs the file boom, corruption
ok
uh, no corruption showed even when i'm spamming commands where the db has to add, subtract and delete stuff
¯_(ツ)_/¯
oh
Try insert-deleting very quickly
I'll better continue using vsc and railway
Like, insert 1000, delete 300, insert 1200, delete 1000, insert 500, etc
Then fs save it during the sequence
ok
my website is optimized (except the perfomance, cause I don't use webpack)
nice
why would webpack lower performance?
probably meant to invert that question
I can't add the webpack to my app
in some way
just some dumb error that I can't google
isn't webpack just a protocol buffer
it split files
so the file requirement will be faster
cause the files are lighter
=> rendering is faster
depends on the configuration
webpack is a bundler, it can be configured in a billion different ways, it wont necessarily improve performance
yeah, but normaly it is used to improve perfomance
i think so..
not really
To my knowledge, it's used to reduce bandwidth.
AFAIK by performance lighthouse means how fast the page takes to load. That means time to download assets
its mostly used to handle stuff like css/js versioning for cache bypass, merge js files into one, and some other quality control features like minification with source maps
and often also transpiling js/ts into older versions for compatibility
var 😔
It's documented: https://discord.js.org/#/docs/main/stable/class/CommandInteraction?scrollTo=reply
// Create an ephemeral reply with an embed
const embed = new MessageEmbed().setDescription('Pong!');
interaction.reply({ embeds: [embed], ephemeral: true })
.then(() => console.log('Reply sent.'))
.catch(console.error);
The only mistake you did was passing a type instead of an actual embed
Why the fuck hasn’t discord verified my intents yet
intents verification is always slow
I have requested it like 6 days ago and haven’t had a single response since
Get used to it, took me 2 months and 5 emails
2 months!!!!??
They kept sending the same email again and again
Until I sent a long complaint email
Then finally a human wrote an email to me
did they bother to say sorry
Asking for a few images/gifs of functionality usage
Yeah I had included that too, but I hope that it won’t take that long as my bot already reached the limit of the amount of guilds and many people dmed me addressing this issue.
Hey KuuHaKu,
Thanks for reaching out and applying for privileged intents! Everything is looking good so far. We had some additional questions to continue with the process:
Would you be able to provide some screenshots or short videos of your bot's moderation and custom answer functionality?
Thanks in advance!
Shipwreck
lol they didn't
Whahahahha erg
and that's just a copy paste response
how long it take for a dns changes?
Before that all they asked was stuff I already answered on the intent form
Wtf, I will try to contact their support later on to get a rough estimate on how long it will take.
It's like sending a CV then being asked your professional experience
cuz 2 months? That is fucking longer than topgg’s own bot verification
Yeah, some get it earlier and some later
I even sent 6 or 7 gifs of the features that required message intent
On the form
I really doubt they even opened 'em
Whahahahah wtf
Just realised my pics are hosted on an image platform that deleted the gifs and images after 1 month
for fuck sakes
Onedrive hosts images sent as attachments
You can just attach it normally
U added a subcommand
That's why
Just do it then
/category subcategory command
This is the structure for commands
/command
/category command
/category subcategory command
Actually
Add a command
Not a subcommand
I guess
You still need to delete the old command
Else you'll get duplicate name error
You need to supply type
For the command option you set
The type of the option could be a string, number, user, channel etc.
Well to late now. I will just message them later on
Too*
Just keep answering their emails
Eventually they'll send a human
After that it'll take at most 1 week or so
You should stop register commands multiple times
create() does register a command and a command does only need to be registered once
If you run the code again and register the same command again this issue can happen even if the code responded to the interaction
Update the commands using the method set()
This does overwrite all commands, guild commands in your case
client.guilds.cache.get('834615041537867806')?.commands.set(commandfile.name, commandfile)
Would that not work to load guild only commands?
Depends on the structure of the var commandfile
It needs to be a valid application command structure
An object with a name, description and optionally options
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
client.commands = new Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
const data = []
for (const file of commandFiles) {
const commandfile = require(`./commands/${file}`);
client.guilds.cache.get('834615041537867806')?.commands.set(commandfile.name, commandfile)
data.push({
name: commandfile.name,
description: commandfile.description,
options: commandfile.options
})
}```
That's the full thing 🤣
Actually it does not it gives random responses
commandfile is your whole module
You can’t push that using set()
In your case data would be what you can push as 2nd parameter in set()
I don’t get why you push an array called data
What’s it’s purpose?
log commands and you will see why map() isn’t available
And what’s the result?
commands is the command application resolver
Not just a property
Oh shit @solemn latch

how do i get a users flags
using discordjs
or better how do i see if a user has X flag
i'm using v12
ty
there was a nitro spammer and it was deleted right when i pinged
pls forgive me
does anyone know or have a "behind the scenes" of how interactions work, more in particular im wondering is discord receiving information as of what slash command interactions my bot has and provides those to the user so they can see and execute them? or does it actually send a message with the slash command and the bot reads it and works with it?
as well can I even change the slash command's slash to something else as writing a slash on mobile is kind-of annoyingly hard where on pc it is easier
is discord receiving information as of what slash command interactions my bot has and provides those to the user so they can see and execute them? or does it actually send a message with the slash command and the bot reads it and works with it?
Most likely the former.
Given you upload your commands and Discord dispatches them
you register your slash commands with this endpoint https://discord.com/api/v8/applications/BOT_ID/commands. They take some time to update so you cant do it all the time
can I even change the slash command's slash to something else
No
thank to both
I tried the link, it appears to be unauthorized access, is it reachable thru the developer portal?
here's more info about that endpoint
https://discord.com/developers/docs/interactions/application-commands#making-a-global-command
if you use a library it takes care of this part for you
i think
yeah i do use DJS library
is there a way to either get a table name or make a "inverse" switch-case?
or at least a non-null type
ok, I'll explain the full context
SELECT c.id
, CASE /* HERE WHAT? */
WHEN ch.card_id THEN 'SENSHI'
WHEN eq.card_id THEN 'EVOGEAR'
WHEN fd.card_id THEN 'FIELD'
ELSE 'KAWAIPON'
END AS type
FROM card c
LEFT JOIN champion ch ON ch.card_id = c.id
LEFT JOIN equipment eq ON eq.card_id = c.id
LEFT JOIN field fd ON fd.card_id = c.id
WHERE c.id = :id
you see, I'm trying to find in which table the join doesn't return null
to find out the card's type
sql is turing-complete actually
not as fun as datalog but still good enough
it's certainly not impossible to do what I'm trying to, and it'll probably be better than my current method
thing is, I need to check which column ISN'T null
ah wait
like an outer join without the inner join stuff?
NOT NULL?
doesn't work
sadge
I'll try converting null/nonnull to boolean
write a program that fixes the data
it will never fix
cuz there's nothing to be fixed
you see, a card can have 3 types
champion, equipment or field
so if it's a champion, it'll always be null in the other 2
move the logic part to the program. fetch the data from the db and do the logic stuff in the program
oh please don't
lol
that never works out
meh, I might just make a "booleanize" procedure
oh wait
SELECT c.id
, CASE FALSE
WHEN ch.card_id IS NULL THEN 'SENSHI'
WHEN eq.card_id IS NULL THEN 'EVOGEAR'
WHEN fd.card_id IS NULL THEN 'FIELD'
ELSE 'KAWAIPON'
END AS type
FROM card c
LEFT JOIN champion ch ON ch.card_id = c.id
LEFT JOIN equipment eq ON eq.card_id = c.id
LEFT JOIN field fd ON fd.card_id = c.id
WHERE c.id = :id
I was thinking too much
forgot "IS NULL" exists
I was thinking of that too
but given you said not null doesn't work I didn't know if that would too
statements vs. expressions man
yep to evaluate which case will be the correct one
funny enough, IS NULL with FALSE is returning 30ms faster than IS NOT NULL with TRUE
or it might just be too few samples to make a proper benchmark
How would I fetch the user's current avatar URL and put it next to their tag on a website? Rn it's just:
<div class="accordion-item">
<button id="accordion-button-1" aria-expanded="false"><span class="accordion-title">Developer</span><span class="icon" aria-hidden="true"></span></button>
<div class="accordion-content">
<p>samm#0021</p>
</div>
</div>```
whichever case returns TRUE will be returned
so like, all will return false but one, which will be the correct card type
use a bot to fetch it
ic
you can also use oauth2 iirc, just need to use proper scope
yeah
I have a typescript module uploaded to github but I don't know how to make it transpile when I install it
How do I check if a message already has a thread?
I get this error when clicking the "Discuss" button.
/home/container/node_modules/discord.js/src/structures/Message.js:765
if (this.hasThread) return Promise.reject(new Error('MESSAGE_EXISTING_THREAD'));
^
Error [MESSAGE_EXISTING_THREAD]: The message already has a thread
at Message.startThread (/home/container/node_modules/discord.js/src/structures/Message.js:765:47)
at Client.<anonymous> (/home/container/index.js:1131:27)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
[Symbol(code)]: 'MESSAGE_EXISTING_THREAD'
}
Line 1131
interaction.message.startThread({
name: 'suggestion',
autoArchiveDuration: 60,
reason: 'Suggestion',
});
Full if statement
if (interaction.customId === "discuss") {
await interaction.deferReply({ ephemeral: true });
interaction.message.startThread({
name: 'suggestion',
autoArchiveDuration: 60,
reason: 'Suggestion',
});
await interaction.editReply("Started thread.");
}
I got a working Automemes Command using Mongodb. But it works only after I restart the bot. [Using client on ready] How do I make it work so it starts after I set the channel. (Multi Guild)
AutoMemes Event Folder: https://sourceb.in/d1sUTaZV4M
Well make an interval when setting the channel
hi
dk how to do that
¯_(ツ)_/¯
How do you set the channel
I think the best way is to make a handler just for that
how e
Cause when you change the channel, you need to delete the old interval and make a new one
hu-
OR
you can make a global variable or put it on client that hold all the current meme channel with guild id as its key
e
What's tofu the bot command
is there anyway to return raw json file from react?
Or simple use cron job
Any idea how i can get my database ping?
const timestamp = Date.now();
//request to your db
const timeTaken = Date.now() - timeStamp;
That how you would do in js
If you are using any other language the logic should be still same

Does it always stay on 0ms?
import { CommandProps, Command } from "../../@types";
import { db } from '../..'
import Discord from 'discord.js'
export = {
name: "ping",
category: "misc",
aliases: [],
description: "Check Bot ping",
usage: "",
cooldown: 5000,
run: function (e: CommandProps) {
const {
message, args, client
} = e;
const timestamp = Date.now();
//request to your db
const timeTaken = Date.now() - timestamp;
message.channel.send(`Calculating Ping...`).then(p =>{
const ping = p.createdTimestamp - message.createdTimestamp
const embed = new Discord.MessageEmbed()
.setColor('GOLD')
.setDescription(`:ping_pong:**Ping:** ${ping}ms\n :clock1230:**API Ping:** ${client.ws.ping}ms\n**Database Ping:** ${timeTaken}ms`);
p.edit({ embeds: [embed], content: null, allowedMentions: { repliedUser: false } });
})
}
} as unknown as Command
You literally copy pasted that
//request to your db
Part was supposed to be
Where you make request to your database
?
What db you use?
Im a bit lost here
MongoDB
ORM?
I see mongoose
You can make a request like this Schema#findOne()
Or something
I am afraid I can't help more than that
Right
Is it possible to send a message to the user who invited the bot via bot? discordjs
how do i loop through every key in mongodb and get the key which contains a specific value? (edited)
like i have 3 keys:
{"user":"blob","skill":"conding"}
{"user":"JoJo","skill":"dancing"}
{"user":"Ben","skill":"coding"}
so i only want to get those who has coding skill
wut
mongoose or vanilla mongodb
ty
Any idea why the button is sending "Interaction Failed"?
import { CommandProps, Command } from "../../@types";
import Discord, { Interaction, MessageActionRow, MessageButton, MessageEmbed } from 'discord.js'
export = {
name: "button",
category: "",
aliases: [],
description: "",
usage: "",
run: async function (e: CommandProps) {
const {
message, args, client
} = e;
if (!message.guild)
return;
const embed = new MessageEmbed()
.setAuthor('Help Desk')
.setColor('GOLD')
.setDescription(`Select your category by pressing a button of your choice!`)
const button = new MessageActionRow()
.addComponents(
new MessageButton()
.setLabel('Moderation')
.setCustomId('mod')
.setEmoji('👑')
.setStyle('SUCCESS')
)
message.reply({ embeds: [embed], components: [button]})
const collector = await message.createMessageComponentCollector();
collector.on('collect', async i => {
if(i.customId === 'mod') {
await i.update({ content: 'A Button was clicked!', components: []})
}
})
}
} as unknown as Command
why are you collecting it from the user message
?
message.createMessageComp.....
Oh
i dunno if it works with reply, but you should save the reply as variable then collect from it
so
const msg = await message.reply(....);
const collector = msg.createMessage.....;
collector.on(....)
I can collect it from a channel right? Like
await channel.createMessageComponentCollector
?
Anyone know how i can fix this?
hey
i need some help
i tried the code you gave me
it returns <pymongo.cursor.Cursor object at 0x7fee812eba60>
so now how do i get the key from this?
oh wait, u used py?
yes
this is js lol
lemme read the docs
<Collection>.find_one({skill: "coding" });
maybe
or did you already do it like that?
ah
skill
just use find then
just find
find
Then add .toArray() at the end
can you show the code
I’m on mobile rn
Works the same on mobile
oh
<Collection>.find({skill: "coding" }).toArray();
an array
let me try
in js
collection.find({"sh":pokemon}).toArray() AttributeError: 'Cursor' object has no attribute 'toArray'
@sacred aurora
k
Oh I think I know
pymongo doesn't need toArray then
@spark flint , now how do i get just the id of the user from this:
[{'_id': ObjectId('61d2d679de9767e5ce917162'), 'user': 742612257275641876, 'sh': 'rayquaza'}, {'_id': ObjectId('61d2dbe855819c0b1d2f9aa3'), 'user': 682489392207626271, 'sh': 'rayquaza'}]
i did not understand
sorry im kinda new to py
are you printing list(collection……)
do something like
all = list(collection …….)
this
yes
i did that too
then
for one in all:
id = one._id
ohhh
i tried this
Indentation error by any chance?
f = list(collection.find({"sh":pokemon}))
for one in f:
id = one.user
await interaction.response.send_message(f"yo {id}")
says it has no attribute user
no
try one['user']
ok
yeah i did it
f = list(collection.find({"sh":pokemon}))
for one in f:
id = one["user"]
i have this code now
how do i add every single user to a string and send them at once
Apparently, the code is trying to tell you that command.options does not return an array that allows you to use the .map() method.
@marble juniper
from javascript import require, On
mineflayer = require('mineflayer')
pathfinder = require('mineflayer-pathfinder')
RANGE_GOAL = 1
BOT_USERNAME = 'python'
bot = mineflayer.createBot({
'host': 'mc.scopes.cf',
'port': 25653,
'username': BOT_USERNAME
})
bot.loadPlugin(pathfinder.pathfinder)
print("Started mineflayer")
@On(bot, 'spawn')
def handle(*args):
print("I spawned 👋")
mcData = require('minecraft-data')(bot.version)
movements = pathfinder.Movements(bot, mcData)
@On(bot, 'chat')
def handleMsg(this, sender, message, *args):
print("Got message", sender, message)
if sender and (sender != BOT_USERNAME):
bot.chat('Hi, you said ' + message)
if 'come' in message:
player = bot.players[sender]
print("Target", player)
target = player.entity
if not target:
bot.chat("I don't see you !")
return
pos = target.position
bot.pathfinder.setMovements(movements)
bot.pathfinder.setGoal(pathfinder.goals.GoalNear(pos.x, pos.y, pos.z, RANGE_GOAL))
@On(bot, "end")
def handle(*args):
print("Bot ended!", args)
It stops at the first print statement
I suggest you to just join https://discord.gg/yXmxRSMa6b
they can help you and also its the discord server related to mineflayer
I have a message filter here
const msgCol = (m) => m.author.id === inter.user.id;
and a collector:
const channelCollector = inter.channel.createMessageCollector({ msgCol });
But for any reason the filter doesnt work and it collects messages from user who didnt create the interaction
because you didnt set a filter
{ filter: msgCol }
if you do { msgCol }, thats a shortcut for { msgCol: msgCol }
there is no msgCol parameter in the collector options
whereas if you name your filter filter, then you can do { filter }, because its a shortcut for { filter: filter }, and filter is a valid collector option
so unless you name it exactly as the name of the option you want, you need to specify the name of the option in the object
js
it is for nodejs
the python thing is just the bridge doing it
mineflayer has no native python implementation
minecraft is java/c++
discoord
works only with prime go or rust or pubg 
wait slash commands have permissions now?
How can I get a users Guild profile pic with DiscordJS v12?
by fetching a member using the raw api
await client.api.guilds(id).members(id).get()
await client.api.guilds(message.guild.id).members(member.id).get()
that would work right?
yes
.
it doesn't help
you doesnt help
how can I filter a object by same content? like ```js
let obj = {
"obj": {age: 22, brick: "Not a brick"},
"obj2": {age: 23, brick: "Yep"},
"obj3": {age: 22, brick: "Homie"}
}
//Filtered output:
obj, obj3 //they have same age
the example doesn't make sense but it's a example...
oh google helped
it was a typo lol
-needdev, hi i have a server with my stickers uploaded but i need a bot to upload the stickers as images, because i lost my original stickers because my computer had to factory reset because chrome browser kept crashing. thank you for reading in advance
Object.values(obj).filter(thing => thing.age === 22);
you can use bot to get the sticker information and then get the url from it
or just use chrome dev tool
/* Logging Direct Messages */
if (message.channel.type === "dm") console.log(`${bold(time.toLocaleString())} | [${magenta('LOG')}] - Direct Message: User Information: ${message.author.tag} (${message.author.id}) Message Content: ${message.content}`);
Am I not able to log the content of the direct messages?
did u enable the dm intents?
I did.
Yes.
DIRECT_MESSAGES u enabled this thing?
Indeed.
It's a legit message.
I'm doing this on the messageCreate event, too.
Did I do something wrong, like?
I stopped it with a log, that's how JS works.
yes
So?
I came here since it doesn't.
What??
That's what I want..
yes
so It won't display the message.content
becasue the code is not executed
when u stoped the code before that
Honestly, if you just log message.content and send a message via DMs, it doesn't work. ;-;
uppercase
yes
^^^
bro, we trying to help you here and you write like kinda rude :<
Dude, how was I rude? I just congratulated myself since it didn't work, I never intended any type of rudeness towards anyone else.
nvm
Although, I am yet to explain to you the following:
Honestly, if you just log
message.contentand send a message via DMs, it doesn't work. ;-;
but it console log hi?
Nope?
nothing?
Nothing. ;-;
can u show me the intents?
it would never log anything because .type === "dm" would always be false
did you fix that?
i guess so
What do you mean?
I fixed that the moment he sent his previous message?
can u show me the intents?
Although, did the changes, still no result.
I had to use the entirety of all intents.

just show me
I curse you with my stare so that your previous curse wears off.
Thee shall face heavenly intentions.
so 32767 equals every intents?
Indeed.
maybe try the old school one
just for a try
intents: [ Intents.FLAGS["DIRECT_MESSAGES"] ]
you dont need to blindly test intents like that, just console.log(message) and see if it logs the dm message
so console.log(message) works but console.log(message.content) does not?
I guess so
im pretty sure he was talking about the other things outside of the if(dm)
When did I mention it does? What???
so the .author is undefined too?
yeah then something with your event or intent
.. and no, it does not log the direct message.
I can tell you're skim reading, I hope you could re-read what I'm trying to achieve. (respectfully)
but the guild messages?
maybe there are just some misunderstanding between us
even if you remove the if?
chill
console.log(message)
That's my code.
like just do console.log(message) directly, without any if(type === dm)
This is legit my code, I have nothing else.
Didn't work.
maybe enable the partial?
Yup, that was the solution, after all.
ok :))
I went to the .Client() options and it turns out, I can add a new property named as partials and enable the six partials. It works, afterall. 👍
Why doesn it react to any reactions from the interaction user?
const reactionFilter = (reaction, user) => {
return reaction.emoji.name === '' && user.id === inter.user.id;
};
enterID = await inter.followUp({ embeds: [embed], fetchReply: true })
enterID.react('')
enterID.awaitReactions({ filter: reactionFilter, max: 1 })
.then(collected => {
console.log(collected)
if (enterID) enterID.delete().catch(err => { })
})
it did have
it was often needed for reaction menus
huh why, I made one but it is not required
the partial
because you wouldnt receive reaction events on uncached messages
oh
so your reaction menu would not work on older messages after your bot restarted
i dont like the partials system, idk why they taught it would be a good idea to omit discord events if there was missing data
but now there aren't a return for it :))
can interaction replies be edited multiple times? 🤔
i dont see why not
well, I must be doing something wrong then, hmm.
Why am i getting {"reason":{"type":"ReplicaSetNoPrimary","servers":{},"stale":false,"compatible":true,"heartbeatFrequencyMS":10000,"localThresholdMS":15,"setName":"atlas-kk6xv2-shard-0","maxSetVersion":6,"maxElectionId":"7fffffff00000000000000ce","commonWireVersion":9,"logicalSessionTimeoutMinutes":30}}
with mongo
on nodejs
ah its working now
@solemn latch it worked
quicker now
down to 140ms
Anyone know how i can fix this?
Not use channel on something that doesn't have channel on it
I have a messageComponent collector, but after leaving the message for a while and clicking then on a button I get this error:
DiscordAPIError: Invalid Webhook Token
code:
const filter = (filter) => {
if (inter.user.id === filter.user.id) return true
return inter.reply({ embeds: [embed], ephemeral: true })
}
const collector = message.createMessageComponentCollector({
filter,
})
collector.on('collect', async (i) => {
try{
i.deferUpdate()
...
}catch()
})
Whole error:
iscordAPIError: Invalid Webhook Token
at RequestHandler.execute (C:\Users\Flo\Documents\GitHub\noah-bot\bot\node_modules\discord.js\src\rest\RequestHandler.js:350:13)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (C:\Users\Flo\Documents\GitHub\noah-bot\bot\node_modules\discord.js\src\rest\RequestHandler.js:51:14)
at async InteractionWebhook.editMessage (C:\Users\Flo\Documents\GitHub\noah-bot\bot\node_modules\discord.js\src\structures\Webhook.js:325:15)
at async CommandInteraction.editReply (C:\Users\Flo\Documents\GitHub\noah-bot\bot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:139:21) {
method: 'patch',
path: '/webhooks/926421352234233866/{token}/messages/@original',
code: 50027,
httpStatus: 401,
requestData: {
json: {
content: undefined,
tts: false,
nonce: undefined,
embeds: [
{
title: 'Logs for Fabboy#4725',
type: 'rich',
....
How can I prevent that error? I have already all stuff in try catch blocks
do you mean inspect element? because that didnt work and im on a chromebook ;-;
why
what is the problem with chromebook
every browser have dev tool tho
just press shift ctrl i
I never sent a webhook btw, it seems like the interaction expires. But I dont know how to prevent that
oh
interaction webhooks expire after 3 seconds, or 15 minutes if you deferred them
sorry didnt read all of them
looks like you are deferring in the collector, you probably are looking to defer before then.
no wait 👀
i would guess the error is on this one.
https://i.imgur.com/fc4rWHQ.png
indeed, its using the return value from the reply as the filter value. since reply returns a promise, and a promise is truthy, your filter passes when it shouldnt
Hi,Is it difficult to slash all your commands?
wdym?
like make all of your command to be slashed?
yes
nah
do i look in elements, console, or sources?
I already have 105 orders with my prefix but I would like to put them in slash
maybe find a src attributs in <img> tag
k, will message back if i dont find it
maybe u can a function that go through your commands, but I haven't tried it. But basicly it is possible
or u can write 106 slash commans
haha ok
tu parle francais ?
okey bro
because with discord who wants to go into slash bah the transferred will be hot
just slash the importain commands
I dont like slash so much, so yeah old cli will better
yes thanks you for help ^^
well i didnt help anything, but ok ^^
thank you thank you :))
const { Client, Collection } = require("discord.js");
const { DiscordTogether } = require('discord-together');
const mongoose = require("mongoose");
const Dashboard = require("./dashboard/dashboard");
const client = new Client({
intents: 32767,
});
module.exports = client;
Dashboard(client);
// Global Variables
client.commands = new Collection();
client.slashCommands = new Collection();
client.config = require("./config.js");
mongoose.connect(client.config.mongooseConnectionString, {
useNewUrlParser: true,
useUnifiedTopology: true
});
client.discordTogether = new DiscordTogether(client, {
token: client.config.token
});
// Initializing the project
require("./handler")(client);
client.login(client.config.token);```
your node.js version is outdated
Ok
@quartz kindle I updated Node Still getting the error
can you show your package.json
sure
@sudden geyser
"name": "djs",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js",
"test": "nodemon index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"aki-api": "^6.0.8",
"autoprefixer": "^10.2.6",
"body-parser": "^1.19.0",
"discord-together": "^1.1.62",
"discord.js": "^13.1.0",
"djs-anime": "^2.0.9",
"djs-games": "^2.0.6",
"djs-misc": "^1.0.1",
"djs-utils": "^1.1.2",
"dotenv": "^10.0.0",
"ejs": "^3.0.2",
"express": "^4.17.1",
"express-session": "^1.17.0",
"fetch": "^1.1.0",
"glob": "^7.1.7",
"mal-scraper": "^2.11.3",
"memer-api": "^3.0.6",
"memorystore": "^1.6.2",
"mongoose": "^5.12.3",
"ms": "^2.1.3",
"node": "^17.3.0",
"node-fetch": "^2.6.1",
"node.js": "0.0.1-security",
"passport": "^0.4.1",
"passport-discord": "^0.1.3",
"postcss": "^8.3.5",
"postcss-cli": "^8.3.1",
"random-words": "^1.1.1",
"reconlx": "^2.5.2",
"txtgen": "^3.0.0",
"weather-js": "^2.0.0",
"weky": "^3.1.8"
}
}
Personally would remove your node modules folder and redo npm install
How
Delete node modules folder(just like any other folder) then run npm install
thats nice
never heard of npm ci
there is no need to run npm ci
it is essentially just npm install but for automated environments (whatever that means)
uhh everything is blurry
what
my eyes are going blurry
then go to a doctor or smth
UUUUGH
Do you have a node_modules folder now
it ran through
and it didn't create a node_modules folder
ill run it again
Can you send an ss of your file structure
collapse any folders
Oh that is repl or smth
I don't know if npm install works on repl
i think it does
If it does then why isn't it working for you
There’s a tab for package install iirc
Tbh would contact replit support, or look at their guides.
yeah its the packages tab
ima instal the NPM package
I thought repl auto installed stuff when you added to the package.json or through the packages tab'
nope
ok
@earnest phoenix it did nothing
ima recode it
ok
thats the top
but nothing happens
@earnest phoenix ima let it all properly go through
ok
so remove start?
you should uninstall fs lol
"fs": "^0.0.1-security",
forever
since always?
did you even read the readme of the package?
hes not using the terminal
the .replit file tells what the run button does
his .replit file probably has npm start
it doesnt matter
the problem is
that replit doesnt support node 16+ by itself
you can't remove it
so people do these weird hacks that involve installing node as an npm package
that wont work lol
are you using replit as well?
if you do node .
it uses replit's system version of node
which is v12
unless you used one of the other methods
internal/modules/cjs/loader.js:818
throw err;
^
Error: Cannot find module 'node:events'
Require stack:
- /home/runner/flash-discordbot-3/node_modules/discord.js/src/client/BaseClient.js
- /home/runner/flash-discordbot-3/node_modules/discord.js/src/index.js
- /home/runner/flash-discordbot-3/index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
at Function.Module._load (internal/modules/cjs/loader.js:667:27)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/home/runner/flash-discordbot-3/node_modules/discord.js/src/client/BaseClient.js:3:22)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/home/runner/flash-discordbot-3/node_modules/discord.js/src/client/BaseClient.js',
'/home/runner/flash-discordbot-3/node_modules/discord.js/src/index.js',
'/home/runner/flash-discordbot-3/index.js'
]
}
exit status 1
```
there are several methods to update node on replit
hes using the one that involves installing the node package from npm
thats probably the easiest way to do it
ok
you need to create a new repl project, using nix as the template, instead of nodejs
this then remove .replit?
like do i remove the .replit file?
no
then do it
you have to create a new project
using a nix template
not nodejs
idk
check docs
this
yes
in the .nix file
{ pkgs }: {
deps = [
pkgs.nodejs-16_x
];
}
is this bad?
did you do this ^
let me do that
console.log(process.version)
ok
now I add my code?
now you can transfer the rest of your files yes
no need
ok
was just to confirm
code ```const { Client, Collection } = require("discord.js");
const { DiscordTogether } = require('discord-together');
const mongoose = require("mongoose");
const Dashboard = require("./dashboard/dashboard");
const client = new Client({
intents: 32767,
});
module.exports = client;
Dashboard(client);
// Global Variables
client.commands = new Collection();
client.slashCommands = new Collection();
client.config = require("./config.js");
mongoose.connect(client.config.mongooseConnectionString, {
useNewUrlParser: true,
useUnifiedTopology: true
});
client.discordTogether = new DiscordTogether(client, {
token: client.config.token
});
// Initializing the project
require("./handler")(client);
client.login(client.config.token);
whats the issuse??
Check the value of client.config.mongooseConnectionString
And see if it conforms to the correct URL structure
um what is this
its definded
const { promisify } = require("util");
const { Client } = require("discord.js");
const globPromise = promisify(glob);
/**
* @param {Client} client
*/
module.exports = async (client) => {
// Commands
const commandFiles = await globPromise(`${process.cwd()}/commands/**/*.js`);
commandFiles.map((value) => {
const file = require(value);
const splitted = value.split("/");
const directory = splitted[splitted.length - 2];
if (file.name) {
const properties = { directory, ...file };
client.commands.set(file.name, properties);
}
});
// Events
const eventFiles = await globPromise(`${process.cwd()}/events/*.js`);
eventFiles.map((value) => require(value));
// Slash Commands
const slashCommands = await globPromise(
`${process.cwd()}/SlashCommands/*/*.js`
);
const arrayOfSlashCommands = [];
slashCommands.map((value) => {
const file = require(value);
if (!file?.name) return;
client.slashCommands.set(file.name, file);
arrayOfSlashCommands.push(file);
});
client.on("ready", async () => {
// Register for a single guild
await client.guilds.cache
.get("834390097621286922")
.commands.set(arrayOfSlashCommands);
// Register for all the guilds the bot is in
// await client.application.commands.set(arrayOfSlashCommands);
});
};
oh
What do you mean
you can also write it like that
Yes you can
hmm why the color change
Is it working?
WHY DID I TRY A PROJECT THIS BIG?!?!?!?
Yes, you can, but it's significantly more difficult for beginners when the thing to do is hard.
Well sorry
no
Exactly
ima go watch a 2 hour javascript learning video
nvm its 3 hours
it will be 12 am when i am done
its 9 PM
its freeCodeCamp im watching
its helped me a few times but i'm gonna watch the full 3 hours
im learning now
should learn some clojure
i have never been committed enough to watch a 3 hour learning video
You don't need to be committed to it.
Watch the video whenever you feel like it in small chunks.
It's the slow path that'll teach you your first programming language.
my friends have been telling me for months bc i used to fork code and use it and they hated me for it
LOL
someone told me to shutdown my bots bc i forked the code
forking projects is fine
I don't get why people get mad over people forking their project
when making it public on github
sad memories of intro to compsci flow through one's mind
pain
1 sec my computers default backspace button is sticking ima plug my keyboard in
await interaction.reply({ content: 'Aviso Enviado!', ephemeral: true });
interaction.channel.createWebhook(name, img).then( msg => {
msg.channel_aviso_no_servidor.send({embeds: [embed_2]})
});```
Erro: TypeError: Cannot read property 'send' of undefined
yes it is
let servidor = interaction.guild.id;
let channel_aviso = db.get(`channel_aviso_${interaction.guild.id}`);
let channel_aviso_no_servidor = client.guilds.cache.get(servidor).channels.cache.get(channel_aviso);
if (!interaction.member.permissions.has("ADMINISTRATOR")) return interaction.reply({content: 'Você não tem permissões para usar esse comando'});
if (!channel_aviso_no_servidor || !channel_aviso || channel_aviso === null || channel_aviso === false) return interaction.reply(`**${interaction.author} o chat aviso não está configurada no servidor.**\n **Use** -setaviso "mencionar chat/id" **para configurar**`);```
lol my method of checking my console logs is using my iPad as a second screen
but is
the problem is on the sender
the "msg" isnt defined i think
because of the "then"
interaction.channel.createWebhook(name, img).then( msg => {
msg.channel_aviso_no_servidor.send({embeds: [embed_2]})```
but if the channel_avisos_no_servidor isnt defined
the command dont run
if (!channel_aviso_no_servidor || !channel_aviso || channel_aviso === null || channel_aviso === false) return interaction.reply(`**${interaction.author} o chat aviso não está configurada no servidor.**\n **Use** -setaviso "mencionar chat/id" **para configurar**`);
huh just figured out you can do this
im watching the video
OOO
I learned that the text listed in the var line is Case sensitive
umm
is that right
i thought it was gonna say its not defined
JavaScript is very loose on types and syntax
It's syntactically correct (how it was written), but semantically incorrect (what it should've done)
Oh dam there’s a shortcut on telling the code what something equals by adding (x += x)
-= *= /= also work
Oo
theres a ton of that stuff
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Addition_assignment
on the left side there's a list of assignments
Like what npm do I run?
Fresh install of mongo(ose) on node 16, just trying to build throws this error when building (TS). Any ideas?
Looks like mongoose has some weird TS generic issues.
I think it's a yarn.lock issue. Nevermind
did you install typings for node?
I have never heard of that.
Interesting.
What's even scarier is the same mongoose version works on two other projects.
Well that did what I wanted.
So I appreciate it.
You can’t
You can but it required some magic shittery
If you search for "update node repl" in this channel you might find something
cc @hidden gorge
can anyone think of a way to scan a servers members and do something if their role == something without members intents
seems to even detect a role change you have to have members intents so dumb
that's the so called "privacy"
it's literally on my own server, i mean why. i can view that info with my eyeballs.
if you have the id you can try fetching the member
users (not bots) normally have member intent
is there a way to webhook it or something with integrations
i'd need to check if the id is in my server though
webhooks are shit
they can't do anything except sending messages
if you have the id
https://discord.com/developers/docs/resources/guild#get-guild-member
wait
it needs guild members intent too
fuc

okay so id need them to send a message in the guild to be added to the list and then every 24 hours fetch every member on the list and check if they're in the guild and have the same role
is discord gonna get annoying if in the future i have to send 1000 fetch requests
if you have the PRESENCE intent you can do this on presence update
so like when someone logs in or out or starts playing a game
Just don't send more that 2 requests per second
if this feature is only for your server you can simply create another bot and turn on member intent
bots under 100 can turn it as they will
discord gonna be pissed off if i do this
?
no
they fuc*ed us enough already
so they should also expect some
how quickly does guild.member_count update
if you dont have members intent, it doesnt.
it does though?
Discord.js command handling - there is local and global deploy option. As i understand global is for all the guilds, local is only for specific guilds?
Because i am just reviewing a code and wondering, if i understood that right..
Can someone tell me please if the above code makes sense? shouldn't global commands also be loaded with the test environment?
I never seen that before, but this is what I have made
add a new variable to Client (client.state as boolean)
if the state is true then it will be run on public, else it will run only in the test server
in the messageCreate event
if(!client.state && message.guild.id !== "GUILD_ID") return;
but that thing, I never seen before
Can someone help me with this? Code and error
const embed = new MessageEmbed()
.setAuthor('Moderation')
.setColor('GOLD')
.setDescription('`.prefix`, `.whois`')
const embed1 = new MessageEmbed()
.setAuthor('Configuration')
.setColor('GOLD')
.setDescription('`.setrolelog`, `.disablerolelog`, `.setjoinchannel`, `.disablejoinchannel`')
client.on('interactionCreate', (interaction) => {
if (interaction.isButton()) {
if (interaction.customId === "mod") {
interaction.reply({ embeds: [embed], ephemeral: true, allowedMentions: {repliedUser: false}});
} else (interaction.customId === "config"); {
interaction.reply({ embeds: [embed1], ephemeral: true, allowedMentions: {repliedUser: false}});
}
}
})
C:\Users\great\OneDrive\Desktop\Angelus\node_modules\discord.js\src\rest\RequestHandler.js:349
throw new DiscordAPIError(data, res.status, request);
^
DiscordAPIError: Unknown interaction
at RequestHandler.execute (C:\Users\great\OneDrive\Desktop\Angelus\node_modules\discord.js\src\rest\RequestHandler.js:349:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (C:\Users\great\OneDrive\Desktop\Angelus\node_modules\discord.js\src\rest\RequestHandler.js:50:14)
at async ButtonInteraction.reply (C:\Users\great\OneDrive\Desktop\Angelus\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:99:5) {
method: 'post',
path: '/interactions/927887488184373258/aW50ZXJhY3Rpb246OTI3ODg3NDg4MTg0MzczMjU4OmR2R1dDeEpla1pVbUQwOWlYZlh0eGVGcWJmUFdmbEhTTWZPUWl6ZE9UR0pFQ2JqU3I5MlF1QjQ5WUZTaHVXRUVHS2tRRFhZbkZTUzNIRTY2MnI3Um50TDBXSzJ3WGJ4a3EyUnNHWUJWaDUzdGdmeGJ3em5wYkNScEpWMDI1QTgz/callback',
code: 10062, httpStatus: 404,
requestData: { json: { type: 4, data: [Object] }, files: [] }
}
[nodemon] app crashed - waiting for file changes before starting...
the interaction that you want to reply is not found? since the http status is 404...
How could i fix it again?
Wait, wdym its not found
is the interaction exist? like is it deleted
log content[0]
is there an api event on user bot add?
Like adding to a server?
If you are using discord.js then guildCreate event fires when the bot joins a guild
If you are using the discord api then guildCreate fires when the bot joins a guild :p
(Assuming you have the correct intents)
but i want to know what site they got added from
hense it from this api
From what api
top.ggs api
not possible unless you add some kind of tracking to your invite link
make different ones for different bot lists
Someone have a cool website template for a discord bot?
I have more than one
https://yagpdb.xyz/
https://carl.gg/
https://mee6.xyz/
why not
probably because you dont quite understand what this does:
const [list] = JSON.parse(response.body);
const [post] = list.data.children;
that is exactly how you parse it tho
what does that do though 👀
const [a] = something is an array destructor assignment
its the same as const a = array[0]
oh thats sweet
[a, b, ...rest] = [10, 20, 30, 40, 50];
console.log(rest);
// expected output: Array [30,40,50]
so whatever item you are destructuring, it needs to be an array-like, aka an iterable
it does not work on objects
if you want to destructure object keys, you need const {a} not const [a]
thats actually so useful in cases.
reddit has mega brain
the response json is structured like this:
{ // note the [
"data": [{
"data": { // here too
"children": [{
// actual post data
}]
}
}]
}
no idea how I didnt know about this
if thats the structure, then if should be const [a] = JSON.parse(...).data
the array is inside the data key
wait there's no [ in the first data
async function fetchMeme() {
let resp = await fetch("https://www.reddit.com/r/memes/random.json");
resp = await resp.json();
const meme = resp[0].data.children.find(x => !x.over_18) || await fetchMeme();
return meme.data;
}
some old code of mine that does this
yes that's a multi purpose bot 
this is what i get from that url
so it should be JSON.parse(response).data.children[0].data
const meme = resp[0]/* wtf */.data.children.yadayadayada
I don't understand my own code
me when i use array on the url that does not need array
it does
it's a single post
but what's the point
JSON.parse(...)[0].data.children
const body = JSON.parse($("pre").innerHTML);
console.log(body[1].data.children);
[]
but why doesn't that have anything in it
what
the code you just sent now
body[1].data.children would error
if body[1] does not exist
you asked why doesnt it have anything in it?
oh you're talking about children?
i though you were saying why send body[1] if it doesnt have anything in it
lmao
.
here is where the errror comes
you are not showing the actual error
discord.js v13 requires node.js v16.6+
repl.it does not officially support node v16
the last official version is v12
oh
a....
one of the most common ones is to create a nix project instead of nodejs
is there any other option to fix that?
one of the most common ones is to create a nix project instead of nodejs



