feat: hug command
This commit is contained in:
66
Sources/zundamon/Actions.swift
Normal file
66
Sources/zundamon/Actions.swift
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
import DiscordBM
|
||||||
|
|
||||||
|
struct Actions {
|
||||||
|
static func getUserFromMention(_ mention: MentionUser) -> String {
|
||||||
|
mention.member?.nick ?? mention.global_name ?? mention.username
|
||||||
|
}
|
||||||
|
|
||||||
|
static let hugRes = (try? String(contentsOfFile: "choices/hug.txt", encoding: .utf8))?
|
||||||
|
.split(separator: "\n")
|
||||||
|
.map({ $0.trimmingCharacters(in: .whitespacesAndNewlines) })
|
||||||
|
|
||||||
|
static func hug(
|
||||||
|
_ args: ArraySlice<String.SubSequence>,
|
||||||
|
client: DiscordClient,
|
||||||
|
ctx: Gateway.MessageCreate
|
||||||
|
) async throws {
|
||||||
|
guard let hugRes = hugRes else { print("hug.txt not loaded"); return }
|
||||||
|
let author = "**\(ctx.member?.nick ?? ctx.author?.global_name ?? ctx.author?.username ?? "Zundamon")**"
|
||||||
|
let dests = ctx.mentions.map(getUserFromMention).map({ "**\($0)**" })
|
||||||
|
|
||||||
|
let retMsg: String
|
||||||
|
|
||||||
|
if dests.count > 1 {
|
||||||
|
let groupHugs = [
|
||||||
|
"{subjects} all huddled together.",
|
||||||
|
"{subjects} hugged each other pairwise, generating a total of **{total}** hugs.",
|
||||||
|
"{subjects} hugged each other at the same time in the same place (although I'm not sure how that works with the current understanding of spacetime).",
|
||||||
|
]
|
||||||
|
|
||||||
|
let group = [author] + dests
|
||||||
|
let total = String(group.count)
|
||||||
|
let subjects = String(group.joined(by: ", "))
|
||||||
|
|
||||||
|
guard let res = groupHugs.randomElement()?
|
||||||
|
.replacingOccurrences(of: "{subjects}", with: subjects)
|
||||||
|
.replacingOccurrences(of: "{total}", with: total)
|
||||||
|
else { print("groupHugs.randomElement() returned null"); return }
|
||||||
|
|
||||||
|
retMsg = res
|
||||||
|
} else {
|
||||||
|
let orig: String
|
||||||
|
let dest: String
|
||||||
|
if let firstDest = dests.first {
|
||||||
|
orig = "**\(author)**"
|
||||||
|
dest = "**\(firstDest)**"
|
||||||
|
} else {
|
||||||
|
orig = "**Zundamon**"
|
||||||
|
dest = "**\(author)**"
|
||||||
|
}
|
||||||
|
|
||||||
|
guard let res = hugRes.randomElement()?
|
||||||
|
.replacingOccurrences(of: "{orig}", with: orig)
|
||||||
|
.replacingOccurrences(of: "{dest}", with: dest)
|
||||||
|
else { print("hug.txt empty"); return }
|
||||||
|
|
||||||
|
retMsg = res
|
||||||
|
}
|
||||||
|
|
||||||
|
try await client.createMessage(
|
||||||
|
channelId: ctx.channel_id,
|
||||||
|
payload: .init(
|
||||||
|
embeds: [.init(description: retMsg)],
|
||||||
|
)
|
||||||
|
).guardSuccess()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,6 +19,7 @@ struct MessageHandler {
|
|||||||
switch command {
|
switch command {
|
||||||
case "wow": try await handleWow(args)
|
case "wow": try await handleWow(args)
|
||||||
case "domath": try await Wolfram.handleMath(args, client: client, ctx: ctx)
|
case "domath": try await Wolfram.handleMath(args, client: client, ctx: ctx)
|
||||||
|
case "hug": try await Actions.hug(args, client: client, ctx: ctx)
|
||||||
default: break
|
default: break
|
||||||
}
|
}
|
||||||
} else if ctx.mentions.contains(where: { $0.id == Zundamon.ownID }) {
|
} else if ctx.mentions.contains(where: { $0.id == Zundamon.ownID }) {
|
||||||
|
|||||||
21
choices/hug.txt
Normal file
21
choices/hug.txt
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{orig} squeezes {dest} tightly.
|
||||||
|
{orig} squeezes {dest} tightly in their arms.
|
||||||
|
{orig} squeezes {dest} tightly in their arms, usually with fondness.
|
||||||
|
{orig} squeezes {dest} tightly, probably to express affection.
|
||||||
|
{orig} holds {dest} in a tight or amorous embrace.
|
||||||
|
{orig} holds {dest} tightly in their arms.
|
||||||
|
{orig} holds {dest} tightly in their arms as a sign of affection.
|
||||||
|
{orig} holds {dest} close to their body.
|
||||||
|
{orig} holds {dest} close to their body, probably to express affection.
|
||||||
|
{orig} holds {dest} close to their body, likely to show that they like, love, or value them.
|
||||||
|
{orig} puts their arms around {dest} and hold them tightly, because {orig} likes {dest} or is pleased to see {dest}.
|
||||||
|
{dest} is trapped with {orig}'s arms wrapped around their back.
|
||||||
|
{orig} wraps their arms around {dest}'s back in a warm embrace.
|
||||||
|
{orig} wraps their arms around {dest}'s back in a warm embrace.
|
||||||
|
{orig} clings onto {dest}.
|
||||||
|
{orig} clings onto {dest} affectionately.
|
||||||
|
{orig} clasps {dest} tightly in their arms.
|
||||||
|
{orig} sneaks up from behind {dest} and puts their arms around {dest}'s waist.
|
||||||
|
{orig} sneaks up from behind {dest} and puts their arms around {dest}'s waist while saying nothing.
|
||||||
|
heheehehehe {orig} hugs {dest} <3<3<##<#,3,33<#3,#3,,3,3,#<...
|
||||||
|
{orig}'s arms consume {dest}'s body, mind, and soul in a comforting and personal spectacle.
|
||||||
Reference in New Issue
Block a user