#development
1 messages · Page 120 of 1
is it possible to make a class that defines a generic not trough the constructor?
anyone who knows how to use tensorflow for py? I need some help with my epoch, batch, layer configs as my mean absolute error is pretty high
i am not asking to ask, this literally was my question
when i work with typescript i try to make everything as simple as possible, because once it starts getting too complicated it quickly becomes an ungodly mess
the problem is that it just is quite a complex project
meaning i dont work too hard to make every single millimetre of code correctly typed down to every single possible combination
Read the content of the website
its fine to sometimes work with a few any's here and there and manually inject type coercions here and there
Especially the first few paragraphs, even though reading the website in its entirety is definitely worth it
do you know about this, tim?
no
Sounds great, don't expect any replies then ^-^
okay 👍
Your message is 1 to 1 the described behavior of the website
Really?
Wow*
I recently used tensorflow to create a model for predicting. I started with 50 units in each layer (except for the dense layer) and also added a batch size of 32, eventually 50 epochs as well. For linear predicting, would anyone know any good values for these variables as i currently get a mean error of around 57%
i know it's a matter of trial and error but is there any ballpark so that it makes the setting up part of my model a bit easier..
is this better for you Moderator Krypton?
directly with generics i dont think so, unless you create a class builder that returns different classes based on options.
you can however use narrowing to filter unions inside classes
See, with some effort it's doable
Though don't expect anyone to answer as the active people don't use py or tensorflow 
with the builder, do you mean instead of this I return the builder with the generic set?
bot dev, nice
?
Show me.
I want Main to Renderer
Not Renderer to Main to Renderer
You can use ipcRenderer.on if I remember correctly
I guess
I guess it could be nice for a ads discord
"PromotionBot is a Discord bot designed to help server owners and administrators promote their servers based on the number of invites users have generated. The bot rewards active users who invite new members to the server by allowing them to promote their own servers once they reach a certain threshold of invites. It also provides an easy-to-use interface for checking the number of invites a user."
its cool for you'r server !
You mean “your server”
No thanks
discord might not like that
promotions for invites
j4j essentially imo
I have already done a project like this I had no problem
j4j is cringe
My bot check J4J 🙂
Agree
yes..
dont worry
guys sorry but i have stupid question
how to make that
Sunday, August 13, 2017 3:21 PM
<t:123>
<t:timestamp>
<t:99999>
Google what timestamp is
ok
Also this
Even more on github
https://gist.github.com/LeviSnoot/d9147767abeef2f770e9ddcd91eb85aa
Or not, that's the same

thanks i was going ask that question
Or just the official documentation lmfao
Creating a gist that straight up is a copy of the docs 
anyone have a bot idea ?
You already have a bot, why do you need another one?
why not 2?
I'd have 272 bots tbh
With each a single command
Shouldn't be too hard
Elon musk
the hosting costs tho
I'm trying to make a TwitchPlayer using SvelteKit, but when I change pages in a "Layout" the iframe reloads and I don't want that. For example, TwitchPlayer will show up in /dashboard/channel but not in /dashboard/videos and if I go from /dashboard/videos to /dashboard/channel the iframe will not load from the beginning.
I solved the iframes not being reloaded by putting them directly in the +layout.svelte file, but how can I make them appear where I want on the page I want?
use routers mayhaps, if you do have access to the path
can anybody help me solve this issue pls
…?
everything is awaited tho
Then you can't do
s = Something()
but have to do
s = await Something()
what am i supposed to await it tho ion get that
Because you declared __init__ as an async function
Welcome to asynchronous programming
ik it sucks
so i remove that async?
Or as said, await it.
Though looking at that madnesss
Makes more sense to remove the async
7 it is awaited
???????
You're awaiting the init call of super
Not YOUR init function
Where do you await it in this line?
but you can’t await tasks in array ? or can you
What you definitely can't do is make magic methods as async
Make your init function non async and don't call await super().__init__()
Starlette.__init__(self, routes=[
Route('/', self.home),
])
is a thing, as shown in their documentation
Or I guess don't await the init call on super, as magic methods are not made to be async either way, so I doubt they made their init method async
Not sure why you decided to await that if it can't be awaited in the first place
If you don't use it correctly or don't understand the fundamentals, obviously
Can't just slap await or async anywhere
that makes sense tho
anyways can you help me explain another error
Collar blue
ok
This function cannot be called when another asyncio event loop is running in the same thread.
Don't have 2 event loops running on the same thread
well i read that but idk what cases that error
i get it
i think
i have to use this right
Do you guys know how to host a bot or develop it through iphone
@fiery stream could you tell me which application do u use?
Host? Use a VPS
Code? Use a PC
replit
i use it for coding tho
I mean I got vps and host bot
not hosting
Yes but you can node it right?
wym
npm i discord.js 
Yes, read the message
theres a tab for packages in there
open new page n click packages n search it
I found it but its v14, I wanna v13 but dont find it
then im not sure mate i dont really code in javascript been a while
how verify bot
You need 100servers to be im then in bot application in discord dev portal you can request to verify yourbot
@celest swan bot join 100 server
76*
https://support.discord.com/hc/en-us/articles/360040720412-Bot-Verification-and-Data-Whitelisting
https://support-dev.discord.com/hc/en-us/articles/6206007597207-How-do-I-get-my-bot-verified-
TLDR
If your bot is in more than 75 servers, you can request verification from its page on the Developer Portal.
Details
If your bot is in more than 75 servers, you will see a banner at the top of ...
thank you
So I installed discord js v13 version and it dont recgonize it
npm install discord.js@14.something
does it execute tho?
I'm trying to make a TwitchPlayer using SvelteKit, but when I change pages in a "Layout" the iframe reloads and I don't want that. For example, TwitchPlayer will show up in /dashboard/channel but not in /dashboard/videos and if I go from /dashboard/videos to /dashboard/channel the iframe will not load from the beginning.
I solved the iframes not being reloaded by putting them directly in the +layout.svelte file, but how can I make them appear where I want on the page I want?
why do racists make bad databases?
because they hate foreign keys.

