mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-17 00:07:36 +02:00
Improve hearing-test
This commit is contained in:
@@ -1,50 +1,47 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"age": "all",
|
"age": "all",
|
||||||
|
"khz": 8,
|
||||||
"file": "8000.mp3"
|
"file": "8000.mp3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"age": "60",
|
"age": "60",
|
||||||
|
"khz": 10,
|
||||||
"file": "10000.mp3"
|
"file": "10000.mp3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"age": "50",
|
"age": "50",
|
||||||
|
"khz": 12,
|
||||||
"file": "12000.mp3"
|
"file": "12000.mp3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"age": "45",
|
"age": "45",
|
||||||
|
"khz": 14,
|
||||||
"file": "14000.mp3"
|
"file": "14000.mp3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"age": "39",
|
"age": "40",
|
||||||
|
"khz": 15,
|
||||||
"file": "15000.mp3"
|
"file": "15000.mp3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"age": "30",
|
"age": "30",
|
||||||
|
"khz": 16,
|
||||||
"file": "16000.mp3"
|
"file": "16000.mp3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"age": "24",
|
"age": "20",
|
||||||
|
"khz": 17,
|
||||||
"file": "17000.mp3"
|
"file": "17000.mp3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"age": "24",
|
"age": "8",
|
||||||
"file": "18000.mp3"
|
"khz": 20,
|
||||||
},
|
|
||||||
{
|
|
||||||
"age": "24",
|
|
||||||
"file": "19000.mp3"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"age": "24",
|
|
||||||
"file": "20000.mp3"
|
"file": "20000.mp3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"age": "20",
|
"age": "max",
|
||||||
"file": "21000.mp3"
|
"khz": 22,
|
||||||
},
|
|
||||||
{
|
|
||||||
"age": "18",
|
|
||||||
"file": "22000.mp3"
|
"file": "22000.mp3"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,6 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const { stripIndents } = require('common-tags');
|
||||||
const { delay, verify } = require('../../util/Util');
|
const { delay, verify } = require('../../util/Util');
|
||||||
const data = require('../../assets/json/hearing-test');
|
const data = require('../../assets/json/hearing-test');
|
||||||
|
|
||||||
@@ -36,18 +37,33 @@ module.exports = class HearingTestCommand extends Command {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
let age;
|
let age;
|
||||||
for (const { age: dataAge, file } of data) {
|
let range;
|
||||||
|
let previousAge = 'all';
|
||||||
|
let previousRange = 8;
|
||||||
|
for (const { age: dataAge, khz, file } of data) {
|
||||||
connection.play(path.join(__dirname, '..', '..', 'assets', 'sounds', 'hearing-test', file));
|
connection.play(path.join(__dirname, '..', '..', 'assets', 'sounds', 'hearing-test', file));
|
||||||
await delay(3500);
|
await delay(3500);
|
||||||
await msg.reply('Did you hear that sound? Reply with **[y]es** or **[n]o**.');
|
await msg.reply('Did you hear that sound? Reply with **[y]es** or **[n]o**.');
|
||||||
const heard = await verify(msg.channel, msg.author);
|
const heard = await verify(msg.channel, msg.author);
|
||||||
if (!heard || file === data[data.length - 1].file) {
|
if (!heard || file === data[data.length - 1].file) {
|
||||||
age = dataAge;
|
age = previousAge;
|
||||||
|
range = previousRange;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
previousAge = dataAge;
|
||||||
|
previousRange = khz;
|
||||||
}
|
}
|
||||||
if (age === 'all') return msg.reply('Everyone should be able to hear that. You cannot hear.');
|
if (age === 'all') return msg.reply('Everyone should be able to hear that. You cannot hear.');
|
||||||
return msg.reply(`You have the hearing of someone **${Number.parseInt(age, 10) + 1} or older**.`);
|
if (age === 'max') {
|
||||||
|
return msg.reply(stripIndents`
|
||||||
|
You can hear any frequency of which a human is capable.
|
||||||
|
The maximum frequency you were able to hear was **${range}000hz**.
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
return msg.reply(stripIndents`
|
||||||
|
You have the hearing of someone **${Number.parseInt(age, 10) + 1} or older**.
|
||||||
|
The maximum frequency you were able to hear was **${range}000hz**.
|
||||||
|
`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "123.0.3",
|
"version": "123.0.4",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user