-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
C# Rewrite, simple functions only so far but more will be added.
- Loading branch information
Showing
84 changed files
with
141,910 additions
and
560 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.34729.27 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Naticord", "Naticord\Naticord.csproj", "{1383FE7A-AB28-48C3-A477-E35655E31D5F}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{1383FE7A-AB28-48C3-A477-E35655E31D5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{1383FE7A-AB28-48C3-A477-E35655E31D5F}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{1383FE7A-AB28-48C3-A477-E35655E31D5F}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{1383FE7A-AB28-48C3-A477-E35655E31D5F}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {CE8FF17F-663A-4879-ABE4-846C1DEA6955} | ||
EndGlobalSection | ||
EndGlobal |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using System; | ||
using System.IO; | ||
using System.Net; | ||
using System.Windows.Forms; | ||
|
||
namespace Naticord | ||
{ | ||
public partial class Login : Form | ||
{ | ||
private const string TokenFileName = "token.txt"; | ||
|
||
public Login() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void loginButton_Click(object sender, EventArgs e) | ||
{ | ||
string accessToken = accessTokenTextBox.Text.Trim(); | ||
|
||
if (string.IsNullOrEmpty(accessToken)) | ||
{ | ||
MessageBox.Show("Please enter your Discord access token.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); | ||
return; | ||
} | ||
|
||
PerformLogin(accessToken); | ||
} | ||
|
||
private void PerformLogin(string accessToken) | ||
{ | ||
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; // TLS 1.2 | ||
|
||
using (var webClient = new WebClient()) | ||
{ | ||
webClient.Headers[HttpRequestHeader.Authorization] = accessToken; | ||
|
||
try | ||
{ | ||
string userProfileJson = webClient.DownloadString("https://discord.com/api/v9/users/@me"); | ||
|
||
SaveToken(accessToken); | ||
|
||
Naticord naticordForm = new Naticord(accessToken); | ||
naticordForm.Show(); | ||
|
||
this.Hide(); | ||
} | ||
catch (WebException ex) | ||
{ | ||
MessageBox.Show("Failed to login. Please enter a valid token! Error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); | ||
} | ||
} | ||
} | ||
|
||
private void SaveToken(string accessToken) | ||
{ | ||
try | ||
{ | ||
string homeDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); | ||
|
||
string filePath = Path.Combine(homeDirectory, TokenFileName); | ||
|
||
File.WriteAllText(filePath, "token=" + accessToken); | ||
} | ||
catch (Exception ex) | ||
{ | ||
MessageBox.Show("Failed to save token: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); | ||
} | ||
} | ||
|
||
private void Login_Load(object sender, EventArgs e) | ||
{ | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.