Git Product home page Git Product logo

modmail's Introduction

chatsift

Monorepo for all of our bots and their common utilities, along with some NPM packages.

Licensing

This project is lincensed under the GNU AGPLv3 license. View the full file here.

modmail's People

Contributors

codeize avatar didinele avatar johnythecarrot avatar officialsirh avatar sazzo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

modmail's Issues

Missing API routes

  • GET /modmail/v1/guilds/:guildId/snippets

  • PUT /modmail/v1/guilds/:guildId/snippets - creates a new snippet, returning it

  • GET /modmail/v1/guilds/:guildId/snippets/:snippetId

  • PATCH /modmail/v1/guilds/:guildId/snippets/:snippetId - update an existing snippet - also needs to insert a SnippetUpdate, returns the updated data

  • DELETE /modmail/v1/guilds/:guildId/snippets/:snippetId, returns the deleted snippet

DMing the bot a message with no content causes a hard crash

CombinedError: Received one or more errors
    at UnionValidator.handle (/root/mod/ModMail/node_modules/@sapphire/shapeshift/src/validators/UnionValidator.ts:111:21)
    at UnionValidator.parse (/root/mod/ModMail/node_modules/@sapphire/shapeshift/src/validators/BaseValidator.ts:80:86)
    at EmbedBuilder.setDescription (/root/mod/ModMail/node_modules/@discordjs/builders/src/messages/embed/Embed.ts:56:52)
    at null.sendMemberThreadMessage (/root/mod/ModMail/packages/bot/src/util/sendMemberThreadMessage.ts:40:5)
    at default_1.handle (/root/mod/ModMail/packages/bot/src/events/modmail/modmailMessageCreate.ts:114:9)
Emitted 'error' event on Client instance at:
    at emitUnhandledRejectionOrErr (node:events:384:10)
    at processTicksAndRejections (node:internal/process/task_queues:85:21) {
  errors: [
    ExpectedValidationError: Expected values to be equals
        at LiteralValidator.handle (/root/mod/ModMail/node_modules/@sapphire/shapeshift/src/validators/LiteralValidator.ts:17:17)
        at LiteralValidator.run (/root/mod/ModMail/node_modules/@sapphire/shapeshift/src/validators/BaseValidator.ts:62:21)
        at UnionValidator.handle (/root/mod/ModMail/node_modules/@sapphire/shapeshift/src/validators/UnionValidator.ts:106:29)
        at UnionValidator.parse (/root/mod/ModMail/node_modules/@sapphire/shapeshift/src/validators/BaseValidator.ts:80:86)
        at EmbedBuilder.setDescription (/root/mod/ModMail/node_modules/@discordjs/builders/src/messages/embed/Embed.ts:56:52)
        at null.sendMemberThreadMessage (/root/mod/ModMail/packages/bot/src/util/sendMemberThreadMessage.ts:40:5)
        at default_1.handle (/root/mod/ModMail/packages/bot/src/events/modmail/modmailMessageCreate.ts:114:9) {
      validator: 's.literal(V)',
      given: '',
      expected: null
    },
    ExpectedConstraintError: Invalid string length
        at Object.run (/root/mod/ModMail/node_modules/@sapphire/shapeshift/src/constraints/StringConstraints.ts:40:18)
        at StringValidator.run (/root/mod/ModMail/node_modules/@sapphire/shapeshift/src/validators/BaseValidator.ts:66:24)
        at UnionValidator.handle (/root/mod/ModMail/node_modules/@sapphire/shapeshift/src/validators/UnionValidator.ts:106:29)
        at UnionValidator.parse (/root/mod/ModMail/node_modules/@sapphire/shapeshift/src/validators/BaseValidator.ts:80:86)
        at EmbedBuilder.setDescription (/root/mod/ModMail/node_modules/@discordjs/builders/src/messages/embed/Embed.ts:56:52)
        at null.sendMemberThreadMessage (/root/mod/ModMail/packages/bot/src/util/sendMemberThreadMessage.ts:40:5)
        at default_1.handle (/root/mod/ModMail/packages/bot/src/events/modmail/modmailMessageCreate.ts:114:9) {
      constraint: 's.string.lengthGreaterThanOrEqual',
      given: '',
      expected: 'expected.length >= 1'
    }
  ]
}```

Move to forums

waiting on d.js to release its set of bug fixes on the feature first - currently blocked, but can be worked on in the meantime using discord.js@dev - just that it won't be merged in that state

RFC: Pagination of data within Discord

Goal

Clear and concise generalistic APIs to paginate data within Discord. More specifically:

  • select menu element, which can currently only hold 25 elements, this would have 2 strategies tied to it:
    1. [⬅️] [Select menu containing the options] [➡️] - buttons here become disabled depending on the current page (e.g. last page can't go right)
    2. [Single select menu] - if the page is 0, show 24 options and then page front. if page is pageCount - 1, show page back and 24 elements, otherwise show page back, 23 elements and page front

Current proposed API

Enum PaginationStrategy

  • Buttons
  • SelectMenuOptions

Interface SelectMenuPaginatorState

  • readonly page: number, current page

Interface SelectMenuPaginatorData<Strategy extends PaginationStrategy> extends SelectMenuPaginatorState

  • warning: pseudo-code ahead
  • pageLeftButton?: Strategy extends PaginationStrategy.Buttons ? APIButton : undefined
  • pageRightButton?: Strategy extends PaginationStrategy.Buttons ? APIButton : undefined
  • selectMenu: APISelectMenu

Interface IStore - simple KV, Map-like storage

  • keys will be the message ID the paginator is bound to
  • values will be SelectMenuPaginatorState
  • readonly size: number, some sort of getter of how many states are being kept
  • get(key: string) -> MaybePromise<SelectMenuPaginatorState>
  • setPage(key: string, state: number) -> MaybePromise<void>
  • has(key: string) -> MaybePromise<boolean>
  • delete(key: string) -> MaybePromise<boolean>, boolean value indicating if the value existed to begin with

Class SelectMenuPaginator<Strategy extends PaginationStrategy>, where

Constructor - new (options: SelectMenuPaginatorOptions) => SelectMenuPaginator, where SelectMenuPaginatorOptions would hold the following fields:

  • data: unknown[] - the data one desires to paginate - this will leave on the class as an immutable property and cannot be changed for its lifetime
  • key: string
  • maxElementsPerPage?: number - defaults to 25, cannot be lower than 1, cannot be higher than 25
  • store: IStore

Methods

  • nextPage() -> Promise<SelectMenuPaginatorData>, should throw if we're at the last page
  • previousPage() -> Promise<SelectMenuPaginatorData>, should throw if we're at the first page
  • setPage(page: number) -> Promise<SelectMenuPaginatorData>, should throw if page is out of bounds
  • getData() -> Promise<SelectMenuPaginatorData>, get current state without any mutations
  • destroy() -> Promise<void> clean-up own state from this.store

Closing thoughts

This will become a library under the @chatsift namespace if it turns out well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.