mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Improve hearing-test
This commit is contained in:
@@ -1,50 +1,47 @@
|
||||
[
|
||||
{
|
||||
"age": "all",
|
||||
"khz": 8,
|
||||
"file": "8000.mp3"
|
||||
},
|
||||
{
|
||||
"age": "60",
|
||||
"khz": 10,
|
||||
"file": "10000.mp3"
|
||||
},
|
||||
{
|
||||
"age": "50",
|
||||
"khz": 12,
|
||||
"file": "12000.mp3"
|
||||
},
|
||||
{
|
||||
"age": "45",
|
||||
"khz": 14,
|
||||
"file": "14000.mp3"
|
||||
},
|
||||
{
|
||||
"age": "39",
|
||||
"age": "40",
|
||||
"khz": 15,
|
||||
"file": "15000.mp3"
|
||||
},
|
||||
{
|
||||
"age": "30",
|
||||
"khz": 16,
|
||||
"file": "16000.mp3"
|
||||
},
|
||||
{
|
||||
"age": "24",
|
||||
"age": "20",
|
||||
"khz": 17,
|
||||
"file": "17000.mp3"
|
||||
},
|
||||
{
|
||||
"age": "24",
|
||||
"file": "18000.mp3"
|
||||
},
|
||||
{
|
||||
"age": "24",
|
||||
"file": "19000.mp3"
|
||||
},
|
||||
{
|
||||
"age": "24",
|
||||
"age": "8",
|
||||
"khz": 20,
|
||||
"file": "20000.mp3"
|
||||
},
|
||||
{
|
||||
"age": "20",
|
||||
"file": "21000.mp3"
|
||||
},
|
||||
{
|
||||
"age": "18",
|
||||
"age": "max",
|
||||
"khz": 22,
|
||||
"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 path = require('path');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const { delay, verify } = require('../../util/Util');
|
||||
const data = require('../../assets/json/hearing-test');
|
||||
|
||||
@@ -36,18 +37,33 @@ module.exports = class HearingTestCommand extends Command {
|
||||
}
|
||||
try {
|
||||
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));
|
||||
await delay(3500);
|
||||
await msg.reply('Did you hear that sound? Reply with **[y]es** or **[n]o**.');
|
||||
const heard = await verify(msg.channel, msg.author);
|
||||
if (!heard || file === data[data.length - 1].file) {
|
||||
age = dataAge;
|
||||
age = previousAge;
|
||||
range = previousRange;
|
||||
break;
|
||||
}
|
||||
previousAge = dataAge;
|
||||
previousRange = khz;
|
||||
}
|
||||
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) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "123.0.3",
|
||||
"version": "123.0.4",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user