...i'll get my coat
Go away
thats more xenophobia than race but yeah lmao
dear god
is the issue sending messages, or is it not receiving commands?
slash commands or prefix?
or something else
prefix
does it have permissions
yes administartion
do you have the message intent enabled?
^
all the 3
in your bot and on the dash?
do you have it enabled in your code
hmm it might be this problem
import discord
from discord.ext import commands
import random
import json
# Load Pokemon names from file
with open('pokes.txt', 'r') as f:
pokemon_names = f.read().splitlines()
# Load Pokemon info from file
with open('pokemon.json', 'r') as f:
pokemon_info = json.load(f)
# Load user data from file
with open('user.json', 'r') as f:
user_data = json.load(f)
intents = discord.Intents.default()
intents.members = True # Enable the privileged gateway intent
bot = commands.Bot(command_prefix='!', intents=intents)
@bot.event
async def on_message(message):
# Ignore messages sent by the bot itself
if message.author == bot.user:
return
await bot.process_commands(message)
@bot.event
async def on_ready():
print('Bot is ready.')
@bot.command(name='hunt')
async def hunt_command(ctx):
pokemon = random.choice(pokemon_names)
# Check if user exists in user_data
if str(ctx.author.id) not in user_data:
user_data[str(ctx.author.id)] = {'hunted_pokemon': []}
hunted_pokemon = user_data[str(ctx.author.id)]['hunted_pokemon']
# Check if the pokemon is already hunted
if pokemon in hunted_pokemon:
await ctx.send(f"You hunted {pokemon}!")
else:
hunted_pokemon.append(pokemon)
# Save user data to file
with open('user.json', 'w') as f:
json.dump(user_data, f)
# Check if the pokemon is hunted for the first time
if hunted_pokemon.count(pokemon) == 1:
await ctx.send(f"A wild {pokemon} appeared! Registered to Dex!")
else:
await ctx.send(f"A wild {pokemon} appeared!")
@bot.command(name='pokemon', aliases=['poks'])
async def pokemon_command(ctx):
# Check if user exists in user_data
if str(ctx.author.id) not in user_data:
await ctx.send('You have not hunted any Pokemon yet!')
else:
hunted_pokemon = user_data[str(ctx.author.id)]['hunted_pokemon']
if not hunted_pokemon:
await ctx.send('You have not hunted any Pokemon yet!')
else:
embed = discord.Embed(title="Your Hunted Pokemon", color=0xff0000)
for i, pokemon in enumerate(hunted_pokemon, start=1):
embed.add_field(name=f'#{i} {pokemon}', value='', inline=False)
await ctx.send(embed=embed)
@bot.command(name='info')
async def info_command(ctx, pokemon_number: int):
# Check if user exists in user_data
if str(ctx.author.id) not in user_data:
await ctx.send('You have not hunted any Pokemon yet!')
return
hunted_pokemon = user_data[str(ctx.author.id)]['hunted_pokemon']
if not hunted_pokemon:
await ctx.send('You have not hunted any Pokemon yet!')
return
if pokemon_number < 1 or pokemon_number > len(hunted_pokemon):
await ctx.send(
f'Invalid Pokemon number. You have hunted {len(hunted_pokemon)} Pokemon.'
)
return
pokemon_name = hunted_pokemon[pokemon_number - 1]
pokemon_info_data = pokemon_info[pokemon_name.lower()]
# Check if user has hunted this Pokemon before
user_hunted_pokemon = [p.lower() for p in hunted_pokemon]
if pokemon_name.lower() in user_hunted_pokemon:
num_hunted = user_hunted_pokemon.count(pokemon_name.lower())
message = f'You have hunted {num_hunted} {pokemon_name}!'
else:
message = 'You haven\'t hunted this Pokemon yet!'
embed = discord.Embed(title=pokemon_name.capitalize(), color=0xff0000)
embed.set_image(url=pokemon_info_data['image'])
embed.add_field(name='Type', value=pokemon_info_data['type'], inline=True)
embed.set_footer(text=message)
await ctx.send(embed=embed)
is it there in the code?
@spark flint
nope
you don't have the intent enabled
intents = discord.Intents.default()
intents.members = True # Enable the privileged gateway intent
bot = commands.Bot(command_prefix='!', intents=intents)
this
the docs go over it
ok
btw, don't use json as a database
?
json is still extremely relevant. its just not meant to be used as a database
never was
you can use it for pokemons, as they wont be changed
is database easy to learn
but definitely not for user data
depends
I think it's fairly easy, but it's "different"
oh
yw
intents = discord.Intents.default()
intents.members = True # Enable the privileged gateway intent
intents.messages = True
bot = commands.Bot(command_prefix='!', intents=intents)
still not replying 💀
💀
sry i read it quickly
scrolling down using my new mouse lol
working
If i use images of pokemon from different sites will it be a issue in future?
like copyright or something?
ok
pokeapi is free right?
ty :)
very likely if your bot becomes big enough
ESPECIALLY if you have any sort of monetization
nintendo doesnt have a good track record of supporting fan apps (especially discord bots)
that depends, if you're doing something nintendo related then there will be issues like the second you do something with those images. there's a creative commons law where you pay to use stock images. now pokemon is protected by trademark law so you can't use anything they have that is trademarked without having the chance of being sued. also pokemon company has answered this question. they said that nobody should use their images because they are unable to review requests relating to pokemon intellectual property
tldr: copyright laws, short answer; no
if i use PokeApi is it safe?
it's a "using pokemon at all" issue, not what api u use
you'll probably fly under the radar for a while, they wont bother with an unknown bot
but the moment you get some popularity, expect a C&D email
if they do happen to notice you using images without permission you will get a cease and desist
damn that came after i hit enter
lul
can 403 errors like this be cause by a lack of permissions or is there a special character that's not allowed?
403 is forbidden
like no permission forbidden?
"you cant access this" forbidden
403 (FORBIDDEN) The Authorization token you passed did not have permission to the resource.
nope, ssi is 5xx
sounds like it's trying to find a permission that doesn't exist, related to API
{
"components": [
{
"type": 1,
"components": [
{
"type": 2,
"label": "Join Lobby",
"style": "3",
"custom_id": "join_lobby_btn.[REMOVED]",
"disabled": true
},
{
"type": 2,
"label": "Leave Lobby",
"style": "2",
"custom_id": "leave_lobby_btn.[REMOVED]"
}
]
},
{
"type": 1,
"components": [
{
"type": 2,
"label": "Start Lobby",
"style": "1",
"custom_id": "start_lobby_btn.[REMOVED]",
"disabled": false
},
{
"type": 2,
"label": "Close Lobby",
"style": "4",
"custom_id": "close_lobby_btn.[REMOVED]"
}
]
},
{
"type": 1,
"components": [
{
"type": 5,
"custom_id": "kick_player_btn.[REMOVED]",
"placeholder": "Kick a player"
}
]
}
],
"embeds": [
{
"title": "zzzAlex-DigimonTCGSP's Hosting a **!A pelear¡** Lobby",
"description": "\n**Lobby is ready to start!** \n\n**Players**\n<@[REMOVED]>\n<@[REMOVED]>\n\n**Lobby Info**\n*Players*: 2 players\n*Team Size*: Free for all\n**Host your own Lobby**\nhttps://discord.com/channels/[REMOVED]/[REMOVED]/[REMOVED]",
"color": 16730441,
"footer": {
"text": "\nA voice channel will be created for everyone to share when the match starts."
}
}
]
}
here's the request body with all IDs replaced with [REMOVED]
Not necessarily wrong token
The code is irrelevant
^
shouldn't style be a number?
what error do you get when the embed is missing required fields?
it's trying to make a PATCH request but it isn't allowed to make that request
400 Bad Request (Invalid Form Body)
As it says
The Authorization token you passed did not have permission to the resource.
Your code may be perfectly correct, if your bot doesn't have access to whatever you're trying to do - it won't go far
it's trying to find the channel but it doesn't have access to the channel
Not necessarily either
Could very well be trying to edit a message it cannot edit
so they'd need send message perms?
That for sure
mmkay, i'll ask them what perms they gave the bot
Unrelated to your issue but may I ask why you're using Axios over the built-in global fetch() function? (Or just Undici, which is where that function comes from), or Node-Fetch
i dont like specifying content-type everytime i make a call
You don't have to, that header is specified by default when possible
u can make a wrapper for fetch
it should be
also dont like doing the res.json thing
sometimes I wonder if I'm the only weirdo that make wrappers when I don't want to specify the same properties everytime
If you're using Node.js v18 or higher, use the built-in global fetch() function, otherwise use Undici
The Fetch API is a standard
fetch diez
It is, but not everything expects the same content-type so you'd have to specify it yourself, besides you can make a wrapper as said if you really need it to be passed in every request you make
Hmm why is that? 🤔
i just like how axios sees im passing json so it make it json
Fetch also does that
.then(res => res.json())
.then((json) => {
// do something with JSON
});```
.then(res => res.json())
you could easily make a small wrapper around that though
Oh I was talking about the header, what you're showing is a body consumer, not everyone wants to consume a body and look at it, which can also take a long time depending on the body type and size
btw, you don't always want the body json
And yeah
it'd be better for large payloads not to call res.json()
when the body is json i always want it to be json. axois does that
and check status beforehand
i thought axios doesn't automatically do that
nope, what if for example, you just want to check if something exists?
you'd not need to get the body json, just the status
this is a weak example tbh, but there are scenarios where not getting the json is preferrable
cough cough like when working with patreon cough
the content-type is set to json when the request body is json. the response is parsed json if the response has a json header content type
the response wont be parsed until you use res.json()
before that it'll be plain text
they're talking about axios?
fetch
I'm sure they mean axios
axois looks at the headers and sees it's json for me
i just tested fetch and it looks like it add the content type headers now
on requests
Fetch already does the first part, the second part however is better left to do manually as the body is not always the preferred response, as KuuHaKu mentioned with an example
like for multipart contenttype responses
just look at the content type. if it's json then parse it to json
we don't mean different headers
we mean that sometimes it's preferrable not to call res.json() if what you want is other data
as that'll parse the text into a json object
thus allocating more resources
wouldn't the content-type not be json in this case?
it doesn't matter
server could be messed up sending the wrong content type
you could have content-type: Shrek Video an still call res.json()
content type doesn't define what's being sent through the body, it just tells the receiver what to expect
if the receiver expects json then why not just call res.json() for me internally?
imagine you have a huge payload, with millions of entries
The API doesn't know if you actually want the body of the request to be consumed, and shouldn't assume that as the receiver may just be looking simply for the status, header data, or similar, or for the body to be consumed as a different type rather than just the specified content-type
fetch is handling too many cases for me
ok, imagine this:
You use an anime api to search for results, you want to know if the anime exists (not anything else like name or episodes), why would you call res.json() instead of just checking if res.statusCode == 200?
why would i return json from the server?
you're not the server, you're consuming the api
the server returns all the info about anime XYZ
in my case i am the server and the consumer
except for the discord api stuff
but they give the right content-type
yes, but forget abt ur current case, we're explaining why res.json() isn't required everytime
for some transactions you simply don't care about the body, you just want the headers or other metadata
it is if you need the body
you could also use the raw body, but it'd be hard to work with
res is the request itself
to get the plaintext you'd use res.body
you'd want to work with a data stream instead of putting the entire res.body into memory
Res is the response, it contains status code, headers, and other metadata sent by the server, if you want to get the text response you would call res.text()
the latter is official
fetch was a browser-only api, but they integrated into node in the newest versions
nodefetch is third party for nodejs
is there a way to get a stream of the response text instead of the whole thing in memory or does that require multipart?
json must be parsed all-or-nothing, if you want to use streams you need to use another format
multipart is just to tell the receiver that there'll be more data to come
i've kinda used json in a stream. each line was a json object so the stream reader would read one line at a time, parse the json, put the record into the db, and then on to the next line
I mean, as long as the json starts and ends in the same request
Yes:
const reader = res.body.getReader();
let data;
while (!(data = await reader.read()).done) {
// Do something with chunk of data
}
misread, nodefetch and fetch use different environments. like kuu said, fetch is browser only, while node-fetch is used in server-side javascript
if you do lots of processing will this hold open the connection so the server waits for the client to read everything?
there's fetch for node now, node-fetch was a third-party surrogate while node didn't get it oficially
The Fetch API is not browser-only, it can be implemented and used everywhere as it's a standard
Node-Fetch implements the Fetch API, and so does Undici (the Fetch API Node.js uses as built-in), Undici does it better and is more standard compliant
Yes
nice, i wonder if it's easier with axios
Undici does it better
lies
well tbf its been a while since i used it, hopefully its much better now
Hey! how can I check that sometimes the server takes more than 3 seconds to answer?
Because sometimes i'm getting unknown interaction from nowhere with Discordjs
well, you catch the Unknown Interaction exception
by rule of thumb, anything that involves additional processing should have the interaction deferred as the very first thing
before starting anything else
in fact it seems happening not on the slash commands but in components
i'm doing that
await event.reply(content).then(e => {
const filter = async i => i.user.id === this.author && await i.deferUpdate()
const collector = e.createMessageComponentCollector({ filter, time: 250000})
collector.on("collect", async r => {
switch(r.customId) {
case "profileDisplay":
if(AllowedPage.includes(r.values[0]) && this.Page[r.values[0]] != undefined) {
const content = {embeds:[this.Page[r.values[0]]]}
r.editReply(content)
}
break;
}
})
})
are you 100% sure that code works?
yep it does
as I see it, you're replying/deferring more than once
oh wait, nvm
that's a collector
but well, see this:
const filter = async i => i.user.id === this.author && await i.deferUpdate()
you're not deferring as the first operation
if the user that clicks is not the author, it wont defer
ah you think it may come from that?
very likely
i'll try
I tried with my secondary acc
and it doesn't send error
it may come from networks issues too no?
unlikely, unless your host is shit
discord has its own internal pooler, so the requests wont come fast enough to cause lost requests
not to mention libraries also have their own poolers
i'll also try to replace my filter by that
const collectorFilter = async i => {
await i.deferUpdate();
return i.user.id === this.author;
};
another tip (not related to the original issue), store the array values in a constant
const page = this.Page[r.values[0]]
How can I make the iframe not reload even if the pages in a route change in ReactJS
but the iframe will appear on a single page
Alright, Thanks you for your time!! I hope its going to work 
gl
guess what this evaluates to without running it.
const title = document.title || typeof document.title === 'undefined' ? "No Title" : "Empty String Title"
i think i broke javascript
Should be !document.title
|| is evaluated before ternary
If title exists OR title undefined = no title doesn't make sense
so your code is basically (document.title || typeof document.title === 'undefined') ? "No Title" : "Empty String Title"

lmao
ternary has one of the lowest priorities
since its basically a glorified if
look at it like this, and it will make more sense
if(document.title || typeof document.title === 'undefined') { "No Title" } else { "Empty String Title" }
i just need to remind myself that logical OR and ternary aren't at the same level
ternary's always seem more like a glorified logical or statement
damn
const { Permissions, EmbedBuilder } = require('discord.js');
module.exports = {
name: 'lockdown',
description: 'Locks down all channels',
category: 'moderation',
usage: '<reason>',
permissions: ['MANAGE_CHANNELS'],
async run(client, message, args) {
// Check if a reason was provided
const reason = args.join(' ');
if (!reason) {
return message.channel.send('Please provide a reason for the lockdown!');
}
// Lock all channels and send embed message
const channels = message.guild.channels.cache.filter(channel => channel.type === 'GUILD_TEXT');
const lockdownEmbed = new EmbedBuilder()
.setColor('#ff0000')
.setTitle(':lock: Server Lockdown')
.setDescription(`The server has been locked down due to the following reason: **${reason}**.\nWe apologize for the inconvenience and we will fix the issue as soon as possible.`);
channels.forEach(channel => {
channel.permissionOverwrites.edit(message.guild.roles.everyone, { SEND_MESSAGES: false });
channel.send({ embeds: [lockdownEmbed] }).catch(console.error);
});
// Create and log the timeout role
const timeoutRole = await message.guild.roles.create({
name: 'Timeout',
color: '#ff0000',
permissions: [],
reason: `Server lockdown: ${reason}`,
});
message.guild.channels.cache.forEach(channel => {
channel.permissionOverwrites.edit(timeoutRole, { SEND_MESSAGES: false });
});
const modLogChannel = message.guild.channels.cache.find(channel => channel.name === 'mod-logs');
if (modLogChannel) {
modLogChannel.send(`🔒 Server locked down by ${message.author.tag} for the following reason: **${reason}**.`).catch(console.error);
}
},
};
error:
RangeError [BitFieldInvalid]: Invalid bitfield flag or number: SEND_MESSAGES.
Hello guys. I am new to bot development and I've seen that there are multiple libraries and frameworks, I've been using discord.py Discord.Client but it is being difficult to integrate slash commands, maybe it would be better to use the interactions framework?
slashes are interactions
I'm saying that what library is better: Discord.client or interactions.client.
Use discord.py and that's it
the difficulty will be arguably the same as you'll be using interaction events
No need to get an additional library whatsoever
just make a decent command structure (d.py has a command manager iirc) and call them inside a single event handler
No need to have an event handler at all
correct
damn
@app_commands.command(name="monke")
async def monke(self, interaction: discord.Interaction) -> None:
await interaction.response.send_message("yes")
All you need
ok thank you!
Is there a easy way to prevent a bot from tagging users as <@id> instead of their name
wdym?
Like @daring fjord
Instead of actually tagging the user, its in discord.js
I have it as a string <@${id}>
But sometimes it doesn't actually tag the user.
is id a string or a number?
string
I think its a cache issue because if I mention the user and then redo the command it works fine
No way to have the bot pull from cache?
it's not the bot that pings, it's discord itself
Okay, thanks for the info.
const { SlashCommandBuilder } = require("@discordjs/builders");
const { MessageActionRow, MessageButton, MessageComponent, MessageEmbed } = require("discord.js")
let x = Math.floor((Math.random() * 6) + 1);
module.exports = {
data: new SlashCommandBuilder()
.setName( "bat")
.setDescription("bat a random bowl"),
async execute (client, interaction) {
const row = new MessageActionRow()
.addComponents(
new MessageButton()
.setStyle("PRIMARY")
.setCustomId("coverdrive")
.setLabel (" Drive "),
new MessageButton()
.setStyle("SECONDARY")
.setCustomId("defend")
.setLabel ("Defend "),
new MessageButton()
.setStyle("DANGER")
.setCustomId("loft")
.setLabel ("Loft "),
)
return interaction.reply({ content: `An Inswing Delivery Is Coming.<@${interaction.user.id}>`, components: [row] });
client.on("interactionCreate", async (ButtonInteraction) => {
if(ButtonInteraction.isButton()) return
if(ButtonInteraction.customId === "loft") {
await ButtonInteraction.reply({content : `${x}`})
}
})
}
}```
it sends message (inswing delivery) but when i am pressing buton,it isn't replying
can u say like how do i make button reply
With interaction collector
Yes, you can, but the minus or plus is that such a button will always work. The one from the collector for a limited time only
this should not be inside the command file
in interactionCreate File?
if you already have an interactionCreate file, then you already have a client.on for that file
so remove the client.on part
do you have a command handler?
or is the code you showed your interactionCreate file?
Update :( It doesn't fix the problem tbh i'm going to just handle them as random error
how's your current code?
i just remove defer from the filter and put it after the collector on
const collector = right.createMessageComponentCollector({ filter: (i) => i.user.id === this.author, time: 250000});
collector.on('collect', async r => {
await r.deferUpdate(),
this.message = r;
await this[r.values[0]]();
})
Oh wait maybe i just remind myself somethings do you think it could come from that?
static async send(event:any, msgTypeInteraction:any, msgTypeMessage:any):Promise<any> {
msgTypeInteraction["fetchReply"] = true
msgTypeMessage["fetchReply"] = true
return event.type == 2 ? await event.editReply(msgTypeMessage) : event.type == 3 ? await event.editReply(msgTypeInteraction) : event.channel.send(msgTypeMessage)
}
I'm doing this weird things to not have two time the same code for Interaction and Message event
Yeah iknow too i should drop the message support
idk how interaction collector works, does it automatically defer if an invalid click is done?
Wdym by invalid click
for example, if someone that's not the author clicks on the button

i got it working you want an example?
me?
i tried it literally didn't reply, send nothing in log and just return error on discord (interaction failed)
yes you 
const filter = (interaction) =>
interaction.user.id === interaction.user.id;
const collector = interaction.channel.createMessageComponentCollector({
filter,
time: ms("30s")
});
collector.on("collect", (interaction) => {
(interaction.customId == "customId") {
//do stuff
}
});
collector.on("end", (collected) => {
interaction.editReply({ components: [] });
// console.log(`Collected ${collected.size} interactions.`);
return;
});``` this is the code i use
let's go bro show me xD
ahh i understand
but it is because you can only do it one time
mine can be press more than one
you can change it to this hang on
Hi who knows any free ai generation api for discord.js bot?
now it will fire everytime the user clicks on the button for 30s
you mean a ai that generates a discord bot for you?
let me know if it works ( or not xD )
in fact
I was almost doing the same thing?
const collector = e.createMessageComponentCollector({ filter: (i:any) => i.user.id == this.author, max:1, time: 300000 });
collector.on('collect', async r => {
await r.deferUpdate();
const NotificationIn = new NotificationReminder(this.playerLang, this.author);
switch(r.customId) {
case "hourlyNotification":
NotificationIn.buildHourlyNotification(currentDate)
NotificationIn.bulkAddNotification();
r.followUp({
content:this.langWriter.writer("notification.remindAdded"),
ephemeral:true
})
collector.stop();
break;
}
})
no?
Do you think say channel change somethings?
like event.channel.createMessageComponentCollector
well in my example it listens for every button click in said channel
may i ask what the customId is you're listening for
because if you do it like this js if (r.customId == "<your customId>") {} maybe it'll work
what do you want to know xD i made a play command that can play and search a song on youtube xD
Images like /imagine spongebob in car and it generates image
Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.
is there any way to see which permissions are set for my bot in someone's server? do i need to find my bot's role on a server and then look at the permissions of that role?
if you use slash commands it's just app_permissions property in the payload
so how do i figure out what this is?
app_permissions: '112150186033143'
deserialize it
or use bitwise and operator
this is the error im getting from this server. u will look at how to do that now
what's this
a Create Guild Channel api call that is failing on a server with app_permissions: '112150186033143'
MANAGE_CHANNELS and possible MANAGE_ROLES is needed
I know the code says 403 but the error says bad request
could it be the data is invalid?
{
"name":"Shared Voice Channel",
"type":2,
"parent_id":"946027446073966645",
"permission_overwrites":[
{
"id":"782212633255870466",
"type":0,
"deny":"3146752"
},
{
"id":"1081014782435537009",
"type":1,
"allow":"3146768"
},
{
"id":"782211758315012128",
"type":1,
"allow":"3146752"
},
{
"id":"219390252064702464",
"type":1,
"allow":"3146752"
}
]
}
i think discord gives 403 errors when it doesn't have perms
perhaps
could be
now that I think of it, newer discord API versions should provide an error with a specific field if there's anything wrong with any
so it could be permissions
how are you sending the request?
post request using my bot token for authorization
left side is app permissions. right side is manage roles permission. does this mean the app has manage roles permission?
16 is manage channels permission
maybe the parent_id category channel has more permission than the bot so it gets denied
no, permission hierarchy is only for managing members
you figure that out, I'm sleeping 
the permission_overwrites are trying to create the channel with these permission given to some members and denied for the everyone role
CONNECT, VIEW_CHANNELS, SPEAK
It also give the bot MANAGE_CHANNELS permission in addition to the other 3.
i think i need to give my bot CONNECT and SPEAK perms so it can make a channel with those perms
ahhh
it works on my server just fine, but not other peoples servers
so idk how to verify
but we will see
make sure your bot has those permissions before creating the channel with the overwrites?
i'll ask them to test it out with those perms to see if works
actually i can test the app_perms thingy
you can test it yourself too
dont use numbers
i like numbers
but js doesn't
true
try bigint
how about this?
add n after all three numbers
is it hex?
that doesn't change anything since it'll still parse it as a number
112150186033143n & 3146768n === 3146768n
yea since the number doesn't overflow
I dunno what the issue is
maybe don't use axios /s
that will fix it
i already use a wrapper function so i'd just need to update one file to get ride of axios
946027446073966645 is the parent channel and my bot doesn't have access to that channel. that's probably the issue
{
"name":"Shared Voice Channel",
"type":2,
"parent_id":"946027446073966645",
"permission_overwrites":[...]
}```
guys
can i use emojis in select menu
options
custom emojis




dead development
!setwelcome title
yo w
shows random code snippet with no context whatsoever
“why doesn’t this work”
gives no information on what doesn’t work about it
DiscordAPIError[50035]: Invalid Form Body
components[0].components[BASE_TYPE_BAD_LENGTH]: Must be between 1 and 1521 in length.
discord keep doing this error
Man almost as if we have no info on what any of that is 🤪🤪
it's a component
Well yeah, but the other 15 variables in there
when i click Request the code above should enable offer and disable request
I’m not going to bother anyways
bruh
✌️
Was just trying to get some more info for the future people trying to help
why is it showing appeal-server:undefined even tho on the help menu it shows the command?
logged client.slashId in interactionCreate of the help menu
it showed the slash ids
but when i logged client in the imports
it showed nothing.
prob when the imports was registered
slash register havent runned yet
yo rarely use this but
which one of you yahoos knows about sharding
i need help with it LOL
i launched it but i need more info i guess, so how does it work and would i need to rewrite my entire file structure to utilize it? I currently use a command handler so not sure if id need to change that to make sharding work
also, can i still use like interaction.reply or would i need to use something else
discord.js btw
tbh i just learn better being taught things but the docs are so confusing 😭
Essentially all sharding does is "split" the bot into multiple processes so it can handle processing server information more effectively. You can do a thing called auto sharding which will automatically spawn shards as it needs or tell it how many shards it needs. With DJS I think the recommended is 1 shard per 2500 servers. The thing with sharding is that not every shard will have access to every guild your bot is in as it will only have access to the guilds the shard manages so you will have to fetch all guilds if you ever need to do that. (there might be a better way I don't really remember off the top of my head).
Really the major thing to look out for is guilds and members when sharding as I said, each shard only covers so many guilds and has no access to other guilds in other shards right off the bat.
Doesn't matter what djs believes is the right amount of guilds per shards
It's discord telling you how many you should use
Indeed
Some people dont listen though
unless they use auto which uses the recommended shards from discord
Would definitely use autosharding tbh
but was it not every 2500 shards a shard should be spawned?
Back when discordjs didn't have auto sharding
(sometimes even less if you're running a processing intensive bot like a music bot)
Ima spawn a shard for my bot in 5 servers
Well you have one my default either way
What I hate about discord is that they're inconsistent, sometimes their retry_after is in milliseconds and sometimes in seconds 
Just annoying because then you may end up waiting for nothing
does anyone know how to work with 2 mongodb databases in 1 project?
Use 2 connections
i got that, my main issue is the models
does editing my bot's page before verification effect it's place in the queue at all?
No
cool thanks
hey i am trying to make buttons reply,but they aren't replying.can someone help me?
const { SlashCommandBuilder } = require("@discordjs/builders");
const { MessageActionRow, MessageButton, MessageComponent, MessageEmbed } = require("discord.js")
let x = Math.floor((Math.random() * 6) + 1);
module.exports = {
data: new SlashCommandBuilder()
.setName( "bat")
.setDescription("bat a random bowl"),
async execute (client, interaction) {
const row = new MessageActionRow()
.addComponents(
new MessageButton()
.setStyle("PRIMARY")
.setCustomId("coverdrive")
.setLabel (" Drive "),
new MessageButton()
.setStyle("SECONDARY")
.setCustomId("defend")
.setLabel ("Defend "),
new MessageButton()
.setStyle("DANGER")
.setCustomId("loft")
.setLabel ("Loft "),
)
return interaction.reply({ content: `An Inswing Delivery Is Coming.<@${interaction.user.id}>`, components: [row] });
client.on("interactionCreate", async (ButtonInteraction) => {
if(ButtonInteraction.isButton()) return
if(ButtonInteraction.customId === "loft") {
await ButtonInteraction.reply({content : `${x}`})
}
})
}
}```
This is how it’s done
i made slashCommand in a bot,the problem is only owner is able to use it
idk how
nothing error in code
whats the code
application.command is on
const { SlashCommandBuilder } = require("@discordjs/builders");
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Shows latency/ms from the B0T'),
async execute(client,interaction) {
await interaction.reply({content: `**The bot ms = ${client.ws.ping}ms**`})
}
}```
only the owner is able to use it
Your question about why only the bot owner can use this command is not explicitly specified in the code you provided.
not others
The problem is probably in the command handler
No
const { readdirSync } = require("fs");
const Discord = require("discord.js")
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { token } = process.env.token;
const ascii = require("ascii-table");
const client = require("discord.js");
const { clientId } = process.env['applicationid'];
let table = new ascii("SlashCommands");
table.setHeading("SlashCommand Name", "Loaded Status");
const slashCommands = []
module.exports = (client) => {
readdirSync("./slashCommands/").forEach(dir => {
const commands = readdirSync(`./slashCommands/${dir}/`).filter((file) =>
file.endsWith(".js")
);
for (const file of commands) {
const pull = require(`../slashCommands/${dir}/${file}`);
slashCommands.push(pull.data.toJSON());
if (pull.data.name) {
client.slashCommands.set(pull.data.name, pull)
table.addRow(pull.data.name, "✅");
} else {
table.addRow(
pull.data.name,
`❌`
);
}
}
console.log(table.toString());
});
client.on('ready', async () => {
const rest = new REST({ version: '9' }).setToken(process.env.token);
try {
console.log('Started refreshing application (/) commands.')
await rest.put(
Routes.applicationCommands(process.env.applicationid),
{ body:slashCommands },
);
console.log('Successfully reloaded application (/) commands.')
} catch(error) {
console.log(error)
}
});
}```
How does this code help?
This is where you register commands. We are interested in where you receive them
what is the point of receiving when u cant run
const {MessageEmbed, Collection } = require("discord.js");
const { readdirSync } = require("fs");
const Discord = require("discord.js")
const client = require("../../index")
const fetch = require("node-fetch");
client.on("interactionCreate", async interaction => {
const { commandName } = interaction;
if (!interaction.isCommand()) return;
const slashCommand =
client.slashCommands.get(interaction.commandName);
const slash = client.slashCommands.get(slashCommand)
try {
await slashCommand.execute(client, interaction);
} catch(err) {
console.log(err)
await interaction.reply({content: "An Error Occured!", ephemeral: true})
}
```
here
off topic - are u good with top.gg api tokens?
Not at all
Rip
Code unhelpful again
what else do i show now
i showed u interactionCreate,showed u handler,showed u command
i suggest you learn & gain a better understanding in javascript and discordjs libary
ihave made like 4 bots before
and they never did like this
that owner can only access
so its strange for me
There is absolutely nothing in any of these codes that would limit the use of the command to only one specific user
exactly
💀
ah
guys
i posted index.js file
and it says
content blocked content...
contains*
show full code + traceback
full code of?
where the traceback tells you the error comes from duh
^
I'm wondering in what sense "command can only be used by the owner". If there is nothing in the code itself, it is possible that it is set in the interaction tab. Of course, it depends on how you checked whether someone else can use it
My bot is having a meltdown
Use html or markdown
Host your image somewhere, e.g. imgur, and use that link
You can even host them on discord and use the discord attachment url
But yes, imgur is a safer option
You had a invite link in your code. Remove the invite and post it again as it was blocked by the anti advertisement rule :)
are you good with top.gg api tokens?
Depends what your question is about. Whats up?
i have no idea whats wrong
how to get discord attachment url
^
or copy link or whatever it's named
whats the best lib for telegram bots in nodejs
Telegraf?
if you guys have experience with telegram bots
this seems like the top option
It's very popular and the documentation is pretty clear too
message url?
No
Yea, copy image adress
Anyone know why a bot may not be getting the guildMemberAdd event
for (const file of eventFiles) {
const event = require(`./events/${file}`);
if (event.once) {
client.once(event.name, (...args: any) =>
event.execute(...args, client, prisma)
);
} else {
client.on(event.name, (...args: any) => {
console.log(event.name), event.execute(...args, client, prisma);
});
}
}
it doesn't have the intent
I have the
: any
ts dev
shh
isn't that like the only way anyway
Do you have this enabled on discord.dev ?
All 3 enabled yea
Are any other events triggering?
ur bot is not yet approved
so the page is not public
u need to use either markdown or html
not simply put the link there
also, don't use discord as an image host
if the messages are ever deleted, you'll lose the images
markdown is easier 
Try toggeling it on and off in discord.dev? Maybe its out of sync or something
markdown is simpler, html allows more styling freedom
so it boils down to what u need
Pretty sure it was synced before because the bot crashed the second I turned it off
Could it be because it’s a partial?
Enable partial for all of ‘em https://discordjs.guide/popular-topics/partials.html#enabling-partials
See if it’s logging then
Figured it out
I have and international keyboard which makes one of the characters is guildMemberAdd not the english one
but it looks identical
does it happen to be cyrilic keyboard? 
idk why ascii has an exact replica of the english alphabet instead of simply using a single table
VSCode Contextual Unicode highlighting saves me every so often xD
cönsolę.løg("Hēllº wõrld!")
did you forget the exclamation mark
const express = require('express');
const app = express();
app.get('/', (req, res) => {
res.send('YOU REALLY THINK THAT THERE WILL BE A WEBSITE HAA LOL. \n Please let me know in my DevelopingWorld Discord Server if you want the bot public! \n Discord invite: ')
});
app.listen(3000, () => {
console.log("Well done soldier, your project is now running!");
});
const Discord = require('discord.js');
const client = new Discord.Client({intents: [
"GUILDS",
"GUILD_MEMBERS",
"GUILD_INTEGRATIONS" ,
"GUILD_BANS" ,
"GUILD_EMOJIS_AND_STICKERS",
"GUILD_MESSAGES" ,
"GUILD_INVITES" ,
"GUILD_PRESENCES" ,
"GUILD_MESSAGE_REACTIONS" ,
"DIRECT_MESSAGES" ,
"DIRECT_MESSAGE_TYPING" ,
"DIRECT_MESSAGE_REACTIONS" ,
], allowedMentions: ["users"]
});
client.commands = new Discord.Collection();
client.aliases = new Discord.Collection();
client.events = new Discord.Collection();
client.slashCommands = new Discord.Collection();
client.config = require("./config.json");
module.exports = client;
["command", "events", "slashcommands"].forEach((handler) => {
require(`./handlers/${handler}`)(client);
});
client.once("ready", async () => {
console.log(`[READY] ${client.user.tag} has logged in.`);
const servers = await client.guilds.cache.size
const servercount = await client.guilds.cache.reduce((a,b) => a+b.memberCount, 0)
let activities = [
`| In ${servers} servers`,
`| ${servercount} members`
]
setInterval(() => {
const presence = activities[Math.floor(Math.random()*activities.length)]
client.user.setPresence({ activities:[{name: `${presence}`, type: `WATCHING`}]})
}, 2500)
})
client.login(process.env.token);
there
<a> is for links
for images it's <image>
i used online converters thats why
lol ty :)
i literally forgot everything
ok nvm i got it thanks
holy that endpoint message is cringe
much
around a couple weeks
As you said, 2 years ago
Z:\\\\\node_modules\discord.js\src\client\actions\MessageCreate.js:13
const message = channel.messages.add(data);
^
TypeError: Cannot read properties of undefined (reading 'add')
channel.messages is undefined
discord.js module
Doesn't matter what it represents, it's undefined
If you could provide a little more of your code someone might be able to help you
I'm fairly sure messages need to be fetched
If the bot has permissions to use the messageCreate event it doesn’t
even then you'd access it through the cache
I will be integrating crypto payments in one of my nodejs projects does anyone have an idea how it works exactly?
idk if that's against TOS
sounds risky
it's kind of almost being on the line's edge/crossing the line
Tos of what?
discord
What?
How is crypto against the TOS
Or are you talking to the other person
^
i mean i guess it isn't depending on what you're using crypto payments for
but still sounds risky
@wheat mesa I think now I understand better why people bash at java (dealing with an "enterprise library" - not a binary, but a source code I need to copypaste into a folder)
boi can people write ugly code
^
because newer java code is likely better maintained from the beginning
it was written in 2022
ok I take that back
it's a flutter -> android compatibility layer for a tablet-like terminal I'm developing a software for
like, if it was legacy code I'd understand but damn
a lot of the code is if-else-if-else-if-else-if-else-if-else-if-else
Yeah there’s some valid reasons to bash java
like, there were better ways to do the same thing, like switch-case or just using model classes
the whole thing is a Map (no, not even Map<String, Object>) being juggled around
now that i can understand it properly. basically like people would already know, using a crypto payment system would involve payment monitoring an using an API
- there are many payment processors such as bitcoin, bitpay, coinbase commerce, etc. i suggest choosing only one.
- using that processor, create an account to obtain the proper credentials to use.
- Configure project using the API.
- create a payment system using the API
- Monitor the payments
- of course if it's successful, you need to make sure to update the account using the information from the step above
since it's a complicated process i'd recommend also using the documentation provided
Okay, i will try and find a platform that supports most of the cryptos
also one thing to note: make sure the whole process is secure, any breaches, hacks, need to be solved asap or the whole business will be destroyed
odds of someone donating (i suppose) are already low enough, crypto even less
Yeah if you’re looking for donations I’d just use like buymeacoffee
Probably much easier
oh yeah value of crypto currencies are currently low
idk if patreon would be a good idea
not after you peek at their api

It's for an actual service (for my customer)
ah
Patreon has always disabled my account for some reason
likely regional issue
Yup i was about to say that
how can i turn a map into an array easily
right now i'm doing this but takes so long to type 💔
const items = Array.from(itemCache, (item => { return { name: item[1].name, emoji: item[1].emoji }}));
I mean, you could do
const items = Array.from(itemCache, item => ({ name: item[1].name, emoji: item[1].emoji }) );
would be slightly smaller
but I dont really understand what exactly you want to do? like you cant just magically turn a map / object into an array, like do you want it to be an array of keys? a 2d array with key-value? ...
i want my map
to become an array
so i can loop through it

you should probably show an example because there are many ways of turning objects into maps and all do different stuff
your code that you sent doesnt really make sense
how doesn't it make sense
I mean im kinda tired rn but that looks like its just assigning elements to a static value, aka it probably doesnt do what its intended to
what
cache of items
exactly (object, array, Map, Set, ...)
Just loop over your map and assign the items to your array
Take the map size as loop maximum
if its an actual Map instance you could just do
for (const [key, value] of Map.entries()) {
console.log(key, value)
}```
for a normal object it would be
for (const [key, value] of Object.entries(object)) {
console.log(key, value)
}```
bro i just said it was a map
literally the first thing i said
so its an actual map instance (new Map())? then just do what I said above to loop over or keep using your version

too much work
how can i do it for less writing
cant really, you could make a function that takes care of it
worthy to note maps dont keep order
depends on what you use the map / array for, probably not
^
huh? for me it was always the opposite
objects always kept their keys in the correct order
maps are ordered by insertion
objects are unordered, but most implementations use some form of ordering these days

for example symbols first, then keys in alphabetic order and what not
the bot is functional now
The iteration order for objects follows a certain set of rules since ES2015, but it does not (always) follow the insertion order. Simply put, the iteration order is a combination of the insertion order for strings keys, and ascending order for number-like keys:
aight, now it kept the order on both
The keys in Map are ordered while keys added to object are not. Thus, when iterating over it, a Map object returns keys in order of insertion. (Note that in the ECMAScript 2015 spec objects do preserve creation order for string and Symbol keys, so traversal of an object with ie only string keys would yield keys in order of insertion)
why dis happening
offer should be disabled but it's enabled somehow 
(on the second embed)
does anyone know
i'm very stumped on this
this is the code for the components
idk how offer is enabled and request is disabled
makes no sense
The library probably assumes that in the presence of explicit enabled calls, the others without explicit calls should be inferred as disabled
what
they're saying it might be turned off by default by the library itself
I doubt djs is this smart lmao
???
what
simplified like explaining to a 5 year old: imagine if you asked for asked for a toy, and your toy box could understand what you want. if you asked for specific toys, the other toys you didn't ask for won't appear
look at this gif
it works on the first embed
buttons are correct
but on second one it doesn't
bro i swear i'm going to dim it down to an explanation for a toddler
just remove the setdisabled
are you sure it's not the third one
because you don't explicitly set it as enabled
why would i need to?

i explicitly set offer as disabled and it's not disabled
i don't think it has anything to do with that
because by default it doesn't have to be added
it will already be disabled
LIKE I SAID EARLIER
what?
in discord.js if you don't specify .setDisabled it will set it as enabled
cus
try it and see
try what and see
bru
by that second button it's already disabled like i said before
what second line
button i mean
i don't understand what you mean
on the buttonBuilder of the request button, set this specifically as setDisabled(false) and see if that does something
and try if that works
ok
I'm trying to apply for verification but I'm getting this
Your app is missing an invite link. Add one so users can easily add your bot to their server.
Not sure how to continue
OAuth > Default Authorization Link
what about this
thanks
did nothing
ok
i think i know why
Why?
ok i know issue but i don't know how to resolve
this code is modifying my code
but how can i do this without it modifying my code

idk
this code
just remove it?
what is the purpose of that block of code?
"i want the mode button enabled"
"no i want to keep the code that always sets the mode button disabled"

when someone clicks on offer or request it should enable the other button
so if i click on request
so I have an array of listeners, now I often add and remove listeners dynamically, whats the most logical way of removing? It should not cause a leak in the end, currently for testing I just assign a listener to null and when executing them check if its truthy but that wont scale well, should I just slice the array or is that too slow / takes too much memory with alot of items?
it should disable request and enable offer
but it shouldn't
i don't honestly think that block of code is modifying the button
look at this gif
if you're using the native event emitter you can just use .off or .removeListener
im using a custom one
look into what the native one does then
but if you have multiple events in an array, you will have to match the function you want to remove, likely using a loop or .find()
then you can use splice
I had the idea of just returning the index when adding one and being able to remove by index, its just an internal emitter
thats a good idea yes
currently I have this