-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from ddivad195/feat/slash-command-migration
feat: slash command migration
- Loading branch information
Showing
13 changed files
with
110 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 19 additions & 22 deletions
41
src/main/kotlin/me/ddivad/keeper/commands/GeneralCommands.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,38 @@ | ||
package me.ddivad.keeper.commands | ||
|
||
import dev.kord.rest.request.KtorRequestException | ||
import dev.kord.x.emoji.Emojis | ||
import dev.kord.x.emoji.addReaction | ||
import me.ddivad.keeper.dataclasses.Configuration | ||
import me.ddivad.keeper.dataclasses.Permissions | ||
import me.ddivad.keeper.embeds.buildSavedMessageEmbed | ||
import me.ddivad.keeper.services.StatisticsService | ||
import me.jakejmattson.discordkt.api.arguments.MessageArg | ||
import me.jakejmattson.discordkt.api.commands.commands | ||
import me.jakejmattson.discordkt.api.extensions.sendPrivateMessage | ||
import me.jakejmattson.discordkt.arguments.MessageArg | ||
import me.jakejmattson.discordkt.commands.commands | ||
import me.jakejmattson.discordkt.extensions.sendPrivateMessage | ||
import mu.KotlinLogging | ||
|
||
private val logger = KotlinLogging.logger { } | ||
|
||
@Suppress("unused") | ||
fun generalCommands(configuration: Configuration, statsService: StatisticsService) = commands("General") { | ||
dmCommand("delete") { | ||
description = "Delete a Keeper bookmark by ID inside of DM channel" | ||
requiredPermission = Permissions.NONE | ||
execute(MessageArg) { | ||
val message = args.first | ||
|
||
if (message.author == this.channel.kord.getSelf().asUser()) { | ||
message.delete() | ||
} else { | ||
respond("Can only delete messages sent by ${this.channel.kord.getSelf().mention} in direct message channels.") | ||
} | ||
} | ||
} | ||
|
||
slash("bookmark", "Bookmark") { | ||
description = "Bookmark a message using Keeper" | ||
requiredPermission = Permissions.NONE | ||
execute(MessageArg) { | ||
val guild = guild?.asGuildOrNull() ?: return@execute | ||
val guild = guild.asGuildOrNull() | ||
statsService.bookmarkAdded(guild) | ||
this.author.sendPrivateMessage { | ||
buildSavedMessageEmbed(args.first.asMessage(), guild) | ||
}.addReaction(Emojis.x) | ||
respond("Message Bookmarked ${Emojis.bookmark}") | ||
try { | ||
this.author.sendPrivateMessage { | ||
buildSavedMessageEmbed(args.first.asMessage(), guild) | ||
}.addReaction(Emojis.x) | ||
respond("Message Bookmarked ${Emojis.bookmark}") | ||
logger.info { "Message Bookmarked by ${this.author.username}" } | ||
} catch (e: KtorRequestException) { | ||
respond("Looks like you have DMs disabled. To bookmark messages, this needs to be enabled.") | ||
logger.error { "Bookmark DM could not be sent" } | ||
} | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 11 additions & 9 deletions
20
src/main/kotlin/me/ddivad/keeper/dataclasses/Configuration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.