Skip to content

Commit

Permalink
Use proper private modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
holzmaster committed Mar 27, 2024
1 parent 465593d commit ee5795f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
10 changes: 5 additions & 5 deletions src/commands/nickname.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export class Nickname implements ApplicationCommand {
);
return;
}
return Nickname.createNickNameVote(
return Nickname.#createNickNameVote(
command,
user,
nickname,
Expand Down Expand Up @@ -252,7 +252,7 @@ export class Nickname implements ApplicationCommand {
await interaction.respond(completions);
}

private static async createNickNameVote(
static async #createNickNameVote(
command: CommandInteraction<CacheType>,
user: User,
nickname: string,
Expand Down Expand Up @@ -345,14 +345,14 @@ export class NicknameButtonHandler implements UserInteraction {

// evaluate the user votes
const votes: UserVote[] = Object.values(userVoteMap);
if (this.hasEnoughVotes(votes, "NO")) {
if (this.#hasEnoughVotes(votes, "NO")) {
await interaction.update({
content: `Der Vorschlag: \`${suggestion.nickName}\` für <@${suggestion.nickNameUserId}> war echt nicht so geil`,
components: [],
});
return;
}
if (this.hasEnoughVotes(votes, "YES")) {
if (this.#hasEnoughVotes(votes, "YES")) {
try {
await nickName.insertNickname(
suggestion.nickNameUserId,
Expand All @@ -377,7 +377,7 @@ export class NicknameButtonHandler implements UserInteraction {
});
}

private hasEnoughVotes(votes: UserVote[], voteType: Vote) {
#hasEnoughVotes(votes: UserVote[], voteType: Vote) {
const mappedVotes = votes
.filter(vote => vote.vote === voteType)
.map(getWeightOfUserVote);
Expand Down
6 changes: 3 additions & 3 deletions src/commands/saufen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export class Saufen implements ApplicationCommand {
return;
}
case "list": {
const files = await this.getSoundFiles(context.soundsDir);
const files = await this.#getSoundFiles(context.soundsDir);
await command.reply(files.map(f => `- ${f}`).join("\n"));
return;
}
Expand All @@ -142,7 +142,7 @@ export class Saufen implements ApplicationCommand {
}
}

private async getSoundFiles(soundDir: string) {
async #getSoundFiles(soundDir: string) {
return (await fs.readdir(soundDir, { withFileTypes: true }))
.filter(f => f.isFile())
.map(f => f.name);
Expand All @@ -157,7 +157,7 @@ export class Saufen implements ApplicationCommand {
return;
}

const files = await this.getSoundFiles(context.soundsDir);
const files = await this.#getSoundFiles(context.soundsDir);

const focusedValue = interaction.options.getFocused().toLowerCase();
const completions = files
Expand Down
4 changes: 2 additions & 2 deletions src/commands/special/dadJoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class DadJokeCommand implements SpecialCommand {
austrian: ["Und i bin da #BOTNAME# oida", "Oida #WHOIS#, was geht?"],
};

private getRandomAnswer(
#getRandomAnswer(
config: PhraseConfig,
slotConfig: Record<Slot, string>,
): string {
Expand Down Expand Up @@ -101,7 +101,7 @@ export class DadJokeCommand implements SpecialCommand {
BOTNAME: client.user?.username ?? "Bot",
};

const answer = this.getRandomAnswer(attributes, slots);
const answer = this.#getRandomAnswer(attributes, slots);

await message.reply({
content: answer,
Expand Down
6 changes: 3 additions & 3 deletions src/commands/special/emoteSender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ export class EmoteSenderCommand implements SpecialCommand {
kk: ["pepeOK", "pepeOK"],
};

private trimMessage(message: Message): string {
#trimMessage(message: Message): string {
return message.content.toLowerCase().trim();
}

matches(message: Message<boolean>): boolean {
const trimmedContent = this.trimMessage(message);
const trimmedContent = this.#trimMessage(message);
return Object.keys(this.emotes).some(
emote => emote === trimmedContent.toLowerCase(),
);
Expand All @@ -34,7 +34,7 @@ export class EmoteSenderCommand implements SpecialCommand {
_client: Client<boolean>,
context: BotContext,
): Promise<CommandResult> {
const trimmedContent = this.trimMessage(message);
const trimmedContent = this.#trimMessage(message);
const pickedEmotes: string[] | undefined = this.emotes[trimmedContent];
if (pickedEmotes === undefined) {
throw new Error(
Expand Down
4 changes: 2 additions & 2 deletions src/commands/special/keywordReact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class TriggerReactOnKeyword implements SpecialCommand {
async handleSpecialMessage(
message: ProcessableMessage,
): Promise<CommandResult> {
if (this.isEmoji(this.emoteName)) {
if (this.#isEmoji(this.emoteName)) {
await message.react(this.emoteName);
return;
}
Expand All @@ -36,7 +36,7 @@ export class TriggerReactOnKeyword implements SpecialCommand {
throw new Error(`${this.emoteName} emote not found`);
}

private isEmoji(str: string): boolean {
#isEmoji(str: string): boolean {
return /\p{Extended_Pictographic}/u.test(str);
}
}

0 comments on commit ee5795f

Please sign in to comment.