Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #131 from BanklessDAO/release/1.4.0
Browse files Browse the repository at this point in the history
Release/1.4.0
  • Loading branch information
Joshua Alexander authored Sep 1, 2021
2 parents 095595a + 54eaef5 commit b5e7960
Show file tree
Hide file tree
Showing 43 changed files with 292 additions and 218 deletions.
1 change: 1 addition & 0 deletions .env.prod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ DISCORD_BOT_TOKEN=
DISCORD_BOT_PUBLIC_KEY=
DISCORD_BOT_APPLICATION_ID=
DISCORD_OWNER_ID=
MONGODB_PREFIX=mongodb+srv
MONGODB_USERNAME=
MONGODB_PASS=
MONGODB_CLUSTER=
Expand Down
1 change: 1 addition & 0 deletions .env.qa
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ DISCORD_BOT_TOKEN=
DISCORD_BOT_PUBLIC_KEY=
DISCORD_BOT_APPLICATION_ID=
DISCORD_OWNER_ID=
MONGODB_PREFIX=mongodb+srv
MONGODB_USERNAME=
MONGODB_PASS=
MONGODB_CLUSTER=
Expand Down
8 changes: 8 additions & 0 deletions docs/CHANGELOG.md → CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 1.4.0-RELEASE (2021-08-31)

1. Fix docker db connection
2. Use mongodb connection pools
3. Expand bounty copies to lvl2+
4. Add Pradhumna Pancholi#3700 to POAP manager list
5. Allow lvl2+ contributors, admin, and genesis squad to use /poap command

## 1.3.2-RELEASE (2021-08-27)

1. Wrap all of guildmember in try/catch block
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ RUN yarn install

COPY . ./

RUN yarn build
RUN yarn build

CMD ["yarn", "start"]
16 changes: 8 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ version: '3.8'

services:
bot:
container_name: degen_bot
build: .
restart: always
volumes:
- .:/app
- /app/node_modules
command: yarn start
working_dir: /app
ports:
- 80:3000
environment:
MONGODB_PREFIX: mongodb
MONGODB_USERNAME: dev
MONGODB_PASS: pass
MONGODB_CLUSTER: mongo

mongo:
container_name: degen_mongo
image: mongo:4.4.6
environment:
MONGO_INITDB_ROOT_USERNAME: dev
Expand All @@ -21,6 +20,7 @@ services:
- 27017:27017
volumes:
- mongodb:/data/db
- ./src/app/utils/mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro

volumes:
mongodb:
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "degen",
"version": "1.3.2",
"version": "1.4.0",
"description": "Administrative and Utilitarian bot for the Bankless Discord Server.",
"main": "app.js",
"private": true,
Expand Down
6 changes: 3 additions & 3 deletions src/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ const creator = new SlashCreator({
token: process.env.DISCORD_BOT_TOKEN,
});

creator.on('debug', (message) => console.log(message));
creator.on('warn', (message) => console.warn(message));
creator.on('error', (error) => console.error(error));
creator.on('debug', (message) => console.log(`debug: ${ message }`));
creator.on('warn', (message) => console.warn(`warn: ${ message }`));
creator.on('error', (error) => console.error(`error: ${ error }`));
creator.on('synced', () => console.info('Commands synced!'));
creator.on('commandRegister', (command) => console.info(`Registered command ${command.commandName}`));
creator.on('commandError', (command, error) => console.error(`Command ${command.commandName}:`, error));
Expand Down
14 changes: 10 additions & 4 deletions src/app/commands/admin/GuestPass.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import { SlashCommand, CommandOptionType, ApplicationCommandPermissionType, CommandContext } from 'slash-create';
import {
SlashCommand,
CommandOptionType,
ApplicationCommandPermissionType,
CommandContext,
SlashCreator,
} from 'slash-create';
import client from '../../app';
import roleIds from '../../service/constants/roleIds';
import { addGuestRoleToUser } from '../../service/guest-pass/AddGuestPass';

export default class GuestPass extends SlashCommand {
constructor(creator) {
constructor(creator: SlashCreator) {
super(creator, {
name: 'guest-pass',
description: 'Grant a temporary guest pass to a user',
Expand Down Expand Up @@ -39,7 +45,7 @@ export default class GuestPass extends SlashCommand {
});
}

async run(ctx: CommandContext) {
async run(ctx: CommandContext): Promise<any> {
if (ctx.user.bot) return;

console.log('/guest-pass start');
Expand All @@ -58,5 +64,5 @@ export default class GuestPass extends SlashCommand {

return ctx.send(`<@${ctx.user.id}> guest pass added and message sent!`);
}
};
}

18 changes: 14 additions & 4 deletions src/app/commands/bounty/Bounty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,22 @@ export default class Bounty extends SlashCommand {
id: roleIds.level4,
permission: true,
},
{
type: ApplicationCommandPermissionType.ROLE,
id: roleIds.admin,
permission: true,
},
{
type: ApplicationCommandPermissionType.ROLE,
id: roleIds.genesisSquad,
permission: true,
},
],
},
});
}

