#development
1 messages · Page 810 of 1
although its mostly safe because the logging in process will likely take longer than the loading process
if you have a gazillion commands, there could be issues, but it will probably never happen
on the other hand, loading commands while logging in also makes your bot login faster lul
I can probably load about 500 commands in time it takes for bot to login
I have 25 atm
lol
anyone can help me for cheerio?
alright, I am suck again, so far I have added the command to a map, and called it using find, but I am unable to get the command.run
it is undefined
what is this?
Error: 400 Bad Request
at IncomingMessage.<anonymous> (/rbd/pnpm-volume/a72fbbf6-7091-4e79-bbd8-073e4d4468bb/node_modules/.registry.npmjs.org/dblapi.js/2.3.1/node_modules/dblapi.js/src/index.js:118:25)
at IncomingMessage.emit (events.js:201:15)
at endReadableNT (_stream_readable.js:1130:12)
at processTicksAndRejections (internal/process/task_queues.js:83:17) {
raw: '{"error":"Required parameter server_count or shards missing"}',
body: { error: 'Required parameter server_count or shards missing' },
status: 400,
i use glitch hosting
how to fetch discord api response time from website. I want to use cheerio but I cant
you mean this?
@earnest phoenix dblapi was not yet updated to work with discord.js v12
in the mean time, you can use .postStats instead, and remove client from the constructor
you mean this?
@quartz kindle yes
do you really need cheerio for that?
Im so confused on what I am doing wrong
all I can get from a require is the name for some reason
do you really need cheerio for that?
@quartz kindle do you have any better idea
@quartz kindle from your screen this is the same response with client.ping no...?
const test = require('../../commands/test');
test.run(client);```
and ```js
module.exports = class test extends Command {
constructor() {
super({
name: 'test'
});
this.testtest = 'testerer';
}
async run(client, message, args) {
console.log(message);
}
};```
TypeError: test.run is not a function```
the async run was just a test, it will be changed, but even then it doesn't load
@summer torrent well, there is this, but idk if the url changes or not https://discord.statuspage.io/metrics-display/ztt4777v23lf/day.json
@earnest phoenix i dont thing so
ty Tim and EGGSY
if the part before day.json changes, you can get the updated one from the status page source code
@crimson vapor You didnt make a new instance of the class
You have to make an instance to use non-static methods
i.e. let x = new test() x.run(args)
given it requires correctly
lets say a class is a blueprint for a car
when you do new Car()
it becomes a car
a normal method only works on the car, not on the blueprint
a static method only works on the blueprint, not on the car
ohhh
Tim do you know if you can override methods with js? I know you cant overload constructors (which is a shame) but I've never really went into sub classing
yes you can override methods
you cant override constructors, but you can work around them
ie: modify data before calling super() and then edit data after
okay, I updated the command loader and now it actually works
thanks so much for helping me learn about classes
ill probably be asking more questions tomorrow when I work on other class stuff
if you think im asking too much please tell me
Procuro alguem q saiba hospedar bot na heroku
I don't even understand this at all:
console.log(actualargs)
if (actualargs !== "") {
exports.loopnum = parseFloat(lineargs);
}
It sends hi in my console (what actualargs is defined to)
but then if (actualargs !== "") doesn't seem to pass
I need help mentioning a user
discordjs?
Yes!
do you know how to make the bot DM?
if (!message.mentions.users.size) {
// no mentions
} else {
mentioneduser = message.mentions.users.first() //stores first mentioned user
// is a mention
}
message.author.send
or
in this case
if (!message.mentions.users.size) {
// no mentions
} else {
mentioneduser = message.mentions.users.first() //stores first mentioned user
mentioneduser.send("something")
// is a mention
}
Do you know ho to DM an embed?
stable or master?
?
so first make the embed var
example:
let embed = new Discord.RichEmbed()
.setAuthor('title')
.setColor("RANDOM")
.addField('test', false)
v12 is stable now lol
then mentioneduser.send(embed)
"Stable"
it is
but that also means you will need to change all richembeds to messageembeds
how do you set version or servers in status?
RichEmbed doesn't work in the new version
oh ok
you simply update your discordjs version using the same npm cmd
The only difference for the new stable/master is instead of embed = new Discord.RichEmbed() you use embed = new Discord.MessageEmbed()
What bot have you developed?
the only one I released is a terrible rpg bot, but i've made other stuff too
yes i have made a better version of my rpg bot, but never released and might never will
making a new one rn
imagine calling your self two 
Two I did the embed part what next?
V11.x.x = Discord.RichEmbed()
V12.x.x = Discord.MessageEmbed()

I added that message
so who do you want it to dm?
V12 is really bad...
message executor/author, mentioned user, or user with a specific id
@shy turret wdym doesnt pass? did you try console.log after the condition?
yes, i tried to add a } else { console.log("No") } and it said "No"
it wont work after the condition because it says the condition is false when it isnt false
@shy turret mentioneduser => i think he want mentioned user
@topaz fjord like what ?
All is différent this isn't good for upgrade 🤷♂️
if (!message.mentions.users.size) {
// no mentions
} else {
mentioneduser = message.mentions.users.first() //stores first mentioned user
let embed = new Discord.RichEmbed()
.setAuthor('title')
.setColor("RANDOM")
.addField('test', false)
mentioneduser.send(embed)
// is a mention
}
```@trail axle
that's why most people recommend updating while it's still in beta
since you have time to change
technically you can still downgrade
it is like some extra parameters in the console
I have been
11.5.1 => 11.6.1
npm i discord.js@11.6.1 to downgrade
when js makes no sense
@shy turret is actualargs hardcoded? that makes no sense
my code makes no sense im not even joking
can you show more code?
lul
why won't you show your code lol
why? does it contain statistical analysis and calculus?
no
pretty sure I'll understand lmao
and?
idk, im just trying to make something orginial
Essentially Skript (https://dev.bukkit.org/projects/skript) but in nodejs (and discordjs), and not for minecraft (for discord bots ofc).
in simple words
ok, but i dont need to know what it does to look at a piece of code and see whats wrong with it
let me post it on github
unless your actualargs gets defined somewhere and then passed around by a gazillion functions
i mean it is but it isnt
hey yo
let color = await prompt(message, "Do you want to apply a color?\nRespond with a hex value or `none`.")
if (color !== "none" && !color.startsWith("#")) return message.channel.send("Please send a valid hex.")
if (color !== "none" && color.length != 7) return message.channel.send("Please send a valid hex.")
if (color === "none") color = "#03fcf8"
color.slice(1)
color = "0x" + color
embed.setColor(color)```
returns the error embed.setColor is not a function
discord.js
would like some help
show where you define embed lol
what is custom?
and that is
...
let embed = new Discord.RichEmbed()
.setTitle(content)
.setDescription(desc)
.setColor(0x00e9f5)
return embed```
console.log(embed) after the custom line
okay
bot.js: https://github.com/real2two/sdjs/blob/master/bot.js
ifargs: https://github.com/real2two/sdjs/blob/master/data/ifargs.js
sdjs File: https://github.com/real2two/sdjs/blob/master/commands/say.sdjs
3 way file
Tim ^ (idk if I should ping or not)
RichEmbed {
title: 'a',
description: 'a',
url: undefined,
color: 59893,
author: undefined,
timestamp: undefined,
fields: [],
thumbnail: undefined,
image: undefined,
footer: undefined,
file: undefined,
files: [] } }```'
ahhh
...
bro u have to do it in 0x form
Also your color is wrong
It's 6 characters
i realize that
the color is supposed to be 03fcf8
If u want you can
So 0xff03fcf8
@lyric mountain 0x03fcf8
0x requires alpha
alpha?
Opacity
ah
what
0x00000000
0x + color
Wut
No
It became a hyperlink
no 0x + color without the #
im okay
embed.color(0x0x03fcf8)
ik
Why 0x0x
i mean that
This is bad
but its a variable
opps

