mirror of
https://github.com/NoiTheCat/BirthdayBot.git
synced 2024-11-22 05:54:36 +00:00
Modified birthday announcement messages
This commit is contained in:
parent
8cec168e1b
commit
756a63c954
1 changed files with 26 additions and 19 deletions
|
@ -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
|
||||||
Next
|
result = $"Hey! Please wish a happy birthday to our wonderful member, **{name}**."
|
||||||
|
|
||||||
If multi Then
|
|
||||||
display.Insert(0, "Happy birthday to our wonderful members:" + vbLf + " - ")
|
|
||||||
Else
|
Else
|
||||||
display.Insert(0, "Please wish a happy birthday to ")
|
' 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
|
||||||
|
result = $"Please wish our members a happy birthday! In no particular order: {namedisplay.ToString()}"
|
||||||
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
|
||||||
|
|
Loading…
Reference in a new issue