mirror of
https://github.com/NoiTheCat/BirthdayBot.git
synced 2024-11-22 05:54:36 +00:00
Add bb.when command
This commit is contained in:
parent
de86ebae96
commit
76afc03ce4
3 changed files with 52 additions and 3 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.1</Version>
|
<Version>1.3.2</Version>
|
||||||
<Authors>Noiiko</Authors>
|
<Authors>Noiiko</Authors>
|
||||||
<Company />
|
<Company />
|
||||||
<Description>Discord bot for birthday reminders.</Description>
|
<Description>Discord bot for birthday reminders.</Description>
|
||||||
|
|
|
@ -43,7 +43,9 @@ Friend Class HelpInfoCommands
|
||||||
$"{cpfx}zone (zone)`" + vbLf +
|
$"{cpfx}zone (zone)`" + vbLf +
|
||||||
$" » Sets your local time zone. See `{CommandPrefix}help-tzdata`." + vbLf +
|
$" » Sets your local time zone. See `{CommandPrefix}help-tzdata`." + vbLf +
|
||||||
$"{cpfx}remove`" + vbLf +
|
$"{cpfx}remove`" + vbLf +
|
||||||
$" » Removes your birthday information from this bot."
|
$" » Removes your birthday information from this bot." + vbLf +
|
||||||
|
$"{cpfx}when (user)`" + vbLf +
|
||||||
|
$" » Displays birthday information of the given user."
|
||||||
}
|
}
|
||||||
Dim cmdModField As New EmbedFieldBuilder With {
|
Dim cmdModField As New EmbedFieldBuilder With {
|
||||||
.Name = "Moderator-only commands",
|
.Name = "Moderator-only commands",
|
||||||
|
|
|
@ -9,7 +9,8 @@ Class UserCommands
|
||||||
Return New List(Of (String, CommandHandler)) From {
|
Return New List(Of (String, CommandHandler)) From {
|
||||||
("set", AddressOf CmdSet),
|
("set", AddressOf CmdSet),
|
||||||
("zone", AddressOf CmdZone),
|
("zone", AddressOf CmdZone),
|
||||||
("remove", AddressOf CmdRemove)
|
("remove", AddressOf CmdRemove),
|
||||||
|
("when", AddressOf CmdWhen)
|
||||||
}
|
}
|
||||||
End Get
|
End Get
|
||||||
End Property
|
End Property
|
||||||
|
@ -162,4 +163,50 @@ Class UserCommands
|
||||||
Await reqChannel.SendMessageAsync(":white_check_mark: Your information has been removed.")
|
Await reqChannel.SendMessageAsync(":white_check_mark: Your information has been removed.")
|
||||||
End If
|
End If
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
Private Async Function CmdWhen(param As String(), reqChannel As SocketTextChannel, reqUser As SocketGuildUser) As Task
|
||||||
|
' Requires a parameter
|
||||||
|
If param.Count = 1 Then
|
||||||
|
Await reqChannel.SendMessageAsync(GenericError)
|
||||||
|
Return
|
||||||
|
End If
|
||||||
|
|
||||||
|
Dim search = param(1)
|
||||||
|
If param.Count = 3 Then
|
||||||
|
' param maxes out at 3 values. param(2) might contain part of the search string (if name has a space)
|
||||||
|
search += " " + param(2)
|
||||||
|
End If
|
||||||
|
|
||||||
|
Dim searchTarget As SocketGuildUser = Nothing
|
||||||
|
|
||||||
|
Dim searchId As ULong = 0
|
||||||
|
If Not TryGetUserId(search, searchId) Then ' ID lookup
|
||||||
|
' name lookup without discriminator
|
||||||
|
For Each searchuser In reqChannel.Guild.Users
|
||||||
|
If String.Equals(search, searchuser.Username, StringComparison.OrdinalIgnoreCase) Then
|
||||||
|
searchTarget = searchuser
|
||||||
|
Exit For
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
Else
|
||||||
|
searchTarget = reqChannel.Guild.GetUser(searchId)
|
||||||
|
End If
|
||||||
|
If searchTarget Is Nothing Then
|
||||||
|
Await reqChannel.SendMessageAsync(BadUserError)
|
||||||
|
Return
|
||||||
|
End If
|
||||||
|
|
||||||
|
Dim users = Instance.GuildCache(reqChannel.Guild.Id).Users
|
||||||
|
Dim searchTargetData = users.FirstOrDefault(Function(u) u.UserId = searchTarget.Id)
|
||||||
|
If searchTargetData Is Nothing Then
|
||||||
|
Await reqChannel.SendMessageAsync("The given user does not exist or has not set a birthday.")
|
||||||
|
Return
|
||||||
|
End If
|
||||||
|
|
||||||
|
With searchTargetData
|
||||||
|
Await reqChannel.SendMessageAsync(FormatName(searchTarget, False) + ": " +
|
||||||
|
$"`{ .BirthDay.ToString("00")}-{Common.MonthNames(.BirthMonth)}`" +
|
||||||
|
If(.TimeZone Is Nothing, "", $" - `{ .TimeZone}`"))
|
||||||
|
End With
|
||||||
|
End Function
|
||||||
End Class
|
End Class
|
||||||
|
|
Loading…
Reference in a new issue