forked from kageru/discord-selphybot
deleted messages are now send to their authors via DM
solves an issue where people would lose long messages due to accidentally using banned words
This commit is contained in:
parent
ebd7f0bb5e
commit
6e7229d787
|
@ -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)
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
2
main.go
2
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user