OWA crash in e.importFromSeriesTimeJsonObject when Add-In requests recurrence data - outlook-web-addins

New Outlook calendar entry. Set recurring (e.g. daily for a few days) and launch the Outlook Add-In.
Outlook Add-In code:
const stLocal: Date = await GetOutlookTimeAsync(this.OutlookEvent.start);
const edLocal: Date = await GetOutlookTimeAsync(this.OutlookEvent.end);
const recurrence: Office.Recurrence = await GetOutlookStructureAsync("recurrence", this.OutlookEvent.recurrence);
..snip..
export const GetOutlookStructureAsync = (func: string, evt: any) => {
return new Promise<any>((resolve, reject) => {
const who: string = "GetOutlookStructure " + func;
DebugLog(who, "Start");
evt.getAsync((asyncResult: Office.AsyncResult<any>) => {
if (asyncResult.status === Office.AsyncResultStatus.Succeeded) {
DebugLog(who, JSON.stringify(asyncResult.value));
resolve(asyncResult.value);
} else {
const errorText: string = asyncResult.error.message;
DebugLog(who, errorText);
reject(new Error(errorText));
}
});
});
};
Browser console shows:
Uncaught TypeError: Cannot read property 'startYear' of undefined
at e.importFromSeriesTimeJsonObject (outlook-web-16.01.js:19)
at Ta (outlook-web-16.01.js:19)
at (outlook-web-16.01.js:19)
at Object.a [as callback] (outlook-web-16.01.js:19)
at L (outlook-web-16.01.js:19)

This error is currently being tracked here:
https://github.com/OfficeDev/office-js/issues/1312

Related

So I'm trying to make a bot that signs up to roblox with puppeteer and ghost-cursor

At the moment, I've got it so then it types in a username, then clicks the drop down menu to select the month, but when I go to actually make it click the month, it just throws an error. Any help?
This is the code I've got so far:
const puppeteer = require("puppeteer");
const { createCursor } = require("ghost-cursor");
genalt();
async function genalt() {
const browser = await puppeteer.launch({ headless: false });
const page = await browser.newPage();
const cursor = createCursor(page);
await page.goto("https://www.roblox.com");
setTimeout(async() => {
await page.evaluate(() => {
function altName() {
let oh = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
let ohString = "";
for (var i = 0; i < 6; i++) {
ohString += oh.charAt(Math.floor(Math.random() * oh.length));
}
return `MysticGen_${ohString}`;
}
document.querySelector('input[name="signupUsername"]').value = `${altName()}`;
});
setTimeout(() => {
cursor.click('select[name="birthdayMonth"]');
setTimeout(() => {
cursor.click('option[value="Jan"]');
}, 1000)
}, 1000)
}, 1000)
}
And this is the error I am getting:
Falling back to JS scroll method ProtocolError: Protocol error (DOM.scrollIntoViewIfNeeded): Node does not have a layout object
at D:\Downloads\Stuff\Code\Roblox Alt Gen\node_modules\puppeteer\lib\cjs\puppeteer\common\Connection.js:329:24
at new Promise (<anonymous>)
at CDPSessionImpl.send (D:\Downloads\Stuff\Code\Roblox Alt Gen\node_modules\puppeteer\lib\cjs\puppeteer\common\Connection.js:325:16)
at Object.<anonymous> (D:\Downloads\Stuff\Code\Roblox Alt Gen\node_modules\ghost-cursor\lib\spoof.js:463:75)
at step (D:\Downloads\Stuff\Code\Roblox Alt Gen\node_modules\ghost-cursor\lib\spoof.js:44:23)
at Object.next (D:\Downloads\Stuff\Code\Roblox Alt Gen\node_modules\ghost-cursor\lib\spoof.js:25:53)
at fulfilled (D:\Downloads\Stuff\Code\Roblox Alt Gen\node_modules\ghost-cursor\lib\spoof.js:16:58)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
originalMessage: 'Node does not have a layout object'
}

TypeError: Cannot read property 'guild' of undefined