async run(ctx: CommandContext) {
async run(ctx: CommandContext): Promise<any> {
if (ctx.user.bot) return;
console.log(`start /bounty ${ctx.user.username}#${ctx.user.discriminator}`);

Expand Down Expand Up @@ -242,7 +252,7 @@ export default class Bounty extends SlashCommand {
}
}

handleCommandError(ctx: CommandContext, command: Promise<any>) {
handleCommandError(ctx: CommandContext, command: Promise<any>): void {
command.then(() => {
console.log(`end /bounty ${ctx.user.username}#${ctx.user.discriminator}`);
return ctx.send(`${ctx.user.mention} Sent you a DM with information.`);
Expand All @@ -256,7 +266,7 @@ export default class Bounty extends SlashCommand {
});
}

buildBountyCreateNewParams(ctxOptions): BountyCreateNew {
buildBountyCreateNewParams(ctxOptions: { [key: string]: any }): BountyCreateNew {
const [reward, symbol] = (ctxOptions.reward != null) ? ctxOptions.reward.split(' ') : [null, null];
const copies = (ctxOptions.copies == null || ctxOptions.copies <= 0) ? 1 : ctxOptions.copies;
let scale = reward.split('.')[1]?.length;
Expand All @@ -272,4 +282,4 @@ export default class Bounty extends SlashCommand {
copies: copies,
};
}
};
}
8 changes: 4 additions & 4 deletions src/app/commands/help/FeatureRequest.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SlashCommand } from 'slash-create';
import { CommandContext, SlashCommand, SlashCreator } from 'slash-create';

export default class FeatureRequest extends SlashCommand {
constructor(creator) {
constructor(creator: SlashCreator) {
super(creator, {
name: 'feature-request',
description: 'Pull up the form to submit a new feature request',
Expand All @@ -13,12 +13,12 @@ export default class FeatureRequest extends SlashCommand {
});
}

async run(ctx) {
async run(ctx: CommandContext): Promise<any> {
// Ignores commands from bots
if (ctx.user.bot) return;
console.log('/featureRequest start');
const form = 'https://docs.google.com/forms/d/e/1FAIpQLSdTvYOyzF6A_YJKmco7iGeVDRzOBmJF2HfYKEiRnfATwcxjFw/viewform';
console.log('/featureRequest end');
return `Here you are ${ctx.user.mention}, the DEGEN feature request form: ${form}`;
}
};
}
4 changes: 2 additions & 2 deletions src/app/commands/help/Help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class Help extends SlashCommand {
});
}

async run(ctx: CommandContext) {
async run(ctx: CommandContext): Promise<any> {
if (ctx.user.bot) return;
console.log(`/help start ${ctx.user.username}#${ctx.user.discriminator}`);

Expand All @@ -51,4 +51,4 @@ export default class Help extends SlashCommand {
console.log(`/bounty end ${ctx.user.username}#${ctx.user.discriminator}`);
return ctx.send(messageOptions);
}
};
}
8 changes: 4 additions & 4 deletions src/app/commands/notion/NotionFAQs.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { SlashCommand, CommandOptionType } from 'slash-create';
import { SlashCommand, CommandOptionType, CommandContext, SlashCreator } from 'slash-create';
import client from '../../app';
import RetrieveFAQs from '../../service/notion/RetrieveFAQs';
const trimPageId = process.env.FAQS_PAGE_ID.replace(/-/g, '');
const FAQ_URL = `https://www.notion.so/FAQs-${trimPageId}`;

export default class NotionFAQs extends SlashCommand {
constructor(creator) {
constructor(creator: SlashCreator) {
super(creator, {
name: 'faqs',
description: 'Get frequently asked questions',
Expand All @@ -24,7 +24,7 @@ export default class NotionFAQs extends SlashCommand {
});
}

async run(ctx) {
async run(ctx: CommandContext): Promise<any> {
// Ignores commands from bots
if (ctx.user.bot) return;
console.log('/faqs start');
Expand Down Expand Up @@ -102,4 +102,4 @@ export default class NotionFAQs extends SlashCommand {
console.error(e);
}
}
};
}
8 changes: 4 additions & 4 deletions src/app/commands/notion/NotionGuildPage.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { SlashCommand, CommandOptionType } from 'slash-create';
import { SlashCommand, CommandOptionType, CommandContext, SlashCreator } from 'slash-create';
import notionPageRefs from '../../service/notion/NotionGuildPages';

export default class NotionGuildPage extends SlashCommand {
constructor(creator) {
constructor(creator: SlashCreator) {
super(creator, {
name: 'notion',
description: 'View a Guild\'s notion page',
Expand Down Expand Up @@ -76,7 +76,7 @@ export default class NotionGuildPage extends SlashCommand {
});
}

async run(ctx) {
async run(ctx: CommandContext): Promise<any> {
// Ignores commands from bots
if (ctx.user.bot) return;
console.log('/notion start');
Expand All @@ -85,4 +85,4 @@ export default class NotionGuildPage extends SlashCommand {
console.log('/notion end');
return `Here you are ${ctx.user.mention}, the ${ctx.options.guild} Guild Notion Page: ${page}`;
}
};
}
54 changes: 49 additions & 5 deletions src/app/commands/poap/poap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import EndPOAP from '../../service/poap/EndPOAP';
import ValidationError from '../../errors/ValidationError';
import poapEvents from '../../service/constants/poapEvents';
import DistributePOAP from '../../service/poap/DistributePOAP';
import roleIds from '../../service/constants/roleIds';

module.exports = class poap extends SlashCommand {
constructor(creator: SlashCreator) {
Expand Down Expand Up @@ -106,18 +107,44 @@ module.exports = class poap extends SlashCommand {
},
defaultPermission: false,
permissions: {
[process.env.DISCORD_SERVER_ID]: getAllowedUsers(),
[process.env.DISCORD_SERVER_ID]: [
{
type: ApplicationCommandPermissionType.ROLE,
id: roleIds.level2,
permission: true,
},
{
type: ApplicationCommandPermissionType.ROLE,
id: roleIds.level3,
permission: true,
},
{
type: ApplicationCommandPermissionType.ROLE,
id: roleIds.level4,
permission: true,
},
{
type: ApplicationCommandPermissionType.ROLE,
id: roleIds.admin,
permission: true,
},
{
type: ApplicationCommandPermissionType.ROLE,
id: roleIds.genesisSquad,
permission: true,
},
],
},
});
}

async run(ctx: CommandContext) {
if (ctx.user.bot) return;
console.log(`start /poap ${ctx.user.username}#${ctx.user.discriminator}`);

const { guildMember } = await ServiceUtils.getGuildAndMember(ctx);
let command: Promise<any>;

try {
switch (ctx.subcommands[0]) {
case 'start':
Expand Down Expand Up @@ -172,4 +199,21 @@ export const getAllowedUsers = (): ApplicationCommandPermissions[] =>{
permission: true,
});
return allowedPermissions;
};
};

// TODO: pass this as a DM conversation... looks like client is not available until after slash commands are set
// export const getAllVoiceChannels = async (): Promise<any[]> => {
// // const voiceChannels: Collection<string, Channel> = client.channels.cache.filter(guildChannel => guildChannel.type === ChannelTypes.GUILD_VOICE.toString());
// // const choices = [];
// // for (const channel of voiceChannels.values()) {
// // choices.push({
// // name: channel.type,
// // value: channel.id,
// // });
// // }
// // return choices;
// return [{
// name: 'blank',
// value: 'asdfsdf',
// }];
// };
2 changes: 0 additions & 2 deletions src/app/events/bounty/messageCreateOnBountyBoard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,5 @@ export default async (message: Message): Promise<any> => {
return guildMember.send({ content: 'Sorry something is not working, our devs are looking into it.' });
}

await dbInstance.close();

return guildMember.send({ content: `Bounty published to #🧀-bounty-board and the website! ${envUrls.BOUNTY_BOARD_URL}${bountyId}` });
};
2 changes: 1 addition & 1 deletion src/app/events/poap/addUserForEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default async (oldState: VoiceState, newState: VoiceState, event: { id: s
await updateUserForPOAP(newState.member, db, event.value, false).catch(console.error);
}

return dbInstance.close();
return;
};

export const isPOAPTrackingActive = async (db: Db, eventValue: string): Promise<boolean> => {
Expand Down
Loading

0 comments on commit b5e7960

Please sign in to comment.