#development
1 messages · Page 1894 of 1
I have no idea what I just read but ok
thanks discord
#discord-news when the
u have discord error i have the stupid miniget error 😄
that anouncement was like 20 minutes late
how can i store things in another file and invoke it in other files? because it's too large and messy
fb gone? lmfao
it was long overdue
Imagine not blocking the facebook network entirely 
what things? if its static data like configuration, etc, use json files
if its functions and code, and export and import
i want to store this
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
lmao
lmao
do you know how to use module.exports?
then you can split it into functions in different files with it
ok
can you give me a example?
// file1.js
module.exports = function(something) {
return something + 1;
}
// file2.js
const plus1 = require("./file1.js");
const result = plus1(10);
console.log(result) // 11
so like
or like this for multiple things:
// file1.js
module.exports = {
plus1: function(something) {
return something + 1;
},
minus1: function(a) {
return a - 1;
}
}
// file2.js
const { plus1 } = require("./file1.js");
const result = plus1(10);
console.log(result) // 11
wdym?
with ```js
//code
plus1
//code
you didnt show the error but channel was likely not found
we can put it in the middle of the code and that's it or something else
The cached channel probably wasn’t found.
well it wasnt found
you dont "put in the middle"
the code stays in another file
you give it whatever it needs to work
but it exists wtf
function parameters
But not in your cache.
Try to fetch it.
ok
yeah
whyyy.. I've been having this problem for a few hours before everything was working correctly
console.log it
console.log(client.guilds.cache.get(id))
and console.log(client.channels.cache.get(id))
value must be 1024 characters or smaller
what dont you understand?
a few hours ago everything was fine
send it in chunks maybe
If i send the code someone can help me please
Check if the ID is correct and if so fetch the channel
embed field is too big mate
maybe yes maybe no, send code and wait
did you disable GUILDS intent?
This and
nah i just forgot to add it to intents, bcs i just made it
this
you problem is not in either of those codes
this
Because when i try to run the play command didn t work
do you know what an embed is?
yea
do you know what an embed field is?
embed.add_field
these are embed fields
you create them using embed.add_field
or with Embed(fields=...) (i think)
if (!message.guild.me.permissions.has(Permissions.FLAGS.VOICE_MISSING_PERMS)) {
message.channel.send('This member can kick');
return}
is VOICE_MISSING_PERMS the right one?
this is the entire error
Mr documentation himself
but appear only when i run the play command
please search your code for embed.add_field
shouldnt python point to the file directly and line
cant see it here
nvm found it
@quartz kindlethis?
how long is that error message bruh
remove these and try to see if happens again
The terminal error is the issue probably not the permissions
Which easily exceeds 1000 chars
print(len(error)) 
Doesn’t make sense to send a stacktrace as discord message on the first place
If needed log it to a file
The value can’t be empty
value kinda empty
I have removed the handler
And this is the "big error"
appear at cloudfare protection
but idk why
so is a discord issue?
$work
You should really begin to handle script errors properly
bot.on('error', (channel, error) => {
channel.send(`An error encoutered, please join the support server and report it immediately `)
})
``` if i add this event when ever there is an error, it will send that only in the channel that the error command happened?
because one time i tried making it and the bot spammed it in a lot of channels
please ping me if know i need to know ASAP
dont do that
the error event does not provide a channel
unless this is an error you are emitting yourself
so it will spam? okay ty i deleted it
it will not even work
that doesnt provide a channel either
so how can i do that if there is an error it will send it in the channel it happened in once
yes
okay ty.
Why do you use google?
Use the official documentation then:
https://discord.js.org/#/docs/main/stable/class/MessageManager?scrollTo=fetch
🤖 