My bot has stopped working, here is my code. I want the bot to listen for #snoop across multiple discord servers and respond with snoop when it is gets hears the ping snoop. Its a basic listen and respond
const Discord = require('discord.js');
const client = new Discord.Client();
const start = new Date();
let snoop = 0;
client.on('ready', () => { console.log(`Logged in as ${client.user.tag}!`); });
client.on('ready', msg => {
if (msg.guild === null || !msg.guild.hasOwnProperty('members') || msg.guild.members === null) { return }
const role = msg.mentions.roles.first();
if (typeof role === "undefined") {
return;
}
const member = msg.guild.members.get(client.user.id);
const channel = msg.channel;
// user is not role member of channel
if (!member.roles.has("" + role.id)) {
return;
}
if (msg.content.match(/(snoop)/i)) {
console.log("snoop detected", role.name, channel.name, channel.id)
const t = Math.floor(Math.random() * (3000 - 2500)) + 2500;
console.debug(`sending snoop to ${channel.name} (${channel.id}) in ${t}ms`)
channel.startTyping();
setTimeout(() => {
channel.send("snoop").then(() => {
setTimeout(() => {
channel.stopTyping();
}, 100);
});
}, t);
boxes++
const s = parseInt((new Date()).getTime() - start.getTime()) / (60 * 1000)
console.info(``)
}
});
client.login('apikeyhere')
This is the error I am getting:
typeError: Cannot read property 'id' of undefined
at ClientDataManager.newChannel (/home/stuart/Downloads/discordbot/node_modules/discord.js/src/client/ClientDataManager.js:81:36)
at Guild.setup (/home/stuart/Downloads/discordbot/node_modules/discord.js/src/structures/Guild.js:307:68)
at new Guild (/home/stuart/Downloads/discordbot/node_modules/discord.js/src/structures/Guild.js:74:12)
at ClientDataManager.newGuild (/home/stuart/Downloads/discordbot/node_modules/discord.js/src/client/ClientDataManager.js:26:19)
at ReadyHandler.handle (/home/stuart/Downloads/discordbot/node_modules/discord.js/src/client/websocket/packets/handlers/Ready.js:20:91)
at WebSocketPacketManager.handle (/home/stuart/Downloads/discordbot/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:108:65)
at WebSocketConnection.onPacket (/home/stuart/Downloads/discordbot/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:336:35)
at WebSocketConnection.onMessage (/home/stuart/Downloads/discordbot/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:299:17)
at WebSocket.onMessage (/home/stuart/Downloads/discordbot/node_modules/ws/lib/event-target.js:120:16)
at WebSocket.emit (events.js:198:13)
When i do node index.js this comes up
You are using twice "client.on('ready'".
One are you using to check if the bot started but the other one that you are using shouldn't be 'ready' but 'message'. Your codes are based on a message and not on when the bot started.

"Cannot read property 'url' of undefined" even though it's already defined