ITSSSSS A VARRIABLE
wdym
like
Bruh
0x + string
Gn
nvm lemme test again
Oh okay
while typing cuz i suc
Gn everyone i'm tired

👋
what
what a name
setting 0x03fcf8 also doesnt work
Two
kmt
what are tou trying to do
someone stole my old tag when i lost nitro 👀
lol
console.log(actualargs)
if (actualargs !== "") {
exports.loopnum = parseFloat(lineargs);
}
doesnt work
that doesnt tell me what you are trying to do
actualargs is set according to console.log()
but it doesnt pass the if statement
exports.loopnum = parseFloat(lineargs); does not occur in simple words
or is it that it always occurs...
let me check
if actual args does not equal anything
what are you trying to do
wait but it shouldnt
are you trying to do exports.loopnum = parseFloat(lineargs) when actualargs doesnt exist
@shy turret i looked at yoir code
is it ugly? ok
Your problem is most likely because youre using global variables in a lot of places
very ugly
setTimeout(() => {
loopCommand(client, message, code, loopnum, lines, cmdvar)
}, 1)
i wonder if i add..
nope didnt work
I didnt look too deep into what your code is doing, but it looked like a lot of uneeded stuff going on
Stop using global variables
That would be a good start
first time i tried using global vars
that's like the only way to connect require() with the main process in a simple way
the fact that it actually works once confuses me
You should rewrite your entire code lol
Youre doing a lot of bad practices
lol
ikr
But im gonna go sleep now
lol
now i use json cuz im too lazy to sql
lazy bomboclaat
and i found out how to fix all the json bugs
yes two
lemme try again
and that took more than a year (some months) (tried to fix somewhere in 2019 and fixed it in 2020)
let color = await prompt(message, "Do you want to apply a color?\nRespond with a hex value or `none`.")
if (color !== "none" && !color.startsWith("#")) return message.channel.send("Please send a valid hex.")
if (color !== "none" && color.length != 7) return message.channel.send("Please send a valid hex.")
if (color === "none") color = "#03fcf8"
color = color.slice(1)
color = "0x" + color
let embed = custom(message, title, content)
console.log(color)
embed.setColor(color)```
this returns embed.setColor is not a function
im trying to find the problem
and color returns 0x03fcf8
now i use json cuz im too lazy to sql
@shy turret use sqlite bro
Easiest database out there
And one of the fastest
async function configSet(name, response) {
//let config = require("./config.json");
try {
if (config[name] === undefined) {
} else {
await delete config[name];
}
if (response.toString() === "") {
} else {
config[name.toString()] = encodeURIComponent(response.toString());
}
} catch(err) {
}
}
function fileSave() {
fs.writeFile("config.json", JSON.stringify(config, null, 2), function(err) {
if (err) throw err;
});
setTimeout(() => {
fileSave();
}, 1000);
}
beat me i fixed all my problems in json
@empty owl console.log(embed) right before embed.setColor
oof
@quartz kindle js Promise { RichEmbed { title: 'a', description: 'a', url: undefined, color: 59893, author: undefined, timestamp: undefined, fields: [], thumbnail: undefined, image: undefined, footer: undefined, file: undefined, files: [] } }
wait
color...
Thats what i thought
the color is not a valid color i think..................
It has npthong to do with cplors
you can put files in embeds??
Yoir embed os retirning a promise
You changed it intp an async function at some point
@empty owl you have to send the embed, not get the promise data with console.log
ah
customs js const Discord = require('discord.js') module.exports = async (message, content, desc) => { let embed = new Discord.RichEmbed() .setTitle(content) .setDescription(desc) .setColor(0x00e9f5) return embed }
Geez, is your keyboard having a stroke?
Yes
Omg
im losing braincells now
Embed = await custpm
ok ty
why do you use a whole require() statement for embeds?
Welp im out
lol ok
there's something called functions
this is something i have used in bots i made before
async function simpleEmbed(message, author, description) {
//let config = require("./config.json");
try {
const embed = new Discord.RichEmbed()
.setAuthor(author)
.setColor("RANDOM")
.setDescription(description)
message.channel.send({embed});
} catch(err) {
console.log(err)
try {
simpleEmbed(message, 'UNKNOWN ERROR', 'An error has occured.');
} catch(err1) {}
}
return;
}
and then use simpleEmbed(message, "oof", "lol") in my code
i do that too
makes my code cleaner
i dont think i really helped..
Normally I make a helper file (class in my case) to store all the commonly used functions
idk how to do that
Just make a function-only file
I think it's better to debug this way
Also it's a bit faster
im assuming it is like eventFile.NAME()
unless it is something like eventFile.run(client, message, "console.log('code2run')")
which is prob isnt
No, it's really a file to contain all functions used across the project
wait
you can store functions
and only use 1 require
to make it work in every bot file, if you have the require in it
ive read a bit of other people's java code before lol
a lot of code is self explanatory to me
because
message.channel.send
gets the message channel and send a message
a lot of code is self explanatory to me
@shy turret it is indeed
You can probably read a java code loud, and you'll understand it like a book
unless this happens: https://obfuscator.io/
JavaScript Obfuscator is a free online tool that obfuscates your source code, preventing it from being stolen and used without permission.
Lets go to general chat
ok
Ok in simple words my code:
actualargs = message.content.toString().slice(message.content.split(' ')[0].length + 1).toString()
Holy
wait, why message.content.toString()? its already a string right
Split that in 3 variables
actualargs = "hi"
cuz lol
then
if (actualargs !== "") {
exports.loopnum = parseFloat(lineargs);
}
WOAH
It doesnt pass
well since its js
simple words
exports.run = (client, message, args, loopnum, maxlines) => {
actualargs = message.content.toString().slice(message.content.split(' ')[0].length + 1).toString()
console.log(actualargs)
if (actualargs !== "") {
console.log("NO")
} else {
console.log("YES")
}
Console:
hi
NO
cant you do !str.len() ?
wdym
.length
i think i know what u mean
shouldnt !str.length be true if its empty?
idk
2 secs
str.length can be 0
Ah
0 -> false , all other -> true
@earnest phoenix omg thanks it actually worked

instantly makes another bug
o
What error?
Is there a thread on here that I can get help getting SWOP to work? I went through everything, thought I did it all right, but i cant get my computer and phone to communicate
show code and expected output
@shy turret
@earnest phoenix what's swop?
^
if this doesnt work
var: | length:
pass (as in no args)
var: hi | length: hi
huh
What
wait
that confuses me
Dude
w h a t
my code confuses me
my code confuses me
@shy turret that might be a sign of low memory
Download some RAM
xD
Download some RAM
where can I get some ram
@lyric mountain yah where can i download ram xD
https://downloadmoreram.com/ xD this isnt how it works
DownloadMoreRAM.com - CloudRAM 2.0
Retrieving all the RAM...
so my uni
Almost there...
just sent out an email saying they wireless is gonna go down ):
Seems like you're having connection issues. Would you like to search in the internet for solutions?
w h a t
alright I am confused rn, not the classes, just code in general, I have this written js if (_guilds.settings.useEmbeds == true) return message.channel.send(NoPremiumEmbed); return message.channel.send(`This command is a Premium Only command.`);
but _guilds.settings.useEmbeds is undefined even though I have it defined, when I console log the _guilds.settings, I get this, does anyone know why I might be getting an undefined, did I misspell because that would make me look really dumb rn
ss?
Screenshot
its the guild data
Sounds like an array?
its an object but yeah
What exactly are you printing?
in the ss? the _guilds.settings
Entire code.?
Could be a variable scope issue. But I can't tell without seeing the rest
needsPremium(client, message, command, _users, _guilds, _userGuild) {
let NoPremiumEmbed = new MessageEmbed()
.setAuthor(message.author.tag, message.author.avatarURL())
.setColor('ff0000')
.setDescription(`This command is a premium command, it cannot be used here\n\n> If this is an error, contact MILLION#1321`)
.setFooter(command.memberName)
.setTimestamp();
console.log(_guilds.settings.useEmbeds);
if (_guilds.settings.useEmbeds == undefined) return message.channel.send(NoPremiumEmbed);
return message.channel.send(`This command is a Premium Only command.`);
}```
when I console log _guilds.settings.useEmbeds its undefined but its in _guilds.settings
I must be spellling wrong because _guilds.settings.prefix works
you arent tho
yeah its weird
log _guilds.settings right before the other log
so js console.log(_guilds.settings); console.log(_guilds.settings.useEmbeds);?
ye
aight one sec
alright
0|index | {
0|index | levels: {
0|index | xpRate: 1,
0|index | levelCooldown: 10,
0|index | levelSpam: 'off',
0|index | roles: { '0': 'N/A' }
0|index | },
0|index | settings: {
0|index | disabledLogs: [],
0|index | disabledCommands: [],
0|index | prefix: 't!',
0|index | logs: 'N/A',
0|index | memberRole: 'N/A',
0|index | useEmbeds: true,
0|index | noPermsMessage: true
0|index | },
0|index | stats: {
0|index | totalMembers: 'N/A',
0|index | totalChannels: 'N/A',
0|index | voiceChannels: 'N/A',
0|index | textChannels: 'N/A',
0|index | totalRoles: 'N/A'
0|index | },
0|index | _id: 5e58330bcb99290b71ae423f,
0|index | warns: { mute: [], kick: [], ban: [] },
0|index | disabledCommands: { commands: [], error: true, embed: true },
0|index | guildId: 611720633050464300,
0|index | premium: { active: true, expires: 'N/A' },
0|index | custom: { '0': 'N/A' },
0|index | __v: 0
0|index | }
0|index | {
0|index | disabledLogs: [],
0|index | disabledCommands: [],
0|index | prefix: 't!',
0|index | logs: 'N/A',
0|index | memberRole: 'N/A',
0|index | useEmbeds: true,
0|index | noPermsMessage: true
0|index | }
0|index | undefined```
probably a bit annoying to read with the index | part
no its fine
it's consistent
thats...
odd..
very odd..
i barely know any js
but
that shouldnt be happening
Alright thanks for helping
np
Not necessarily
Is there any reason why some of my bot's shards are randomly going out?
It's Discord, expect shards to be unstable
await event.player.hook(event)
AttributeError: 'NoneType' object has no attribute 'player' ``` ```@commands.command(name='stop')
async def do_stop(self, ctx):
player = self.bot.wavelink.get_player(ctx.guild.id)
await player.disconnect()
await ctx.send(f'Disconnecting to {channel.name}')
Ummmm ok
what ide are you using?
and paste the entire stack trace if yu can, @outer niche
Issue was figured out
oki
if (users[0]) var firstplace = await client.fetchUser(users[0].userid)
if (users[1]) var secondplace = await client.fetchUser(users[1].userid)
if (users[2]) var thirdplace = await client.fetchUser(users[2].userid)
if (users[3]) var fourthplace = await client.fetchUser(users[3].userid)
if (users[4]) var fifthplace = await client.fetchUser(users[4].userid)
let embed = new Discord.RichEmbed()
.setColor("00FFFF")
.setDescription(`1 - ${firstplace && firstplace.tag || 'Nobody Yet'} : ${users[0] && users[0].balance || 'None'}
2 - ${secondplace && secondplace.tag || 'Nobody Yet'} : ${users[1] && users[1].balance || 'None'}
3 - ${thirdplace && thirdplace.tag || 'Nobody Yet'} : ${users[2] && users[2].balance || 'None'}
4 - ${fourthplace && fourthplace.tag || 'Nobody Yet'} : ${users[3] && users[3].balance || 'None'}
5 - ${fifthplace && fifthplace.tag || 'Nobody Yet'} : ${users[4] && users[4].balance || 'None'}`);
message.channel.send(embed);```
Is there any mistake?
Discord Api error
`(node:16569) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body11:05 AM
user_id: Value "5.10796282139509e+17" is not snowflake.`
yea
its not actually in that code afaik
its telling you that what should be an id (snowflake) isnt
if it is in the code, i'd say the first five lines
it looks like js is trying to convert a number to a floating point, hence the e+17
that- im not sure.
v12 when?
idk if djs will take a string as a snowflake
you'd have to look in the docs for that
sure
Then i can use this? .send({embed: {description: here}})
well no cuz you'd still run into the same problem
no
Mm
that's not how it works
AFAIK, what's happening is that the users[0].userid is being converted to a float
as to why - again cant tell you
Hm
imma just leave this one to @pale vessel since they seem to know djs ;p

i dont use javascript, and i only really know the basics
Try catching the error on the fetchUser.
Since that might also cause another issue in the future
also Invalid form body means that the format of the embed is invalid.
Yes
but its also saying about it not being a snowflake, and the only place in that code where its even passed snowflakes is the first 5 lines
I was sending it by .send(`here`)
Would you mind giving me an example of what users[0] or users[1] would be defined as in a command?
I am using discord-economy api
(print users[0])
You will find that in npm discord-economy examples
I'm asking you for it and you can console#log(users[0]) and get the output of it
Lk
Ok
user_id: Value "5.10796282139509e+17" is not snowflake.11:27 AM
at /rbd/pnpm-volume/04d2b97d-b6b0-4096-bd33-46a980d362e6/node_modules/.registry.npmjs.org/discord.js/11.6.1/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:85:1511:27 AM
at /rbd/pnpm-volume/04d2b97d-b6b0-4096-bd33-46a980d362e6/node_modules/.registry.npmjs.org/snekfetch/3.6.4/node_modules/snekfetch/src/index.js:215:2111:27 AM
at processTicksAndRejections (internal/process/task_queues.js:88:5)11:27 AM
(node:17461) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)11:27 AM
(node:17461) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
it's telling you exactly what to do there... like I told you before: https://discordapp.com/channels/264445053596991498/272764566411149314/685363345305632849
Yes
so catch the client#fetchUser
aand discord.js and eris has the user ids as a string
@charred jetty
Hm
aand discord.js and eris has the user ids as a string
@restive furnace
that
@charred jetty
see
what @lilac wharf didnt tell you
better add .toString()
^
Promise {12:00 PM
User {12:00 PM
id: '510796282139508756',12:00 PM
username: 'My Hero Bot',12:00 PM
discriminator: '4718',12:00 PM
avatar: '4b093ba9b0dc8c41e7ad1fe3e7ffd6dc',12:00 PM
bot: false,12:00 PM
lastMessageID: '685373830990004234',12:00 PM
....
Many details
About the user
Promise 12 pm?
timestamp
Oh
at timeout.client.setTimeout (/rbd/pnpm-volume/f47eb651-9c16-4ad3-ad8a-ecf9a6d5bbdc/node_modules/.registry.npmjs.org/discord.js/11.6.1/node_modules/discord.js/src/client/ClientManager.js:40:57)
at Timeout.setTimeout [as _onTimeout] (/rbd/pnpm-volume/f47eb651-9c16-4ad3-ad8a-ecf9a6d5bbdc/node_modules/.registry.npmjs.org/discord.js/11.6.1/node_modules/discord.js/src/client/Client.js:436:7)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
at Timer.listOnTimeout (timers.js:290:5)
(node:135) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 7)
(node:135) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
help ???
@storm bluff that's nothing to worry about it just means that discord.js couldn't complete a task, restart your bot
@golden condor, Okey thanks -<3
If that doesn't work, feel free to ping me
okey
Got the actual problem
{ userid: '5.10796282139509e+17', balance: '100' }
The userid
F
I need to reinstall the api
F
Or
Delete database
json db?
It's api
Discord-economy
I reinstalled it but nothing changed
@finite bough and i think the user is you

Or someone
@charred jetty you can just convert the user id to string
if it was a string then it would not show that:
{ userid: '5.10796282139509e+17', balance: '100' }
Wait
user I'd cannot have dots or alphabets
yeah I know
But e+17 is used for long integers
you can try it on a calculator
const F = someput.map(s => console.log(s) + "|" + s.balance).join("\n")
message.channel.send(F)```
A discours user ID is 17 or 18 numbers long
18
I used it to check what's happening
And i got it from Console
if it was a string then it would not show that:
{ userid: '5.10796282139509e+17', balance: '100' }
@gleaming narwhal
but some of them exceeds the maximum value of integer, right?
Yes
No
If he become 4rth i think it will work properly
Make a new db, and make sure u store userid as `${user ID} `
@charred jetty is it. json db?
or maybe you can convert to string for making it sure
@finite bough no
It is
it is
it is
but why result doesn't have a quote char around key
yep

