A554551N / chorumfur-bot

A bot to manage a custom discord
1 stars 0 forks source link

implement logic layer #90

Open A554551N opened 1 year ago

A554551N commented 1 year ago

Implement abstraction layer behind the discord.py frontend. Goal is to remove all logic from the bot proper, instead transferring data to the backend to be managed.

Need for this is to ensure that methods are functional without discord.py so that pytest will be able to test the logic successfully.

Will implement in phases (likely tracked under separate issues) alongside new features.

Rules

  1. Middleware may not make use of ANY discord.py code (commands, and especially the Client and CTX objects)
  2. Bot layer may not communicate directly to db under any circumstance
  3. Ideal format for command body is await ctx.send(middleware.doTheThing(args))
  4. Developer must be mindful that any logic occurring inside of the Bot layer is not being tested in unit tests.
  5. Any Bot layer element may import any logic layer element (IE beware circular imports)
  6. Backend layer may NOT import logic layer elements (to prevent circular imports)
  7. Each Logic Layer file must import database_methods (to access backend)
A554551N commented 1 year ago

Inventory is the first Cog I would like to convert. It is relatively low impact and should present a good case study.

A554551N commented 1 year ago

I think I'm going to tackle Ticket Cog next. It's more core to the functionality of the program, but is mostly standard read/write that shouldn't present any challenges.