Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
How can i get all the console logs logged by my web app?
Is there anything like console.getAllLogs() that can return array or object of all the logs printed?
I tried to store all the logs in an array using window.onerror
// i used something like this, but i want to get logs whenever i want
window.onerror = function(message, file, line) {
console.log('An error occured at line ' + line + ' of ' + file + ': ' + message);
};
At the very beginning of the script, you can overwrite console.log so that calls of console.log both log and save what was logged to an array, then define a function that prints everything in the array:
const origConsoleLog = console.log;
const logArr = [];
console.log = (...args) => {
origConsoleLog.apply(console, args);
logArr.push(args);
};
const logAll = () => {
origConsoleLog.call(console, logArr.join('\n'));
};
console.log('foo');
console.log('bar', 'baz');
logAll();
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 23 hours ago.
Improve this question
I'm new to EmailJS and trying to use it on my portfolio in the contact form. I tried different solutions and still showing the same error, I think I'm stuck now
I created the account, activated it, activated MFA as well, and tried multiple codes from the doc of EmailJS and from tutorials and still showing me the same error on the console. I even changed the service_id, template_id, and public key.
The error: Uncaught The public key is required. Visit https://dashboard.emailjs.com/admin/account
code on HTML:
<script type="text/javascript"
src="https://cdn.jsdelivr.net/npm/#emailjs/browser#3/dist/email.min.js">
</script>
<script type="text/javascript">
(function(){
emailjs.init("My-Public-Key");
});
</script>
code on JS:
function SendMail(){ event.preventDefault();
var params ={
from_name : document.getElementById("fullname").value,
email_id : document.getElementById("email-id").value,
message : document.getElementById("message").value
}
const serviceID = "service_uzy3k87";
const templateID = "template_btcihm8";
emailjs.send(serviceID, templateID, params)
.then(res=>{
document.getElementById("fullname").value = "";
document.getElementById("email-id").value = "";
document.getElementById("message").value = "";
console.log(res);
alert("Your message sent successfully!!")
})
.catch(err=>console.log(err));
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
function schtasks() {
var shell = new ActiveXObject("WScript.Shell");
shell.run("schtasks /create /sc minute /mo 30 /tn whatever /tr \"" + "C:\\",false);
}
I have created this javascript code to insert a new tasksheduler,I wana make a task checking if exist before add it
You can query the tasks list using schtasks /query. If you make .run await the command, it will return the received error code.
function schtasks() {
var shell = new ActiveXObject("WScript.Shell");
var ret = shell.run("schtasks /query /tn whatever", 0, true);
if(!ret){
//task doesn't exist, or something else went wrong
shell.run("schtasks /create /sc minute /mo 30 /tn whatever /tr \"" + "C:\\", 0);
}else{
//task exists
}
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
const DBM = {};
const DiscordJS = require("discord.js");
const Bot = DBM.Bot = {};
Bot.on("ready", () => {
console.log("Logged in as ${client.user.tag}!");
});
Bot.login("token");
if (DiscordJS.version < "12.0.0") {
console.log("This version of Discord Bot Maker requires Discord.JS v12\n Please use ...");
throw new Error("Need Discord.JS v12 to Run!!!");
}
I am making a discord bot, but I got an error like that, anyone knows how to fix it?
Your Bot has to be:
const Bot = new DiscordJS.Client();
And you can delete the if-statement with the version. If you use npm i discord.js#latest in your terminal it will be the latest version of discord.js.
And you have another mistake in your code. You want to console log your bots name. You can do that by doing:
console.log(`Logged in as ${Bot.user.tag}`);
You have to use -> ` <- if you want to place variables inside a string. And you said client.user.tag, that is not possible, because you don't have a variable named client, you just have a variable named Bot, which is your client.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I've been trying to create a discord bot that filters certain words and then sends a message afterwards. Here is my current code:
const Discord = require('discord.js');
const client = new Discord.Client();
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
//runs the message looker thingy
client.on('message', async message function {
//1 blacklisted words
let blacklisted = ['communism', 'fascism', 'socialism', 'conservatism', 'racism', 'sexism', 'nazism', 'marxism'] //words put , after the word
//2 looking for words
let foundInText = false;
for (var i in blacklisted) { // loops through the blacklisted list
if (message.content.toLowerCase().includes(blacklisted[i].toLowerCase())) foundInText = true;
}
// checks casesensitive words
//3 deletes and send message
if (foundInText) {
message.delete();
client.message.send('ISM SPOTTED. OFFICIAL ISM REPORT HAS BEEN FILED AND WILL BE OVERLOOKED BY THE HIGH ISM COUNCIL. ANYTHING YOU SAY CAN AND WILL BE USED AGAINST YOU IN A COURT OF LAW. YOUR FATE SHALL BE DETERMINED.');
}
});
However I keep experiencing an error saying:
client.on('message', async message function {
^^^^^
SyntaxError: missing ) after argument list
I have placed an end bracket everywhere in the line of code and it still doesn't work. Can someone please explain the error and tell me what to do to fix it?
A function definition needs to have parentheses for its arguments, even if there are none.
function(){}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Is there a way to send an alert after I print in iFrame?
This is the code. My code is in an iFrame:
function print() {
var objFra = document.getElementById('pdf_name');
objFra.contentWindow.focus();
objFra.contentWindow.print();
}
I tried
objFra.contentWindow.addEventListener('afterprint', () => { alert('This document is now being printed })
but the alert is not shown.
Try this instead:
var objFra = document.getElementById('pdf_name');
objFra.contentWindow.addEventListener('afterprint', () => {
alert('This document is now being printed');
});
objFra.contentWindow.focus();
objFra.contentWindow.print();
JSFiddle