Modified birthday announcement messages

This commit is contained in:
Noikoio 2018-07-24 16:37:52 -07:00
parent 8cec168e1b
commit 756a63c954

View file

@ -156,32 +156,39 @@ Class BackgroundWorker
Private Async Function BirthdayAnnounceAsync(g As SocketGuild, c As SocketTextChannel, names As IEnumerable(Of SocketGuildUser)) As Task Private Async Function BirthdayAnnounceAsync(g As SocketGuild, c As SocketTextChannel, names As IEnumerable(Of SocketGuildUser)) As Task
If c Is Nothing Then Return If c Is Nothing Then Return
Dim display As New StringBuilder() Dim result As String
Dim multi = names.Count > 1 If names.Count = 1 Then
For i = 0 To names.Count - 1 ' Single birthday. No need for tricks.
If i <> 0 Then display.Append(", ") Dim name As String
If i > 0 And i Mod 5 = 0 Then If names(0).Nickname IsNot Nothing Then
display.AppendLine() name = names(0).Nickname
display.Append(" - ")
End If
Dim user = names(i)
If user.Nickname IsNot Nothing Then
display.Append($"{user.Nickname} ({user.Username}#{user.Discriminator})")
Else Else
display.Append($"{user.Username}#{user.Discriminator}") name = names(0).Username
End If End If
result = $"Hey! Please wish a happy birthday to our wonderful member, **{name}**."
Else
' Build name list
Dim namedisplay As New StringBuilder()
Dim first = True
For Each item In names
If Not first Then
namedisplay.Append(", ")
End If
first = False
Dim name As String
If item.Nickname IsNot Nothing Then
name = item.Nickname
Else
name = item.Username
End If
namedisplay.Append(name)
Next Next
result = $"Please wish our members a happy birthday! In no particular order: {namedisplay.ToString()}"
If multi Then
display.Insert(0, "Happy birthday to our wonderful members:" + vbLf + " - ")
Else
display.Insert(0, "Please wish a happy birthday to ")
End If End If
Try Try
Await c.SendMessageAsync(display.ToString()) Await c.SendMessageAsync(result)
Catch ex As Discord.Net.HttpException Catch ex As Discord.Net.HttpException
' Ignore ' Ignore
End Try End Try