I'm making a Discord music Bot and I'm having trouble with an error saying
TypeError: Cannot read property 'url' of undefined
I tried console logging it and it showed me the url, so I don't understand what is the problem with my code.
Here's my code:
//musicBOT
const Discord = require('discord.js');
const client = new Discord.Client();
const ytdl = require('ytdl-core');
const mcPrefix = '.';
const queue = new Map();
client.on('ready', () => console.log('Music bot ready!'));
client.on('message', async message => {
if(message.author.bot) return;
if(!message.content.startsWith(mcPrefix)) return;
const args = message.content.substring(mcPrefix.length).split(" ");
const serverQueue = queue.get(message.guild.id);
if(message.content.startsWith(`${mcPrefix}play`)) {
const voiceChannel = message.member.voice.channel;
if(!voiceChannel) return message.channel.send("Hang-szobában kell lenned zenelejátszáshoz.");
const permissions = voiceChannel.permissionsFor(message.client.user);
if(!permissions.has('CONNECT')) return message.channel.send("Nincs jogosultságom csatlakozni a hangszobához.");
if(!permissions.has('SPEAK')) return message.channel.send("Nincs jogosultságom megszólalni ebben a hangszobában.");
const songInfo = await ytdl.getInfo(args[1])
const song = {
title: songInfo.title,
url: songInfo.videoDetails.video_url
}
if(!serverQueue) {
const queueConstruct = {
textChannel: message.channel,
voiceChannel: voiceChannel,
connection: null,
songs: [],
volume: 5,
playing: true
}
queue.set(message.guild.id, queueConstruct)
queueConstruct.songs.push(song)
try{
var connection = await voiceChannel.join();
message.channel.send(`${song.title} lejátszása.`)
queueConstruct.connection = connection
play(message.guild, queueConstruct.songs[0])
}catch(e){
console.log(`Hiba csatlakozás közben itt: ${e}`);
queue.delete(message.guild.id)
return message.channel.send(`Hiba volt a csatlakozás közben itt: ${e}`)
}
} else{
serverQueue.songs.push(song)
return message.channel.send(`**${song.title}** hozzáadva a lejátszási listához.`)
}
return undefined
}else if (message.content.startsWith(`${mcPrefix}stop`)) {
if(!message.member.voice.channel) return message.channel.send("Hang-szobában kell lenned ahhoz, hogy leállítsd a zenét.")
if(!serverQueue) return message.channel.send("There is nothing playing")
serverQueue.songs= []
serverQueue.connection.dispatcher.end()
message.channel.send("Sikeresen megálltottad a zenét.")
return undefined
}else if(message.content.startsWith(`${mcPrefix}skip`)){
if(!message.member.voice.channel) return message.channel.send("Hang-szobában kell lenned a skip parancshoz.")
if(!serverQueue) return message.channel.send("There is nothing playing")
serverQueue.connection.dispatcher.end()
message.channel.send("Zene továbbléptetve.")
message.channel.send(`${song.title} játszása.`)
return undefined
}
function play(guild, song) {
const serverQueue = queue.get(guild.id)
if(!serverQueue.songs){
serverQueue.voiceChannel.leave()
queue.delete(guild.id)
return
}
const dispatcher = serverQueue.connection.play(ytdl(song.url))
.on('finish', () => {
serverQueue.songs.shift()
play(guild, serverQueue.songs[0])
})
.on('error', error => {
console.log(error)
})
dispatcher.setVolumeLogarithmic(serverQueue.volume / 5)
}
})
//musicBOT
and here is the full error:
const dispatcher = serverQueue.connection.play(ytdl(songInfo.url))
^
TypeError: Cannot read property 'url' of undefined
at play (C:\Users\Levi\Desktop\Discord BOT Javascript\bot.js:97:70)
at StreamDispatcher.<anonymous> (C:\Users\Levi\Desktop\Discord BOT Javascript\bot.js:100:17)
at StreamDispatcher.emit (node:events:388:22)
at finish (node:internal/streams/writable:734:10)
at processTicksAndRejections (node:internal/process/task_queues:80:21)
I started searching on the internet but found nothing about it, I guess my basic javascript knowledge is just not enough.
The empty songs array checking in play function is incorrect:
// This "if" clause will never be run, voice channel won't leave when there's no song
if(!serverQueue.songs){
serverQueue.voiceChannel.leave()
...
}
Fix:
if(serverQueue.songs.length === 0){
...
}

onCreate handler's DocumentSnapshot undefined

I'm trying to set a trigger for an onCreate event in a subcollection. I can get the event to trigger fine, but for some reason the DocumentSnapshot is undefined when I try to access it.
My function is based on the sample here: https://github.com/firebase/functions-samples/blob/master/child-count/functions/index.js
exports.onCreateReview = functions.firestore
.document('spots/{spotId}/reviews/{reviewId}')
.onCreate(
(snapshot, _) => {
console.log(snapshot.exists())
const collectionRef = snapshot.ref.parent
const countRef = collectionRef.parent.child('num_reviews');
const promise = countRef.transaction((current) => {
return current + 1;
});
console.log('num_reviews incremented');
return promise;
});
When I check the logs in my Firebase project, I get a TypeError: Cannot read property of undefined
A snapshot is not a promise as it can fire multiple times whereas a promise resolves once.
Here's a snippet of one of my .onCreate functions that you might find helpful as a guide.
exports.newFeedback = functions.firestore.document("feedback/{feedback}").onCreate(function (snap, context) {
var feedbackObj = snap.data();
var msg = feedbackObj.message;
var subject = "New Feedback: " + msg.substring(0,36);
var feedbackMsg = {
to: "ron#hightechtele.com",
from: "noreply#hightechtele.com",
subject: subject,
templateId: "----------------------------",
substitutionWrappers: ["{{", "}}"],
substitutions: {
message: msg,
senderDisplayName: feedbackObj.sender,
senderEmail: feedbackObj.senderEmail,
senderUid: feedbackObj.senderUid
}
};
return sendgrid.send(feedbackMsg);
});