imagine using json or txt as a db anyway

for small bots i litterally have one class that i use for everything that handles adding removing stuff etc..
pretty sure it supports a .db file
Yes
Lol
then why not just us .db?
@charred jetty it can
But the api uses .sqlite file
Glitch can use sqlite
sqlite works with .db ez
^
Glitch can use it but can't show me the file
it can
You just have to install a module for this like sqlite or sqlite3
u need a sqlite code reader
i mean its a db file your not supposed to just open in
Lol
u need a sqlite code reader
Yes
some modules on vsc will do it
DBs are NOT text files
A sqlite file can't be read like this, this isn't magic
Json can, this isn't really for db but....
Now everything is ok.. and me gonna offline
No it dont exist
😂 topic changed
xD
Now Go to #memes-and-media
Don't lie
Magie is a lie.
no
Here we talk about development problems, normt magic
every boy has magic inside his pants
@tight plinth yes :(
Ik only one thing.. idc about magic exist or not but glitch exist
Glitch exists
no
And it sucks
Oof
(til I get a real vps)
Team glitch
lumap ill cover you for a while ig
Wdym
ill give you my vps for some time
Rly!?
you know those moments where you just go "wow"
yeah
i am having omega wow moment
I'm in class, I have to do "the comedy"
oof
i implemented a thingy to my bot
Hmmm
and it changed literally everything
its a gamechanger
wow
its one of the moments where you get to remove like
100 or more lines of code
"one day"
"Two days"
"same"
Eri comes out, let's continue to talk about development
eri: pls go to #memes-and-media
So
I'm only 16, lol
Glitch is bad ONLY if you don’t use it correctly @earnest phoenix
And stay on-topic please
lumap insulted it not dany :/
i have ascended
My bot sometimes randomly crashes without any reason, just see that the bot restarts and the log says the app was sropped
Stopped
@flat pelican no glitch is bad for big bots and not really good :/
Correct
@tight plinth if you are using a free plan probably it stops the app when it becomes unactive
heroku does the same too
Just says an error occurred, a'd then restart
@tight plinth you are not handling promises
glitch is bad for big bots
Why would you use a free host for a big bot
if you are using free dyno
hmm idk then
@slender thistle not everyon can paid
Shouldn't you have some money by the time your bot gets big
For the pleasure
Heroku restarts workers every day iirc
creating a bot is an investment of money not a freelo-money
maybe to gain experience
@gleaming narwhal yes also
You can create a bot for fun, experience, to learn something - but if your plans are bigger, then you should spend money
I was never able to hit 1 day uptime with glitch, but I can easily hit 1 week uptime with heroku
Everything in life isn’t free
by making a bot you can practice your coding skills and do something useful for people, double win
@flat pelican the air is free
#roasted

Not if you kill our trees
imagine killing trees
But i don't kill and tree
you don't
lol
uh this isnt offtopic dw.
Wtf
Anyway, yes
@cursive dagger shh
your convo isnt dev anymore
#memes-and-media is still a good place to talk about tree addiction
its developing our brain cells
Yeah
Contabo is nice for quality and cheap hosts if someone is looking for one
And everyone leaves this chan
contabo is getting bad for music bots
but for normal ones w/o dealing with youtube
its fine
Tbf that's cuz YT basically decided to just blanket ban IPs now
my bot runs fine on computer but when running on pi it throws error:
Error: ENOENT: no such file or directory, scandir
Im currently seeing if rebuilding node helps
nope
didnt
idk about error but make sure you have same modules on pi
i have all the same modules
does node version is same too?
yep
im not sure then
it mirrors my computer perfectly
this also follows the fact that i also cant write to disk with fs
on pi
idk about node
permission is denied
it doesnt make any sense
its running as root
it literally has all the perms
my bot runs fine on computer but when running on pi it throws error:
Error: ENOENT: no such file or directory, scandir
@lethal stratus can you show full error
not much more to see, but sure
Mar 06 20:29:38 raspberrypi node[14719]: throw err;
Mar 06 20:29:38 raspberrypi node[14719]: ^
Mar 06 20:29:38 raspberrypi node[14719]: Error: ENOENT: no such file or directory, scandir './cmds/fun'
Mar 06 20:29:38 raspberrypi node[14719]: at Object.readdirSync (fs.js:786:3)
Mar 06 20:29:38 raspberrypi node[14719]: at Object.<anonymous> (/home/pi/Desktop/h40/bot.js:21:9)
Mar 06 20:29:38 raspberrypi node[14719]: at Module._compile (internal/modules/cjs/loader.js:689:30)
Mar 06 20:29:38 raspberrypi node[14719]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
Mar 06 20:29:38 raspberrypi node[14719]: at Module.load (internal/modules/cjs/loader.js:599:32)
Mar 06 20:29:38 raspberrypi node[14719]: at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
Mar 06 20:29:38 raspberrypi node[14719]: at Function.Module._load (internal/modules/cjs/loader.js:530:3)
Mar 06 20:29:38 raspberrypi node[14719]: at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
Mar 06 20:29:38 raspberrypi node[14719]: at startup (internal/bootstrap/node.js:283:19)
Mar 06 20:29:38 raspberrypi node[14719]: at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)```
yes bot can't find cmds/fun
uh
the folder exists
auth.json bot.js cmds h40 helps.json node_modules package.json package-lock.json prefix.json rebooted.json
pi@raspberrypi:~/Desktop/h40 $ ```
```pi@raspberrypi:~/Desktop/h40/cmds $ ls
fun owner useful
pi@raspberrypi:~/Desktop/h40/cmds $ ```
it seems to folder path is incorrect
its running from bot.js which is at ~/Desktop/h40
inside of h40 (./) is cmds, and cmds/fun
however, i will still try doing it from ~
see if its having issues with local folders
Mar 06 20:36:26 raspberrypi node[15010]: throw err;
Mar 06 20:36:26 raspberrypi node[15010]: ^
Mar 06 20:36:26 raspberrypi node[15010]: Error: ENOENT: no such file or directory, scandir '~/Desktop/h40/cmds/fun'
Mar 06 20:36:26 raspberrypi node[15010]: at Object.readdirSync (fs.js:786:3)
Mar 06 20:36:26 raspberrypi node[15010]: at Object.<anonymous> (/home/pi/Desktop/h40/bot.js:21:9)
Mar 06 20:36:26 raspberrypi node[15010]: at Module._compile (internal/modules/cjs/loader.js:689:30)
Mar 06 20:36:26 raspberrypi node[15010]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
Mar 06 20:36:26 raspberrypi node[15010]: at Module.load (internal/modules/cjs/loader.js:599:32)
Mar 06 20:36:26 raspberrypi node[15010]: at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
Mar 06 20:36:26 raspberrypi node[15010]: at Function.Module._load (internal/modules/cjs/loader.js:530:3)
Mar 06 20:36:26 raspberrypi node[15010]: at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
Mar 06 20:36:26 raspberrypi node[15010]: at startup (internal/bootstrap/node.js:283:19)
Mar 06 20:36:26 raspberrypi node[15010]: at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)```
didnt change it
hell, at this point im gonna try /home/pi/Desktop/h40/cmds
FULL PATH!
aight, here we go
i had same issues about hosting it too
good to have someone in the same boat as me
horrah!
it just DMed me that it rebooted successfully
./cmds/
on hosting it heroku i had file accessing issues too
nice to hear it is working now
:)
const owner = await message.guild.fetchMember(message.guild.ownerID)
it says invalid or uncached id provided
what discord,js version?
I don't use discord.js but you can try message.guild.owner
@quartz kindle v11
are you sure about fetchMember requires a user id instead of a user object
it says invalid or uncached id provided
@earnest phoenix show result
@gleaming narwhal yes, it accepts ids or any type of object which contains a user id
oh ok then
huh thats really weird
but i dont use v11 so idk
when you request a member in the discord api, its user comes with it
hmm
let usr = await client.fetchUser(message.guild.ownerID, true);
let owner = await message.guild.fetchMember(usr.id);
thats what i used @quartz kindle
holdon
@quartz kindle Look at the things to update that discord.js posted
what things to update?
@earnest phoenix no need to fletch it
Oh I thought you needed help my bad
just use message.guild.ownerID
yeah i told him to console.log it as well
lul
else votings[user_id].voteCount++;
try {
fs.writeFileSync('./DBLcount.json', JSON.stringify(votings));
} catch(err) {
console.error(err);
}```
Is there any mistake?
const votings = require('./DBLcount.json');
app.post("/hook", async (req, res) => {
if (req.headers.authorization !== config.auth) return res.send({code: "invalid auth"})
let user_id = req.body.user;
let usertag = client.users.get(user_id).tag
let bot = req.body.bot;
const arg = "sstl_spinning"
const emojiname = client.emojis.find(emoji => emoji.name === arg).name
const emojiid = client.emojis.find(emoji => emoji.name === arg).id
if (!votings[user_id]) votings[user_id] = { voteCount: 1 };
else votings[user_id].voteCount++;
try {
fs.writeFileSync('./DBLcount.json', JSON.stringify(votings));
} catch(err) {
console.error(err);
}```
wait that doesnt look right
what is the problem?
Not working
error?
save it 1st
did you debug it?
ie: put a console.log at the beginning to see if the request is arriving
Yes
do refresh in the console
Ok
put a console.log in there, and check if you are actually receiving the request
glitch doesnt like when the client edits the files
@charred jetty if u want to edit that everytime someone votes
u have to restart the bot
Ohk
why?
to restart it when something is triggered
why restart everytime he gets a request?
How to add me bot on site Discord.bots
That is a bad idea to restart on every vote etcmm
?
How to add me bot on site Discord.bots ?
the json,js,txt files wont be updated till u restart ur bot
@modest maple ik
there is no other way to update the json files tho
What is the full commands
Then use a db
the limitation that files edited on the backend (i.e. in code or in the console) don’t automatically sync with the editor. If you want to see those changes in the editor you need to run the refresh command
wait
the file itself should be saved properly, it just doesnt show in the code editor
well
holdon
ima screen share to show u that it doesnt update it
join general
@quartz kindle
?


