Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'I haven't seen much of these for VB.net, so here's something I made...
- 'Please note that I am a beginner, so some things may be able to be optimised.
- 'However, this does work very fast.
- Imports System.Collections.Specialized
- Imports System.Net
- Module Module1
- Public Class dWebHook
- Implements IDisposable
- Private ReadOnly dWebClient As WebClient
- Private Shared discordValues As NameValueCollection = New NameValueCollection()
- Public Property WebHook As String
- Public Property UserName As String
- Public Property ProfilePicture As String
- Public Sub New()
- dWebClient = New WebClient()
- End Sub
- Public Sub SendMessage(ByVal msgSend As String)
- discordValues.Add("username", UserName)
- discordValues.Add("avatar_url", ProfilePicture)
- discordValues.Add("content", msgSend)
- dWebClient.UploadValues(WebHook, discordValues)
- discordValues.Remove("username")
- discordValues.Remove("avatar_url")
- discordValues.Remove("content")
- End Sub
- Public Sub Dispose()
- dWebClient.Dispose()
- End Sub
- Private Sub IDisposable_Dispose() Implements IDisposable.Dispose
- DirectCast(dWebClient, IDisposable).Dispose()
- End Sub
- End Class
- Sub Main()
- Dim username, webhook, message
- Try
- Console.WriteLine("")
- Console.WriteLine("Please link your webhook here.")
- Console.WriteLine("Example: https://discordapp.com/api/webhooks/longlistofnumbersandletters")
- webhook = Console.ReadLine()
- Console.Clear()
- Console.WriteLine("")
- Console.WriteLine("Please write the name you want your webhook to have.")
- Console.WriteLine("Example: 'dave'")
- username = Console.ReadLine
- Console.Clear()
- Console.WriteLine("")
- Console.WriteLine("Please write the message you wish to send.")
- Console.WriteLine("Example: 'Hello world!'")
- message = Console.ReadLine
- Console.Clear()
- Dim dcWeb As dWebHook = New dWebHook
- dcWeb.UserName = username
- dcWeb.WebHook = webhook
- dcWeb.SendMessage(message)
- Console.ReadLine()
- Catch ex As System.ArgumentException
- Console.WriteLine("Error. Please use the examples provided for guidance.")
- Console.ReadLine()
- End Try
- End Sub
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement