mirror of
https://github.com/NoiTheCat/BirthdayBot.git
synced 2024-11-22 05:54:36 +00:00
Add more input options for specifying announce channel
This commit is contained in:
parent
de7752eb21
commit
de86ebae96
2 changed files with 24 additions and 12 deletions
|
@ -4,7 +4,7 @@
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<RootNamespace>BirthdayBot</RootNamespace>
|
<RootNamespace>BirthdayBot</RootNamespace>
|
||||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||||
<Version>1.3.0</Version>
|
<Version>1.3.1</Version>
|
||||||
<Authors>Noiiko</Authors>
|
<Authors>Noiiko</Authors>
|
||||||
<Company />
|
<Company />
|
||||||
<Description>Discord bot for birthday reminders.</Description>
|
<Description>Discord bot for birthday reminders.</Description>
|
||||||
|
|
|
@ -129,24 +129,36 @@ Friend Class ManagerCommands
|
||||||
gi.UpdateAnnounceChannel(Nothing)
|
gi.UpdateAnnounceChannel(Nothing)
|
||||||
Await reqChannel.SendMessageAsync(":white_check_mark: The announcement channel has been unset.")
|
Await reqChannel.SendMessageAsync(":white_check_mark: The announcement channel has been unset.")
|
||||||
Else
|
Else
|
||||||
' Parameter check: This needs a channel mention to function.
|
' Determine channel from input
|
||||||
|
Dim chId As ULong = 0
|
||||||
|
|
||||||
|
' Try channel mention
|
||||||
Dim m = ChannelMention.Match(param(1))
|
Dim m = ChannelMention.Match(param(1))
|
||||||
If Not m.Success Then
|
If m.Success Then
|
||||||
Await reqChannel.SendMessageAsync(":x: The given parameter must be a channel. (The channel name must be clickable.)")
|
chId = ULong.Parse(m.Groups(1).Value)
|
||||||
Return
|
ElseIf ULong.TryParse(param(1), chId) Then
|
||||||
|
' Continue...
|
||||||
|
Else
|
||||||
|
' Try text-based search
|
||||||
|
Dim res = reqChannel.Guild.TextChannels _
|
||||||
|
.FirstOrDefault(Function(ch) String.Equals(ch.Name, param(1), StringComparison.OrdinalIgnoreCase))
|
||||||
|
If res IsNot Nothing Then
|
||||||
|
chId = res.Id ' Yeah... we are throwing the full result away only to look for it again later.
|
||||||
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Dim chId = ULong.Parse(m.Groups(1).Value)
|
' Attempt to find channel in guild
|
||||||
' Check if the channel isn't in the local guild.
|
Dim chTt As SocketTextChannel = Nothing
|
||||||
Dim chInst = reqChannel.Guild.GetTextChannel(chId)
|
If chId <> 0 Then
|
||||||
If chInst Is Nothing Then
|
chTt = reqChannel.Guild.GetTextChannel(chId)
|
||||||
Await reqChannel.SendMessageAsync(":x: Unable to find the specified channel on this server.")
|
End If
|
||||||
|
If chTt Is Nothing Then
|
||||||
|
Await reqChannel.SendMessageAsync(":x: Unable to find the specified channel.")
|
||||||
Return
|
Return
|
||||||
End If
|
End If
|
||||||
|
|
||||||
' Update the value
|
' Update the value
|
||||||
Dim gi = Instance.GuildCache(reqChannel.Guild.Id)
|
Instance.GuildCache(reqChannel.Guild.Id).UpdateAnnounceChannel(chId)
|
||||||
gi.UpdateAnnounceChannel(chId)
|
|
||||||
|
|
||||||
' Report the success
|
' Report the success
|
||||||
Await reqChannel.SendMessageAsync($":white_check_mark: The announcement channel is now set to <#{chId}>.")
|
Await reqChannel.SendMessageAsync($":white_check_mark: The announcement channel is now set to <#{chId}>.")
|
||||||
|
|
Loading…
Reference in a new issue