Added Debug command

This commit is contained in:
Purplebored
2023-09-24 19:11:15 +02:00
parent daf41e7233
commit 63ff45bfa3

View File

@@ -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.
@@ -271,7 +337,7 @@ public class Commands : ModuleBase
} }
// Very simple very say command. // Very simple very say command.
private List<string> blacklist = new List<string> private List<string> blacklist = new List<string>
{ {
"nigga", "nigger", "n i g g a", "fuck", "shit", "piss", "cunt", "dick", "fag", "faggot", "kys", "ky$", // Blacklist for the say command "nigga", "nigger", "n i g g a", "fuck", "shit", "piss", "cunt", "dick", "fag", "faggot", "kys", "ky$", // Blacklist for the say command
}; };
@@ -789,31 +855,30 @@ public class Commands : ModuleBase
[Command("hentai")] [Command("hentai")]
public async Task hentai() public async Task hentai()
{ {
if (!(Context.Channel is TextChannel textChannel) || !textChannel.IsNsfw) if (!(Context.Channel is TextChannel textChannel) || !textChannel.IsNsfw)
{ {
await Context.Channel.SendMessageAsync( await Context.Channel.SendMessageAsync(
"This command is only allowed in NSFW channels. So go to a NSFW channel to get your NSFW smh"); "This command is only allowed in NSFW channels. So go to a NSFW channel to get your NSFW smh");
return; return;
} }
using (HttpClient client = new HttpClient()) using (HttpClient client = new HttpClient())
{
string apiUrl = "https://nekobot.xyz/api/image?type=hneko";
HttpResponseMessage response = await client.GetAsync(apiUrl);
if (response.IsSuccessStatusCode)
{ {
string nekoJson = await response.Content.ReadAsStringAsync(); string apiUrl = "https://nekobot.xyz/api/image?type=hneko";
dynamic nekoObject = Newtonsoft.Json.JsonConvert.DeserializeObject(nekoJson); HttpResponseMessage response = await client.GetAsync(apiUrl);
string imageUrl = nekoObject["message"]; if (response.IsSuccessStatusCode)
{
string nekoJson = await response.Content.ReadAsStringAsync();
dynamic nekoObject = Newtonsoft.Json.JsonConvert.DeserializeObject(nekoJson);
await ReplyAsync(imageUrl); string imageUrl = nekoObject["message"];
}
else await ReplyAsync(imageUrl);
{ }
await ReplyAsync("Sorry, I couldn't fetch a neko image at the moment. Please try again later."); else
{
await ReplyAsync("Sorry, I couldn't fetch a neko image at the moment. Please try again later.");
}
} }
} }
}
} }