我想将结果拆分为 mysql 你能帮我吗?
i want to split a result in mysql can you help me?
嗯,首先这是我的代码
client.on('message', async (message) => { //فايف ام داتابيس
if(message.channel.type == 'dm') return;
var prefix = prefixx.get(message.guild.id);
if(message.author.bot) return;
if(message.content.toLowerCase().startsWith(prefix + 'ip')) {
if(!message.member.hasPermission('ADMINISTRATOR')) return message.channel.send('ما عندك رتبة عشان تستخدم الأمر هذا');
let args = message.content.split(" ");
connection1.query(
`select ifnull((select last_login from vrp_users where id = ${args[1]}),'لا يوجد ايدي بهذا الرقم') As ResultFound`, function (error, result, fields) {
if (error) throw error;
console.log(`Got IP of user ${args[1]}`);
if(!result) return message.channel.send('There is an error');
if(error) return message.channel.send('There is an error');
let embed = new Discord.MessageEmbed() .setColor('RANDOM') .setTitle(`اي بي ${args[1]}`) .setThumbnail(message.guild.iconURL( { dynamic : true } )) .setAuthor(client.user.tag, client.user.avatarURL( {dynamic : true} )) .addField('IP', `\`${result[0].ResultFound}\``);
message.channel.send(embed)
}
);
}
});
结果是这样的:
77.223.232.147 23:50:55 29/06/2020
我想要结果只有ip 你们能帮帮我吗?
试试这个:
.addField('IP', `\`${result[0].ResultFound.split(' ')[0]}\``);
例如,如果结果是您在问题中提供的结果:
const result = '77.223.232.147 23:50:55 29/06/2020'
// split the message by every space
const array = result.split(' ');
console.log(array[0]); // IP adress
console.log(array[1]); // time (I presume)
console.log(array[2]); // date
嗯,首先这是我的代码
client.on('message', async (message) => { //فايف ام داتابيس
if(message.channel.type == 'dm') return;
var prefix = prefixx.get(message.guild.id);
if(message.author.bot) return;
if(message.content.toLowerCase().startsWith(prefix + 'ip')) {
if(!message.member.hasPermission('ADMINISTRATOR')) return message.channel.send('ما عندك رتبة عشان تستخدم الأمر هذا');
let args = message.content.split(" ");
connection1.query(
`select ifnull((select last_login from vrp_users where id = ${args[1]}),'لا يوجد ايدي بهذا الرقم') As ResultFound`, function (error, result, fields) {
if (error) throw error;
console.log(`Got IP of user ${args[1]}`);
if(!result) return message.channel.send('There is an error');
if(error) return message.channel.send('There is an error');
let embed = new Discord.MessageEmbed() .setColor('RANDOM') .setTitle(`اي بي ${args[1]}`) .setThumbnail(message.guild.iconURL( { dynamic : true } )) .setAuthor(client.user.tag, client.user.avatarURL( {dynamic : true} )) .addField('IP', `\`${result[0].ResultFound}\``);
message.channel.send(embed)
}
);
}
});
结果是这样的:
77.223.232.147 23:50:55 29/06/2020
我想要结果只有ip 你们能帮帮我吗?
试试这个:
.addField('IP', `\`${result[0].ResultFound.split(' ')[0]}\``);
例如,如果结果是您在问题中提供的结果:
const result = '77.223.232.147 23:50:55 29/06/2020'
// split the message by every space
const array = result.split(' ');
console.log(array[0]); // IP adress
console.log(array[1]); // time (I presume)
console.log(array[2]); // date