Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README example code is broken. #2

Open
aomi opened this issue Nov 22, 2020 · 3 comments
Open

README example code is broken. #2

aomi opened this issue Nov 22, 2020 · 3 comments

Comments

@aomi
Copy link

aomi commented Nov 22, 2020

Hello,

I tried using setting up a scenario similar to one found in the README but get the following error.

 FAIL  src/__tests__/index.test.ts
  messageRouter
    ✕ works properly (1 ms)

  ● messageRouter › works properly

    TypeError: Cannot read property 'client' of undefined

      20 |     it('works properly', async () => {
      21 |         const message = new MockMessage();
    > 22 |         const channel = new MockTextChannel();
         |                         ^
      23 |
      24 |         message.content = '!ping';
      25 |         message.channel = channel;

      at new GuildChannel (node_modules/discord.js/src/structures/GuildChannel.js:28:17)
      at new TextChannel (node_modules/discord.js/src/structures/TextChannel.js:21:5)
      at src/__tests__/index.test.ts:22:25
      at step (src/__tests__/index.test.ts:33:23)
      at Object.next (src/__tests__/index.test.ts:14:53)
      at src/__tests__/index.test.ts:8:71
      at Object.<anonymous>.__awaiter (src/__tests__/index.test.ts:4:12)
      at Object.<anonymous> (src/__tests__/index.test.ts:20:26)

Test case:

     const message = new MockMessage();
     const channel = new MockTextChannel();

     message.content = '!ping';
     message.channel = channel;

     const tedis = new Tedis();

     messageRouter(tedis)(message);  
     expect(MockedTedis).toBeCalled();

I am wondering if the library is broken or I am doing something wrong. Thanks in advance 🙇

@codewithtyler
Copy link

I don't think you're doing anything wrong. I ran into this issue as well. I'll post back here if I figure out the issue. I suspect the README documentation is just missing some info.

@samhwang
Copy link

Hey @PallasMedia have you figured out what the issue was ? I was trying to install this into my project as well and it failed at the same spot. :(

@Chris-Bitler any chance we can have an update on the documentations ?

@codewithtyler
Copy link

No, I ended up taking a different approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants