https://github.com/queer/yangmal
양말 means "socks." Typesafe commands for catnip
https://github.com/queer/yangmal
Last synced: about 1 year ago
JSON representation
양말 means "socks." Typesafe commands for catnip
- Host: GitHub
- URL: https://github.com/queer/yangmal
- Owner: queer
- Created: 2019-02-08T11:00:33.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-09-13T15:46:57.000Z (over 5 years ago)
- Last Synced: 2025-03-10T14:55:43.718Z (over 1 year ago)
- Language: Java
- Homepage:
- Size: 85 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 양말
"양말" means "socks" in Korean. Love you @natanbc <33
양말 is a command library for catnip.
## Building
Just run `mvn clean package`.
## Usage
Default prefix is `!`.
```Java
final class README {
private README() {}
public static void main(final String[] args) {
final Catnip catnip = Catnip.catnip("token");
catnip.loadExtension(
new Yangmal()
// If you just want to always use the same prefix everywhere
.constantPrefix("!!")
// Alternatively, you can use the message to help determine the prefix.
// Prefix suppliers are called asynchronously.
.prefixSupplier(msg -> {
return database.getPrefixAsync(msg.guildId());
})
// Hooks populate the context with whatever data you think you'll need:
// user, guild, member, channel, stuff from your database, ...
// Hooks are called asynchronously.
.addContextHook((ctx, msg) -> {
return database.getSomething(msg.author())
.thenAccept(thing -> ctx.param("thing", thing));
})
// Command checks are whether or not the command can be run. They get
// whatever data you pass in the context, and determine whether the
// command should be run or not
// Checks are called asynchronously
.addCommandCheck(ctx -> {
return someAsynchronousThing(ctx.param("thing"));
})
// Type converters
.registerTypeConverter()
// Handle errors during command parsing, ex. if you want errors to go
// to your Sentry.io instance
// You guessed it, asynchronous
.errorHandler(e -> {
Sentry.capture(e);
})
// Handle commands that aren't found. Does nothing by default.
// Guess what? Async!
.invalidCommandHandler((name, ctx) -> {
logger.warn("Couldn't find command: {}", name);
})
// Handle messages that aren't commands
.notCommandHandler(msg -> {
chatLevels.process(msg);
})
// Handled command checks that don't pass
.checksFailedHandler((msg, name, ctx) -> {
logger.warn("Command checks failed for command {}", name);
})
// Finally, load all the commands and register catnip listeners
.setup()
);
}
}
```