diff --git a/CHANGELOG.md b/CHANGELOG.md index 9274303..a896a62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Selphybot Changelog Updates are listed in reverse chronological order. +### 1.4 (dev) +- a copy of each deleted message is now send via DM to the author (suggested by CommanderLook) +- seasonal fluff + ### 1.3 - use global array of pointers to commands to allow easier modification and avoid unnecessary memcpy - added feedback to !complain (used to work but was forgotten when refactoring) diff --git a/command.go b/command.go index ce575bd..dd39dc9 100644 --- a/command.go +++ b/command.go @@ -128,7 +128,7 @@ func executeCommand(session *discordgo.Session, message *discordgo.MessageCreate session.ChannelMessageSendEmbed(message.ChannelID, command.OutputEmbed) } if command.DeleteInput { - session.ChannelMessageDelete(message.ChannelID, message.ID) + deleteAndSendViaDM(session, message) } } else { // execute custom function @@ -146,6 +146,13 @@ func removeCooldown(command *Command, uid string) { } } +func deleteAndSendViaDM(s *discordgo.Session, message *discordgo.MessageCreate) { + s.ChannelMessageDelete(message.ChannelID, message.ID) + dm := getDMChannelFromMessage(s, message) + s.ChannelMessageSend(dm.ID, "Deine Nachricht wurde gelöscht, weil sie ein verbotenes Wort enthielt. Falls du sie editieren und erneut abschicken willst, hier die Nachricht:") + s.ChannelMessageSend(dm.ID, message.Content) +} + func generateReply(message *discordgo.MessageCreate, command *Command) string { output := command.Output if command.OutputIsReply { diff --git a/helpers.go b/helpers.go index a0bc46f..2b56f81 100644 --- a/helpers.go +++ b/helpers.go @@ -42,6 +42,11 @@ func isDM(s *discordgo.Session, m *discordgo.MessageCreate) bool { return (getChannel(s.State, m.ChannelID).Type == discordgo.ChannelTypeDM) } +func getDMChannelFromMessage(s *discordgo.Session, m *discordgo.MessageCreate) *discordgo.Channel { + dm, _ := s.UserChannelCreate(m.Author.ID) + return dm +} + func isAdmin(u *discordgo.User) bool { for _, admin := range config.Admins { if u.ID == admin { diff --git a/main.go b/main.go index 50f29ee..24eea1f 100644 --- a/main.go +++ b/main.go @@ -68,8 +68,8 @@ func addCommands() { registerCommand(Command{Trigger: "/o\\", Output: "\\o/", Type: CommandTypeFullMatch, Cooldown: 10}) registerCommand(Command{Trigger: "!heil", Output: "(ノ・ェ・)ノ Selphy (ノ・ェ・)ノ", Type: CommandTypeFullMatch, Cooldown: 30}) registerCommand(Command{Trigger: "ayy", Output: "lmao", Type: CommandTypeFullMatch, Cooldown: 0}) + registerCommand(Command{Trigger: "<:selphyPadoru:525766188240732180>", Output: "<:selphypadoru:526644596558659594> Padoru <:selphypadoru:526644596558659594> Padoru <:selphypadoru:526644596558659594> Pado Padoru <:selphypadoru:526644596558659594>", Type: CommandTypeFullMatch, Cooldown: 10800}) registerCommand(Command{Trigger: "<:selphyDango:507979223244341267>", Output: "<:dango:430669469799677953> :notes: Dango Daikazoku :notes: <:dango:430669469799677953>", Type: CommandTypeFullMatch, Cooldown: 10800}) - registerCommand(Command{Trigger: "<:selphyBoo:501622721881571329>", Output: "<:dango:430669469799677953> :notes: Dango Daikazobuh :notes: <:dango:430669469799677953>", Type: CommandTypeFullMatch, Cooldown: 10800}) registerCommand(Command{Trigger: "praise the sun", Output: "If only I could be so grossly incandescent \\\\[T]/", Type: CommandTypeContains, IgnoreCase: true, Cooldown: 85600}) // Information