Closed jakevoytko closed 7 years ago
Per discordgo docs - need to grab the ChannelID from the Message struct, call Session.Channel(ChannelID) and check the resulting *Channel for IsPrivate - if true, reply with error requiring user to unlearn in public.
Looks to me like the ChannelID is passed around as 'channel' in the feature itself, so this may be as simple as adding the following lines to func (f *UnlearnFeature) Execute(s DiscordSession, channel string, command *Command)
:
c, err := s.Channel(channel)
if err != nil {
fatal("This message didn't come from a valid channel", errors.New("wat"))
}
if c.IsPrivate {
s.ChannelMessageSend(channel, fmt.Sprintf(MsgUnlearnMustBePublic, command.Unlearn.Call))
}
Will try to validate this and send PR.
If you're gonna destroy a command, you should do it in public.
Relevant Discord discussion:
[10:03 AM] Jake: i'm thinking of changing
?learn
and?unlearn
so they don't work from PMs. does anyone have any compelling use cases for keeping them? [10:03 AM] Jake: ^ these are the types of thoughts i wake up with suddenly at 3am, in case anyone was wondering [10:04 AM] BL: The compelling case is that it makes the surprise more fun [10:04 AM] BL: in a chat involving randos i'd def disallow but here it's great when you get surprised [10:11 AM] Timmes: i would say [10:11 AM] Timmes: keep?learn
in PMs [10:11 AM] Timmes: don't keep?unlearn
in PMs [10:14 AM] Timmes: the value of surprising someone with a?navyseal
is nontrivial, imo [10:15 AM] Timmes: but if you're?unlearn
ing something and destroying something someone created, you should have the balls to say "hey i'm a coward and don't want?ryan
anymore because it hurts what little of my feelings my children have left behind" [10:15 AM] Timmes: in public [10:15 AM] Timmes: where we all can see you