Fields.flat is not a function on raspberry pi
(node:4992) UnhandledPromiseRejectionWarning: TypeError: fields.flat is not a function at Function.normalizeFields (/home/pi/Mr.Mod/node_modules/discord.js/src/structures/MessageEmbed.js:450:8) at MessageEmbed.setup (/home/pi/Mr.Mod/node_modules/discord.js/src/structures/MessageEmbed.js:78:91) at new MessageEmbed (/home/pi/Mr.Mod/node_modules/discord.js/src/structures/MessageEmbed.js:18:10) at embedLikes.map.e (/home/pi/Mr.Mod/node_modules/discord.js/src/structures/APIMessage.js:166:40) at Array.map () at APIMessage.resolveData (/home/pi/Mr.Mod/node_modules/discord.js/src/structures/APIMessage.js:166:31) at TextChannel.send (/home/pi/Mr.Mod/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:166:62) at Object.run (/home/pi/Mr.Mod/commands/utility/help.js:53:25) at process._tickCallback (internal/process/next_tick.js:68:7) (node:4992) 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: 5)
I am running it on raspberry pi and I don't see it anywhere in my script. Mind helping anyone?
do you know?
how many words do you know
See also questions close to this topic
-
how to change prettier format for react native
my code formatting prettier didn't works well for react native, i don't understand where to config it but it works well with flutter
from this code
import { View, Text } from 'react-native' import React from 'react' export default function App() { return ( <View> <Text>Apps</Text> </View> ) }
it's formatted to this
import { View, Text } from 'react-native' import React from 'react' export default function App() { return ( < View > < Text > Apps < /Text> < /View> ) }
-
MarkLogic server-side JavaScript and XQuery
I am just starting using NoSQL MarkLogic DB and trying to choose for me the best query language to learn and use in future. On server side MarkLogic provides the possibility to use JavaScript API or XQuery API.
I want to receive an advice. Which language is better to concentrate on and learn? JavaScript or XQuery?
- Popover in chrome extension using js
-
Is there any way of connecting minecraft javaPlugin to discord javaScript bot?
So basiclly, I was making a minecraft plugin, and I want to add function that alows you to log in into serwer in minecraft only if you are on discord. But i dont really know how can i call js from java.
-
Discord.js How to find all the servers a different discord user is in
I want to make a website where people can change what the bot does on their server. I'm currently using Autocode to make it (using discord.js). I also don't know how to link OAouth2 with the code. This is the full code of what I'm at
// Using Node.js 14.x + // use "lib" package from npm const lib = require('lib')({ token: 'token_here' }); // make API request let result = await lib.discord.guilds['@0.2.4'].list({ limit: 100 }); console.log(result[0]);
it works but only gets what guilds the bot is in. I tried to link it to the user but I couldn't find out what to put
-
How to control a sainsmart relay using NodeJs
Hi I am trying to turn on and off a relay to power 12v lights and others, using sainsmart relays.
I would like to my own interface with buttons so I would setup a web page with express to interact with my nodejs server and this would control the gpio and relays
Since I am new to raspberry pi I don't really know how to do it and all the exemples that I can find are using switches or just 27 sec videos that do not show any code
const Gpio = require('pigpio').Gpio; const frontLight = new Gpio(12, { mode: Gpio.OUTPUT, pullUpDown: Gpio.PUD_DOWN, edge: Gpio.FALLING_EDGE } console.log('GPIO Outputs Configured'); //this above is from the basic switch video that I kinda adapted by instinct //and under is something I put up to show what I would like to be frontLight.on('interrupt', function(level) { //checkbox1 would be on the express web page if(checkbox1.Checked()){ frontLight.Relay.On console.log('On'); } else { frontLight.Relay.Off console.log('Off'); } });
my configuration is :
Raspberry Pi 4 with RasPi OS
-
Raspberry PI 4 camera snapshot not working
I am working on a project with raspberry pi 4 and a camera. I wanted to try and check if the camera was up and running but I am running into an issue when attempting to take a snapshot. I have set up the camera correctly as the camera is detected by the raspberry pi. Below are some of the commands I run:
pi@raspberrypi:~ $ vcgencmd get_camera supported=1 detected=1
pi@raspberrypi:~ $ raspistill -v "raspistill" Camera App (commit bab9bf8790cd Tainted) Camera Name imx219 Width 3280, Height 2464, filename (null) Using camera 0, sensor mode 0 GPS output Disabled Quality 85, Raw no Thumbnail enabled Yes, width 64, height 48, quality 35 Time delay 5000, Timelapse 0 Link to latest frame enabled no Full resolution preview No Capture method : Single capture Preview Yes, Full screen Yes Preview window 0,0,1024,768 Opacity 255 Sharpness 0, Contrast 0, Brightness 50 Saturation 0, ISO 0, Video Stabilisation No, Exposure compensation 0 Exposure Mode 'auto', AWB Mode 'auto', Image Effect 'none' Flicker Avoid Mode 'off' Metering Mode 'average', Colour Effect Enabled No with U = 128, V = 128 Rotation 0, hflip No, vflip No ROI x 0.000000, y 0.000000, w 1.000000 h 1.000000 mmal: mmal_vc_component_enable: failed to enable component: ENOSPC mmal: camera component couldn't be enabled mmal: main: Failed to create camera component mmal: Failed to run camera app. Please check for firmware updates
The above is the error I am getting, I assume the problem is that the camera is being used by another processes, but I do not know how to find those process.
Any input on this will be highly appreciated.
-
Cannot unpack noniterable bool object
I'm new to Python and posting on SO.
I'm doing a class project on trying to create an automated climate control system with a Raspberry pi(Pi4 4GB) and a DHT. Here is my current error and code and I'm not sure what's causing the fail in the loop. It works for a while then errors out. It seems to error when it gets a bad read from the sensor, but until then it works fine.
Traceback (most recent call last): File "/home/pi/raphael-kit/python/Climatecontrol.py", line 156, in <module> main() File "/home/pi/raphael-kit/python/Climatecontrol.py", line 118, in main humidity, temperature = readDht11() TypeError: cannot unpack non-iterable bool object
import RPi.GPIO as GPIO import time import LCD1602 dhtPin = 17 relayPin = 23 # Set GPIO23 as control pin set_temp = 25 # this is the required temperature GPIO.setmode(GPIO.BCM) # Set relayPin's mode to output, # and initial level to High(3.3v) GPIO.setup(relayPin, GPIO.OUT, initial=GPIO.HIGH) MAX_UNCHANGE_COUNT = 100 STATE_INIT_PULL_DOWN = 1 STATE_INIT_PULL_UP = 2 STATE_DATA_FIRST_PULL_DOWN = 3 STATE_DATA_PULL_UP = 4 STATE_DATA_PULL_DOWN = 5 def readDht11(): GPIO.setup(dhtPin, GPIO.OUT) GPIO.output(dhtPin, GPIO.HIGH) time.sleep(0.05) GPIO.output(dhtPin, GPIO.LOW) time.sleep(0.02) GPIO.setup(dhtPin, GPIO.IN, GPIO.PUD_UP) unchanged_count = 0 last = -1 data = [] while True: current = GPIO.input(dhtPin) data.append(current) if last != current: unchanged_count = 0 last = current else: unchanged_count += 1 if unchanged_count > MAX_UNCHANGE_COUNT: break state = STATE_INIT_PULL_DOWN lengths = [] current_length = 0 for current in data: current_length += 1 if state == STATE_INIT_PULL_DOWN: if current == GPIO.LOW: state = STATE_INIT_PULL_UP else: continue if state == STATE_INIT_PULL_UP: if current == GPIO.HIGH: state = STATE_DATA_FIRST_PULL_DOWN else: continue if state == STATE_DATA_FIRST_PULL_DOWN: if current == GPIO.LOW: state = STATE_DATA_PULL_UP else: continue if state == STATE_DATA_PULL_UP: if current == GPIO.HIGH: current_length = 0 state = STATE_DATA_PULL_DOWN else: continue if state == STATE_DATA_PULL_DOWN: if current == GPIO.LOW: lengths.append(current_length) state = STATE_DATA_PULL_UP else: continue if len(lengths) != 40: #print ("Data not good, skip") return False shortest_pull_up = min(lengths) longest_pull_up = max(lengths) halfway = (longest_pull_up + shortest_pull_up) / 2 bits = [] the_bytes = [] byte = 0 for length in lengths: bit = 0 if length > halfway: bit = 1 bits.append(bit) #print ("bits: %s, length: %d" % (bits, len(bits))) for i in range(0, len(bits)): byte = byte << 1 if (bits[i]): byte = byte | 1 else: byte = byte | 0 if ((i + 1) % 8 == 0): the_bytes.append(byte) byte = 0 #print (the_bytes) checksum = (the_bytes[0] + the_bytes[1] + the_bytes[2] + the_bytes[3]) & 0xFF #if the_bytes[4] != checksum: #print ("Data not good, skip") #return False return the_bytes[0], the_bytes[2] def main(): while True: humidity, temperature = readDht11() if humidity is not None and temperature is not None: print("Temp={0:0.1f}*C Humidity={1:0.1f}%".format(temperature, humidity)) # test for low temperature if temperature < set_temp: print(GPIO.output(relayPin, GPIO.LOW)) # test for high temperature if temperature > (set_temp + 1): print(GPIO.output(relayPin, GPIO.HIGH)) else: print("Failed to retrieve data from humidity sensor") time.sleep(5) #this is the time between taking readings and acting on them you can reduce it but not below 5 seconds # Define a destroy function for clean up everything after # the script finished def setup(): LCD1602.init(0x27, 1) # init(slave address, background light) LCD1602.write(0, 0, 'Temperature: %s C') LCD1602.write(1, 1, 'humidity: %s %%') time.sleep(2) def destroy(): # set relay to off GPIO.output(relayPin, GPIO.LOW) # Release resource GPIO.cleanup() if __name__ == '__main__': try: setup() except KeyboardInterrupt: destroy()
as a note I haven't managed to get the LCD working in tandem but im more worried about the main functionality