mirror of
https://github.com/NoiTheCat/BirthdayBot.git
synced 2024-11-21 21:54:36 +00:00
Improve role error message handling and display
This commit is contained in:
parent
6355a86ddb
commit
3ac8a209f3
2 changed files with 14 additions and 6 deletions
|
@ -121,12 +121,19 @@ Class BackgroundWorker
|
|||
Dim announceNames As IEnumerable(Of SocketGuildUser)
|
||||
Try
|
||||
announceNames = Await BirthdayApplyAsync(guild, role, birthdays)
|
||||
Catch ex As Exception
|
||||
SyncLock _bot.KnownGuilds
|
||||
' Failed to apply role. Reset the warning.
|
||||
_bot.KnownGuilds(guild.Id).RoleWarning = True
|
||||
_bot.KnownGuilds(guild.Id).RoleWarning = False
|
||||
End SyncLock
|
||||
Return 0
|
||||
Catch ex As Discord.Net.HttpException
|
||||
If ex.HttpCode = HttpStatusCode.Forbidden Then
|
||||
SyncLock _bot.KnownGuilds
|
||||
' Failed to apply role. Set the warning.
|
||||
_bot.KnownGuilds(guild.Id).RoleWarning = True
|
||||
End SyncLock
|
||||
Return 0
|
||||
End If
|
||||
|
||||
Throw
|
||||
End Try
|
||||
If announceNames.Count <> 0 Then
|
||||
' Send out announcement message
|
||||
|
|
|
@ -18,11 +18,12 @@ Friend Class GuildSettings
|
|||
|
||||
Private _roleWarning As Boolean
|
||||
Private _roleLastWarning As New DateTimeOffset(DateTime.MinValue, TimeSpan.Zero)
|
||||
Private Shared ReadOnly RoleWarningInterval As New TimeSpan(0, 10, 0)
|
||||
Private Shared ReadOnly RoleWarningInterval As New TimeSpan(1, 0, 0)
|
||||
|
||||
''' <summary>
|
||||
''' Flag for notifying servers that the bot is unable to manipulate its role.
|
||||
''' Can be set at any time. Reading this will only return True once every 10 minutes, if at all.
|
||||
''' Can be set at any time. Reading this will only return True if it's been set as such,
|
||||
''' and it is only returned after a set time has passed in order to not constantly show the message.
|
||||
''' </summary>
|
||||
Public Property RoleWarning As Boolean
|
||||
Get
|
||||
|
|
Loading…
Reference in a new issue