real-serious-games / activecollab-discord-bot Goto Github PK
View Code? Open in Web Editor NEWDiscord integration for ActiveCollab
License: MIT License
Discord integration for ActiveCollab
License: MIT License
After messaging the bot directly with most commands such as !wallofshame, !timereport or !times, the notification that the bot is typing appears after the message has been posted to the channel and never goes away. We should make sure that it stops "typing" as soon as the message is sent.
Leading zeroes are removed from the minutes value in the time report. To reproduce, log time with the total value for the week having a single digit number of minutes, then message the bot directly with the !timereport
command. The field at the bottom will look like this: "Total: 38:0", when it should be this: "Total: 38:00".
Build succeeds on current LTS Node.js (8.11.1) and previous stable (9.8.0), but fails on 10.0.0.
https://travis-ci.org/Real-Serious-Games/activecollab-discord-bot/jobs/372847569
Assertion failed: Cannot send without a channel: undefined
Assertion failed: Channels not found for project ID: 1
Assertion failed: Project ID not valid: undefined
Assertion failed: Username not valid: undefined
FAIL test/discord.test.ts (10.982s)
calling sendMessageToChannel
✓ should send message to channel when channel is valid (7ms)
✕ should error when channel is invalid (89ms)
calling determineChannels
✓ should return channels when given valid project ID (2ms)
✓ should return found channels when given valid project ID and log warning when not all channels found (1ms)
✕ should return ID not found error when channels for project ID not found (18ms)
✕ should return invalid ID error when project ID not valid (11ms)
✓ should return channel not found error when channel not found (1ms)
calling getUserId
✓ should return user ID when input valid and exists in a guild (1ms)
✓ should throw error when guilds not found (1ms)
✕ should throw error when username invalid (13ms)
✓ should throw error when username not found in guild
client receiving message
✓ should send help message when message is "!tasks" (26ms)
✓ should send help message when message is "!tasks" with unknown command (2ms)
✓ should send message when command is unknown (1ms)
✓ should send message when command is unknown task command (2ms)
✓ should send list of commands when command is !help (1ms)
✓ should send list of commands when command is !commands (2ms)
✓ should do nothing when message doesn't start with prefix or message sent with bot (1ms)
✓ should do nothing when message is empty and starts with prefix (2ms)
when message is "!tasks create"
✓ should call commandController.createTask when command is sent from project channel (2ms)
✓ should call send message when creating task fails (2ms)
✓ should send warning message when channel type is not text (1ms)
✓ should send error message and log when error getting project ID (2ms)
when message is "!tasks due"
✓ should call commandController.tasksDueThisWeekForProject when command is sent from project channel (6ms)
✓ should send warning message when channel type is not text (2ms)
✓ should send error message and log when error getting project ID (2ms)
when command is "!tasks list"
✓ should call commandController.listTasksForUser when command all caps (2ms)
✓ should call commandController.listTasksForUser and send message when command is "!tasks list for @user" (2ms)
when message is "!tasks in <list>"
✓ should call commandController.taskInListForProject with list from command and project ID from channel (2ms)
✓ should send warning when channel type is not text (1ms)
✓ should send warning and log error when error getting project ID (4ms)
● calling sendMessageToChannel › should error when channel is invalid
expect(function).toThrow(string)
Expected the function to throw an error matching:
"Cannot send without a channel: undefined"
Instead, it threw:
TypeError: Cannot read property 'send' of undefined
117 | this.guildNames[channelMap.guildIndex] === textChannel.guild.name
118 | )
> 119 | );
120 |
121 | let unfoundChannels = '';
122 |
at DiscordController.sendMessageToChannel (src/controllers/discord.ts:119:9)
at expect (test/discord.test.ts:29:22)
at Object.<anonymous> (node_modules/expect/build/to_throw_matchers.js:42:7)
at Object.throwingMatcher [as toThrow] (node_modules/expect/build/index.js:147:24)
at Object.it (test/discord.test.ts:30:9)
28 |
29 | expect(() => discordController.sendMessageToChannel(undefined, undefined))
> 30 | .toThrow('Cannot send without a channel: undefined');
31 | });
32 | });
33 |
at Object.it (test/discord.test.ts:30:9)
● calling determineChannels › should return ID not found error when channels for project ID not found
expect(function).toThrow(string)
Expected the function to throw an error matching:
"Channels not found for project ID: 1"
Instead, it threw:
TypeError: Cannot read property 'map' of undefined
110 | .client
111 | .channels
> 112 | .findAll('type', 'text')
113 | .map(channel => channel as discord.TextChannel)
114 | .filter(textChannel => channelMaps
115 | .some(channelMap =>
m
at DiscordController.determineChannels (src/controllers/discord.ts:112:30)
at expect (test/discord.test.ts:165:40)
at Object.<anonymous> (node_modules/expect/build/to_throw_matchers.js:42:7)
at Object.throwingMatcher [as toThrow] (node_modules/expect/build/index.js:147:24)
at Object.it (test/discord.test.ts:125:9)
123 | name: 'channel',
124 | guild: { name: guildNames[0]}
> 125 | } as TextChannel
126 | );
127 |
128 | const clientMock = new DiscordClientMockBuilder()
at Object.it (test/discord.test.ts:125:9)
● calling determineChannels › should return invalid ID error when project ID not valid
expect(function).toThrow(string)
Expected the function to throw an error matching:
"Project ID not valid: undefined"
Instead, it threw:
TypeError: Cannot read property 'map' of undefined
110 | .client
111 | .channels
> 112 | .findAll('type', 'text')
113 | .map(channel => channel as discord.TextChannel)
114 | .filter(textChannel => channelMaps
115 | .some(channelMap =>
at DiscordController.determineChannels (src/controllers/discord.ts:112:30)
at expect (test/discord.test.ts:174:40)
at Object.<anonymous> (node_modules/expect/build/to_throw_matchers.js:42:7)
at Object.throwingMatcher [as toThrow] (node_modules/expect/build/index.js:147:24)
at Object.it (test/discord.test.ts:131:9)
129 | .withChannels({
130 | findAll: jest.fn().mockReturnValue(clientChannels)
> 131 | })
132 | .build();
133 |
134 | const warnMock = jest.fn();
at Object.it (test/discord.test.ts:131:9)
● calling getUserId › should throw error when username invalid
expect(function).toThrow(string)
Expected the function to throw an error matching:
"Username not valid: undefined"
Instead, it threw:
Guilds not found: Guild 1,Guild 2
145 |
146 | if (guilds.every(guild => guild === undefined)) {
> 147 | throw Error(`Guilds not found: ${this.guildNames}`);
148 | }
149 |
150 | const members = guilds
at DiscordController.getUserId (src/controllers/discord.ts:147:19)
at expect (test/discord.test.ts:267:40)
at Object.<anonymous> (node_modules/expect/build/to_throw_matchers.js:42:7)
at Object.throwingMatcher [as toThrow] (node_modules/expect/build/index.js:147:24)
at Object.it (test/discord.test.ts:200:9)
198 |
�[0m 199 | const discordController = new DiscordControllerBuilder()
> 200 | .withClient(clientMock)
201 | .withGuildNames(guildNames)
202 | .withMappingController(mappingControllerMock)
203 | .build();
at Object.it (test/discord.test.ts:200:9)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.