How do I push an image to the top of an embed
I cant seem to find how to do it in discord.js v12
you cant
images always appear after an embed, if the image is not attached to the embed
Well you can send two messages
embed icon
If the timestamp is close enough the will mostly appear as one
there we go
That’s a thumbnail
Which is bigger than the one in the title
Hmmm
TS is being bad again
await axios.get(`https://thumbnails.roblox.com/v1/assets?assetIds=${GM}&returnPolicy=PlaceHolder&size=768x432&format=Png&isCircular=false`).then((d) => {
shot = d.data.data[0].imageUrl
buuut
its saying Property 'data' does not exist on type 'never'.
HMMM
BUT ITS VALID
These red lines are going to make me jump of a bridge, its the computer thats wrong
computers are never wrong
Got a fix to TS dying?
Yes, it says it does not exist
but it exists
...
It gives me the link
https://t0.rbxcdn.com/e0ccbb9f6a457df3b3cd74515b7393c6
wut
At least more intelligent than most humans 
TS only shows never in editor and never isn't a runtime type
What happened to AI will rule us all tim
...
IT works
but it does not
Task
Failed
Successfully
What's the type of the resolved promise value?
Axios probably just has shitty typings. Wouldn't be surprised. I hate axios
its likely hitting a non-200 status code, which likely returns a type that shouldnt have data
From what I've read, the code works fine, it's just TS yelling at them.
Indeed
lemme check the code
Nope
It returns 200
Idk axios' api by heart, but if the code is working fine and you're following the tutorials properly, then just add a // @ts-ignore above the erroring line
alternatively, I would highly suggest using a different http lib
Use ts ignore sparingly because it is most likely a logical error on your end
how do i stop my bot from randomly crashing on error embed_field_value
Confirm that the value is valid before adding a field with that value
I tested on a test bot and I didn't get the error
But when I did it on my main I got the error
value cannot be empty
those variables can be empty
inspect them
for example if track.author is undefined, or null
then the value field will be empty
Remove it? Cause it show the data
if it errors, then there is no data
use it only if available
if its not available dont use it
or use fallback value
See it work
just because it works, doesnt mean its perfect
it can error
you are getting those values from something that you dont control
so you have to check them
if it worked then you would not have errors
for id, reason in afks.items():
member = get(message.guild.members,id=id)
if member.id in message.raw_mentions:
await message.reply(f"{member.name} is afk now|Note : {reason}")
im getting a error "None type" object has no attribute id
whats wrong can someone explain
get returns Optional[T] or in your case, Optional[Member]. So check whether or not it's None before accessing the id attribute
What's so funny
nothing
i found out the command is not adding stuff in my dict
can you help?
Also, make sure id is of type int. And you shouldn't use get in this case because you can just do a hash lookup with <Guild>.get_member
Send the relevant code, I guess
@commands.command()
async def afk(self , ctx ,*,reason = "Not Set"):
member = ctx.author
if member.id in afks.keys():
afks.pop(member.id)
else:
try:
await member.edit(nick=f"[AFK] {member.display_name}")
except:
pass
afks[member.id] = reason
embed = discord.Embed(title=":zzz: Member AFK",description = f"{member.mention} is now afk.",color = 0xED4245)
embed.set_thumbnail(url = ctx.author.avatar_url)
embed.add_field(name = "AFK Reason:",value = reason)
embed.timestamp = ctx.message.created_at
await ctx.send(embed = embed)
main code for afk command
this is it
I'm trying to create a "dynamic queueing" system, where every second the range of the player matching with another person increases. I have the match making system down, but whenever I try to create a while loop with a setTimeout function whether it be:
while (true) {
setTimeout(function () {
// do stuff
}, 1000);
}
Or (as it is currently):
do {
setTimeout(function () {
// do stuff
}, 1000);
} while (true);
I get the "memory leak" error or whatever. How would I achieve a loop that waits 1 second, then if the condition is false loop back through again?
Current code:
let ready = 1; // test var, since while (true) is just an infinite loop
let skipse = 1; // dynamic queueing related; skipse increases by 1. dont have that system down, but that's unimportant right now.
do {
setTimeout(function () {
matchMaking(memberID, skipse, newState.member);
ready++; // test var as said above
}, 1000);
} while(ready < 100);
use only a setInterval, while is unnecessary
You have to make sure to clear the interval after matchmaking is done though
Perhaps also give up after x amount of time and allow players to do content solo
Hey how can i add a bot using the bots id
through my bot
i use python btw
ok
Bots need an user authentication to be added to a server or generally being created in the developer portal
Anything else would be non sense and a huge security risk

Bots inviting bots inviting other bots
That would probably be the result, yeah
Add one bot and get raided by their 20 "friends bots"
wdym
Exactly what I said
It's pretty clear tbh
like how
A discord server member is using the bots invite link and confirms a form in discord to allow the bot to join the server
is it possible to use pycord with topggpy
this is unrelated to discord bot development but rather a top down view of converting a base 10 integer to binary--is there a method of doing this where i can find the 2^nth power for any given number that, when subtracted, would never result in n > 0 where n is the base 10 int? say i have a big ass number like 2^18 + 1, what is the fastest way of finding out that this satisfies n > 0 because (2^18 + 1) - 2^18 > 0
i developed the bot, how i can verify it here ?
iterating through exponents would work, however i feel like this is unnecessary computation and that there's a faster way to do this
what i aim to get out of this is to be able to know how many bytes to use when converting base 10 to binary, so as not to fill a 32 bit integer with zeroes when it doesn't need them
please
Dbl zendesk submit
How to use Top.gg
How to submit your bot
instead of reading file everytime to get prefix
i used watchFile
it detects when file is updated but doesnt change prefix :(
someone can help me please
you are passing blank argument or it doesnt exist
can i send the code?
send the line where error occurs
you running forEach on something that doesnt exist, or whatever it is in python
this?
see that
if i send the code can u help me?
this has changed to null - NoneType
this?
yes
what should i change?
when does it error
on start or when you use play command
a few times when I use the play command
something happens and voice_client becomes null
maybe when it changes voice channel
or it doesnt exist at all
and can not be solved?
everything can be solved
just catch the error
and update voice_client (on error)
does try/except work in async python?
yea
i think this is the main problem
in line 268
and 70
can i send the code to check?
why not
log data
print it
how
print(data)?
or an item from it
see if it exists
like that?
ye
it doesn't work now it always gives me the error
because you are logging it after error xd
put it after line 68
same..
put data in try/except thingy
npm kill shux
I think every single line of this code has a mistake in it
oh that's watchFile not readFile
require has its own cache, so requiring the same file again wont update it, you have to read it with fs
you probably don't want to name both the function and variable prefix inside the module
how do i disable pings for certain users?
like !disable @primal heron @role1 will disable the role1 pings for user1
aha okay
you CAN make their nickname unmentionable tho
by, yk, adding fancy 'n shitty letters
or zero-width space between letters
the username will still be mentionable tho
You can also shift click the name to mention it, or use the id to mention
No
Best example is this discord
While I can mention Woo, I can’t mention the mod role
aha i see
ah i rather meant, is it possible tot make sure people only get pinged if they have that certain role?
For example: !set @short wraith @role1 will make sure user can only be pinged if @role is being used (probably a role adder)
is there like any way to do that with djs v12
Like change it for the bot? Or for people in the server?
people in the server
No
wait i can justt add a role to a user
@solemn latch me mention woo now
that would work lol
But how do you prevent users from mentioning the user with the role then?
You said you wanted the opposite of that 👀
I’m using the node.js MySQL library and am wondering how I can prevent SQL injections. I tried using con.escapeId, but I can still inject (see the image; I logged the query). Is there a better way to do this?
Pseudo code:
var sql = “SELECT * FROM table WHERE “ + con.escapeId(name, true);
con.query(sql);
I’m on mobile sorry
Prepared statements
How do i use slashComandBuilder?
or clear the cache:)
Control f5 on the discord dashboard obvs
regarding SQL, concatenation is never ever forever an option
I alr read that but dk where i add to that
just have this in mind and you're safe
const Discord = require('discord.js')
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
name: "ping",
description: "pong",
async run(client, i) {
const data = new SlashCommandBuilder()
.setName('echo')
.setDescription('Replies with your input!')
.addStringOption(option =>
option.setName('input')
.setDescription('The input to echo back')
.setRequired(true));
i.reply("Pong!", data)
}
}
to check permissions i thought this worked if (!interaction.user.permissions.has('BAN_MEMBERS')) but i get a error saying TypeError: Cannot read properties of undefined (reading 'permissions')
const member = i.guild.members.cache.get(i.user.id)
if(!member.permissions.has)
Would better
wouldnt it be easier to just use i.member in the first place?
I didnt know intreaction has member option
now i have this error TypeError: Cannot read properties of undefined (reading 'highest') with this code if (user.roles.highest.positon >= interaction.member.roles.highest.positon)
how is user defined?
const user = interaction.options.getUser('target');
i also tried with interaction.user instead of interaction.member
getUser gives a user, not a member
a User is the object not associated with any guild, so User.roles cannot exist
you need the member
so i also need a getMember?
yeah
you also need to check getMember returns something thats not undefined.
tbh, you probably dont need to get a user for this command.
get the member every time, if you need a user property member should have it.
https://discord.js.org/#/docs/main/stable/class/GuildMember?scrollTo=user
it works now thanks
{"roleids":["34629395626262", "0395309530]}``` how would i check if a user has any of these roles? it's btw from a json file with the variable bypassed assined to it!
how can an object from a Listener be null????
especially the interaction listener?
object is possibly null
wtf, every interaction has a channel
it can NEVER be null
not according to the docs, https://discord.js.org/#/docs/main/stable/class/CommandInteraction?scrollTo=channel
likely due to partials

which is why channelId is not nullable.
https://discord.js.org/#/docs/main/stable/class/CommandInteraction?scrollTo=channelId
so what the hell do I put to not trigger TS compiler?
cuz I didn't have strict before in the config
since you are just getting the channel id anyway, why not use the proper parameter? channelId
its not nullable
interaction.guild
guild, and guildId are both nullable
so I need to do as Guild for this?
will this work or no
because im trying to make it work and its not
no error or anything
sounds right, I dont use ts 👀
usually when I imply that the type will be Guild it silences the error xD
it's nullable
Free nitro
Nice
Also handle the possible case it is null. Use a default string that will return no data. Etc
It's telling you it's possible because it is
🤔 but its not supposed to be.
https://github.com/discordjs/discord.js/blob/stable/src/structures/BaseCommandInteraction.js#L26-L30
it's not nullable on a commandinteraction but it is on other interaction types and they haven't narrowed the type to commandinteraction
heck, you are right
I need to stop assuming interactions are command interactions, just 99% of the time "interaction" variables are command interactions
client.on("guildCreate", async guild => {
const owner = await client.users.fetch(guild.ownerID)
const channel = client.channels.cache.get('CHANNEL_ID')
const embed = new Discord.MessageEmbed()
.setAuthor(`${client.user.username} | New Server`, client.user.avatarURL())
.addField(`Server`, `Name: \`${guild.name}\`\nID: \`${guild.id}\``)
.addField(`Ownership`, `Name: \`${owner.tag}\`\nID: \`${guild.ownerID}\``)
.addField(`Server Info`, `Members: \`${guild.memberCount}\`\n> Channels: \`${guild.channels.cache.size}\`\n> Created: **${moment(guild.createdTimestamp).format('LL')}** (\`${moment(guild.createdTimestamp).fromNow()}\`)`)
.setThumbnail(guild.iconURL({ dynamic:true }))
.setColor('GREEN')
.setTimestamp()
.setFooter("Made by: Marshy")
channel.send(embed)
});```
this is for anyone that wants guild logs
sends a embed like this
dont spoonfeed
loll
im just giving it out because why not
i give out some small things that people may like
that's...literally written in the rules
find the impossible thing that became possible
impossibru
Negative ping is possible
1.17ms ping
ah yes a packet arrives before it is even requested
it preemptively knew a packet was going to arrive
time travelling packets
discord has semi accurate unix timestamps
semi because negative pings sometimes happen
Not every computer has a nuclear clock in it, so time precision isn't correct
close enough, but inaccuracies suck for time sensitive logic
nuclear clock?
its how extremely time sensitive stuff is handled, like gps satalites, where a thousandth of a second can make your gps think you are a mile off.
you mean atom clocks?
probably 👀
show your client options
also, its messageCreate now, although message should still work
client.on("messageCreate", message => {})
discord is running on double instance as it seems
thx for the module.exports thing, it worked
mine sometimes send twice too
mine is always
ok
Is there a Script with which I can block the node Process & the Event Loop? Need it for testing sth.
then it's not my bot's error
mutex it
i was saying what happened bc i don't have nothing that makes double instance
while(true) {}
yeah works, never knew that a while blocks the event loop
is there any way to fetch somehow more than the 100 last messages of a channel (basically, fetch all of them) ?
new Discord.Client({ options here })
you can only fetch 100 at a time
if you want 1000 you need to fetch 10 times
then thats why
intents controls what discord sends you
you made it so they only send you guilds and nothing else
no messages no nothing
(node:291) UnhandledPromiseRejectionWarning: Response: Internal Server Error
at RequestHandler.execute (/home/runner/Clash-Chest/node_modules/discord.js/src/rest/RequestHandler.js:161:15)```
module.exports = {
name: "rr-add",
aliases: [],
group: "roles",
description: "add a role into the category. ",
clientPermissions: ["SEND_MESSAGES",
"EMBED_LINKS"],
memberPermissions: ["MANAGE_ROLES" || "MANAGE_SERVER"],
examples: ["rr-add {category} {@role} {name} {emoji}" || "rr-add pings, @chat-ping, chat-revive, @ping"],
cooldown: {
time: 5000,
message: ""
},
nsfw: false,
run: async(client, message, args, data) => {
try {
let arg = args.join(" ").split(",")
let category = arg[0]
let role = client.resolvers.resolveRole({
message,
search: arg[1]
})
let name = arg[2]
let emoji = arg[3]
if(!category || !data.roles.map(c => c).find(c => c.category === category)) return message.error("Invalid Format\nExample: rr-add pings, @ping, chat-revive, emoji");
if(!role) return message.error("Invalid Format\nExample: rr-add pings, @ping, chat-revive, emoji");
if(!name) return message.error("Invalid Format\nExample: rr-add pings, @ping, chat-revive, emoji");
if(!emoji || !emoji.startsWith("<") && !emoji.endsWith(">") && !emoji.includes(":") || !client.emojis.cache.get(emoji)) {
emoji = null
}
let array = data.roles.map(c => c).find(c => c.category === category)
console.log(array.roles)
array.roles.push({
name: name,
role: role,
emoji: emoji
})
await data.save()
console.log(data)
message.success(`Role added with name: ${name} to ${category}`)
} catch (e) {
message.error("Something went wrong ;)..\nError: " + e.message)
console.log(e)
}
}
}```
why its not adding role to array
ping me if you know
did u enable on dashboard?
interaction event has user info
Yeah.
FYI, let [category, roleId, name, emoji] = arg is valid
I tried to do interaction.user.id
But it "isn't defined".
And I'm not entirely sure how to define it correctly.
Nevermind. I'm brain dead.
log interaction and you'll see the proper variable name
thats not a problem
but its not saving data to db
well, ur not adding anything to it
did you restart your bot?
Does dpy support buttons?
"activity": "{members} Members | !help",
How do i show how many people it is watching?
seems like a custom thing, can you give us a snippet of your code?
Loop through all guilds or use the collection filter to combine the guild memberCount property
???
i have never done members before
I know basic code
iterate over all guilds, collecting the member count of each one
then just sum it
???
...ok, I'll dumbify it more
1 - get your guilds (servers) collection
2 - for (const guild of <collection name here>) <-- a loop
3 - get the members collection of guild and .size() it
4 - add that value to a variable
5 - 1 + 1 = 2
don't think I can go any simpler than that
No need to use the member collection as members aren’t cached at any time.
Just use the guilds property memberCount
with discord oauth2 i can't use cookies to keep a user logged into a site can i?
they'll remain logged in until YOU logs them out
Keep in mind the user data can’t be updated while using cookies since you don’t actually get an API request
Response not request
Means your user database might not be up to date as users can change their name or email etc.
I just now realized you can do sql update queries that return some of the pre updated values.
Hm if I remember right SELECT, UPDATE and INSERT can return values.
But didn’t know that one, too even after so many years.
Most likely because I’ve never had use case this could become relevant.
That’s why people say you’re never done with learning even if you think you know ur shit
Sweet potatos aren't potatos

When I try to watch the ad to vote it glitches and restarted every time pls help
Pls
Pls
cough ad blocker if so
when a user is already logged in i just refetch there data as well as refresh the access token

and if there was an error refreshing the access token ill just log them out 
same as if there was an error fetching there data
hello , i want to make a command for my bot so that it gives the user something when they vote , like dankmemer , i vote in top.gg and it gives a reward ..... how do i do that?
how can I approved my bot
Oauth
TypeError: Cannot read property 'author' of undefined
at embedEqual (/home/container/node_modules/discord-giveaways/src/utils.js:14:16)
at /home/container/node_modules/discord-giveaways/src/Manager.js:536:33
at Array.forEach (<anonymous>)
at GiveawaysManager._checkGiveaway (/home/container/node_modules/discord-giveaways/src/Manager.js:471:24)
at Timeout._onTimeout (/home/container/node_modules/discord-giveaways/src/Manager.js:587:58)
at listOnTimeout (node:internal/timers:557:17)
at processTimers (node:internal/timers:500:7)
``` where is the error
i have been searching
help
sry what?
nm, dont use oauth
https://top.gg/bot/BOT_ID/webhooks
OOOO THX
go to your bot page
if only there was an html element for making someone go to another part of your site
i need help
my bot is running on a server but when i use its commands it doesn't respond
python1 from something.xyz sevrer to be precise

why?
./ - the current directory
../ - the parent of the current directory
@earnest phoenix show ur files
and show the line/code where the error is coming from
afaik fs reads files at the main directory
aka home/runner/yourProjectName
so act like fs is at index.js aka at the top of everything
do .readFileSync("./shop.json")
fs roots r always at home/runner/yourProjectName/ in repl.it
Are u sure
yes i am
Root is where the file is

body {
background-color: <%= def.site.color %>;
}
why wont it change the site bg's color?
it just worked a few mins ago
??
y don't u simply use css variables?
whats that
lul
in nextjs is there any difference between
pages
/route
/index.jsx
/subroute.jsx
and
pages
/route.jsx
/route
/subroute.jsx
Also you need a folder called commands
That way that when the interaction is called, it can pull the command specified from the commands folder as code
they already have it
Oh
I am thinking to take errors/console_logs in a specific call and send all of them to a specific channel in my server
So what I thought is everytime I use console.log , I will replace it by calling a specific file say log.js
Can anyone guide me about this (:
process.stdout.write("\n" + "hello") and console.log("hello") are roughly the same so you can change the console.log function to write the log file and write to stdout
const __realConsoleLog = console.log;
console.log = function(...data) {
// Send here...
__realConsoleLog(...data);
}
^ you would have to do that when you have access to the client, or the channel
in the ready event for example
wouldn't changing the value of console.log change the value of __realConsoleLog
functions are objects and objects are references
try it out for yourself 🙂
short answer, no
i get your question now
i want my bot to send all logs to some channel in discord...so i can check it easily
you are trying to replace console.log with a log file reader
wait i am showing
message.channel.send(fs.readFileSync("log.js", "utf-8"));
I'd keep the content in-memory so you don't have to read a file every time
.
.code
}catch (e){
myfunc(e);
}```
Now that myfunc() is in some file ```logs.js```, and i'm using it wherever i want by calling it with the help of a variable say ```const myvar = require("./logs.js")```
and myfunc() simply takes e as argument and does ```channel.send(e);```
i am thinking something like this
so what's the problem
Stack traces can easily be larger than the max amount of chars you can send via your message.
If sending the error fails where do send the error than? 
Keep errors in log files or you console.
put the entire error in a file but only send the error message in discord
if fails then nothing harms myfunc() contains a try...catch which does console.log the big errors
and yes also i can run djsv13 in replit but slash commands wont work.......any fixes?
you need to put the command in your .replit file
run="npx node index.js"
otherwise pressing the run button will use v12
that command already downloads node 16 on repl
const myChart = new QuickChart();
myChart.setConfig({
type: 'bar',
data: { labels: ['Hello world', 'Foo bar'], datasets: [{ label: 'Foo', data: [1, 2] }] },
});```
I use resultsArr[][] for results.
[0][0] and [0][1] matches in case of tie
In all other case [0][0] is the winner
I want to use my data to create charts displaying how many user has voted for each.
How can I fit my data in the above format?
in shell its still 12
npx node is different from the actual node
the actual node will always be v12
try running npx node -v
/home/runner/VOTIFYv13/node_modules/@discordjs/rest/dist/lib/RequestManager.js:66
const hash = this.hashes.get(`${request.method}:${routeID.bucketRoute}`) ?? `Global(${request.method}:${routeID.bucketRoute})`;
^
SyntaxError: Unexpected token '?'```
did you even read my message
yes?
i said use npx node instead of node
f
ok i still cant figure this out
How can I disable a slash command? So a user cant use the slash command any longer
discord.js v13
you can't disable a slash command from showing the menu
but you can check the user's permission before running the command
for detritusjs you can just do onBefore: context => context.member.hasPermission("smth")
alright then how can I delete a slash command?
delete the file
¯_(ツ)_/¯
Are bots able to record something / to hear something in voice chats?
yes
recording is possible . hearing isn't
(:
I keep getting this error when I try to use npx or npm i -g
> npx vite --host
npm ERR! code ENOLOCAL
npm ERR! Could not install from "AFTAB\AppData\Roaming\npm-cache\_npx\6008" as it does not contain a package.json file.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\ASIFA AFTAB\AppData\Roaming\npm-cache\_logs\2021-10-06T14_38_38_588Z-debug.log
Install for [ 'vite@latest' ] failed with code 1
your dir has a package.json?
it doesn't
yes shouldn't affect as u're using a -g flag
you didn't get the error
my global dir has no package.json because the dir doesn't exist
module.exports = {
name: "rr-add",
aliases: [],
group: "roles",
description: "add a role into the category. ",
clientPermissions: ["SEND_MESSAGES",
"EMBED_LINKS"],
memberPermissions: ["MANAGE_ROLES" || "MANAGE_SERVER"],
examples: ["rr-add {category} {@role} {name} {emoji}" || "rr-add pings, @chat-ping, chat-revive, @ping"],
cooldown: {
time: 5000,
message: ""
},
nsfw: false,
run: async(client, message, args, data) => {
try {
let arg = args.join(" ").split(",")
let category = `${arg[0]}`
let role = message.guild.roles.cache.get((arg[1].match(/\d{17,19}/)||[])[0]) ||
message.guild.roles.cache.find(r => r.name === role);
let name = `${arg[2]}`
let emoji = `${arg[3]}`
if(!category || !data.roles.map(c => c).find(c => c.category === category)) return message.error("Invalid Format\nExample: rr-add pings, @ping, chat-revive, emoji.");
if(!role) return message.error("Invalid Format\nExample: rr-add pings, @ping, chat-revive, emoji");
if(!name) return message.error("Invalid Format\nExample: rr-add pings, @ping, chat-revive, emoji");
if(!emoji || !emoji.startsWith("<") && !emoji.endsWith(">") && !emoji.includes(":") || !client.emojis.cache.get(emoji)) {
emoji = null
}
await data.roles.map(c => c).find(c => c.category === category).roles.push({
name: `${name}`,
role: `${role.id}`,
emoji: `${emoji}`
})
await data.save()
message.success(`Role added with name: ${name} to ${category}`)
} catch (e) {
message.error("Something went wrong ;)..\nError: " + e.message)
console.log(e)
}
}
}```
its not pushing data to array
the current project has a package.json?
where r u storing data?
in mongodb
wheres the schema then?
are you sure the schema works perfectly?
first check that
yep
i consoled it
and its saying
{ category: "pings", role: [] }
roles array is empty
I wanna make simple slash command handler can someone help
how can he record without hearing?
i keep getting: ```
C:\testatis3\node_modules\discord.js\src\rest\RequestHandler.js:298
throw new DiscordAPIError(data, res.status, request);
^
DiscordAPIError: Cannot send an empty message
at RequestHandler.execute (C:\testatis3\node_modules\discord.js\src\rest\RequestHandler.js:298:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (C:\testatis3\node_modules\discord.js\src\rest\RequestHandler.js:50:14)
at async TextChannel.send (C:\testatis3\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:171:15) {
method: 'post',
path: '/channels/888810902294523994/messages',
code: 50006,
httpStatus: 400,
requestData: {
json: {
content: undefined,
tts: false,
nonce: undefined,
embeds: undefined,
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined
},
files: []
}
}
its in discord.jsv13
Code?
Somewhere in your code you’re sending a message with no content in it
its this command (and some more but they have the same structure
yep forgot to change message.channel.send(TAFEmbed); to message.channel.send({ embeds: [TAFEmbed] }); biggest facepalm moment ever for me
Not only that, but your last embed sets the description field to data fetched from an API, which could potentially be empty (depending what the api responds with, not sure)
Which would also cause an error
can i get member in interaction options
nodejs discord bot fanboys
what is a nice lib other than discord js which has a slash command builder and is nice
i refuse to use that burning garbage of a library called discord.js
create an interaction url endpoint and dont use a libraru
that sounds like a good idea but i quit making production bots
i just want a nice library to have fun with friens
detritus 
My interaction is replying and then i get error interaction could not found
how do i slow up a command? like if the message is sent, it'll respond 5s later
setTimeout()
Detritus based
const embed = new Discord.MessageEmbed()
embed.setTitle("Pong") 
embed.setTitle is not a function
Discordjs being much op
Onu bende biliyorum
Koşul sağlanırsa başlığı farklı ayarlaması için böyle kullanmam lazım
Is that all of your code?
const Discord = require('discord.js')
module.exports = {
name: 'ping',
description: 'Shows ping',
options: [],
async run(client, i, lang, options) {
const embed = new Discord.MessageEmbed();
if(lang === "english") {
embed.setTitle("Pong! eng " + client.ws.ping)
}
if(lang === "turkish") {
embed.setTitle("Pong! tr " + client.ws.ping)
}
return i.reply({
embeds:[embed]
})
},
};
it's just .setTitle()
Double check you saved and restarted the bot
the embed before it is not nessescary
What? Yes it is necessary
Testing new commands on glitch so it already restarted many times
My problem isnt if it necessary......
No, you can’t do that in his case.
That only works when you instantiate the embed and put the options right underneath it
Otherwise js doesn’t know what object you’re trying to call .setTitle() on
The way he has it looks correct to me
hold on lemme look back at my code
^^
Sorry my cam is broken and i am lazy to use ss of pc
discordjs is bleeding 
You are using it on the embed there too
Yes, like I said you can do that if you put the options right underneath instantiating the object
But what he’s trying to do is set the title based on the condition of the language
Seems like it was having the issue here anyway.
If you really wanted to just don't use the embed builder
hold on what is lang supposed to be
Same language
Lang in his function is the language the bot is set to (Id assume)
Oh you mean the variable kek, shouldn't matter in this case as it's running
const lang = await db.get(lang+i.guild.id) || "english"
cmd.run(client, i , lang)
I guess log embed and see if it's a proper embed.
that's what i meant
No idea why it wouldn't be though
It fixed by nothing
Kek weird
i was busy looking at something else
Discordjs really weird
My bot creashed many times by nothing
if (message.member.permissions.has(Discord.Permissions.FLAGS.MANAGE_MESSAGES)) return;
^
TypeError: Cannot read properties of null (reading 'permissions')
Someone likely tried to use the bot in DMs
if(!message.guild) return
Member objects are associated with guilds, therefore you would only receive a member object if someone used it in a guild
First line
Partials enabled?
Second line
I didnt get what you mean
Then probably not, weird.
anyoen know how i can do render_templates but in express.js
render_templates is from Python
and I need to render HTML files but with data added
Like ejs?
in flask I would add {{variablename}} to the html then do return await render_template("index.html", variablename=user.name) etc
Pretty much the same with ejs
ah alr
/ban is coming
Huh

I dont know what that means, and no need to tag random people
Pleas
Pleas what*
mb
Pleas project bot button
huh?
You need help with buttons?
He wants a boy with buttons
Yes
I’m kurdish
main language?
Wergêrê bikar bînin
Language Me Kurdish
...
const Discord = require('discord.js')
module.exports = {
name: 'ping',
description: 'Shows ping',
options: [{
name: "input",
description: "input",
type: "INTEGER",
addChoice: "0",
required: true,
}],
async run(client, i, lang, options) {
let x = ${i.options.getString('input')}
return i.reply(x)
},
};
How do i add choice
wdym?
Choices need to be an array of objects
"choices": [
{
"name": "Dog",
"value": "animal_dog"
},
{
"name": "Cat",
"value": "animal_cat"
},
{
"name": "Penguin",
"value": "animal_penguin"
}
]
I’m not sure if they exist in combination with interger inputs but you will find yourself I guess
I think he want discord buttons project ( github project ) I think
I meant bot not boy lol
I got it thanks

data.embeds[0].description: This field is required
I get this error this time
i keep getting:
/home/container/node_modules/discord.js/src/rest/RESTManager.js:32
const token = this.client.token ?? this.client.accessToken;
^
SyntaxError: Unexpected token '?'
at wrapSafe (internal/modules/cjs/loader.js:915:16)
at Module._compile (internal/modules/cjs/loader.js:963:27)
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)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/home/container/node_modules/discord.js/src/client/BaseClient.js:4:21)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at my hosting but at my pc it does work
npm i node@latest
Nope his structure is obviously for slash commands as there are no components
Does djs allow you to disable certain caching options or is that not a thing
on v13 it should be
Ok
My bots heartbeat has been blocked for more than 30mins and i am unable to somehow bring the bot back online without fully shutting down it. Should i kill the process?
Nevermind i force killed the process
How did I never notice Windows Terminal its like cmd and Powershell combined + extras
Because it hasn’t be rolled out on Windows consumer versions not even on the latest server version for some reason.
But you could download it yourself the whole time
Windows has been a huge junkyard over the years trying to redesign things, force apps etc and overload the ecosystem with trash nobody wants but still keeps ALL the old functionality on board
Seems to be installed on Win11
Which has become a huge waste of space over the years especially on consumer versions
Maybe idk, not interested in version 11 anyways
so when ur bot gets added to a guild its called "guildcreate" whats it called when it leaves a guild/gets kicked
guildDelete
so im working with react but this is more of a css issue - i've been working with flexbox the entire time (without margins and stuff) but it's ever so slightly off-centred (as you can see by the orange border above being slightly offset from the actual centre in the footer)
also the colours are just guides for me to figure out this issue - the site doesn't actually look this shitty if you're wondering
so im trying to get my bot to reply to a message with an embed, and message.reply() is not working
is it returning any errors?
you've tried { embeds: [<MessageEmbed] }, yes?
No
Are you doing message.reply({embeds: [embedVariable]})
its just message.reply(Embed)
This ^
<Message>.reply({ embeds: [<MessageEmbed>] })
That syntax works in v12 but isn’t supported in v13
np (:
that makes sense
hate that change
id imagine id have to update nodejs to nodejs 13+ too
because im on node 12 rn
What’s your code?
You’re using djs v12 for sure if you’re still on node 12, as djs v13 requires nodejs 16
Do node -v
Whatever version of djs you have (it has to be v12 if you’re on <nodejs v16), the error you’re getting isn’t related to the version
It’s hard to work off of just an error, can you send your code?
yea, lemme try to update to nodejs 16 just to see if it helps
It’s not going to change anything
Don’t bother with that for now
Your code is the issue here
That’s why
You’re setting your title field to an empty string
Which isn’t allowed
i removed the .setTitle
oh wait do i need message.channel.reply
no
hm
this is the code
and i get this
i am very confused
Your title is empty as the other fields contain chars
it shouldnt be
success
Is the right term
i know its spelt wrong
Just to say 
Oh
second time today djs has been weird
Missing what?
Try to set the title as description
Maybe embeds with a titles only aren’t allowed to work anymore
nope, same error
Now im worried because my bot is getting reviewed soon
lmao
this is the 2nd time ive applied
Can you to add a content to your reply?
does it have to have a value
message.reply({ content: "text", embeds: [embed] });
yea
you can make it a zero width space so it doesnt appear
Let’s see if the embed pops up
Write some text in the content option
At least 1 letter
cross your fingers
Wtf what’s this message coming from?
the other weird issue we had earlier was embed builder related too.
try manually making the embed
But the object is correct
as in?
🤔 fair
{ title: "test", description: "test" }
Try that one please
… { embeds: [this above] }
Without the content option
reply({ embeds: [{ title: "test", description: "test" }] }.catch(…);
Okay seems to be an issue on discord’s end then I guess
that sucks




