#development
1 messages · Page 871 of 1
U mean
the tip?
.atag::after {
That
ey the css part of ur inspect is ur friend
Not done CSS in around 2 years, haha.
lol u literally just copy whats in the styles
click on ur class
and then it tells u what its supposed to look like in css
My brain hurts lookin at dis
lol
nope
That's just sad
Yes, as long as you are not modifying the report buttons and buttons like that it's fine. This is also not the channel for it, feel free to ask further questions about the list in #general, @earnest phoenix.
anyone else getting UnhandledPromiseRejectionWarning: AbortError: The user aborted a request. issues?
api issues I see
This is bannable @neat harness
No comment --
It's called "abuse of power"
wut
[Visible CONFUSION]
Hello, do you know how to make the message sent by my bot have predetermined reactions?
In Visual Studio Code
And Discord.js
?
message.channel.send("test").then(msg => {
msg.react("✅");
msg.react("❌");
});
Oh thacks my friend
@pine widget those commands go in #commands or #265156322012561408
ok or delete the message lol
Ohhh okay,sorry
I need some help with trying to make a music bot but i always getting this error after installing FFMPEG and Restarting my System
Error: FFMPEG not found
ffmpeg is literally drag and drop there's nothing to install except on linux
who are we roasting today
i run and still the same error
npm install ffmpeg
that's not
jesus christ
uh
that's not how you install ffmpeg
bruh
you have to download
yeah
there
ty
Heres a pretty good video if you are still confused
no
How to Install FFmpeg on Windows 10 Easy and Fast.
In this video we install FFmpeg on Windows 10 first we download and extract a static build of FFmpeg we then add our downloaded FFmpeg build to our system path so we are able to run it from any directory on our Windows 10 syst...
this is easier https://www.wikihow.com/Install-FFmpeg-on-Windows
I don't know if they're on windows tho
o rite
thanks
why the fuck do you need a tutorial to download an exe file and drop it into your folder
cause people need that sometimes
we need a brain cell kill count here
lmao
we must make it
at least one of my brain cells just died
Chill
client.on("message", message => {
let args = message.content.substring(PREFIX.length).split(" ");
switch (args[0]) {
case "pat":
let pat = [
'https://gph.is/16uD0uM', 'https://gph.is/16uD0uM', 'https://gph.is/28LZXVY', 'https://gph.is/29jux8N', 'https://media.giphy.com/media/109ltuoSQT212w/giphy.gif', 'https://media.giphy.com/media/REwolzD4SjNvO/giphy.gif'
];
let random = pat[Math.floor(Math.random() * pat.length)];
if (message.mentions.users.first().id === message.author.id){
return message.channel.send("I'm sorry you can't pat yourself");
}
let patEmbed = new Discord.MessageEmbed()
.setColor('#aec6cf')
.setTitle("**PATTING...**")
.setAuthor(`${message.author.username} pats ${message.mentions.users.first().username}!`)
.setImage(random)
.setFooter(`Requested by ${message.author.tag}`, message.author.displayAvatarURL({
dynamic: true,
size: 1024,
format: 'png'
}))
.setTimestamp()
message.channel.send(patEmbed);
break;
}
});
it doesnt send the patEmbed message
i assume in your code its client.on and not lient.on right?
yeah just a error copying
is it returning an error?
hey so right now i have a system which checks if the guild is found on the database per message and if not it will always reply with "Please re-invite this bot!"
but what if someone creates a bot which quickly invites and kicks the bot
it might create two
because before i had a system which would check each message and then create it if not
but more than one message was sent and two rows were created with the same info
its using Discord.NET but this should apply to any kind of bot
no
@zinc condor what db are u using
@queen needle try adding console.log('test') right after the case "pat": to see if the command is even being run
ok
alternatively try running the pat command on yourself to see if you get the can't pat yourself response
i do
it says i cant pat myself
set interval of 10-50 min checking if there is a db for each server and no server is repeated
using ready event
thats not the issue
checking for a db with each msg is a bad idea
but it doesnt pat other people
atleast make it bot cmds only
no i need to check db with each message because of the level system
and configurable prefixes
plus the command works on my other bot
yea just use set interval
with the exact same code?
yes
make your database thread safe
use SemaphoreSlim if you're in an async context, if not use lock
anyway my issue here isnt that, my issue is how am i supposed to make sure that im not having two of the exact same rows in the database
your solution is the message above
i check on join to see if there is already data but someone can make a bot which kicks and rejoins the bot before the first query completed
ah
thanks ill look into that
Umm, how to get my bot to make a server invite and dm it to me?
Why i have this error:
(node:7712) DeprecationWarning: Guild#createChannel: Create channels with an options object instead of separate parameters
Code:
let variable_categorie = message.guild.channels
.filter(channel => channel.type === "category")
.find(cate => cate.name === "⭐ Stats du serveur");
if (variable_categorie)return message.channel.send("** Votre serveur à déjà été setup. Si cela est une erreur, supprimez la catégorie correspondante nommée `⭐ Stats du serveur`.**");
if (!variable_categorie) {
let server = message.guild;
let category = await server.createChannel(
"⭐ Stats du serveur",
"category"
);
await category.overwritePermissions(message.guild.id, {
CONNECT: false,
VIEW_CHANNEL: true
});
let userchannel = await message.guild.createChannel(
`👤 Utilisateurs : ${message.guild.memberCount -
message.guild.members.filter(m => m.user.bot).size}`,
"voice"
);
await userchannel.setParent(category.id);
await userchannel.overwritePermissions(message.guild.id, {
CONNECT: false
});```
@earnest phoenix are you in v12?
Ah, 1 sec
ok
You need to follow this format https://discord.js.org/#/docs/main/11.5.1/class/Guild?scrollTo=createChannel
editing the message when the message.author reacts with a certain emoji
which library do you use @neat mulch
guide for discord.js https://tonybo981.gitbook.io/reaction-help-guide/
which library
and what version
GuildMember#roles.cache for user roles
and GuildMember#roles.highest for highest role
for d.js v12
check the libs documentation, you'll find it
Now, I'm sorry for asking so much, how exactly do i use APIs, like POST and GET? I read the docs, it didn't help me.
you need to use a module to make a request
discord.js v.12.1.1 node 14.x
you need to use a module to make a request
@pale vessel How? As in the code
you can use something like node-fetch
Discord.js or node doesn't have a GET or POST function in them @high bough
node-fetch is awesome
Yup
So, what do i do?
npm install node-fetch
discord.js v12 uses node-fetch
And then?
read the docs
How undo in andoid glitch
By mistake I deleted all codes
OOF
an example of a post request using node-fetchjs fetch('https://httpbin.org/post', { method: 'POST', body: 'a=1' }) .then(res => res.json()) // expecting a json response .then(json => console.log(json));
By mistake I deleted all codes
@surreal notch You can't.
your first mistake was using glitch and mobile in the first place
true
Lol
wtf
@surreal notch at least if you're gonna code in mobile use Termux instead
GG
Lol that's a nice save

I'm pretty sure Glitch sucks, so I moved over to GCP, they're both free (sort of).
client.user.setStatus('dnd'); // dnd, idle, online, invisible
Wht doesn't this cose set the "dnd" status to the bot?
Use setActivity instead
@high bough that's not the status
wait...
setStatus should work
Oh, yeah, you're right
@balmy knoll it will set it but it takes 5 minutes or so because the
setStatus is the most drunk thing ever
client.user.setStatus("dnd")
i love this
Despite using setStatus, the bot's status is always online
client.on("ready", () => {
console.log(`Hi, ${client.user.username} is now online and it's detecting new connections to the Main Channel.`);
client.user.setStatus("dnd"); // dnd, idle, online, invisible
client.user.setActivity('Test');
});
@balmy knoll better to place the setStatus on the bot's ready event
Oh
@balmy knoll that's correct but gotta wait 5 minutes or more
you can try to use setPresence as it allows you to send activity and status in one request
The bot has been online for about 20 minutes and I have restarted it about a dozen times
(I have never seen a function more drunk than the setStatus() ngl)
(`${answer}`)
Okok
wait why not just do answer then lul
True
Please be careful when sharing code
😕
Don't show your token
Ohh
I know it wasnt the full token but please DO NOT show it ever
using glitch from phone is bad idea
¯_(ツ)_/¯
after 50 people hack it
And people can abuse it while they regenerate it
200IQ
🤪
And that's why the screenshot was deleted
I got my errror
Hmm
@surreal notch and when you said
"By mistake i deleted all code" is like saying "I deleted system 32 by mistake..."
Lmao
🤨
🤯
I made a command
But maybe there a random no. To be came
Not like that
How to create voice channel with highest bitrate.
Have a server with 30+ boosts
Then to go channel settings and drag the slider for bitrate all the way to 384KPBS
No.. I meant using bot
What lib?
Js
<VoiceChanne>.setBitrate(your number)
Ohk
The number has to be the full bitrate, so for 384KPBS it would be 384000
Could anyone help me
Ok
What's up?
@surreal notch can i see your setDescription () code?
@charred jetty more info here: https://discord.js.org/#/docs/main/stable/class/VoiceChannel?scrollTo=setBitrate
So i can help
Yes
Show me
You can just do
.setDescription(answer)
@surreal notch
Lemme try
K
@earnest phoenixthx
Np
It has done
Nice
@earnest phoenixfrm which country u are
Iran
Nice ;)
Very Noice 👍

