I am making a Discord bot in node.js, and need to store some per-guild data. I want to store it in separate JSON files in data/<guild.id>.json using the built in fs/promises. I have a function setGuildData(guildID: string, dataToAssign: object) that reads the current JSON file, parses the JSON to fileData, then assigns the new data using Object.assign() to finally stringify
Tag: javascript
How to check if my input file is valid and existed in Javascript?
I am getting strings from a text file in Javascript. I just want to show a message whenever the user enters the wrong file name or invalid file name. like this: console.log(“You input is invalid”); My code to read my text file and transfer the data to my variable is as follow: I don’t know how to check the existence
Unable to access menu item in QML through shortcuts
This is the code with QtQuick.Controls.12.2. It displays properly but when I press Ctrl nothing happens. I expect the print statement to execute. What am I doing wrong here? Answer Indeed it looks like it’s not possible to use a single modifier (Ctrl/Shift/…) as a shortcut value. (See this similar question) Will work: Will not work: A possible workaround for
JavaScript Follow / Unfollow Button
I would like to make a simple JavaScript program witch allow you to like and dislike. So actually I am new in JavaScript it’s a bit difficult me yet. So when you click onto the Follow button it will increase the “countF” variable’s amount with 1, and change the button text to “Unfollow”. So as I said it is a
HTML Local Storage Dark Mode Using JavaScript
I tried to make a complete darkmode to my website. It’s almost done, but I have an issue. When I reload the page the dark mode goes back to the default light mode. How can I sovle this problem? I tried some code but it didn’t work. I want to use Local Storage, but I don’t know how to add
spawn strace command with Node.js child_process
Since I’m not happy with this approach and I got no answers, I’m trying another method to track the output of an already running program. I based this code on this Unix Stack Exchange and what I’m trying to do is just retrieve the log information of a program that is already running. Obs: to use strace without sudo you
How to declare a global array within an exec in javascript
I’m writing a js script to locate all pid files on a server, extract the pids and then run ‘ ps -fp {pid} ‘ on each of it and extract the memory usages. This is what I’ve got so far: The issue is pidsarr is not getting updated, probably since it’s not declared global or something to do with exec
I can’t start node.js on hosting
I am trying to install my node.js server in hosting. The server running on Windows but not work in hosting. RUN NPM INSTALL ERRROR START SERVER ERROR Answer You need to stop the application before running NPM install. That should fix it
Is there a javascript function to add a generic text box to Gnome extension applets?
I am creating an indicator applet for Ubuntu in the form of a Gnome extension. I’m using javascript (which I don’t have very much experience with). The goal is to have an icon in the panel which when clicked simply pops up a small window (connected to the panel like a menu) with a text box that allows the user
How do I extract data from df ~ onto my website?
I am creating a pie chart which shows how much disk space is available/used on my linux box. However, I am unsure how to parse the data onto a microservice url. Help will greatly be appreciated. Here is what I have at the moment: Router: Controller: Answer You might try the approach below, we create a row object for each