Skip to content

Commit

Permalink
Refuse to load newly created DMs
Browse files Browse the repository at this point in the history
This completely prevents the user from sending messages in newly-created
DM channels, since doing so will trigger Discord's anti-spam measures
and may cause the account to be limited or even banned.
  • Loading branch information
diamondburned committed Sep 19, 2024
1 parent 7c629a4 commit ffdff32
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions internal/messages/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,21 +542,31 @@ func (v *View) load() {
v.LoadablePage.SetLoading()
v.unload()

state := gtkcord.FromContext(v.ctx).Online()
state := gtkcord.FromContext(v.ctx)

ch, _ := state.Cabinet.Channel(v.chID)
if ch == nil {
v.LoadablePage.SetError(fmt.Errorf("channel not found"))
return
}

gtkutil.Async(v.ctx, func() func() {
msgs, err := state.Messages(v.chID, 15)
msgs, err := state.Online().Messages(v.chID, 15)
if err != nil {
return func() {
v.LoadablePage.SetError(err)
}
return func() { v.LoadablePage.SetError(err) }
}

sort.Slice(msgs, func(i, j int) bool {
return msgs[i].ID < msgs[j].ID
})

return func() {
if len(msgs) == 0 && ch.Type == discord.DirectMessage {
v.LoadablePage.SetError(errors.New(
"refusing to load DM: please send a message via the official client first"))
return
}

v.setPageToMain()
v.Scroll.ScrollToBottom()

Expand Down

0 comments on commit ffdff32

Please sign in to comment.