Lol
client.on("message", message => {
if(message.content.startsWith(PREFIX + 'work')){
let work1 = Math.floor(Math.random()*550 + 250);
coins[message.author.id] = {
coins: coins[message.author.id].coins + work1
};
fs.writeFile("./coins.json", JSON.stringify(coins), (err) => {
if (err) console.error(err);
});
message.channel.send('You earned ' + work1 + ' coins')
}
})```
how could i make it so that they can only do the command every 6 hours
or so
you can use Set() to add users to the cooldown list and setTimeout() to set the cooldown duration
@queen needle
Add this on the very top:
let workedRecently = new Set();
And then in the first line of the command code:
return message.channel.send("You can only work every 6 hours...");
}```
Then before the message.channel.send('You earned this many coins'), add:
```workedRecently.add(message.author.id).then(() => {
setTimeout(function(){
workedRecently.delete(message.author.id)
}, 1500000);
});```
@queen needle
yeah another command has that for 5 seconds but the problem is if i do any command after it no matter the command it says wait 5 seconds

i have problem
help
my eval command so real token
but i want to make her puclic
Check if the args include:
<client>.token()
And if it includes it... Return it to send a message saying:
this is the bot's token so you're not allowed to see it
@cerulean pebble
Wdym?
do not make public
is client.token a function @earnest phoenix
that is dangerous
@tight plinth wait it isn't?
its not
Hmm
this one works
Yup
i have problem
help
my eval command so real token
but i want to make her puclic
@cerulean pebble someone can delete all of your bot's files with eval command
^
Yup

