(Discord.js) Problem with music command nowplaying - discord.js

this morning I saw that my discord music bot gave errors when executing the command "nowplaying", that should show the song that is currently playing. (ps: I never changed anything in that command file).
Here is the error:
TypeError: createBar is not a function
at Object.execute (/home/runner/Nightcorer-New/Music/nowplaying.js:60:47)
And the code where the error should be:
//If its not a stream
if (ms > 0 && ms < 10000) {
nowPlaying.addField("\u200b", "**``[" + createBar((ms == 0 ? seek : ms), seek, 25, "▬", "🔘")[0] + "]``**\n**" + "\n[" + new Date(seek * 1000).toISOString().substr(11, 8) + " / " + (ms == 0 ? " ◉ LIVE" : new Date(ms * 1000).toISOString().substr(11, 8)) + "]**" + "\n" + "\n **Time Remaining:**" + "``" + new Date(left * 1000).toISOString().substr(11, 8) + "``", false);

As assumed in the comments, the package string-progressbar doesn't export one function anymore since v1.0.3. Since v1.0.4 there are an object with two functions exported:
<script type="module">
import stringProgressbar from 'https://cdn.skypack.dev/string-progressbar';
console.log(stringProgressbar.filledBar(20, 10));
console.log(stringProgressbar.splitBar(20, 10));
</script>
So in order to fix your problem...
...update createBar(...) to createBar.filledBar(...) or createBar.splitBar(...)
...reinstall v1.0.3 if you want to stick to your old code.

Related

Why my R seems take forever to run a Mixed effects logistic regression

I indeed got a relatively big dataset and my mixed effects logistic regression is like below. Is that normal to take that long to run? or I made some mistakes?
library(lme4)
glmer_EBRD_undersample_1 <- glmer(leave_happened ~
performance_rating_2016 + performance_rating_2017 + performance_rating_2018 + performance_rating_2019 + performance_rating_2020
+ gender
+ target_group
+ target_pmf_band
+ target_hq_or_ro
+ target_office_location_country_distilled
+ target_org_unit_cost_centre_code_distilled
+ target_ebrd_region_distilled
+ target_contract_group_distilled
+ target_position_tenure_group
+ target_length_of_service_group_distilled
+ leaves_to_date
+ moves_to_date
+ joins_to_date
+ applied_count_to_date
+ line_reviewed_to_date
+ interviewed_to_date
+ offered_to_date
+ hired_to_date
+ (1 | person_id)
,
data = train_undersample_1,
family = binomial,
control = glmerControl(optimizer = "bobyqa"),
nAGQ = 10
)
summary(glmer_EBRD_undersample_1)
Also gave a warning like this: Warning in commonArgs(par, fn, control, environment()) :
maxfun < 10 * length(par)^2 is not recommended.

Making a discord bot and the way I'm adding roles is causing crashes

trying to make a level system that adds roles at certain levels but the bot is crashing everytime saying that at msg.member.roles.add() giving me a can't read properties of null (reading roles)
if (Date.now() - userStats.last_message > 60000) {
userStats.xp += between(15, 25);
userStats.last_message = Date.now();
//setup what xp needs for levels and reseting/setting levels and xp and adding roles for
certain levels
const xpToNextLevel = 5 * Math.pow(userStats.level, 2) + 50 * userStats.level + 100;
if (userStats.xp >= xpToNextLevel) {
userStats.level++;
userStats.xp = userStats.xp - xpToNextLevel;
msg.channel.send(msg.author.username + ' has increased their chubee faith level to ' +
userStats.level + ' <a:pepesimp:881812231208181790> \n');
if (userStats.level >= 1 && userStats.reached_level_1 === 0) {
userStats.reached_level_1 = 1;
msg.member.roles.add(chubee_follower);
msg.channel.send(msg.author.username + ' is now a chubee follower. Welcome
<a:chubee_pat:881808870681481216>');
You may need to check if member is defined in the message before trying to give the role. This is because there are some cases (like DMing the bot) where member is not defined in the message.
You can do this by changing
msg.member.roles.add(chubee_follower);
for
if(msg.member) msg.member.roles.add(chubee_follower);

Jmeter - How to loop data based on the 'jar' file

I want to create scenario where i want use data from jar file into Jmeter Loop logic.
My jar looks like:
public String Australia()
{
String a = "{"
+ "\"location\": {"
+ "\"lat\": -33.8669710,"
+ "\"lng\": 151.1958750"
+ "},"
+ "\"accuracy\": 50,"
+ "\"name\": \"Google Shoes!\","
+ "\"phone_number\": \"(02) 9374 4000\","
+ "\"address\": \"48 Pirrama Road, Pyrmont, NSW 2009, Australia\","
+ "\"types\": [\"shoe_store\"],"
+ "\"website\": \"http://www.google.com.au/\","
+ "\"language\": \"en-AU\""
+
"}";
return a;
}
public String canada()
{
String c = "{"
+ "\"location\": {"
+ "\"lat\": -33.8669710,"
+ "\"lng\": 151.1958750"
+ "},"
+ "\"accuracy\": 50,"
+ "\"name\": \"Google Shoes!\","
+ "\"phone_number\": \"(02) 9374 4000\","
+ "\"address\": \"48 Pirrama Road, Pyrmont, NSW 2009, Canada\","
+ "\"types\": [\"shoe_store\"],"
+ "\"website\": \"http://www.google.com.ca/\","
+ "\"language\": \"en-CA\""
+
"}";
return c;
}
1) with above data i want to 'feed' Jmeter call as described on the bellow picture
2) every time i add new country at the jar file, loop be increased accordingly.
Some thought how this could be done, what should i use as variable and how i can tell the loop to increase?
Add JSR223 PreProcessor as a child of the 002_2_send payment request
Put the following code into "Script" area:
def testData = new com.example.TestData()
def methods = testData.class.getDeclaredMethods()
def payload = org.apache.commons.lang.reflect.MethodUtils.invokeExactMethod(testData, methods[vars.get('__jm__Loop Controller__idx') as int].getName())
sampler.addNonEncodedArgument('',payload,'')
sampler.setPostBodyRaw(true)
Define "Loop Count" in the Loop Controller using __groovy() function like:
${__groovy(com.example.TestData.getDeclaredMethods().size(),)}
Change com.example to your own package name and TestData to your class name
Once you drop the new version of .jar to JMeter Classpath you will need to restart JMeter to pick up the changes
That's it, each iteration of the Loop Controller the JSR223 PreProcessor will execute the next function in your class and update the request body with the returned data:
References:
Java Reflection API
Apache Groovy - Why and How You Should Use It

How to save Array[String, Int] data into file

I am trying to save a Array[String, Int] data into file. However, every time, it reports:
object not serializable
I also tried to combine the two columns into a string, and want to write it line by line, but it still report such error. The code is:
val fw = new PrintWriter(new File("/path/data_stream.txt"))
myArray.foreach(x => fw.write((x._1.toString + " " + x._2.toString + "\n").toByte
import java.nio.file._
val data = Array(("one", 1), ("two", 2), ("three", 3))
data.foreach(d => Files.write(Paths.get("/path/data_stream.txt"), (d._1 + " " + d._2 + "\n").getBytes, StandardOpenOption.CREATE, StandardOpenOption.APPEND))

I have custom code that I need to bold for output. What google sheets script can I use?

I have created a customized work order submission form in Forms & Sheets that auto emails a confirmation from each submission (job request form) to create a data trail of vendor activity. Fairly integrated and totally cobbled together by a lot of reading in these forums coupled with a gazillion frustrating moments of trial & error. Novice moving towards "capable" but Im stuck on a piece of code for a triggered confirmation email with random work order generator and email confirmations and toggle based management built in. The code below that I actually need help with is for that triggered confirmation email that sends a confirmation of service, work order #, and also shows everything they originally submitted. The problem is that the code I have is providing the data exactly how and I want it and placement is great, but I need to create visual distinction between the column titles and the variable submission data. Can someone please help me add a bold code to the column titles in line 16 to help create that visual differentiation between columnar "category and submission data?
// This constant is written in column C for rows for which an email
// has been sent successfully.
var EMAIL_SENT = "EMAIL_SENT";
function sendEmails2() {
var sheet = SpreadsheetApp.getActiveSheet();
var startRow = 2; // First row of data to process
var numRows = 1000; // Number of rows to process
// Fetch the range of cells A2:B3
var dataRange = sheet.getRange(startRow, 1, numRows, 27)
// Fetch values for each row in the Range.
var data = dataRange.getValues();
for (var i = 0; i < data.length; ++i) {
var row = data[i];
var emailAddress = row[19];
var message = row[16] + "\n\n" + "Submitted By: " + row[19] + "\n\n" + "Date Submitted: " + row[0] + "\n\n" + row[21] + "\n\n" + "IMPORTANT NOTES FROM CDS: " + row[20] + "\n\n" + "Full Show Services: " + row[3] + "\n\n" + "Event Start Date: " + row[4] + "\n\n" + "Event End Date: " + row[5] + "\n\n" + "Warehouse Locations: " + row[6] + "\n\n" + "Individual Services Requested: " + row[7] + "\n\n" + "Individual Services - Warehouse(s) & Date(s) Requested: " + row[8] + "\n\n" + "Partial Hourly Staffing Details Requested: " + row[9] + "\n\n" + "Requestors Instructions / Comments: " + row[10] + "\n\n" + "Files: " + row[11] + row[12] + "\n\n" + "Thank you for your request. We appreciate your business. CDS Special Events Team ";// Second columnn
var emailSent = row[18];
var subject = row[16];// Third columnvar ss = SpreadsheetApp.getActiveSpreadsheet();
if (emailSent != EMAIL_SENT) { // Prevents sending duplicates
MailApp.sendEmail(emailAddress, subject, message);
sheet.getRange(startRow + i, 19).setValue(EMAIL_SENT);
// Make sure the cell is updated right away in case the script is interrupted
SpreadsheetApp.flush();
}
}
}

Resources