aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md9
-rw-r--r--package.json10
-rw-r--r--src/config/example-options.ts9
-rw-r--r--src/lib/extensions/BotClient.ts8
-rw-r--r--src/lib/utils/TopGG.ts110
5 files changed, 11 insertions, 135 deletions
diff --git a/README.md b/README.md
index 92074ce..42d5cf6 100644
--- a/README.md
+++ b/README.md
@@ -1,26 +1,25 @@
<h1 align = "center">
- <img src="https://media.discordapp.net/attachments/732377549975453697/818730315778228224/3c024ae2fdbc99065681e4821569106c.png?width=100&height=100">
+ <img src="https://cdn.discordapp.com/avatars/767478359348740148/8e9fc569e00fa3973b9d2d89ce2acf62.png">
<br>
- Utilibot discord bot
+ Bush bot
</h1>
<div align="center">
<!-- [![CodeFactor](https://img.shields.io/codefactor/grade/github/TymanWasTaken/Utilibot?style=for-the-badge)](https://www.codefactor.io/repository/github/tymanwastaken/cascade) -->
-[![discord badge](https://img.shields.io/badge/Join%20the-Discord-blue?style=for-the-badge)](https://discord.gg/2pf4xfG)
[![uses badges](https://img.shields.io/badge/Uses-Badges-yellow?style=for-the-badge)](https://shields.io)
[![made with typescript](https://img.shields.io/badge/Made%20With-Typescript-orange?style=for-the-badge)](https://www.typescriptlang.org/)
</div>
-Utilibot is a discord bot meant to automate tasks in your discord server, and also have other assorted fun things.
+Bush bot is a custom bot for the Moulberry's Bush discord server.
If you would like to set up for yourself, please see [SETUP.md](https://github.com/TymanWasTaken/Utilibot/blob/v2/SETUP.md)
<h2 align="center">Contributing</h2>
-You are free to report bugs or contribute to this project. Just open <a href="https://github.com/TymanWasTaken/Utilibot/issues">Issues</a> or <a href="https://github.com/TymanWasTaken/Utilibot/pulls">Pull Requests</a> and the Developer team will look into them.
+You are free to report bugs or contribute to this project. Just open <a href="https://github.com/NotEnoughUpdates/bush-bot/issues">Issues</a> or <a href="https://github.com/NotEnoughUpdates/bush-bot/pulls">Pull Requests</a> and the Developer team will look into them.
<h2 align="center">Credits</h2>
diff --git a/package.json b/package.json
index e8b966b..7809385 100644
--- a/package.json
+++ b/package.json
@@ -1,10 +1,10 @@
{
- "name": "utilibot",
+ "name": "bush-bot",
"version": "2.0.0",
- "description": "A utility bot for discord",
+ "description": "A custom bot for Moulberry's Bush",
"main": "dist/bot.js",
- "repository": "https://github.com/tyman-productions/utilibot",
- "author": "TymanWasTaken <tyman@tyman.tech>",
+ "repository": "https://github.com/NotEnoughUpdates/bush-bot",
+ "author": "Tyman, IRONM00N, and TrashCan",
"license": "MIT",
"scripts": {
"start": "yarn build && node --trace-warnings -r source-map-support/register dist/bot.js",
@@ -70,4 +70,4 @@
"singleQuote": true,
"trailingComma": "none"
}
-}
+} \ No newline at end of file
diff --git a/src/config/example-options.ts b/src/config/example-options.ts
index ce204e9..9a3e71e 100644
--- a/src/config/example-options.ts
+++ b/src/config/example-options.ts
@@ -1,25 +1,20 @@
// Credentials
export const credentials = {
- botToken: 'token here',
- dblToken: 'token here',
- dblWebhookAuth: 'auth here'
+ botToken: 'token here'
};
// Options
export const owners = [
'487443883127472129', // Tyman#7318
- '642416218967375882' // ๐Ÿ’œClari#7744
];
-export const prefix = 'u2!' as string;
+export const prefix = '-' as string;
export const dev = true as boolean;
export const channels = {
- dblVote: 'id here',
log: 'id here',
error: 'id here',
dm: 'id here',
command: 'id here'
};
-export const topGGPort = 3849;
// Database specific
export const db = {
diff --git a/src/lib/extensions/BotClient.ts b/src/lib/extensions/BotClient.ts
index 4d1c31a..5ef8c31 100644
--- a/src/lib/extensions/BotClient.ts
+++ b/src/lib/extensions/BotClient.ts
@@ -14,13 +14,10 @@ import { Util } from './Util';
import * as Tasks from '../../tasks';
import { v4 as uuidv4 } from 'uuid';
import { exit } from 'process';
-import { TopGGHandler } from '../utils/TopGG';
export interface BotConfig {
credentials: {
botToken: string;
- dblToken: string;
- dblWebhookAuth: string;
};
owners: string[];
prefix: string;
@@ -31,9 +28,7 @@ export interface BotConfig {
host: string;
port: number;
};
- topGGPort: number;
channels: {
- dblVote: string;
log: string;
error: string;
dm: string;
@@ -46,7 +41,6 @@ export class BotClient extends AkairoClient {
public listenerHandler: ListenerHandler;
public inhibitorHandler: InhibitorHandler;
public commandHandler: CommandHandler;
- public topGGHandler: TopGGHandler;
public util: Util;
public ownerID: string[];
public db: Sequelize;
@@ -115,7 +109,6 @@ export class BotClient extends AkairoClient {
logging: false
}
);
- this.topGGHandler = new TopGGHandler(this);
BotGuild.install();
BotMessage.install();
}
@@ -147,7 +140,6 @@ export class BotClient extends AkairoClient {
Object.keys(Tasks).forEach((t) => {
setInterval(() => Tasks[t](this), 60000);
});
- this.topGGHandler.init();
}
public async dbPreInit(): Promise<void> {
diff --git a/src/lib/utils/TopGG.ts b/src/lib/utils/TopGG.ts
deleted file mode 100644
index 9c06816..0000000
--- a/src/lib/utils/TopGG.ts
+++ /dev/null
@@ -1,110 +0,0 @@
-import { Api } from '@top-gg/sdk';
-import { BotStats, WebhookPayload } from '@top-gg/sdk/dist/typings';
-import { BotClient } from '../extensions/BotClient';
-import { topGGPort, credentials, channels } from '../../config/options';
-import express, { Express } from 'express';
-import { TextChannel, MessageEmbed, WebhookClient } from 'discord.js';
-import { stripIndent } from 'common-tags';
-import {
- json as bodyParserJSON,
- urlencoded as bodyParserUrlEncoded
-} from 'body-parser';
-
-export class TopGGHandler {
- public api = new Api(credentials.dblToken);
- public client: BotClient;
- public server: Express = express();
- public constructor(client: BotClient) {
- this.client = client;
- }
- public init(): void {
- setInterval(this.postGuilds.bind(this), 60000);
- this.server.use(bodyParserJSON());
- this.server.use(bodyParserUrlEncoded({ extended: true }));
- this.server.post('/dblwebhook', async (req, res) => {
- if (req.headers.authorization !== credentials.dblWebhookAuth) {
- res.status(403).send('Unauthorized');
- await this.client.util.warn(
- `Unauthorized DBL webhook request ๐Ÿ‘€ ${await this.client.util.haste(
- JSON.stringify(
- {
- 'Correct Auth': credentials.dblWebhookAuth,
- 'Given Auth': req.headers.authorization,
- 'Headers': req.headers,
- 'Body': req.body
- },
- null,
- '\t'
- )
- )}`
- );
- return;
- } else {
- res.status(200).send('OK');
- }
- const data = req.body as WebhookPayload;
- await this.postVoteWebhook(data);
- });
- this.server.listen(topGGPort, () => {
- console.log(`Started express top.gg server at port ${topGGPort}`);
- });
- }
- public async postGuilds(): Promise<BotStats> {
- if (this.client.config.dev) return;
- return await this.api.postStats({
- serverCount: this.client.guilds.cache.size,
- shardCount: this.client.shard ? this.client.shard.count : 1
- });
- }
- public async postVoteWebhook(data: WebhookPayload): Promise<void> {
- try {
- if (data.type === 'test') {
- await this.client.util.info(
- `Test vote webhook data recieved, ${await this.client.util.haste(
- JSON.stringify(data, null, '\t')
- )}`
- );
- return;
- } else {
- const parsedData = {
- user: await this.client.users.fetch(data.user),
- type: data.type as 'upvote' | 'test',
- isWeekend: data.isWeekend
- };
- const channel = (await this.client.channels.fetch(
- channels.dblVote
- )) as TextChannel;
- const webhooks = await channel.fetchWebhooks();
- const webhook =
- webhooks.size < 1
- ? await channel.createWebhook('Utilibot Voting')
- : webhooks.first();
- const webhookClient = new WebhookClient(webhook.id, webhook.token, {
- allowedMentions: { parse: [] }
- });
- await webhookClient.send(undefined, {
- username: 'Utilibot Voting',
- avatarURL: this.client.user.avatarURL({ dynamic: true }),
- embeds: [
- new MessageEmbed()
- .setTitle('Top.GG Vote')
- // prettier-ignore
- .setDescription(
- stripIndent`
- User: ${parsedData.user.tag}
- Weekend (worth double): ${parsedData.isWeekend ? 'Yes' : 'No'}
- `
- )
- .setAuthor(
- parsedData.user.tag,
- parsedData.user.avatarURL({ dynamic: true })
- )
- .setTimestamp()
- ]
- });
- }
- } catch (e) {
- console.error(e);
- }
- }
-}