Eval is fucking dangerous
https://corynth.xyz/lumap/pAHi4yq0.png
@tight plinth time to bruteforce
[TIME TO REGENERATE]
@summer torrent what if I rengenerate token
¯_(ツ)_/¯
too late
@cerulean pebble yea it should be client.token
hide what
Hide what?
deleting commands/eval.js
=))
just don't make that public
@cerulean pebble eval can do anything
but how can ...
store your token somewhere else and restrict your eval command to owner only
Just need to know how they can access your pc files and delete everything
<Output>.replace(client.token, "[TOKEN]")
@spring dagger haah vietnamese
Just need to know how they can access your pc files and delete everything
@earnest phoenix show me example
@cerulean pebble i can't...
I never did that to someone or myself lmao
you can delete files with eval
rm -rf *
use your imagination
executing with child_process

@cerulean pebble you can read an article made by someone in GitHub that shows you about how dangerous the eval command is...
pls don't tell ppl to run that command
I'm resetting my token now fk
@high bough your token already resetted
Lol
I'm resetting my resetted token
300IQ
big brain move
MIND-BLOWING
lmao
lmao
lol

time to add this
@cerulean pebble This is an example of what i told you earlier
lol
@high bough how many guilds is your bot on?
Oh lol... I thought it was like 400 or something
Mine is in 28... But waiting to achieve that legendary 75 guilds
If it's that much, I'll be somethin like a certified developer?
Discord Verified bruh
To be certified your bot needs to be a unique bot that is like one of it's kind
It's way easier
@earnest phoenix i waiting 7 days
and discord not responce
lol why luca not vertifed ?
@cerulean pebble 5 business days
Bcz it doesn't have that much servers?
Waiting for discord bot Verification? @cerulean pebble
Luca isn't in 75+ servers?
No
264811613708746752
Luca
1375
Luca is a bot for managing and informing members of the server
discord.js
- or @Luca#1375
265
4
2 Servers
@fossil oxide

