Skip to content

Commit

Permalink
feat: 国勢調査の項目を追加 (#104)
Browse files Browse the repository at this point in the history
* feat: 人間カウントの追加

* feat: Embedのfieldの文字を改善

* feat: 国勢調査の改善後のテストを追加
  • Loading branch information
meru authored Mar 29, 2022
1 parent 529b901 commit affe2e3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
13 changes: 9 additions & 4 deletions src/service/kokusei-chousa.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createMockMessage } from './command-message';
test('use case of kokusei-chousa', async () => {
const responder = new KokuseiChousa({
allMemberCount(): Promise<number> {
return Promise.resolve(100);
return Promise.resolve(150);
},
botMemberCount(): Promise<number> {
return Promise.resolve(50);
Expand All @@ -20,13 +20,18 @@ test('use case of kokusei-chousa', async () => {
expect(message).toStrictEqual({
title: '***†只今の限界開発鯖の人口†***',
fields: [
{
name: '人間+Bot',
value: `150人`,
inline: true
},
{
name: '人類の数',
value: `100人`,
value: '100人',
inline: true
},
{ name: 'Bot数', value: `50人`, inline: true },
{ name: 'Bot率', value: '50.000%', inline: true }
{ name: 'Botの数', value: `50人`, inline: true },
{ name: 'Bot率', value: '33.333%' }
]
});
return Promise.resolve();
Expand Down
12 changes: 9 additions & 3 deletions src/service/kokusei-chousa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,24 @@ export class KokuseiChousa implements CommandResponder {

const botMemberCount = await this.stats.botMemberCount();
const allMemberCount = await this.stats.allMemberCount();
const peopleCount = allMemberCount - botMemberCount;
const botRate = (botMemberCount / allMemberCount) * 100;

await message.reply({
title: '***†只今の限界開発鯖の人口†***',
fields: [
{
name: '人類の数',
name: '人間+Bot',
value: `${allMemberCount}人`,
inline: true
},
{ name: 'Bot数', value: `${botMemberCount}人`, inline: true },
{ name: 'Bot率', value: botRate.toFixed(3) + '%', inline: true }
{
name: '人類の数',
value: `${peopleCount}人`,
inline: true
},
{ name: 'Botの数', value: `${botMemberCount}人`, inline: true },
{ name: 'Bot率', value: botRate.toFixed(3) + '%' }
]
});
}
Expand Down

0 comments on commit affe2e3

Please sign in to comment.