> const today = new Date(2016, 7, 7)
undefined
> const tomorrow = new Date(2016, 7, 8)
undefined
> tomorrow >= today
true
> today <= tomorrow
true
> today == tomorrow
false
const allowed = {
'1': true,
'2': true,
'3': true,
'4': true,
'5': true,
'6': true,
'7': true,
'8': true,
'9': true,
'0': true,
'ArrowLeft': true,
'ArrowDown': true,
'ArrowRight': true,
'ArrowUp': true,
'Backspace': true,
'.': true,
}
const isValidInput = allowed[key]
export const LandingReducer=createSlice({
name:'MAIN_SLICE',
initialState:initialStates,
reducers: {
changeStateValue:(state,action) => {
state[action.payload.name] = action.payload.value
const check = action.payload.name.includes('.')
if (!check) {
state[action.payload.name] = action.payload.value
}else{
const groups=action.payload.name.split('.')
console.log(groups);
if(groups.length===2){
state[groups[0]][groups[1]]=action.payload.value;
}else if(groups.length===3){
state[groups[0]][groups[1]][groups[2]]=action.payload.value;
}else if(groups.length===4){
state[groups[0]][groups[1]][groups[2]][groups[3]]=action.payload.value;
}
}
}
}
});
/*
* _____________________________________________________
* ___________↓___↓____________________________________________ |
* _↓_________↓|___|________________________________________ | |
* ______↓|_________||___|↓___________________________________ | | |
* _____↓__↓__||_________||___||_______________________________ | | | |
* _↓__↓_|__|__||_________||___||___________________________ | | | | |
* _________↓|__|_|__|↓_||_________||___||_______________________ | | | | | |
* ↓ ↓ || | | || || || || | | | | | | | */
opcId = child.replace(/([.])?(?:((.+)=(.+))|(([a-zA-Z]+)(\d*)))/g, function (match, m1, m2, m3, m4, m5, m6, m7) {
const Discord = require("discord.js");
const bot = new Discord.Client();
const TOKEN = "NOPE"
var color = require('chalk');
var fs = require('fs');
bot.on("ready", function(message) {
console.log(color.green("Online"))
})
bot.on("message", function(message){
console.log("Channel:" + color.blue(message.channel) + " " + "Author:" + color.blue(message.author) + " " + "Message:" + color.blue(message.content))
if (message.content.includes("uranium") || message.content == "Uranium" || message.content == "uranium" || message.content.includes("uranium")) {
console.log(color.black.yellow("Message Flagged As Suspicous"))
console.log(color.black.yellow("Contains: Uranium"))
console.log(color.black.bgYellow("Message:" + message.content))
console.log(color.black.bgYellow("Message Id:" + message.id))
console.log(color.black.bgYellow("Author Id:" + message.author.id))
console.log(color.black.bgYellow("Channel Id:" + message.channel.id))
console.log(color.yellow("Severity:" + "1"))
var alertsev1 = `Message + Id: + ${message.id} + | + Author + Id: + ${message.author.id} + | + Message + Channel Id: ${message.channel.id} + | + Message: + ${message.content}`
fs.writeFile('alerts.txt', `${alertsev2}`)
}
if (message.content.includes("raid") || message.content.includes("Raid")) {
console.log(color.black.red("Message Flagged As Suspicous"))
console.log(color.black.red("Contains: Raid"))
console.log(color.black.bgRed("Message:" + message.content))
console.log(color.black.bgRed("Message Id:" + message.id))
console.log(color.black.bgRed("Author Id:" + message.author.id))
console.log(color.black.bgRed("Channel Id:" + message.channel.id))
console.log(color.black.red("Severity:" + "2"))
var alertsev2 = `Message + Id: + ${message.id} + | + Author + Id: + ${message.author.id} + | + Message + Channel Id: ${message.channel.id} + | + Message: + ${message.content}`
fs.writeFile('alerts.txt', `${alertsev2}`)
}
if (message.content.includes("raid") && message.content.includes("uranium") || message.content.includes("raid") && message.content.includes("Uranium") || message.content.includes("raid") && message.content.includes("uranium") || message.content.includes("Raid") && message.content.includes("uranium") || message.content.includes("Raid")) {
console.log(color.black.red("Message Flagged As Possible Raid Initiation"))
console.log(color.black.red("Contains: Raid, Uranium"))
console.log(color.black.bgRed("Message:" + message.content))
console.log(color.black.bgRed("Message Id:" + message.id))
console.log(color.black.bgRed("Author Id:" + message.author.id))
console.log(color.black.bgRed("Channel Id:" + message.channel.id))
console.log(color.black.red("Severity:" + "3"))
var alertsev3 = `Message + Id: + ${message.id} + | + Author + Id: + ${message.author.id} + | + Message + Channel Id: ${message.channel.id} + | + Message: + ${message.content}`
fs.writeFile('alerts.txt', `${alertsev3}`)
}
})
bot.login(TOKEN)
I'm making a discord message logger but I want to output message.content message.author message.id message.channel.id into one text file everytime a message is sent in the following format: Message ID:(Id here) Message Author: (Author ID here) Channel ID: (Channel ID here) Message: (message here) ive tried with the following code but it printed undefined out into the text document
if (!String.prototype.replaceLast) {
String.prototype.replaceLast = function(find, replace) {
String.prototype.replaceLast = function (what, replacement) {
var pcs = this.split(what);
var lastPc = pcs.pop();
return pcs.join(what) + replacement + lastPc;
};
};
}
Prototypes are super buggy anyway, I should rewrite that as a pure function.
if(userEndDate.getTime() != null
&& userEndDate.getTime() > today.getTime()
&& endDateFromRequest != null ? endDateFromRequest.getTime() !== userEndDate.getTime() : true){
//some code
}
for code lovers :D
const ws = new WebSocket('wss://echo.websocket.org', {
agent: new HttpsProxyAgent(`https://${proxy}`)
});
wsz.push(ws);
ws.onopen = () => {
if (ws.readyState === WebSocket.OPEN) {
.....
ws.close();
}
};
ws.onerror = () => {
ws.close();
};
u just cant trust, just cant......
function edit_vehality: locality,
google_place_id: '1'
};
let opts = { 'method': 'put', 'route': '/border/' + border_id, 'status': status, 'account_access_token': saved_values.superadmin.account_access_token, 'params': params };
request(opts)
.then(function(res) {
resolve(res.result);
}).catch(reject);
})
}
var div = '<div class="imgdiv" '+(user[5] ? 'style="display: flex; flex-direction: column; padding: 10px; justify-content: flex-end; background-image: url(\''+user[5]+'\');"' : '')+'>'
+ (usersVideos[userId] && <?= ($authuser ? 'true' : 'false') ?> ? '<i class="f7-icons icon-acc" onclick="videoShow('+user[uID]+')" style="color: white; font-size: 50px; margin-bottom: 5px; cursor: pointer; text-align: left;">play_round</i>' : '')
+ (iam && page=='home' ? '<div> <input id="video-input" onchange="uploadVideo(files)" type="file" accept="video/*" style="display: none; width: 80%; height: 100px; margin: auto; padding-top: 20px;"/> </div> <p class="action_cont" style="padding: 0; padding-top: 12;"> <a class="act_btn" onmousedown=document.getElementById("video-input").click() href="javascript:void(0)" style="text-decoration: none; margin: auto; width: calc(100% - 26px); text-align: center;"> ' + (myMods['video'] ? 'Загрузить новое видео' : 'Добавить видео-превью' ) + ' </a> </p>' : '')
+ '</div>'
JS + CSS + PHP + HTML
function clean(toClean, source){
if (typeof(toClean) !== 'string') return true;
if (typeof(source) !== 'string') return true;
return source.replace(toClean, String('CLEANED')).toString();
}
Found this in a project at work and someone clearly doesn't trust JavaScripts typeof function
function renderGroupSelectedSuccessors() {
var index = 0;
if (tempSuccessorsGroupsList != null && tempSuccessorsGroupsList.length > 0) {
var groups = tempSuccessorsGroupsList.splice(0, PageSettings.lazyRenderItemsPerPage);
var groupSuccessors = '';
for (var i = 0; i < groups.length; i++) {
if (index % 10 == 0) {
groupSuccessors += '<div style="float: left;"><ul>';
}
groupSuccessors += '<li><a data-groupid="'+groups[i].GroupID+'">' + groups[i].GroupName + '</a></li>';
index++;
if (index % 10 == 0 || i == groups.length - 1) {
groupSuccessors += '</ul></div>';
}
}
$('#divGroupSuccessorsList').append(groupSuccessors);
SetCheckBoxState();
setTimeout(renderGroupSelectedSuccessors, 50);
}
}
Where does the data come from? Where does it go? Why isn't this an endless recursive loop? Why has this worked for three years?
return isDisabled == false ? false : true;
Handlebars.registerHelper("compare", function(a, operator, b) {
var result = false;
try {
switch (operator) {
case "==":
// eslint-disable-next-line eqeqeq
result = a == b;
break;
case "===":
result = a === b;
break;
case "!=":
// eslint-disable-next-line eqeqeq
result = a != b;
break;
case "!==":
result = a !== b;
break;
case "<":
result = a < b;
break;
case ">":
result = a > b;
break;
case "<=":
result = a <= b;
break;
case ">=":
result = a >= b;
break;
case "typeof":
// eslint-disable-next-line valid-typeof
result = typeof a === b;
break;
default: {
throw new Error(
"helper {{compare}}: invalid operator: ' + ".concat(operator, " + '")
);
}
}
} catch (err) {
console.error("\n********** ".concat(err, "."));
}
return result;
});
set_locations(locations){
return new Promise((resolve, reject) => {
this.locations = locations;
resolve();
});
}