@languid dragon 
@bitter sundial 
Invite | Website | GitHub | Support Server
It's in only 15 or 2 guilds
Lol
-botinfo 422087909634736160
422087909634736160
Discord Server List
8005
The official Discord bot for the Discord Server List!
discord.js
N/A
1567
38
No server count
@fossil oxide

@languid dragon 
@bitter sundial 
-botinfo @frank torrent
657215950420049941
Corona-chan
5095
It's corona virus but in anime version and make by cute loli girl with love
discord.js
!hps
286
101
1633 Servers
@crystal furnace
@cerulean pebble
[This channel turned into #commands or #265156322012561408 ]
Ok, my bot is rebooted with the new token
@cerulean pebble if your bot is in 1000+ guilds you should use shards
not need

exports.run = async(client, guild) => {
console.log(
`New guild joined: ${guild.name} (id: ${guild.id}). This guild has ${guild.memberCount} members!`
);
let value = 0;
await client.guilds.cache.forEach(g => value += g.memberCount)
client.user.setPresence({ activity: { name: `c!help | ${client.guilds.cache.size} servers | ${value.toLocaleString()} users` }, status: 'dnd' })
const cnl = client.channels.cache.get("672484520175599636");
const embed = new Discord.MessageEmbed()
.setAuthor(`New Server Joined!`)
.addField("Server name ", `${guild.name}`)
.addField(`Member Count`, `${guild.memberCount}`)
.addField(`Server ID`, `${guild.id}`)
.setThumbnail(guild.iconURL())
.setColor("#00aaff");
cnl.send({ embed });
}``` For some reason this code doesn't work for new servers
It shows console.log
and updates status
But doesn't send the message
[This channel turned into #commands or #265156322012561408 ]
@earnest phoenix Very mmuch
Hmm
I dunno why it doesn't send anything
Someone would have a code for the bot to send a message in private message
i really don't care
=)))
It just means you are a brain-dead developer who can't figure out such simple shit for yourself
It just means you are a brain-dead developer who can't figure out such simple shit for yourself
@golden condor no just a idea bro calm down
who has to copy paste
@earnest phoenix like a dm?
sad
Cxllm, be nice. Shiro, dont spoonfeed.
=)))
and using it to spoonfeed himself
*she 🙂
I asked for help on the code
From my POV they were gonna fix it for you.
No
Aka spoon feeding.
=))
She said she was gonna take the code and use it for herself and make it work for her
I think I'll just use a webhook
Spoon-feeding is better than confusing the person you're trying to help even more
In fact, it's not
that's true
@golden condor any errors in the console?
You almost never learn by being spoonfed.
Ok, I haven’t played much with djs v12
I'll add to a test server hold on
yeah
But it looks correct to me
I am dumb
@earnest phoenix I want my bot to send a DM message from all users
I didn't define discord
@earnest phoenix that's API abuse and not allowed
Why do you want to send a DM to all users?
for promoting
How can I write better?
loader.forEach(handler => {
require(`./util/${handler}`)(client);
});```
@earnest phoenix
thx
Yea?
Np
how do you change the way your text looks in discord?
You mean showing code?
like how @robust moth did
With this
That's Markdown, I suggest you Google itup
```
+ Like this```
Error: Erorr```
hmm
How you colour it?
"""ok"""
Not those
i dont get it yet
hi```
console.log('test')
+ hello```
You can do red
Ok let;s not get off topic here now
@earnest phoenix How to write short
basically you put a programming language after the first ```
ok
your guys right eval so dangerous
i do in my dev bot
but the exectue is my main bot
well that seems a lil retarded
i delete her
even i do not turn on corona chan
or delay
deloy
but still show on corona chan
@earnest phoenix why
Hmm uhh?
hey um sometimes when i play music on my bot the music just randomly stopping nearly the end of the song...
my code is: ```
let dispatcher = connection.play(ytdl(link, {filter: 'audioonly',quality: 'highestaudio', highWaterMark: 600}),{ volume: 0.5, passes: 3 });
What
What
@slender thistle my dev bot and my main bot use same DBI token for some reason ( if you want i can explain later )
and when i do command eval in my dev bot
the work bot is my main bot
@slender thistle no i use same token to test something
but when i use command eval in bot a
it show result on bot b
it's make me confuse 1 hour

i just want to ask
how it possble
like you use command on tatsu
but mee6 is reponse
@slender thistle 😦
Same prefix?
How I can define user, I want to put here the user who send the command
@royal tree tag them
which library do you use
which library do you use
@summer torrent look forward
i have a strange problem with eval
Wait... Bot.user.tag is correct tho
what do you want to do @cerulean pebble
@summer torrent i want to understand
@royal tree and you
any errors in bot A
@royal tree also change the second one to
bot.user.displayAvatarURL()
for my testing
I want when someone use a command to show who used the command
message.author.tag
Yup
message.author.tag
@summer torrent message is not defined
i pm my friend he not trust me
message.author.tag or message.author.username + '#' + message.author.discriminator
@royal tree uhh...
@royal tree show full code
no one care me
yeah message.author.tag is the right one
@cerulean pebble please show the error
i show
msg
the error is
i do command in bot a
but bot b is respone
not bot a
that's why i fucking myself in 70 mins
@royal tree and first learn js basics pls
@royal tree what version of discord.js are you using?
to understand what happen
how to set bot's game in eris
that is msg.author.tag
you have maybe confused the prefixes
@tight plinth read the docs
@finite bough NO
I tried
the bot a prefix is !

the bot b is !hps
why i do eval command on corona chan dev test
but i show on main corona chan
@cerulean pebble are both of your bots in the same folder?
Eris, a NodeJS Discord library
same destop
thx
30 mins
thx @summer torrent
i am study a little
ok
I have a coins system, I tried to add a lot of coins and now when I use the remove all coins command it will only remove 1
I have troubles dming someone with eris. I tried using bot.createMessage(msg.author.getDMChannel().id, "test") but it doesnt work
maybe msg.author.id ?
reee
no one help me =))
I have a coins system, I tried to add a lot of coins and now when I use the remove all coins command it will only remove 1
explain the problem
@earnest phoenix like you post on facebook but it show on twitter
lol
wait what
Why are you getting the role from guild and then checking if it's in guild?
ah
hi
Guys how to cache all the users of my bot quickly?
Or to find out how many of them quickly?
Help?!?!
@tight plinth
i am a first girl make error like that in world
@cerulean pebble Because it starts with your prefix?
!hps starts with !, Maybe that's the issue
Try a different prefix
@high bough there is not a quick way to fetch all the uncached members and place them in the cached data
But how to get the guild member amount
await message.guild.members.fetch() is all you can do
message.guild.memberCount
Like 133627 users or somethin
Oh like that?
You just need to have the await message.guild.members.fetch() in your server info command and use it in many servers your bot is in as possible
Wuat? How??
If i like have 23 servera
I mean, i can
But if it goes big, imma lazy
@high bough you need to only use it on guilds that have a lot of members
K
you can cache all members via client options
await <client>.users.fetch()?
@quartz kindle
Client({fetchAllMembers:true})
Hmm
Hmmm...
I have a coins system, I tried to add a lot of coins and now when I use the remove all coins command it will only remove 1
Await client({fetchAllMembers:true}).users.fetch
no...
its a client option
you put it in your client
where you create your client
show where you create your client
yes
Yes how?
@quartz kindle
let bot = new <discordclientName>.Client({fetchAllMembers: true});
?
Yeah ?
now if you check the docs, you will see that client supports an options object
if you go to the docs and click on ClientOptions you will see a list of options that the client supports
Thanks @quartz kindle
I have a coins system, I tried to add a lot of coins and now when I use the remove all coins command it will only remove 1
one of the options is fetchAllMembers
@earnest phoenix using db or json for coin amount storing?
db
Hmm idk about that...
well there are too many coins so it cant remove them all
and im trying to fix that
Lol
@earnest phoenix show code
And making it multipurpose with message.author.id + "whatever"
the coins code or the remove coins code ?
both
alright
Meanwhile here i am using json parse and fs module to store coins and make a economy system... @high bough
@quartz kindle My CPU usage jumped to 64%, oh God.
yeah
lmao
lmao
well there is a reason it says this
Did you take a look at my code?
Still, 64%?!?!
Yeah?
discord will only send 1000 at a time
so your bot is waiting for 130k members 1000 at a time
Legend that is
Um Tim sorry im asking again but did you take a look at my code?
it will take about 20-30 seconds on average, during that time your cpu will have very high usage
your cpu should go back down when it finishes
@quartz kindle i love the smell of BURNING cpus in the morning
@earnest phoenix looking
Lol
The rest are trash
Lol
enough for 5 years lmao
their HDDs are still slow af tho
Yeah, true
[but when you open your wallet...
Emptyness enough for 5 years] @high bough
Yep.
Tim why is the quick.db not able to remove that many coins ?
Lol
@royal portal meanwhile my bot ping is above 20k rn...
lol
console.log(all,args[1])
lol
then its not working
what is too big?
the number
give me an example of "too big"
1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
well of course that will not work
but why is that
javascript numbers are represented as double precision floating point numbers
which have a maximum accurate integer representation of 9007199254740991
any number bigger than that will become inaccurate and be automatically rounded
so
i can math.round it?
you should not allow numbers to ever that get big, unless you use BigInt or a library to handle large numbers
a simple way is to just check if the number is bigger than that, return an error
you can also use Number.MAX_SAFE_INTEGER and Number.isSafeInteger()
but i have games where you can play and earn
so after every game it will check for the money of the user and set it to max if its too big ?
if your games give users that much money that they will regularly hit the limit, you should probably consider lowering your economy as a whole, making everything worth less money
if(!Number.isSafeInteger(usercoins)) return coins.set(`${message.guild.id}.${user.id}`, maxnumber)```
yes that would work
what is the max again?
you can use Number.MAX_SAFE_INTEGER as the max number
oh
it will auto-get the max?
yes
im thinking about setting my own max
like 1 trillion
Lol
also an option
you can add coins to yourself as an admin, i want the max to be 1t
if you really want such large numbers, you could use a library that handles large numbers using string composition
yes..
i dont tho
client.on("message", async (message) => {
if(!Number.isSafeInteger(usercoins)) return coins.set(`${message.guild.id}.${message.author.id}`, 1000000000000)
if(!Number.isSafeInteger(userxp)) return xp.set(`${message.guild.id}.${message.author.id}`, 1000000000000)
if(!Number.isSafeInteger(userlevel)) return level.set(`${message.guild.id}.${message.author.id}`, 1000000000000)
})```
I used an event, I think that's the best option
Thanks again!
not available
What should I do?
How to fix (node:22634) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body
embed: Embed size exceeds maximumsize of 6000
(node:22634) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body
embed: Embed size exceeds maximumsize of 6000
```I was using `)eval message.channel`
@high bough it means the embed it was trying to send has reached the max limit of characters as it's 6000
how to use )eval message.channel then?
Don't lol it's not possible
Just
Do
console.log(message.channel) @high bough
hmm, okay
@earnest phoenix that makes no sense what the fuck
thats bad in so many levels
@high bough it is possible if you limit the levels of nesting
you can do so using node's util.inspect()
@lime hare you need to post your server count using the top.gg api
Please I trying to fix problem I trying to create server bot config set server bot prefix ....
but I using fs to create .json file it create when I want to read it huffconst sconfig = require(server) server is message.guild.id +".json"
it send me err
Error: Cannot find module '699731423862718636.json'
the json file is in the same folder ehere js file
can you import a json file?
what did u meen?
like, does require() work for json files?
yes
config.json in that I have bot token and it reding it
config.token
I loggining bot with token from it
yes
fs automaticly created it when detected the server options file does not exit
and i check bot file
and that .json file is exit
what about the file path, is it in the same folder as that js file?
just a comment, but using one file for each server is far from being optimized
are you creating the file then trying to require it in the same code?
yes
show code
but when I restart bot and file is exist it give me err that same err xD
I'm on stable version 11.0.0
Just use a DB like SQLite reeeee
just try to fix problem xD
the relevant parts
Can someone help me understand the usage of the state parameter in OAuth?
As for as my current knowledge goes, it is to be generated and stored in client side before redirecting the user to the authorization flow URL and once they're redirected back, it is to be confirmed that the returned state is the same as the stored state.
const sconfig = require(server);
const serveroptions = message.guild.id;
const server = serveroptions + ".json";
fs.readFile(server, "utf-8", function(err, text){
if(!text){
let template = `{"prefix": "id.","options":{"returnbot": "true","modules":{"moderation":{"status": "false"},"music":{"status": "false"},"chat":{"status": "false"}}}}`
fs.writeFile(server, template, (err) => {
if(err) console.log(err);
})
}
})
fs detect if code exist if not create normal server options
file*
but
wait
you are trying to use server before you define it?
no
const ds = require("discord.js");
const client = new ds.Client();
const config = require("./config.json");
const fs = require("fs");
client.on("ready", () => {
console.log("Bot is sturter up");
});
client.on("message", async message =>{
const serveroptions = message.guild.id;
const server = serveroptions + ".json";
fs.readFile(server, "utf-8", function(err, text){
if(!text){
let template = `{"prefix": "id.","options":{"returnbot": "true","modules":{"moderation":{"status": "false"},"music":{"status": "false"},"chat":{"status": "false"}}}}`
fs.writeFile(server, template, (err) => {
if(err) console.log(err);
})
}
})
fs.readFile(serveroptions, "utf-8", function(err, text){if(err){console.log(err)}})
const sconfig = require(server)
const args = message.content.slice(sconfig.prefix.length).split(' ');
const command = args.shift().toLowerCase();
if(command === "setprefix"){
let prefix = args.join(" ");
fs.readFile(server, "utf-8", function(err, text){
let template = text.replace(`"prefix": "${sconfig.prefix}"`, `${prefix}`);
fs.writeFile(server, template, (err) => {
if(err){
console.log(err);
}
message.channel.send("prefix zmeneny")
})
})
}
});
client.login(config.token)
all code
xD
your code makes no sense
if fsreadfile text dont exit it meens file with server options dont exit then it create it
and read it as sconfig
but
youre using fs async functions so your code will not wait for anything you do
it dont read it
it doing what i want
it create that file
and setprefix cmd is doing what i wont
but
1 thing is not good
const sconfig = require(server)
this thing creating err
your code does not wait for the file to be created
everything other is doing what i want
it tries to read the file before its created
yes
it do
but
it create file if file does not exit
its simple
and then read it with const sconfig = require(server)
if the file does not exist, it creates file but reads it before its created
please 1 err is here this thing const sconfig = require(server) everything other is doing what i want
im explaining to you whats happening
If file doesn't exist, it would create the file. But it would try reading before it gets created. Not only that, you're trying to read the file in a wrong way. Unless you specify that you want to require a file from the current directory, it will try to find it as a module instead.
uh
tehre no err without const sconfig = require(server)
before I write it to core there is no err
Yes and the error probably is No module named <guild-id>.json found
what dont you understand? there is no file when you call require(server), because the fs.writeFIle did not finish yet
it finish AFTER the require

