Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public async mute(
message: Message,
member: GuildMember,
duration: number,
reason: string
) {
const dbMember = await DBGuildMember.findOne({
where: { id: member.id }
});
const dbGuild = await DBGuild.findOne({
where: { id: member.guild.id }
});
if (!dbMember) await DBGuildMember.createOrUpdate(member, dbGuild!);
duration = Math.floor(parse(duration) / 60000); // parse to minutes
console.log(duration);
await member.addRole(this.muteRole);
await getPublicLogger().send({
type: "mute",
duration,
member,
moderator: message.author,
reason
});
// Shorter equivalent of `valueOf` (returns a Unix timestamp).
let unmuteAt = Math.floor(+new Date() / 1000);
// Add minutes to the timestamp.
unmuteAt += duration * 60;
onTimeChanged (worklog, editedTime) {
if (editedTime != '') {
let ms = parseDuration(editedTime)
// Is the timer entered valid?
if (ms > 0)
this.props.updateWorkLogTime(worklog, Math.round(ms / 1000))
}
this.onResetEditTime()
}
onTimeChanged (timerId, editedTime) {
if (editedTime != '') {
let ms = parseDuration(editedTime)
// Is the timer entered valid?
if (ms > 0)
this.props.updateTimer(timerId, ms)
}
this.onResetEditTime()
}
console.log(`Found existing build ${build.id}. Cancelling.`);
cloudbuild.projects.builds.cancel({ projectId, id: build.id });
});
}
} catch (e) {
console.log(
'Error fetching existing builds, not cancelling existing builds.',
);
}
console.log(`Starting cloud build for pull request ${pull.number}.`);
const cloudbuildConfig: Build = config.repos[repo].cloudbuild;
const sanitizedConfig: Build = cloudbuildConfig.timeout
? {
...cloudbuildConfig,
timeout: `${parseDuration(cloudbuildConfig.timeout) /
MILLIS_IN_SECOND}s`,
}
: cloudbuildConfig;
await cloudbuild.projects.builds.create({
projectId,
requestBody: {
...sanitizedConfig,
options: {
...sanitizedConfig.options,
substitutionOption: 'ALLOW_LOOSE',
},
substitutions,
tags,
},
});
const parseNumber = (v) => {
const n = typeof v === 'number'
? v
: parseDuration(v)
if (isNaN(n)) throw new Error(`Invalid number: ${v}`)
return n / 1000
}