Skip to content

Commit 1e6f501

Browse files
committed
add dockerfile ; ban command ; base of suggest (not done)
1 parent 0aca52c commit 1e6f501

7 files changed

Lines changed: 93 additions & 6 deletions

File tree

Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM alpine:latest
2+
3+
RUN apk update && \
4+
apk add nodejs npm git nano && \
5+
git clone https://github.com/discord-bio/bot /home/bot && \
6+
cd /home/bot && \
7+
npm i && \
8+
npm i -g typescript && \
9+
cp config.example.json config.json
10+
11+
CMD sh

src/commands/discord.bio/profile.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { MessageEmbed } from 'discord.js';
44
import { DefaultCommandOptions } from '../../constants';
55
import DiscordBioClient from '../../client';
66

7-
const ProfileCommandOptions: CommandOptions = {
7+
const ThisCommandOptions: CommandOptions = {
88
...DefaultCommandOptions,
99
name: 'profile',
1010
};
@@ -17,7 +17,7 @@ enum Gender {
1717

1818
export default class extends Command {
1919
constructor(store: CommandStore, file: string[], directory: string) {
20-
super(store, file, directory, ProfileCommandOptions);
20+
super(store, file, directory, ThisCommandOptions);
2121
}
2222

2323
public async run(message: KlasaMessage): Promise<KlasaMessage | KlasaMessage[] | null> {

src/commands/discord.bio/top.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ const FIELD_COUNT = 2;
1010

1111
const USER_LIMIT = 10;
1212

13-
const PingCommandOptions: CommandOptions = {
13+
const ThisCommandOptions: CommandOptions = {
1414
...DefaultCommandOptions,
1515
name: 'top'
1616
};
1717

1818
export default class extends Command {
1919
constructor (store: CommandStore, file: string[], directory: string) {
20-
super(store, file, directory, PingCommandOptions);
20+
super(store, file, directory, ThisCommandOptions);
2121
}
2222

2323
public async run (message: KlasaMessage): Promise<KlasaMessage | KlasaMessage[] | null> {

src/commands/misc/ping.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { Command, CommandStore, CommandOptions, KlasaClient, KlasaMessage } from 'klasa';
22
import { DefaultCommandOptions } from '../../constants';
33

4-
const PingCommandOptions: CommandOptions = {
4+
const ThisCommandOptions: CommandOptions = {
55
...DefaultCommandOptions,
66
name: 'ping'
77
};
88

99
export default class extends Command {
1010
constructor (store: CommandStore, file: string[], directory: string) {
11-
super(store, file, directory, PingCommandOptions);
11+
super(store, file, directory, ThisCommandOptions);
1212
}
1313

1414
public async run (message: KlasaMessage): Promise<KlasaMessage | KlasaMessage[] | null> {

src/commands/mod/ban.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { Command, CommandStore, CommandOptions, KlasaClient, KlasaMessage } from 'klasa';
2+
import { DefaultCommandOptions } from '../../constants';
3+
4+
const MOD_ROLE = "661332732168765440";
5+
6+
const MILLISECONDS_IN_DAY = 86400000
7+
8+
const BAN_LIMIT = 50;
9+
10+
const ThisCommandOptions: CommandOptions = {
11+
...DefaultCommandOptions,
12+
name: 'ban',
13+
};
14+
15+
export default class extends Command {
16+
private usesThisInterval = 0
17+
private intervalReset = Date.now()
18+
19+
constructor(store: CommandStore, file: string[], directory: string) {
20+
super(store, file, directory, ThisCommandOptions);
21+
}
22+
23+
public async run(message: KlasaMessage): Promise<KlasaMessage | KlasaMessage[] | null> {
24+
if (!message.member?.roles.has(MOD_ROLE) && !message.member?.permissions.has('BAN_MEMBERS')) return null;
25+
const memberId = message.content.split(" ")[1];
26+
const member = message.guild?.members.get(memberId.replace(/[<|>|\@|\!]/g, ''));
27+
if (!member) return await message.sendMessage('Member not found');
28+
const reason = message.content.split(" ").slice(2).join(' ');
29+
await member.ban({
30+
reason: reason || 'No reason provided',
31+
});
32+
if(this.usesThisInterval >= BAN_LIMIT) {
33+
return message.sendMessage(`The daily ban limit has been exceeded. Reset at: ${new Date(this.intervalReset).toUTCString()}`)
34+
}
35+
this.usesThisInterval++;
36+
return await message.sendMessage('Banned member');
37+
}
38+
39+
public async init(): Promise<any> {
40+
this.intervalReset += MILLISECONDS_IN_DAY
41+
setInterval(() => {
42+
this.intervalReset += MILLISECONDS_IN_DAY
43+
this.usesThisInterval = 0;
44+
}, MILLISECONDS_IN_DAY)
45+
}
46+
}

src/commands/util/suggest.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { Command, CommandStore, CommandOptions, KlasaMessage } from 'klasa';
2+
import { DefaultCommandOptions, SUGGESTION_CHANNEL_ID } from '../../constants';
3+
import { TextChannel } from 'discord.js';
4+
5+
const ThisCommandOptions: CommandOptions = {
6+
...DefaultCommandOptions,
7+
name: 'suggest'
8+
};
9+
10+
export default class extends Command {
11+
constructor (store: CommandStore, file: string[], directory: string) {
12+
super(store, file, directory, ThisCommandOptions);
13+
}
14+
15+
public async run (message: KlasaMessage): Promise<KlasaMessage | KlasaMessage[] | null> {
16+
const content = message.content;
17+
if(!content) {
18+
return message.sendMessage('No suggestion provided');
19+
} else {
20+
const suggestion = content.split(' ').slice(1)
21+
const suggestionChannel = message.client.channels.get(SUGGESTION_CHANNEL_ID);
22+
if(!suggestionChannel) throw new Error('No channel found');
23+
return (<KlasaMessage> <unknown> (<TextChannel> suggestionChannel).send('', { embed: {
24+
description: `Suggestion: ${suggestion}`
25+
}}));
26+
}
27+
}
28+
}

src/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export const COMMAND_MESSAGE_LIFETIME = 30000;
77

88
export const DISABLED_STOCK_COMMANDS = ['stats'];
99

10+
export const SUGGESTION_CHANNEL_ID = "725762022490374164";
11+
1012
export const ClientOptions: KlasaClientOptions = {
1113
prefix: config.prefix,
1214
fetchAllMembers: false,

0 commit comments

Comments
 (0)