nope
dude...
but
go learn about async functions
@sick apex read up on asynchronous code, then re read what both Tim and Drone told you
@quartz kindle although with that code, I am positive he'd get the error even if he created the file manually before ever running the code.
i told him to add ./ before the file, he said it would produce the same error lol
@quasi forge looks correct
Is there anything else it's to be used for?
Like it's of no use after the authorisation right?
I try to use some other methode thanks
Hello, is anyone here familiar with discord.js? I’m having trouble with a clear command
yes, ask your question
Okay so I think there is a syntax or logic error with my code for a clear command. I’m using arguments for it and I think that’s what’s wrong
We need more information on your error/what's happening
I’ll send the error message I’m getting in a moment
yes do it
@earnest phoenix I think your issue probably is that args[1] is probably a string
Try converting it to a number
parseInt
Using parseInt() function
So it’s only line 34 that’s wrong?
No
Or is it 35 that’s wrong?
Line 35
It's quite obvious
you should also check for NaN
because if args[1] is not a number, parseInt() will return NaN, which will cause the same error again
Sorry I’m new to discord.js
Well, that would only happen if the user is trying to mess with the bot but it's nonetheless possible
But I’ll try to look up examples of how parseInt is used so I learn about it
And not just blindly copy a template
@quartz kindle need sp
so you will find your answers in places like the mozilla docs, and not in discord.js docs
why i use eval command in bot a
but bot b responce
like
i post facebook somthing

show bot b code
hmm the problem is bot a prefix is !
bot b prefix is !hps
but when i do !eval
bot b is responce
then bot b prefix is not working
no
I think I understand what parseInt does now. It converts a string into an integer?
yes




