We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ee52ed5 commit c77bae0Copy full SHA for c77bae0
src/ps/commands/sample.ts
@@ -0,0 +1,19 @@
1
+import { parsePoint } from '@/utils/grid';
2
+import { sample } from '@/utils/random';
3
+
4
+import type { PSCommand } from '@/types/chat';
5
6
+export const command: PSCommand = {
7
+ name: 'sample',
8
+ help: 'Generates random numbers.',
9
+ syntax: 'CMD [max=10] x [count=5]',
10
+ aliases: ['random'],
11
+ async run({ arg, broadcast, originalCommand }) {
12
+ const [max, count] = parsePoint(arg) ?? [10, 5];
13
+ const nums =
14
+ originalCommand[0] === 'random'
15
+ ? Array.from({ length: count }, () => sample(max) + 1)
16
+ : Array.from({ length: count }, (_, index) => index + 1).sample(count);
17
+ broadcast(nums.join(', '));
18
+ },
19
+};
0 commit comments