stub never called with sinon and nodejs using chai-as-promised

i'm facing a issue with my unit test, stuck completely, the code is simple, please need to understand what's going on, my stub is never called, the set seems to be correct, here the code:
let strategy = fixtures.load('strategy')
chai.use(chaiAsPromised)
describe.only('Spawn Order Job', () => {
let getPositionsStub, createJobStub, daoStub,sandbox
beforeEach(()=>{
sandbox = sinon.createSandbox()
daoStub = sandbox.stub(dao, 'updateActiveOrders').resolves(true) //async
getPositionsStub = sandbox.stub(strategyModule, 'getPositions') //sync
createJobStub = sandbox.stub(helpers, 'createJob') //sync
createJobStub.returns(true)
getPositionsStub.resolves([{fake:'t'}, {fake:'t'}])
})
afterEach(()=>{
sandbox.restore()
})
//OK
it('Should failed with no param, type error context', ()=> {
const promise = spawnOrderJob()
expect(promise).to.be.rejectedWith(TypeError)
})
//OK
it('Should throw error timeout order', () => {
getPositionsStub.resolves([{fake:'t'}, {fake:'t'}])
strategy.lastDateOrder = new Date()
const ctx = { state: {strategy, dashboard, position:null}}
const action = {b: true, s: false}
const promise = spawnOrderJob(action, ctx)
expect(getPositionsStub.called).to.be.true
expect(daoStub.called).to.be.false
expect(createJobStub.called).to.be.false
expect(promise).to.be.rejectedWith(ORDER_ERROR, 'Timeout between order not expired.')
})
//KO stub never called
it.only('Should pass validation on buy', () => {
strategy.lastDateOrder = 0
const ctx = { state: {strategy, dashboard, position: null }}
const action = {b: true, s: false}
const promise = spawnOrderJob(action, ctx)
expect(promise).to.be.fulfilled
expect(getPositionsStub.called).to.be.true //ok
expect(createJobStub.called).to.be.true //never callled ????
expect(daoStub.called).to.be.true //never called ????
})
})
Want to understand what's going now there, the call are correct imo, running with mocha 5.2
Helpers.js : function is described as follow:
async function spawnOrderJob(action, ctx) {
try {
const { strategy, dashboard, position } = ctx.state
const {b, s} = action
//check in case strategy context
if (strategy) {
//pass validation buy contnext
if (b) {
//this stub is working
const positions = await strategyModule.getPositions(ctx)
const { maxPosition } = strategy.allocatedBTC
const { activeOrders, maxActiveOrders, timeBetweenOrder, lastDateOrder } = strategy
debug('Active orders:', strategy.activeOrders)
debug('Position:', positions.length)
if (activeOrders >= maxActiveOrders)
throw new ORDER_ERROR('Max active orders reach.')
if (positions.length + activeOrders >= maxPosition)
throw new ORDER_ERROR('Max positions reach.')
if (!timeoutExpired(lastDateOrder, timeBetweenOrder))
throw new ORDER_ERROR('Timeout between order not expired.')
//increment active orders counter
//stub fail, but not called at all
await dao.updateActiveOrders(strategy, true)
}
//Sell context
if (s) {
if (!position)
throw new ORDER_ERROR('No position to sell')
}
}
//stub fail, but called internally
return createJob(constants.DASHBOARD_CREATE_ORDER, {
orderType: b ? 'BUY' : 'SELL',
title: `Strategy create order ( ${ b ? 'BUY' : 'SELL'} )`,
strategy,
dashboard,
position
})
} catch (e) {
throw e
}
}
function createJob(name, data){
//shortcut queue.create (kue.js)
return queue.c(name,data)
}
module.exports = {
createJob,
spawnOrderJob
}
DAO
const updateActiveOrders = async (strategy, increment) => {
try {
const s = await model.findOne({_id: strategy._id})
if (!s) throw new Error('Strategy not found.')
s.activeOrders = increment ? s.activeOrders+1 :s.activeOrders-1
s.lastDateOrder = new Date()
return await s.save()
}catch(e){
throw e
}
}
module.exports = {updateActiveOrders}

Resources