Added Debug command
This commit is contained in:
79
Program.cs
79
Program.cs
@@ -26,7 +26,7 @@ class Program
|
|||||||
});
|
});
|
||||||
|
|
||||||
await Client.StartAsync();
|
await Client.StartAsync();
|
||||||
await Client.CurrentUser.ModifySelfAsync(statusText: new Option<string>("Always Evolving!"));
|
await Client.CurrentUser.ModifySelfAsync(statusText: new Option<string>("God please someone kill me."));
|
||||||
await Client.CurrentUser.ModifySelfAsync(statusType: new Option<UserStatusType>(UserStatusType.Focus));
|
await Client.CurrentUser.ModifySelfAsync(statusType: new Option<UserStatusType>(UserStatusType.Focus));
|
||||||
CommandHandler CommandHandler = new CommandHandler(Client);
|
CommandHandler CommandHandler = new CommandHandler(Client);
|
||||||
CommandHandler.LoadCommands();
|
CommandHandler.LoadCommands();
|
||||||
@@ -79,7 +79,7 @@ public class CommandHandler
|
|||||||
context.Channel.SendMessageAsync("Error: " + result.ErrorReason);
|
context.Channel.SendMessageAsync("Error: " + result.ErrorReason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Only god and the dude behing RevoltSharp know what's going on here.
|
// Only god and the dude behind RevoltSharp know what's going on here.
|
||||||
}
|
}
|
||||||
public class Commands : ModuleBase
|
public class Commands : ModuleBase
|
||||||
{
|
{
|
||||||
@@ -89,8 +89,8 @@ public class Commands : ModuleBase
|
|||||||
[Command("help")]
|
[Command("help")]
|
||||||
public async Task Help()
|
public async Task Help()
|
||||||
{
|
{
|
||||||
var helpMessage = "### List of available commands:\n\n" +
|
var helpMessage = "#### List of available commands:\n\n" +
|
||||||
"### Practical Commands: \n" +
|
"#### Practical Commands: \n" +
|
||||||
"`?help` - Displays this command.\n" +
|
"`?help` - Displays this command.\n" +
|
||||||
"`?source` - Links to the bots source code. \n" +
|
"`?source` - Links to the bots source code. \n" +
|
||||||
"`?credits` - Displays bot's credit.\n" +
|
"`?credits` - Displays bot's credit.\n" +
|
||||||
@@ -100,7 +100,7 @@ public class Commands : ModuleBase
|
|||||||
"`?mod-help` - Displays a list of available mod commands. \n " +
|
"`?mod-help` - Displays a list of available mod commands. \n " +
|
||||||
"`?ping` - tests the bot ping. \n" +
|
"`?ping` - tests the bot ping. \n" +
|
||||||
"`?nsfw-help` - Sends a list of all aviable nsfw commands. \n " +
|
"`?nsfw-help` - Sends a list of all aviable nsfw commands. \n " +
|
||||||
"### Fun Commands: \n" +
|
"#### Fun Commands: \n" +
|
||||||
"`?dice` - Rolls a random number between 1 and 6.\n" +
|
"`?dice` - Rolls a random number between 1 and 6.\n" +
|
||||||
"`?say` - says what the user told it to say!. \n" +
|
"`?say` - says what the user told it to say!. \n" +
|
||||||
"`?dm` - Just DMs the user Hi :3. \n" +
|
"`?dm` - Just DMs the user Hi :3. \n" +
|
||||||
@@ -154,8 +154,74 @@ public class Commands : ModuleBase
|
|||||||
"https://app.haydar.dev/bot/01HA55V3K8B26T87TBKMZMWRKJ \n" +
|
"https://app.haydar.dev/bot/01HA55V3K8B26T87TBKMZMWRKJ \n" +
|
||||||
"but if you on nightly.haydar.dev use this link \n" +
|
"but if you on nightly.haydar.dev use this link \n" +
|
||||||
"https://nightly.haydar.dev/bot/01HA55V3K8B26T87TBKMZMWRKJ \n" +
|
"https://nightly.haydar.dev/bot/01HA55V3K8B26T87TBKMZMWRKJ \n" +
|
||||||
"If you find any bugs report them to the bots creator. thank you bai");
|
"If you find any bugs report them to the bots creator. Thank you bye!");
|
||||||
}
|
}
|
||||||
|
[Command("debug")]
|
||||||
|
public async Task Debug()
|
||||||
|
{
|
||||||
|
DMChannel DM = await Context.User.GetDMChannelAsync();
|
||||||
|
if (DM == null)
|
||||||
|
{
|
||||||
|
await ReplyAsync("Your code is so messed up that even DMs are broken :skull: wow");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Send initial message
|
||||||
|
await DM.SendMessageAsync("DMs work if you received this message.");
|
||||||
|
await DM.SendMessageAsync("-----");
|
||||||
|
await DM.SendMessageAsync("You should recive the ping of the bot and a shitpost");
|
||||||
|
// Ping part
|
||||||
|
var stopwatch = new Stopwatch();
|
||||||
|
stopwatch.Start();
|
||||||
|
await DM.SendMessageAsync("-----");
|
||||||
|
stopwatch.Stop();
|
||||||
|
var latency = stopwatch.ElapsedMilliseconds;
|
||||||
|
await DM.SendMessageAsync($"The ping is: {latency}ms");
|
||||||
|
await DM.SendMessageAsync("-----");
|
||||||
|
// Shitpost part
|
||||||
|
await SendRandomMeme(DM);
|
||||||
|
await DM.SendMessageAsync("If you saw a Shitpost and the ping of the bot everything should work correctly.");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
await DM.SendMessageAsync($"An error occurred: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Shitpost Logic
|
||||||
|
private async Task SendRandomMeme(DMChannel DM)
|
||||||
|
{
|
||||||
|
const string apiUrl = "https://api.thedailyshitpost.net/random";
|
||||||
|
|
||||||
|
using (HttpClient client = new HttpClient())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
HttpResponseMessage response = await client.GetAsync(apiUrl);
|
||||||
|
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
string memeJson = await response.Content.ReadAsStringAsync();
|
||||||
|
dynamic memeObject = Newtonsoft.Json.JsonConvert.DeserializeObject(memeJson);
|
||||||
|
|
||||||
|
string title = memeObject.title;
|
||||||
|
string imageUrl = memeObject.url;
|
||||||
|
|
||||||
|
await DM.SendMessageAsync($"{imageUrl}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await DM.SendMessageAsync("Sorry, The Shitpost API is having issues again.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await DM.SendMessageAsync($"An error occurred while fetching a meme: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// End of the Debug command.
|
||||||
// End of DM commands.
|
// End of DM commands.
|
||||||
|
|
||||||
// Debug commands.
|
// Debug commands.
|
||||||
@@ -815,5 +881,4 @@ public class Commands : ModuleBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user