Skip to content

Commit 6928010

Browse files
committed
Simplify cock
1 parent 2095ea7 commit 6928010

1 file changed

Lines changed: 15 additions & 18 deletions

File tree

src/commands/penis.ts

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import type { BotContext } from "@/context.js";
44
import type { MessageCommand } from "@/commands/command.js";
55
import type { ProcessableMessage } from "@/service/command.js";
66
import type { Penis } from "@/storage/db/model.js";
7-
8-
import * as penis from "@/storage/penis.js";
9-
import log from "@log";
107
import { NormalDistribution, RandomNumberGenerator, SecureRandomSource } from "@/service/random.js";
8+
import * as penis from "@/storage/penis.js";
119
import { clamp } from "@/utils/math.js";
1210

11+
import log from "@log";
12+
1313
export type Radius = 0 | 1 | 2 | 3;
1414

1515
const RADIUS_CHARS: Record<Radius, string> = {
@@ -124,13 +124,16 @@ export default class PenisCommand implements MessageCommand {
124124
async handleMessage(message: ProcessableMessage, context: BotContext) {
125125
const { author } = message;
126126
const mention = message.mentions.users.first();
127-
const userToMeasure = mention !== undefined ? mention : author;
127+
const userToMeasure = mention ?? author;
128+
129+
const isBotCock = userToMeasure.id === context.client.user.id;
130+
if (isBotCock) {
131+
await message.reply(`${userToMeasure} hat natürlich den längsten.`);
132+
return;
133+
}
128134

129135
log.debug(`${author.id} wants to measure penis of user ${userToMeasure.id}`);
130-
const measurement = await this.#getOrCreateMeasurement(
131-
userToMeasure,
132-
userToMeasure.id === context.client.user.id,
133-
);
136+
const measurement = await this.#getOrCreateMeasurement(userToMeasure);
134137

135138
await sendPenis(
136139
userToMeasure,
@@ -141,24 +144,18 @@ export default class PenisCommand implements MessageCommand {
141144
);
142145
}
143146

144-
async #getOrCreateMeasurement(userToMeasure: User, hasLongest: boolean): Promise<Penis> {
147+
async #getOrCreateMeasurement(userToMeasure: User): Promise<Penis> {
145148
const recentMeasurement = await penis.fetchRecentMeasurement(userToMeasure);
146149
if (recentMeasurement !== undefined) {
147150
return recentMeasurement;
148151
}
149152

150-
log.debug(`No recent measuring of ${userToMeasure.id} found. Creating Measurement`);
151-
152-
const size = hasLongest
153-
? PENIS_LENGTH_MAX
154-
: clamp(sizeGenerator.get(), 1, PENIS_LENGTH_MAX); // TODO: Do we really want to clamp here? Maybe just clamp(v, 1, Infinity)?
153+
log.debug(`No recent measuring of ${userToMeasure.id} found. Creating Measurement.`);
155154

156-
const radiusRaw = hasLongest
157-
? PENIS_RADIUS_MAX
158-
: clamp(radiusGenerator.get(), 1, PENIS_RADIUS_MAX); // TODO: Do we really want to clamp here? Maybe just clamp(v, 1, Infinity)?
155+
const size = clamp(sizeGenerator.get(), 1, PENIS_LENGTH_MAX); // TODO: Do we really want to clamp here? Maybe just clamp(v, 1, Infinity)?
159156

160157
// TODO: Maye we want the radius to be integer only for display (and keep the float internally)
161-
const radius = clamp(Math.round(radiusRaw), 1, PENIS_RADIUS_MAX) as Radius;
158+
const radius = clamp(Math.round(radiusGenerator.get()), 1, PENIS_RADIUS_MAX) as Radius; // TODO: Do we really want to clamp here? Maybe just clamp(v, 1, Infinity)?
162159

163160
if (await isNewLongestDick(size)) {
164161
log.debug(`${userToMeasure} has the new longest dick with size ${size}`);

0 commit comments

Comments
 (0)