?ping command ?dice command ?gif command ?avatar command
This commit is contained in:
119
Program.cs
119
Program.cs
@@ -1,10 +1,12 @@
|
|||||||
using Optionals;
|
using System.Diagnostics;
|
||||||
|
using Optionals;
|
||||||
using RevoltSharp.Commands;
|
using RevoltSharp.Commands;
|
||||||
using RevoltSharp;
|
using RevoltSharp;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
||||||
class Program
|
class Program
|
||||||
{
|
{
|
||||||
public static RevoltClient Client;
|
public static RevoltClient Client;
|
||||||
@@ -24,7 +26,7 @@ class Program
|
|||||||
});
|
});
|
||||||
|
|
||||||
await Client.StartAsync();
|
await Client.StartAsync();
|
||||||
await Client.CurrentUser.ModifySelfAsync(statusText: new Option<string>("Now Open source! `?source`"));
|
await Client.CurrentUser.ModifySelfAsync(statusText: new Option<string>("Always Evolving!"));
|
||||||
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();
|
||||||
@@ -77,11 +79,11 @@ 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.
|
||||||
|
|
||||||
}
|
}
|
||||||
public class Commands : ModuleBase
|
public class Commands : ModuleBase
|
||||||
{
|
{
|
||||||
|
|
||||||
// Help commands:
|
// Help commands:
|
||||||
// Basic Help Command.
|
// Basic Help Command.
|
||||||
[Command("help")]
|
[Command("help")]
|
||||||
@@ -94,13 +96,12 @@ public class Commands : ModuleBase
|
|||||||
"`?credits` - Displays bot's credit.\n" +
|
"`?credits` - Displays bot's credit.\n" +
|
||||||
"`?test` - Simple test command you say test bot will response.\n" +
|
"`?test` - Simple test command you say test bot will response.\n" +
|
||||||
"`?invite` - Send a link to invite this bot to your server! \n" +
|
"`?invite` - Send a link to invite this bot to your server! \n" +
|
||||||
"`?changelog` - very simple command gives a list of changes and new additions! \n" +
|
|
||||||
"`?calculate` {num} {+, - , / , * } {num} - A very simple calculator. \n" +
|
"`?calculate` {num} {+, - , / , * } {num} - A very simple calculator. \n" +
|
||||||
"`?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" +
|
||||||
"`?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" +
|
||||||
"`?roll` - Rolls a random number between 1 and 6.\n" +
|
"`?dice` - Rolls a random number between 1 and 6.\n" +
|
||||||
"`?hi` - just says hi to the user. \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" +
|
||||||
"`?rps {paper,rock,scissors}` - Simple Rock paper scissors game.\n" +
|
"`?rps {paper,rock,scissors}` - Simple Rock paper scissors game.\n" +
|
||||||
@@ -110,11 +111,13 @@ public class Commands : ModuleBase
|
|||||||
"`?flipcoin` - a Command so easy a child could do it. \n " +
|
"`?flipcoin` - a Command so easy a child could do it. \n " +
|
||||||
"`?fact` - Gives a random useless fact. \n " +
|
"`?fact` - Gives a random useless fact. \n " +
|
||||||
"`?urban + {word}` - uses the urban dictionary the search for the word. \n" +
|
"`?urban + {word}` - uses the urban dictionary the search for the word. \n" +
|
||||||
"`?shitpost` - Sends a random shitpost. \n " +
|
"`?shitpost` - Sends a random shitpost. (The shitpost API is broken.) \n " +
|
||||||
"`?cat` - Cat :3 \n " +
|
"`?cat` - Cat :3 \n " +
|
||||||
"`?neko` - Neko command \n " +
|
"`?neko` - Neko command \n " +
|
||||||
"`?advice` - Gives the user a life Advice \n " +
|
"`?advice` - Gives the user a life Advice \n " +
|
||||||
"`?quote` - Gives a random quote using yet another API. \n ";
|
"`?quote` - Gives a random quote using yet another API. \n " +
|
||||||
|
"`?gif {term}` - Allows the user to search for gifs using giphy (Beta) \n" +
|
||||||
|
"`?avatar` - Sends the user Avatar (Beta) \n ";
|
||||||
await ReplyAsync(helpMessage);
|
await ReplyAsync(helpMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,20 +138,6 @@ public class Commands : ModuleBase
|
|||||||
// End of the help command Section
|
// End of the help command Section
|
||||||
|
|
||||||
// Dm Commands (commands that dm the user in some way.):
|
// Dm Commands (commands that dm the user in some way.):
|
||||||
// Very simple DM command
|
|
||||||
[Command("dm")]
|
|
||||||
public async Task DM()
|
|
||||||
{
|
|
||||||
DMChannel DM = await Context.User.GetDMChannelAsync();
|
|
||||||
if (DM == null)
|
|
||||||
{
|
|
||||||
await ReplyAsync("Could not open a DM :(");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await DM.SendMessageAsync("Hi :)");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Invite Command - Sends a invite in the DM
|
// Invite Command - Sends a invite in the DM
|
||||||
[Command("invite")]
|
[Command("invite")]
|
||||||
public async Task Invite()
|
public async Task Invite()
|
||||||
@@ -167,13 +156,6 @@ public class Commands : ModuleBase
|
|||||||
"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 bai");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simple Hi command DMs the user Hi
|
|
||||||
[Command("hi")]
|
|
||||||
public async Task Hi()
|
|
||||||
{
|
|
||||||
await ReplyAsync("Hi " + Context.User.Username);
|
|
||||||
}
|
|
||||||
// End of DM commands.
|
// End of DM commands.
|
||||||
|
|
||||||
// Debug commands.
|
// Debug commands.
|
||||||
@@ -184,8 +166,61 @@ public class Commands : ModuleBase
|
|||||||
{
|
{
|
||||||
await ReplyAsync("Ig it works :tm:");
|
await ReplyAsync("Ig it works :tm:");
|
||||||
}
|
}
|
||||||
|
// Ping command.
|
||||||
|
[Command("ping")]
|
||||||
|
public async Task PingCommand()
|
||||||
|
{
|
||||||
|
var stopwatch = new Stopwatch();
|
||||||
|
stopwatch.Start();
|
||||||
|
|
||||||
|
await ReplyAsync("Ping...");
|
||||||
|
|
||||||
|
stopwatch.Stop();
|
||||||
|
var latency = stopwatch.ElapsedMilliseconds;
|
||||||
|
|
||||||
|
await ReplyAsync($"Pong! (Latency: {latency}ms)");
|
||||||
|
}
|
||||||
|
// End of the Debug commands.
|
||||||
|
|
||||||
// Fun commands:
|
// Fun commands:
|
||||||
|
// Gif command
|
||||||
|
[Command("gif")]
|
||||||
|
public async Task GifCommand([Remainder] string keyword)
|
||||||
|
{
|
||||||
|
using (HttpClient client = new HttpClient())
|
||||||
|
{
|
||||||
|
IConfiguration Configuration = new ConfigurationBuilder()
|
||||||
|
.SetBasePath(AppDomain.CurrentDomain.BaseDirectory)
|
||||||
|
.AddJsonFile("giphy.json")
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
string apiKey = Configuration["GiphyApiKey"];
|
||||||
|
string apiUrl = $"https://api.giphy.com/v1/gifs/search?api_key={apiKey}&q={keyword}&limit=1";
|
||||||
|
|
||||||
|
HttpResponseMessage response = await client.GetAsync(apiUrl);
|
||||||
|
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
string gifJson = await response.Content.ReadAsStringAsync();
|
||||||
|
JObject gifObject = JObject.Parse(gifJson);
|
||||||
|
|
||||||
|
string gifUrl = gifObject["data"][0]["images"]["original"]["url"]?.ToString();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(gifUrl))
|
||||||
|
{
|
||||||
|
await Context.Channel.SendMessageAsync(gifUrl);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await Context.Channel.SendMessageAsync("Sorry, I couldn't find a GIF for that keyword.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await Context.Channel.SendMessageAsync("Sorry, I couldn't fetch a GIF at the moment. Please try again later.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// A Rock paper Scicors command.
|
// A Rock paper Scicors command.
|
||||||
[Command("rps")]
|
[Command("rps")]
|
||||||
@@ -227,8 +262,8 @@ public class Commands : ModuleBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Roll command roles a random number between 1 - 6 (Perfect for bets :troll")
|
// Roll command roles a random number between 1 - 6 (Perfect for bets :troll")
|
||||||
[Command("roll")]
|
[Command("dice")]
|
||||||
public async Task Roll()
|
public async Task dice()
|
||||||
{
|
{
|
||||||
var random = new Random();
|
var random = new Random();
|
||||||
var result = random.Next(1, 7);
|
var result = random.Next(1, 7);
|
||||||
@@ -309,7 +344,8 @@ public class Commands : ModuleBase
|
|||||||
await ReplyAsync("Sorry, I couldn't fetch advice at the moment. Please try again later.");
|
await ReplyAsync("Sorry, I couldn't fetch advice at the moment. Please try again later.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // Dog fact command very simple very fun
|
}
|
||||||
|
// Dog fact command very simple very fun
|
||||||
[Command("dogfact")]
|
[Command("dogfact")]
|
||||||
public async Task DogFact()
|
public async Task DogFact()
|
||||||
{
|
{
|
||||||
@@ -582,17 +618,14 @@ public class Commands : ModuleBase
|
|||||||
await ReplyAsync("This bot is made using revoltsharp by Purplebored known as Kniaż Jarema on nightly");
|
await ReplyAsync("This bot is made using revoltsharp by Purplebored known as Kniaż Jarema on nightly");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Command("changelog")]
|
// Avatar command
|
||||||
public async Task changelog()
|
[Command("avatar")]
|
||||||
|
public async Task AvatarCommand()
|
||||||
{
|
{
|
||||||
await ReplyAsync(
|
var user = Context.Message.Author.GetAvatarUrl();
|
||||||
"# Changelog: \n ### Neko! 0.0.4 \n New command! ?neko!)");
|
var avatarUrl = $"{user}";
|
||||||
}
|
|
||||||
// Simple source command that leads to this project source
|
await Context.Channel.SendMessageAsync($"Your avatar: {avatarUrl}");
|
||||||
[Command("source")]
|
|
||||||
public async Task source()
|
|
||||||
{
|
|
||||||
await ReplyAsync("If you want to contribute or check out the source code you can do it here: https://codeberg.org/Purplebored/Chrobry");
|
|
||||||
}
|
}
|
||||||
// End of the misc commands
|
// End of the misc commands
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user