added a few roleplay commands and edited the user-agent text
This commit is contained in:
@@ -17,7 +17,7 @@ namespace SkyBot.Commands
|
|||||||
|
|
||||||
private static readonly HttpClient _http = new()
|
private static readonly HttpClient _http = new()
|
||||||
{
|
{
|
||||||
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0" } }
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
};
|
};
|
||||||
|
|
||||||
public async Task Execute(CommandContext ctx)
|
public async Task Execute(CommandContext ctx)
|
||||||
|
|||||||
118
SkyBot/Commands/RP/Baka.cs
Normal file
118
SkyBot/Commands/RP/Baka.cs
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Text.Json;
|
||||||
|
using SkyBot.Helpers;
|
||||||
|
using SkyBot.Models;
|
||||||
|
using Valour.Sdk.Models;
|
||||||
|
using Valour.Shared.Models;
|
||||||
|
|
||||||
|
namespace SkyBot.Commands
|
||||||
|
{
|
||||||
|
public class Baka : ICommand
|
||||||
|
{
|
||||||
|
public string Name => "baka";
|
||||||
|
public string[] Aliases => ["idiot"];
|
||||||
|
public string Description => "Call someone a baka with a random gif.";
|
||||||
|
public string Section => "RP";
|
||||||
|
public string Usage => "baka [@user]";
|
||||||
|
|
||||||
|
private static readonly HttpClient _http = new()
|
||||||
|
{
|
||||||
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
|
};
|
||||||
|
|
||||||
|
public async Task Execute(CommandContext ctx)
|
||||||
|
{
|
||||||
|
ConcurrentDictionary<long, Channel> channelCache = ctx.ChannelCache;
|
||||||
|
long channelId = ctx.ChannelId;
|
||||||
|
|
||||||
|
if (!channelCache.TryGetValue(channelId, out var channel)) return;
|
||||||
|
|
||||||
|
await channel.SendIsTyping();
|
||||||
|
|
||||||
|
string json;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
json = await _http.GetStringAsync("https://nekos.best/api/v2/baka");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not fetch a baka gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
using var doc = JsonDocument.Parse(json);
|
||||||
|
var results = doc.RootElement.GetProperty("results");
|
||||||
|
string gifUrl = results[0].GetProperty("url").GetString()!;
|
||||||
|
|
||||||
|
byte[] gifBytes;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
gifBytes = await _http.GetByteArrayAsync(gifUrl);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not download the baka gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int width = 0, height = 0;
|
||||||
|
if (gifBytes.Length >= 10)
|
||||||
|
{
|
||||||
|
width = gifBytes[6] | (gifBytes[7] << 8);
|
||||||
|
height = gifBytes[8] | (gifBytes[9] << 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
string cdnUrl;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var form = new MultipartFormDataContent();
|
||||||
|
using var fileContent = new ByteArrayContent(gifBytes);
|
||||||
|
fileContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("image/gif");
|
||||||
|
form.Add(fileContent, "file", "baka.gif");
|
||||||
|
|
||||||
|
var uploadResult = await ctx.Planet.Node.PostMultipartDataWithResponse<string>("upload/image", form);
|
||||||
|
if (!uploadResult.Success)
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not upload the baka gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cdnUrl = uploadResult.Data!;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not upload the baka gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string? target = null;
|
||||||
|
if (ctx.Message.ReplyToId is not null)
|
||||||
|
{
|
||||||
|
var replied = await ctx.Message.FetchReplyMessageAsync();
|
||||||
|
if (replied is not null)
|
||||||
|
{
|
||||||
|
var author = await replied.FetchAuthorAsync();
|
||||||
|
if (author is not null)
|
||||||
|
target = author.Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (target is null && ctx.Args.Length > 0)
|
||||||
|
target = string.Join(" ", ctx.Args);
|
||||||
|
|
||||||
|
string sender = ctx.Member.Nickname ?? ctx.Member.User?.Name ?? "Unknown";
|
||||||
|
string text = target is not null
|
||||||
|
? $"{sender} calls {target} a baka!"
|
||||||
|
: $"{sender} says baka!";
|
||||||
|
|
||||||
|
var attachment = new MessageAttachment(MessageAttachmentType.Image)
|
||||||
|
{
|
||||||
|
Location = cdnUrl,
|
||||||
|
MimeType = "image/gif",
|
||||||
|
FileName = "baka.gif",
|
||||||
|
Width = width,
|
||||||
|
Height = height
|
||||||
|
};
|
||||||
|
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, text, [attachment]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ namespace SkyBot.Commands
|
|||||||
|
|
||||||
private static readonly HttpClient _http = new()
|
private static readonly HttpClient _http = new()
|
||||||
{
|
{
|
||||||
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0" } }
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
};
|
};
|
||||||
|
|
||||||
public async Task Execute(CommandContext ctx)
|
public async Task Execute(CommandContext ctx)
|
||||||
|
|||||||
118
SkyBot/Commands/RP/Blowkiss.cs
Normal file
118
SkyBot/Commands/RP/Blowkiss.cs
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Text.Json;
|
||||||
|
using SkyBot.Helpers;
|
||||||
|
using SkyBot.Models;
|
||||||
|
using Valour.Sdk.Models;
|
||||||
|
using Valour.Shared.Models;
|
||||||
|
|
||||||
|
namespace SkyBot.Commands
|
||||||
|
{
|
||||||
|
public class Blowkiss : ICommand
|
||||||
|
{
|
||||||
|
public string Name => "blowkiss";
|
||||||
|
public string[] Aliases => [];
|
||||||
|
public string Description => "Blow a kiss with a random gif.";
|
||||||
|
public string Section => "RP";
|
||||||
|
public string Usage => "blowkiss [@user]";
|
||||||
|
|
||||||
|
private static readonly HttpClient _http = new()
|
||||||
|
{
|
||||||
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
|
};
|
||||||
|
|
||||||
|
public async Task Execute(CommandContext ctx)
|
||||||
|
{
|
||||||
|
ConcurrentDictionary<long, Channel> channelCache = ctx.ChannelCache;
|
||||||
|
long channelId = ctx.ChannelId;
|
||||||
|
|
||||||
|
if (!channelCache.TryGetValue(channelId, out var channel)) return;
|
||||||
|
|
||||||
|
await channel.SendIsTyping();
|
||||||
|
|
||||||
|
string json;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
json = await _http.GetStringAsync("https://nekos.best/api/v2/blowkiss");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not fetch a blowkiss gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
using var doc = JsonDocument.Parse(json);
|
||||||
|
var results = doc.RootElement.GetProperty("results");
|
||||||
|
string gifUrl = results[0].GetProperty("url").GetString()!;
|
||||||
|
|
||||||
|
byte[] gifBytes;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
gifBytes = await _http.GetByteArrayAsync(gifUrl);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not download the blowkiss gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int width = 0, height = 0;
|
||||||
|
if (gifBytes.Length >= 10)
|
||||||
|
{
|
||||||
|
width = gifBytes[6] | (gifBytes[7] << 8);
|
||||||
|
height = gifBytes[8] | (gifBytes[9] << 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
string cdnUrl;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var form = new MultipartFormDataContent();
|
||||||
|
using var fileContent = new ByteArrayContent(gifBytes);
|
||||||
|
fileContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("image/gif");
|
||||||
|
form.Add(fileContent, "file", "blowkiss.gif");
|
||||||
|
|
||||||
|
var uploadResult = await ctx.Planet.Node.PostMultipartDataWithResponse<string>("upload/image", form);
|
||||||
|
if (!uploadResult.Success)
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not upload the blowkiss gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cdnUrl = uploadResult.Data!;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not upload the blowkiss gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string? target = null;
|
||||||
|
if (ctx.Message.ReplyToId is not null)
|
||||||
|
{
|
||||||
|
var replied = await ctx.Message.FetchReplyMessageAsync();
|
||||||
|
if (replied is not null)
|
||||||
|
{
|
||||||
|
var author = await replied.FetchAuthorAsync();
|
||||||
|
if (author is not null)
|
||||||
|
target = author.Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (target is null && ctx.Args.Length > 0)
|
||||||
|
target = string.Join(" ", ctx.Args);
|
||||||
|
|
||||||
|
string sender = ctx.Member.Nickname ?? ctx.Member.User?.Name ?? "Unknown";
|
||||||
|
string text = target is not null
|
||||||
|
? $"{sender} blows a kiss to {target}!"
|
||||||
|
: $"{sender} blows a kiss!";
|
||||||
|
|
||||||
|
var attachment = new MessageAttachment(MessageAttachmentType.Image)
|
||||||
|
{
|
||||||
|
Location = cdnUrl,
|
||||||
|
MimeType = "image/gif",
|
||||||
|
FileName = "blowkiss.gif",
|
||||||
|
Width = width,
|
||||||
|
Height = height
|
||||||
|
};
|
||||||
|
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, text, [attachment]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ namespace SkyBot.Commands
|
|||||||
|
|
||||||
private static readonly HttpClient _http = new()
|
private static readonly HttpClient _http = new()
|
||||||
{
|
{
|
||||||
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0" } }
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
};
|
};
|
||||||
|
|
||||||
public async Task Execute(CommandContext ctx)
|
public async Task Execute(CommandContext ctx)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace SkyBot.Commands
|
|||||||
|
|
||||||
private static readonly HttpClient _http = new()
|
private static readonly HttpClient _http = new()
|
||||||
{
|
{
|
||||||
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0" } }
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
};
|
};
|
||||||
|
|
||||||
public async Task Execute(CommandContext ctx)
|
public async Task Execute(CommandContext ctx)
|
||||||
|
|||||||
118
SkyBot/Commands/RP/Carry.cs
Normal file
118
SkyBot/Commands/RP/Carry.cs
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Text.Json;
|
||||||
|
using SkyBot.Helpers;
|
||||||
|
using SkyBot.Models;
|
||||||
|
using Valour.Sdk.Models;
|
||||||
|
using Valour.Shared.Models;
|
||||||
|
|
||||||
|
namespace SkyBot.Commands
|
||||||
|
{
|
||||||
|
public class Carry : ICommand
|
||||||
|
{
|
||||||
|
public string Name => "carry";
|
||||||
|
public string[] Aliases => [];
|
||||||
|
public string Description => "Carry someone with a random gif.";
|
||||||
|
public string Section => "RP";
|
||||||
|
public string Usage => "carry [@user]";
|
||||||
|
|
||||||
|
private static readonly HttpClient _http = new()
|
||||||
|
{
|
||||||
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
|
};
|
||||||
|
|
||||||
|
public async Task Execute(CommandContext ctx)
|
||||||
|
{
|
||||||
|
ConcurrentDictionary<long, Channel> channelCache = ctx.ChannelCache;
|
||||||
|
long channelId = ctx.ChannelId;
|
||||||
|
|
||||||
|
if (!channelCache.TryGetValue(channelId, out var channel)) return;
|
||||||
|
|
||||||
|
await channel.SendIsTyping();
|
||||||
|
|
||||||
|
string json;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
json = await _http.GetStringAsync("https://nekos.best/api/v2/carry");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not fetch a carry gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
using var doc = JsonDocument.Parse(json);
|
||||||
|
var results = doc.RootElement.GetProperty("results");
|
||||||
|
string gifUrl = results[0].GetProperty("url").GetString()!;
|
||||||
|
|
||||||
|
byte[] gifBytes;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
gifBytes = await _http.GetByteArrayAsync(gifUrl);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not download the carry gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int width = 0, height = 0;
|
||||||
|
if (gifBytes.Length >= 10)
|
||||||
|
{
|
||||||
|
width = gifBytes[6] | (gifBytes[7] << 8);
|
||||||
|
height = gifBytes[8] | (gifBytes[9] << 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
string cdnUrl;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var form = new MultipartFormDataContent();
|
||||||
|
using var fileContent = new ByteArrayContent(gifBytes);
|
||||||
|
fileContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("image/gif");
|
||||||
|
form.Add(fileContent, "file", "carry.gif");
|
||||||
|
|
||||||
|
var uploadResult = await ctx.Planet.Node.PostMultipartDataWithResponse<string>("upload/image", form);
|
||||||
|
if (!uploadResult.Success)
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not upload the carry gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cdnUrl = uploadResult.Data!;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not upload the carry gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string? target = null;
|
||||||
|
if (ctx.Message.ReplyToId is not null)
|
||||||
|
{
|
||||||
|
var replied = await ctx.Message.FetchReplyMessageAsync();
|
||||||
|
if (replied is not null)
|
||||||
|
{
|
||||||
|
var author = await replied.FetchAuthorAsync();
|
||||||
|
if (author is not null)
|
||||||
|
target = author.Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (target is null && ctx.Args.Length > 0)
|
||||||
|
target = string.Join(" ", ctx.Args);
|
||||||
|
|
||||||
|
string sender = ctx.Member.Nickname ?? ctx.Member.User?.Name ?? "Unknown";
|
||||||
|
string text = target is not null
|
||||||
|
? $"{sender} carries {target}!"
|
||||||
|
: $"{sender} wants to carry someone!";
|
||||||
|
|
||||||
|
var attachment = new MessageAttachment(MessageAttachmentType.Image)
|
||||||
|
{
|
||||||
|
Location = cdnUrl,
|
||||||
|
MimeType = "image/gif",
|
||||||
|
FileName = "carry.gif",
|
||||||
|
Width = width,
|
||||||
|
Height = height
|
||||||
|
};
|
||||||
|
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, text, [attachment]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
118
SkyBot/Commands/RP/Clap.cs
Normal file
118
SkyBot/Commands/RP/Clap.cs
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Text.Json;
|
||||||
|
using SkyBot.Helpers;
|
||||||
|
using SkyBot.Models;
|
||||||
|
using Valour.Sdk.Models;
|
||||||
|
using Valour.Shared.Models;
|
||||||
|
|
||||||
|
namespace SkyBot.Commands
|
||||||
|
{
|
||||||
|
public class Clap : ICommand
|
||||||
|
{
|
||||||
|
public string Name => "clap";
|
||||||
|
public string[] Aliases => [];
|
||||||
|
public string Description => "Clap with a random gif.";
|
||||||
|
public string Section => "RP";
|
||||||
|
public string Usage => "clap [@user]";
|
||||||
|
|
||||||
|
private static readonly HttpClient _http = new()
|
||||||
|
{
|
||||||
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
|
};
|
||||||
|
|
||||||
|
public async Task Execute(CommandContext ctx)
|
||||||
|
{
|
||||||
|
ConcurrentDictionary<long, Channel> channelCache = ctx.ChannelCache;
|
||||||
|
long channelId = ctx.ChannelId;
|
||||||
|
|
||||||
|
if (!channelCache.TryGetValue(channelId, out var channel)) return;
|
||||||
|
|
||||||
|
await channel.SendIsTyping();
|
||||||
|
|
||||||
|
string json;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
json = await _http.GetStringAsync("https://nekos.best/api/v2/clap");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not fetch a clap gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
using var doc = JsonDocument.Parse(json);
|
||||||
|
var results = doc.RootElement.GetProperty("results");
|
||||||
|
string gifUrl = results[0].GetProperty("url").GetString()!;
|
||||||
|
|
||||||
|
byte[] gifBytes;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
gifBytes = await _http.GetByteArrayAsync(gifUrl);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not download the clap gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int width = 0, height = 0;
|
||||||
|
if (gifBytes.Length >= 10)
|
||||||
|
{
|
||||||
|
width = gifBytes[6] | (gifBytes[7] << 8);
|
||||||
|
height = gifBytes[8] | (gifBytes[9] << 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
string cdnUrl;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var form = new MultipartFormDataContent();
|
||||||
|
using var fileContent = new ByteArrayContent(gifBytes);
|
||||||
|
fileContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("image/gif");
|
||||||
|
form.Add(fileContent, "file", "clap.gif");
|
||||||
|
|
||||||
|
var uploadResult = await ctx.Planet.Node.PostMultipartDataWithResponse<string>("upload/image", form);
|
||||||
|
if (!uploadResult.Success)
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not upload the clap gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cdnUrl = uploadResult.Data!;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not upload the clap gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string? target = null;
|
||||||
|
if (ctx.Message.ReplyToId is not null)
|
||||||
|
{
|
||||||
|
var replied = await ctx.Message.FetchReplyMessageAsync();
|
||||||
|
if (replied is not null)
|
||||||
|
{
|
||||||
|
var author = await replied.FetchAuthorAsync();
|
||||||
|
if (author is not null)
|
||||||
|
target = author.Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (target is null && ctx.Args.Length > 0)
|
||||||
|
target = string.Join(" ", ctx.Args);
|
||||||
|
|
||||||
|
string sender = ctx.Member.Nickname ?? ctx.Member.User?.Name ?? "Unknown";
|
||||||
|
string text = target is not null
|
||||||
|
? $"{sender} claps for {target}!"
|
||||||
|
: $"{sender} is clapping!";
|
||||||
|
|
||||||
|
var attachment = new MessageAttachment(MessageAttachmentType.Image)
|
||||||
|
{
|
||||||
|
Location = cdnUrl,
|
||||||
|
MimeType = "image/gif",
|
||||||
|
FileName = "clap.gif",
|
||||||
|
Width = width,
|
||||||
|
Height = height
|
||||||
|
};
|
||||||
|
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, text, [attachment]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ namespace SkyBot.Commands
|
|||||||
|
|
||||||
private static readonly HttpClient _http = new()
|
private static readonly HttpClient _http = new()
|
||||||
{
|
{
|
||||||
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0" } }
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
};
|
};
|
||||||
|
|
||||||
public async Task Execute(CommandContext ctx)
|
public async Task Execute(CommandContext ctx)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace SkyBot.Commands
|
|||||||
|
|
||||||
private static readonly HttpClient _http = new()
|
private static readonly HttpClient _http = new()
|
||||||
{
|
{
|
||||||
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0" } }
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
};
|
};
|
||||||
|
|
||||||
public async Task Execute(CommandContext ctx)
|
public async Task Execute(CommandContext ctx)
|
||||||
|
|||||||
118
SkyBot/Commands/RP/Dance.cs
Normal file
118
SkyBot/Commands/RP/Dance.cs
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Text.Json;
|
||||||
|
using SkyBot.Helpers;
|
||||||
|
using SkyBot.Models;
|
||||||
|
using Valour.Sdk.Models;
|
||||||
|
using Valour.Shared.Models;
|
||||||
|
|
||||||
|
namespace SkyBot.Commands
|
||||||
|
{
|
||||||
|
public class Dance : ICommand
|
||||||
|
{
|
||||||
|
public string Name => "dance";
|
||||||
|
public string[] Aliases => [];
|
||||||
|
public string Description => "Dance with a random gif.";
|
||||||
|
public string Section => "RP";
|
||||||
|
public string Usage => "dance [@user]";
|
||||||
|
|
||||||
|
private static readonly HttpClient _http = new()
|
||||||
|
{
|
||||||
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
|
};
|
||||||
|
|
||||||
|
public async Task Execute(CommandContext ctx)
|
||||||
|
{
|
||||||
|
ConcurrentDictionary<long, Channel> channelCache = ctx.ChannelCache;
|
||||||
|
long channelId = ctx.ChannelId;
|
||||||
|
|
||||||
|
if (!channelCache.TryGetValue(channelId, out var channel)) return;
|
||||||
|
|
||||||
|
await channel.SendIsTyping();
|
||||||
|
|
||||||
|
string json;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
json = await _http.GetStringAsync("https://nekos.best/api/v2/dance");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not fetch a dance gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
using var doc = JsonDocument.Parse(json);
|
||||||
|
var results = doc.RootElement.GetProperty("results");
|
||||||
|
string gifUrl = results[0].GetProperty("url").GetString()!;
|
||||||
|
|
||||||
|
byte[] gifBytes;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
gifBytes = await _http.GetByteArrayAsync(gifUrl);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not download the dance gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int width = 0, height = 0;
|
||||||
|
if (gifBytes.Length >= 10)
|
||||||
|
{
|
||||||
|
width = gifBytes[6] | (gifBytes[7] << 8);
|
||||||
|
height = gifBytes[8] | (gifBytes[9] << 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
string cdnUrl;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var form = new MultipartFormDataContent();
|
||||||
|
using var fileContent = new ByteArrayContent(gifBytes);
|
||||||
|
fileContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("image/gif");
|
||||||
|
form.Add(fileContent, "file", "dance.gif");
|
||||||
|
|
||||||
|
var uploadResult = await ctx.Planet.Node.PostMultipartDataWithResponse<string>("upload/image", form);
|
||||||
|
if (!uploadResult.Success)
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not upload the dance gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cdnUrl = uploadResult.Data!;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not upload the dance gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string? target = null;
|
||||||
|
if (ctx.Message.ReplyToId is not null)
|
||||||
|
{
|
||||||
|
var replied = await ctx.Message.FetchReplyMessageAsync();
|
||||||
|
if (replied is not null)
|
||||||
|
{
|
||||||
|
var author = await replied.FetchAuthorAsync();
|
||||||
|
if (author is not null)
|
||||||
|
target = author.Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (target is null && ctx.Args.Length > 0)
|
||||||
|
target = string.Join(" ", ctx.Args);
|
||||||
|
|
||||||
|
string sender = ctx.Member.Nickname ?? ctx.Member.User?.Name ?? "Unknown";
|
||||||
|
string text = target is not null
|
||||||
|
? $"{sender} dances with {target}!"
|
||||||
|
: $"{sender} is dancing!";
|
||||||
|
|
||||||
|
var attachment = new MessageAttachment(MessageAttachmentType.Image)
|
||||||
|
{
|
||||||
|
Location = cdnUrl,
|
||||||
|
MimeType = "image/gif",
|
||||||
|
FileName = "dance.gif",
|
||||||
|
Width = width,
|
||||||
|
Height = height
|
||||||
|
};
|
||||||
|
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, text, [attachment]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ namespace SkyBot.Commands
|
|||||||
|
|
||||||
private static readonly HttpClient _http = new()
|
private static readonly HttpClient _http = new()
|
||||||
{
|
{
|
||||||
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0" } }
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
};
|
};
|
||||||
|
|
||||||
public async Task Execute(CommandContext ctx)
|
public async Task Execute(CommandContext ctx)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace SkyBot.Commands
|
|||||||
|
|
||||||
private static readonly HttpClient _http = new()
|
private static readonly HttpClient _http = new()
|
||||||
{
|
{
|
||||||
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0" } }
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
};
|
};
|
||||||
|
|
||||||
public async Task Execute(CommandContext ctx)
|
public async Task Execute(CommandContext ctx)
|
||||||
|
|||||||
118
SkyBot/Commands/RP/Holdhand.cs
Normal file
118
SkyBot/Commands/RP/Holdhand.cs
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Text.Json;
|
||||||
|
using SkyBot.Helpers;
|
||||||
|
using SkyBot.Models;
|
||||||
|
using Valour.Sdk.Models;
|
||||||
|
using Valour.Shared.Models;
|
||||||
|
|
||||||
|
namespace SkyBot.Commands
|
||||||
|
{
|
||||||
|
public class Holdhand : ICommand
|
||||||
|
{
|
||||||
|
public string Name => "holdhand";
|
||||||
|
public string[] Aliases => [];
|
||||||
|
public string Description => "Hold hands with a random gif.";
|
||||||
|
public string Section => "RP";
|
||||||
|
public string Usage => "holdhand [@user]";
|
||||||
|
|
||||||
|
private static readonly HttpClient _http = new()
|
||||||
|
{
|
||||||
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
|
};
|
||||||
|
|
||||||
|
public async Task Execute(CommandContext ctx)
|
||||||
|
{
|
||||||
|
ConcurrentDictionary<long, Channel> channelCache = ctx.ChannelCache;
|
||||||
|
long channelId = ctx.ChannelId;
|
||||||
|
|
||||||
|
if (!channelCache.TryGetValue(channelId, out var channel)) return;
|
||||||
|
|
||||||
|
await channel.SendIsTyping();
|
||||||
|
|
||||||
|
string json;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
json = await _http.GetStringAsync("https://nekos.best/api/v2/handhold");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not fetch a handhold gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
using var doc = JsonDocument.Parse(json);
|
||||||
|
var results = doc.RootElement.GetProperty("results");
|
||||||
|
string gifUrl = results[0].GetProperty("url").GetString()!;
|
||||||
|
|
||||||
|
byte[] gifBytes;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
gifBytes = await _http.GetByteArrayAsync(gifUrl);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not download the handhold gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int width = 0, height = 0;
|
||||||
|
if (gifBytes.Length >= 10)
|
||||||
|
{
|
||||||
|
width = gifBytes[6] | (gifBytes[7] << 8);
|
||||||
|
height = gifBytes[8] | (gifBytes[9] << 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
string cdnUrl;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var form = new MultipartFormDataContent();
|
||||||
|
using var fileContent = new ByteArrayContent(gifBytes);
|
||||||
|
fileContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("image/gif");
|
||||||
|
form.Add(fileContent, "file", "handhold.gif");
|
||||||
|
|
||||||
|
var uploadResult = await ctx.Planet.Node.PostMultipartDataWithResponse<string>("upload/image", form);
|
||||||
|
if (!uploadResult.Success)
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not upload the handhold gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cdnUrl = uploadResult.Data!;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not upload the handhold gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string? target = null;
|
||||||
|
if (ctx.Message.ReplyToId is not null)
|
||||||
|
{
|
||||||
|
var replied = await ctx.Message.FetchReplyMessageAsync();
|
||||||
|
if (replied is not null)
|
||||||
|
{
|
||||||
|
var author = await replied.FetchAuthorAsync();
|
||||||
|
if (author is not null)
|
||||||
|
target = author.Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (target is null && ctx.Args.Length > 0)
|
||||||
|
target = string.Join(" ", ctx.Args);
|
||||||
|
|
||||||
|
string sender = ctx.Member.Nickname ?? ctx.Member.User?.Name ?? "Unknown";
|
||||||
|
string text = target is not null
|
||||||
|
? $"{sender} holds hands with {target}!"
|
||||||
|
: $"{sender} wants to hold hands!";
|
||||||
|
|
||||||
|
var attachment = new MessageAttachment(MessageAttachmentType.Image)
|
||||||
|
{
|
||||||
|
Location = cdnUrl,
|
||||||
|
MimeType = "image/gif",
|
||||||
|
FileName = "handhold.gif",
|
||||||
|
Width = width,
|
||||||
|
Height = height
|
||||||
|
};
|
||||||
|
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, text, [attachment]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ namespace SkyBot.Commands
|
|||||||
|
|
||||||
private static readonly HttpClient _http = new()
|
private static readonly HttpClient _http = new()
|
||||||
{
|
{
|
||||||
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0" } }
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
};
|
};
|
||||||
|
|
||||||
public async Task Execute(CommandContext ctx)
|
public async Task Execute(CommandContext ctx)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace SkyBot.Commands
|
|||||||
|
|
||||||
private static readonly HttpClient _http = new()
|
private static readonly HttpClient _http = new()
|
||||||
{
|
{
|
||||||
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0" } }
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
};
|
};
|
||||||
|
|
||||||
public async Task Execute(CommandContext ctx)
|
public async Task Execute(CommandContext ctx)
|
||||||
|
|||||||
118
SkyBot/Commands/RP/Laugh.cs
Normal file
118
SkyBot/Commands/RP/Laugh.cs
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Text.Json;
|
||||||
|
using SkyBot.Helpers;
|
||||||
|
using SkyBot.Models;
|
||||||
|
using Valour.Sdk.Models;
|
||||||
|
using Valour.Shared.Models;
|
||||||
|
|
||||||
|
namespace SkyBot.Commands
|
||||||
|
{
|
||||||
|
public class Laugh : ICommand
|
||||||
|
{
|
||||||
|
public string Name => "laugh";
|
||||||
|
public string[] Aliases => [];
|
||||||
|
public string Description => "Laugh with a random gif.";
|
||||||
|
public string Section => "RP";
|
||||||
|
public string Usage => "laugh [@user]";
|
||||||
|
|
||||||
|
private static readonly HttpClient _http = new()
|
||||||
|
{
|
||||||
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
|
};
|
||||||
|
|
||||||
|
public async Task Execute(CommandContext ctx)
|
||||||
|
{
|
||||||
|
ConcurrentDictionary<long, Channel> channelCache = ctx.ChannelCache;
|
||||||
|
long channelId = ctx.ChannelId;
|
||||||
|
|
||||||
|
if (!channelCache.TryGetValue(channelId, out var channel)) return;
|
||||||
|
|
||||||
|
await channel.SendIsTyping();
|
||||||
|
|
||||||
|
string json;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
json = await _http.GetStringAsync("https://nekos.best/api/v2/laugh");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not fetch a laugh gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
using var doc = JsonDocument.Parse(json);
|
||||||
|
var results = doc.RootElement.GetProperty("results");
|
||||||
|
string gifUrl = results[0].GetProperty("url").GetString()!;
|
||||||
|
|
||||||
|
byte[] gifBytes;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
gifBytes = await _http.GetByteArrayAsync(gifUrl);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not download the laugh gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int width = 0, height = 0;
|
||||||
|
if (gifBytes.Length >= 10)
|
||||||
|
{
|
||||||
|
width = gifBytes[6] | (gifBytes[7] << 8);
|
||||||
|
height = gifBytes[8] | (gifBytes[9] << 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
string cdnUrl;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var form = new MultipartFormDataContent();
|
||||||
|
using var fileContent = new ByteArrayContent(gifBytes);
|
||||||
|
fileContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("image/gif");
|
||||||
|
form.Add(fileContent, "file", "laugh.gif");
|
||||||
|
|
||||||
|
var uploadResult = await ctx.Planet.Node.PostMultipartDataWithResponse<string>("upload/image", form);
|
||||||
|
if (!uploadResult.Success)
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not upload the laugh gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cdnUrl = uploadResult.Data!;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not upload the laugh gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string? target = null;
|
||||||
|
if (ctx.Message.ReplyToId is not null)
|
||||||
|
{
|
||||||
|
var replied = await ctx.Message.FetchReplyMessageAsync();
|
||||||
|
if (replied is not null)
|
||||||
|
{
|
||||||
|
var author = await replied.FetchAuthorAsync();
|
||||||
|
if (author is not null)
|
||||||
|
target = author.Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (target is null && ctx.Args.Length > 0)
|
||||||
|
target = string.Join(" ", ctx.Args);
|
||||||
|
|
||||||
|
string sender = ctx.Member.Nickname ?? ctx.Member.User?.Name ?? "Unknown";
|
||||||
|
string text = target is not null
|
||||||
|
? $"{sender} laughs at {target}!"
|
||||||
|
: $"{sender} is laughing!";
|
||||||
|
|
||||||
|
var attachment = new MessageAttachment(MessageAttachmentType.Image)
|
||||||
|
{
|
||||||
|
Location = cdnUrl,
|
||||||
|
MimeType = "image/gif",
|
||||||
|
FileName = "laugh.gif",
|
||||||
|
Width = width,
|
||||||
|
Height = height
|
||||||
|
};
|
||||||
|
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, text, [attachment]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ namespace SkyBot.Commands
|
|||||||
|
|
||||||
private static readonly HttpClient _http = new()
|
private static readonly HttpClient _http = new()
|
||||||
{
|
{
|
||||||
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0" } }
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
};
|
};
|
||||||
|
|
||||||
public async Task Execute(CommandContext ctx)
|
public async Task Execute(CommandContext ctx)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace SkyBot.Commands
|
|||||||
|
|
||||||
private static readonly HttpClient _http = new()
|
private static readonly HttpClient _http = new()
|
||||||
{
|
{
|
||||||
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0" } }
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
};
|
};
|
||||||
|
|
||||||
public async Task Execute(CommandContext ctx)
|
public async Task Execute(CommandContext ctx)
|
||||||
|
|||||||
118
SkyBot/Commands/RP/Nya.cs
Normal file
118
SkyBot/Commands/RP/Nya.cs
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Text.Json;
|
||||||
|
using SkyBot.Helpers;
|
||||||
|
using SkyBot.Models;
|
||||||
|
using Valour.Sdk.Models;
|
||||||
|
using Valour.Shared.Models;
|
||||||
|
|
||||||
|
namespace SkyBot.Commands
|
||||||
|
{
|
||||||
|
public class Nya : ICommand
|
||||||
|
{
|
||||||
|
public string Name => "nya";
|
||||||
|
public string[] Aliases => [];
|
||||||
|
public string Description => "Nya with a random gif.";
|
||||||
|
public string Section => "RP";
|
||||||
|
public string Usage => "nya [@user]";
|
||||||
|
|
||||||
|
private static readonly HttpClient _http = new()
|
||||||
|
{
|
||||||
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
|
};
|
||||||
|
|
||||||
|
public async Task Execute(CommandContext ctx)
|
||||||
|
{
|
||||||
|
ConcurrentDictionary<long, Channel> channelCache = ctx.ChannelCache;
|
||||||
|
long channelId = ctx.ChannelId;
|
||||||
|
|
||||||
|
if (!channelCache.TryGetValue(channelId, out var channel)) return;
|
||||||
|
|
||||||
|
await channel.SendIsTyping();
|
||||||
|
|
||||||
|
string json;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
json = await _http.GetStringAsync("https://nekos.best/api/v2/nya");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not fetch a nya gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
using var doc = JsonDocument.Parse(json);
|
||||||
|
var results = doc.RootElement.GetProperty("results");
|
||||||
|
string gifUrl = results[0].GetProperty("url").GetString()!;
|
||||||
|
|
||||||
|
byte[] gifBytes;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
gifBytes = await _http.GetByteArrayAsync(gifUrl);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not download the nya gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int width = 0, height = 0;
|
||||||
|
if (gifBytes.Length >= 10)
|
||||||
|
{
|
||||||
|
width = gifBytes[6] | (gifBytes[7] << 8);
|
||||||
|
height = gifBytes[8] | (gifBytes[9] << 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
string cdnUrl;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var form = new MultipartFormDataContent();
|
||||||
|
using var fileContent = new ByteArrayContent(gifBytes);
|
||||||
|
fileContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("image/gif");
|
||||||
|
form.Add(fileContent, "file", "nya.gif");
|
||||||
|
|
||||||
|
var uploadResult = await ctx.Planet.Node.PostMultipartDataWithResponse<string>("upload/image", form);
|
||||||
|
if (!uploadResult.Success)
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not upload the nya gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cdnUrl = uploadResult.Data!;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not upload the nya gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string? target = null;
|
||||||
|
if (ctx.Message.ReplyToId is not null)
|
||||||
|
{
|
||||||
|
var replied = await ctx.Message.FetchReplyMessageAsync();
|
||||||
|
if (replied is not null)
|
||||||
|
{
|
||||||
|
var author = await replied.FetchAuthorAsync();
|
||||||
|
if (author is not null)
|
||||||
|
target = author.Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (target is null && ctx.Args.Length > 0)
|
||||||
|
target = string.Join(" ", ctx.Args);
|
||||||
|
|
||||||
|
string sender = ctx.Member.Nickname ?? ctx.Member.User?.Name ?? "Unknown";
|
||||||
|
string text = target is not null
|
||||||
|
? $"{sender} nyas at {target}!"
|
||||||
|
: $"{sender} nyas!";
|
||||||
|
|
||||||
|
var attachment = new MessageAttachment(MessageAttachmentType.Image)
|
||||||
|
{
|
||||||
|
Location = cdnUrl,
|
||||||
|
MimeType = "image/gif",
|
||||||
|
FileName = "nya.gif",
|
||||||
|
Width = width,
|
||||||
|
Height = height
|
||||||
|
};
|
||||||
|
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, text, [attachment]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ namespace SkyBot.Commands
|
|||||||
|
|
||||||
private static readonly HttpClient _http = new()
|
private static readonly HttpClient _http = new()
|
||||||
{
|
{
|
||||||
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0" } }
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
};
|
};
|
||||||
|
|
||||||
public async Task Execute(CommandContext ctx)
|
public async Task Execute(CommandContext ctx)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace SkyBot.Commands
|
|||||||
|
|
||||||
private static readonly HttpClient _http = new()
|
private static readonly HttpClient _http = new()
|
||||||
{
|
{
|
||||||
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0" } }
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
};
|
};
|
||||||
|
|
||||||
public async Task Execute(CommandContext ctx)
|
public async Task Execute(CommandContext ctx)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace SkyBot.Commands
|
|||||||
|
|
||||||
private static readonly HttpClient _http = new()
|
private static readonly HttpClient _http = new()
|
||||||
{
|
{
|
||||||
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0" } }
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
};
|
};
|
||||||
|
|
||||||
public async Task Execute(CommandContext ctx)
|
public async Task Execute(CommandContext ctx)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace SkyBot.Commands
|
|||||||
|
|
||||||
private static readonly HttpClient _http = new()
|
private static readonly HttpClient _http = new()
|
||||||
{
|
{
|
||||||
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0" } }
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
};
|
};
|
||||||
|
|
||||||
public async Task Execute(CommandContext ctx)
|
public async Task Execute(CommandContext ctx)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace SkyBot.Commands
|
|||||||
|
|
||||||
private static readonly HttpClient _http = new()
|
private static readonly HttpClient _http = new()
|
||||||
{
|
{
|
||||||
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0" } }
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
};
|
};
|
||||||
|
|
||||||
public async Task Execute(CommandContext ctx)
|
public async Task Execute(CommandContext ctx)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace SkyBot.Commands
|
|||||||
|
|
||||||
private static readonly HttpClient _http = new()
|
private static readonly HttpClient _http = new()
|
||||||
{
|
{
|
||||||
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0" } }
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
};
|
};
|
||||||
|
|
||||||
public async Task Execute(CommandContext ctx)
|
public async Task Execute(CommandContext ctx)
|
||||||
|
|||||||
118
SkyBot/Commands/RP/Sleep.cs
Normal file
118
SkyBot/Commands/RP/Sleep.cs
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Text.Json;
|
||||||
|
using SkyBot.Helpers;
|
||||||
|
using SkyBot.Models;
|
||||||
|
using Valour.Sdk.Models;
|
||||||
|
using Valour.Shared.Models;
|
||||||
|
|
||||||
|
namespace SkyBot.Commands
|
||||||
|
{
|
||||||
|
public class Sleep : ICommand
|
||||||
|
{
|
||||||
|
public string Name => "sleep";
|
||||||
|
public string[] Aliases => ["eep"];
|
||||||
|
public string Description => "Sleep with a random gif.";
|
||||||
|
public string Section => "RP";
|
||||||
|
public string Usage => "sleep [@user]";
|
||||||
|
|
||||||
|
private static readonly HttpClient _http = new()
|
||||||
|
{
|
||||||
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
|
};
|
||||||
|
|
||||||
|
public async Task Execute(CommandContext ctx)
|
||||||
|
{
|
||||||
|
ConcurrentDictionary<long, Channel> channelCache = ctx.ChannelCache;
|
||||||
|
long channelId = ctx.ChannelId;
|
||||||
|
|
||||||
|
if (!channelCache.TryGetValue(channelId, out var channel)) return;
|
||||||
|
|
||||||
|
await channel.SendIsTyping();
|
||||||
|
|
||||||
|
string json;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
json = await _http.GetStringAsync("https://nekos.best/api/v2/sleep");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not fetch a sleep gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
using var doc = JsonDocument.Parse(json);
|
||||||
|
var results = doc.RootElement.GetProperty("results");
|
||||||
|
string gifUrl = results[0].GetProperty("url").GetString()!;
|
||||||
|
|
||||||
|
byte[] gifBytes;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
gifBytes = await _http.GetByteArrayAsync(gifUrl);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not download the sleep gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int width = 0, height = 0;
|
||||||
|
if (gifBytes.Length >= 10)
|
||||||
|
{
|
||||||
|
width = gifBytes[6] | (gifBytes[7] << 8);
|
||||||
|
height = gifBytes[8] | (gifBytes[9] << 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
string cdnUrl;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var form = new MultipartFormDataContent();
|
||||||
|
using var fileContent = new ByteArrayContent(gifBytes);
|
||||||
|
fileContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("image/gif");
|
||||||
|
form.Add(fileContent, "file", "sleep.gif");
|
||||||
|
|
||||||
|
var uploadResult = await ctx.Planet.Node.PostMultipartDataWithResponse<string>("upload/image", form);
|
||||||
|
if (!uploadResult.Success)
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not upload the sleep gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cdnUrl = uploadResult.Data!;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not upload the sleep gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string? target = null;
|
||||||
|
if (ctx.Message.ReplyToId is not null)
|
||||||
|
{
|
||||||
|
var replied = await ctx.Message.FetchReplyMessageAsync();
|
||||||
|
if (replied is not null)
|
||||||
|
{
|
||||||
|
var author = await replied.FetchAuthorAsync();
|
||||||
|
if (author is not null)
|
||||||
|
target = author.Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (target is null && ctx.Args.Length > 0)
|
||||||
|
target = string.Join(" ", ctx.Args);
|
||||||
|
|
||||||
|
string sender = ctx.Member.Nickname ?? ctx.Member.User?.Name ?? "Unknown";
|
||||||
|
string text = target is not null
|
||||||
|
? $"{sender} falls asleep on {target}!"
|
||||||
|
: $"{sender} is sleeping! zzz...";
|
||||||
|
|
||||||
|
var attachment = new MessageAttachment(MessageAttachmentType.Image)
|
||||||
|
{
|
||||||
|
Location = cdnUrl,
|
||||||
|
MimeType = "image/gif",
|
||||||
|
FileName = "sleep.gif",
|
||||||
|
Width = width,
|
||||||
|
Height = height
|
||||||
|
};
|
||||||
|
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, text, [attachment]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ namespace SkyBot.Commands
|
|||||||
|
|
||||||
private static readonly HttpClient _http = new()
|
private static readonly HttpClient _http = new()
|
||||||
{
|
{
|
||||||
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0" } }
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
};
|
};
|
||||||
|
|
||||||
public async Task Execute(CommandContext ctx)
|
public async Task Execute(CommandContext ctx)
|
||||||
|
|||||||
118
SkyBot/Commands/RP/Spin.cs
Normal file
118
SkyBot/Commands/RP/Spin.cs
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Text.Json;
|
||||||
|
using SkyBot.Helpers;
|
||||||
|
using SkyBot.Models;
|
||||||
|
using Valour.Sdk.Models;
|
||||||
|
using Valour.Shared.Models;
|
||||||
|
|
||||||
|
namespace SkyBot.Commands
|
||||||
|
{
|
||||||
|
public class Spin : ICommand
|
||||||
|
{
|
||||||
|
public string Name => "spin";
|
||||||
|
public string[] Aliases => [];
|
||||||
|
public string Description => "Spin with a random gif.";
|
||||||
|
public string Section => "RP";
|
||||||
|
public string Usage => "spin [@user]";
|
||||||
|
|
||||||
|
private static readonly HttpClient _http = new()
|
||||||
|
{
|
||||||
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
|
};
|
||||||
|
|
||||||
|
public async Task Execute(CommandContext ctx)
|
||||||
|
{
|
||||||
|
ConcurrentDictionary<long, Channel> channelCache = ctx.ChannelCache;
|
||||||
|
long channelId = ctx.ChannelId;
|
||||||
|
|
||||||
|
if (!channelCache.TryGetValue(channelId, out var channel)) return;
|
||||||
|
|
||||||
|
await channel.SendIsTyping();
|
||||||
|
|
||||||
|
string json;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
json = await _http.GetStringAsync("https://nekos.best/api/v2/spin");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not fetch a spin gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
using var doc = JsonDocument.Parse(json);
|
||||||
|
var results = doc.RootElement.GetProperty("results");
|
||||||
|
string gifUrl = results[0].GetProperty("url").GetString()!;
|
||||||
|
|
||||||
|
byte[] gifBytes;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
gifBytes = await _http.GetByteArrayAsync(gifUrl);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not download the spin gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int width = 0, height = 0;
|
||||||
|
if (gifBytes.Length >= 10)
|
||||||
|
{
|
||||||
|
width = gifBytes[6] | (gifBytes[7] << 8);
|
||||||
|
height = gifBytes[8] | (gifBytes[9] << 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
string cdnUrl;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var form = new MultipartFormDataContent();
|
||||||
|
using var fileContent = new ByteArrayContent(gifBytes);
|
||||||
|
fileContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("image/gif");
|
||||||
|
form.Add(fileContent, "file", "spin.gif");
|
||||||
|
|
||||||
|
var uploadResult = await ctx.Planet.Node.PostMultipartDataWithResponse<string>("upload/image", form);
|
||||||
|
if (!uploadResult.Success)
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not upload the spin gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cdnUrl = uploadResult.Data!;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not upload the spin gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string? target = null;
|
||||||
|
if (ctx.Message.ReplyToId is not null)
|
||||||
|
{
|
||||||
|
var replied = await ctx.Message.FetchReplyMessageAsync();
|
||||||
|
if (replied is not null)
|
||||||
|
{
|
||||||
|
var author = await replied.FetchAuthorAsync();
|
||||||
|
if (author is not null)
|
||||||
|
target = author.Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (target is null && ctx.Args.Length > 0)
|
||||||
|
target = string.Join(" ", ctx.Args);
|
||||||
|
|
||||||
|
string sender = ctx.Member.Nickname ?? ctx.Member.User?.Name ?? "Unknown";
|
||||||
|
string text = target is not null
|
||||||
|
? $"{sender} spins {target} around!"
|
||||||
|
: $"{sender} is spinning!";
|
||||||
|
|
||||||
|
var attachment = new MessageAttachment(MessageAttachmentType.Image)
|
||||||
|
{
|
||||||
|
Location = cdnUrl,
|
||||||
|
MimeType = "image/gif",
|
||||||
|
FileName = "spin.gif",
|
||||||
|
Width = width,
|
||||||
|
Height = height
|
||||||
|
};
|
||||||
|
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, text, [attachment]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
118
SkyBot/Commands/RP/Tableflip.cs
Normal file
118
SkyBot/Commands/RP/Tableflip.cs
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Text.Json;
|
||||||
|
using SkyBot.Helpers;
|
||||||
|
using SkyBot.Models;
|
||||||
|
using Valour.Sdk.Models;
|
||||||
|
using Valour.Shared.Models;
|
||||||
|
|
||||||
|
namespace SkyBot.Commands
|
||||||
|
{
|
||||||
|
public class Tableflip : ICommand
|
||||||
|
{
|
||||||
|
public string Name => "tableflip";
|
||||||
|
public string[] Aliases => [];
|
||||||
|
public string Description => "Flip a table with a random gif.";
|
||||||
|
public string Section => "RP";
|
||||||
|
public string Usage => "tableflip [@user]";
|
||||||
|
|
||||||
|
private static readonly HttpClient _http = new()
|
||||||
|
{
|
||||||
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
|
};
|
||||||
|
|
||||||
|
public async Task Execute(CommandContext ctx)
|
||||||
|
{
|
||||||
|
ConcurrentDictionary<long, Channel> channelCache = ctx.ChannelCache;
|
||||||
|
long channelId = ctx.ChannelId;
|
||||||
|
|
||||||
|
if (!channelCache.TryGetValue(channelId, out var channel)) return;
|
||||||
|
|
||||||
|
await channel.SendIsTyping();
|
||||||
|
|
||||||
|
string json;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
json = await _http.GetStringAsync("https://nekos.best/api/v2/tableflip");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not fetch a tableflip gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
using var doc = JsonDocument.Parse(json);
|
||||||
|
var results = doc.RootElement.GetProperty("results");
|
||||||
|
string gifUrl = results[0].GetProperty("url").GetString()!;
|
||||||
|
|
||||||
|
byte[] gifBytes;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
gifBytes = await _http.GetByteArrayAsync(gifUrl);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not download the tableflip gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int width = 0, height = 0;
|
||||||
|
if (gifBytes.Length >= 10)
|
||||||
|
{
|
||||||
|
width = gifBytes[6] | (gifBytes[7] << 8);
|
||||||
|
height = gifBytes[8] | (gifBytes[9] << 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
string cdnUrl;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var form = new MultipartFormDataContent();
|
||||||
|
using var fileContent = new ByteArrayContent(gifBytes);
|
||||||
|
fileContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("image/gif");
|
||||||
|
form.Add(fileContent, "file", "tableflip.gif");
|
||||||
|
|
||||||
|
var uploadResult = await ctx.Planet.Node.PostMultipartDataWithResponse<string>("upload/image", form);
|
||||||
|
if (!uploadResult.Success)
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not upload the tableflip gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cdnUrl = uploadResult.Data!;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not upload the tableflip gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string? target = null;
|
||||||
|
if (ctx.Message.ReplyToId is not null)
|
||||||
|
{
|
||||||
|
var replied = await ctx.Message.FetchReplyMessageAsync();
|
||||||
|
if (replied is not null)
|
||||||
|
{
|
||||||
|
var author = await replied.FetchAuthorAsync();
|
||||||
|
if (author is not null)
|
||||||
|
target = author.Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (target is null && ctx.Args.Length > 0)
|
||||||
|
target = string.Join(" ", ctx.Args);
|
||||||
|
|
||||||
|
string sender = ctx.Member.Nickname ?? ctx.Member.User?.Name ?? "Unknown";
|
||||||
|
string text = target is not null
|
||||||
|
? $"{sender} flips the table at {target}! (╯°□°)╯︵ ┻━┻"
|
||||||
|
: $"{sender} flips the table! (╯°□°)╯︵ ┻━┻";
|
||||||
|
|
||||||
|
var attachment = new MessageAttachment(MessageAttachmentType.Image)
|
||||||
|
{
|
||||||
|
Location = cdnUrl,
|
||||||
|
MimeType = "image/gif",
|
||||||
|
FileName = "tableflip.gif",
|
||||||
|
Width = width,
|
||||||
|
Height = height
|
||||||
|
};
|
||||||
|
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, text, [attachment]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
118
SkyBot/Commands/RP/Teehee.cs
Normal file
118
SkyBot/Commands/RP/Teehee.cs
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Text.Json;
|
||||||
|
using SkyBot.Helpers;
|
||||||
|
using SkyBot.Models;
|
||||||
|
using Valour.Sdk.Models;
|
||||||
|
using Valour.Shared.Models;
|
||||||
|
|
||||||
|
namespace SkyBot.Commands
|
||||||
|
{
|
||||||
|
public class Teehee : ICommand
|
||||||
|
{
|
||||||
|
public string Name => "teehee";
|
||||||
|
public string[] Aliases => ["hehe"];
|
||||||
|
public string Description => "Teehee with a random gif.";
|
||||||
|
public string Section => "RP";
|
||||||
|
public string Usage => "teehee [@user]";
|
||||||
|
|
||||||
|
private static readonly HttpClient _http = new()
|
||||||
|
{
|
||||||
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
|
};
|
||||||
|
|
||||||
|
public async Task Execute(CommandContext ctx)
|
||||||
|
{
|
||||||
|
ConcurrentDictionary<long, Channel> channelCache = ctx.ChannelCache;
|
||||||
|
long channelId = ctx.ChannelId;
|
||||||
|
|
||||||
|
if (!channelCache.TryGetValue(channelId, out var channel)) return;
|
||||||
|
|
||||||
|
await channel.SendIsTyping();
|
||||||
|
|
||||||
|
string json;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
json = await _http.GetStringAsync("https://nekos.best/api/v2/teehee");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not fetch a teehee gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
using var doc = JsonDocument.Parse(json);
|
||||||
|
var results = doc.RootElement.GetProperty("results");
|
||||||
|
string gifUrl = results[0].GetProperty("url").GetString()!;
|
||||||
|
|
||||||
|
byte[] gifBytes;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
gifBytes = await _http.GetByteArrayAsync(gifUrl);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not download the teehee gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int width = 0, height = 0;
|
||||||
|
if (gifBytes.Length >= 10)
|
||||||
|
{
|
||||||
|
width = gifBytes[6] | (gifBytes[7] << 8);
|
||||||
|
height = gifBytes[8] | (gifBytes[9] << 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
string cdnUrl;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var form = new MultipartFormDataContent();
|
||||||
|
using var fileContent = new ByteArrayContent(gifBytes);
|
||||||
|
fileContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("image/gif");
|
||||||
|
form.Add(fileContent, "file", "teehee.gif");
|
||||||
|
|
||||||
|
var uploadResult = await ctx.Planet.Node.PostMultipartDataWithResponse<string>("upload/image", form);
|
||||||
|
if (!uploadResult.Success)
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not upload the teehee gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cdnUrl = uploadResult.Data!;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not upload the teehee gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string? target = null;
|
||||||
|
if (ctx.Message.ReplyToId is not null)
|
||||||
|
{
|
||||||
|
var replied = await ctx.Message.FetchReplyMessageAsync();
|
||||||
|
if (replied is not null)
|
||||||
|
{
|
||||||
|
var author = await replied.FetchAuthorAsync();
|
||||||
|
if (author is not null)
|
||||||
|
target = author.Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (target is null && ctx.Args.Length > 0)
|
||||||
|
target = string.Join(" ", ctx.Args);
|
||||||
|
|
||||||
|
string sender = ctx.Member.Nickname ?? ctx.Member.User?.Name ?? "Unknown";
|
||||||
|
string text = target is not null
|
||||||
|
? $"{sender} teehees at {target}!"
|
||||||
|
: $"{sender} teehees~";
|
||||||
|
|
||||||
|
var attachment = new MessageAttachment(MessageAttachmentType.Image)
|
||||||
|
{
|
||||||
|
Location = cdnUrl,
|
||||||
|
MimeType = "image/gif",
|
||||||
|
FileName = "teehee.gif",
|
||||||
|
Width = width,
|
||||||
|
Height = height
|
||||||
|
};
|
||||||
|
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, text, [attachment]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ namespace SkyBot.Commands
|
|||||||
|
|
||||||
private static readonly HttpClient _http = new()
|
private static readonly HttpClient _http = new()
|
||||||
{
|
{
|
||||||
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0" } }
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
};
|
};
|
||||||
|
|
||||||
public async Task Execute(CommandContext ctx)
|
public async Task Execute(CommandContext ctx)
|
||||||
|
|||||||
118
SkyBot/Commands/RP/Wave.cs
Normal file
118
SkyBot/Commands/RP/Wave.cs
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Text.Json;
|
||||||
|
using SkyBot.Helpers;
|
||||||
|
using SkyBot.Models;
|
||||||
|
using Valour.Sdk.Models;
|
||||||
|
using Valour.Shared.Models;
|
||||||
|
|
||||||
|
namespace SkyBot.Commands
|
||||||
|
{
|
||||||
|
public class Wave : ICommand
|
||||||
|
{
|
||||||
|
public string Name => "wave";
|
||||||
|
public string[] Aliases => [];
|
||||||
|
public string Description => "Wave with a random gif.";
|
||||||
|
public string Section => "RP";
|
||||||
|
public string Usage => "wave [@user]";
|
||||||
|
|
||||||
|
private static readonly HttpClient _http = new()
|
||||||
|
{
|
||||||
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
|
};
|
||||||
|
|
||||||
|
public async Task Execute(CommandContext ctx)
|
||||||
|
{
|
||||||
|
ConcurrentDictionary<long, Channel> channelCache = ctx.ChannelCache;
|
||||||
|
long channelId = ctx.ChannelId;
|
||||||
|
|
||||||
|
if (!channelCache.TryGetValue(channelId, out var channel)) return;
|
||||||
|
|
||||||
|
await channel.SendIsTyping();
|
||||||
|
|
||||||
|
string json;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
json = await _http.GetStringAsync("https://nekos.best/api/v2/wave");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not fetch a wave gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
using var doc = JsonDocument.Parse(json);
|
||||||
|
var results = doc.RootElement.GetProperty("results");
|
||||||
|
string gifUrl = results[0].GetProperty("url").GetString()!;
|
||||||
|
|
||||||
|
byte[] gifBytes;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
gifBytes = await _http.GetByteArrayAsync(gifUrl);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not download the wave gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int width = 0, height = 0;
|
||||||
|
if (gifBytes.Length >= 10)
|
||||||
|
{
|
||||||
|
width = gifBytes[6] | (gifBytes[7] << 8);
|
||||||
|
height = gifBytes[8] | (gifBytes[9] << 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
string cdnUrl;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var form = new MultipartFormDataContent();
|
||||||
|
using var fileContent = new ByteArrayContent(gifBytes);
|
||||||
|
fileContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("image/gif");
|
||||||
|
form.Add(fileContent, "file", "wave.gif");
|
||||||
|
|
||||||
|
var uploadResult = await ctx.Planet.Node.PostMultipartDataWithResponse<string>("upload/image", form);
|
||||||
|
if (!uploadResult.Success)
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not upload the wave gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cdnUrl = uploadResult.Data!;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not upload the wave gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string? target = null;
|
||||||
|
if (ctx.Message.ReplyToId is not null)
|
||||||
|
{
|
||||||
|
var replied = await ctx.Message.FetchReplyMessageAsync();
|
||||||
|
if (replied is not null)
|
||||||
|
{
|
||||||
|
var author = await replied.FetchAuthorAsync();
|
||||||
|
if (author is not null)
|
||||||
|
target = author.Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (target is null && ctx.Args.Length > 0)
|
||||||
|
target = string.Join(" ", ctx.Args);
|
||||||
|
|
||||||
|
string sender = ctx.Member.Nickname ?? ctx.Member.User?.Name ?? "Unknown";
|
||||||
|
string text = target is not null
|
||||||
|
? $"{sender} waves at {target}!"
|
||||||
|
: $"{sender} waves!";
|
||||||
|
|
||||||
|
var attachment = new MessageAttachment(MessageAttachmentType.Image)
|
||||||
|
{
|
||||||
|
Location = cdnUrl,
|
||||||
|
MimeType = "image/gif",
|
||||||
|
FileName = "wave.gif",
|
||||||
|
Width = width,
|
||||||
|
Height = height
|
||||||
|
};
|
||||||
|
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, text, [attachment]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
118
SkyBot/Commands/RP/Wink.cs
Normal file
118
SkyBot/Commands/RP/Wink.cs
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Text.Json;
|
||||||
|
using SkyBot.Helpers;
|
||||||
|
using SkyBot.Models;
|
||||||
|
using Valour.Sdk.Models;
|
||||||
|
using Valour.Shared.Models;
|
||||||
|
|
||||||
|
namespace SkyBot.Commands
|
||||||
|
{
|
||||||
|
public class Wink : ICommand
|
||||||
|
{
|
||||||
|
public string Name => "wink";
|
||||||
|
public string[] Aliases => [];
|
||||||
|
public string Description => "Wink with a random gif.";
|
||||||
|
public string Section => "RP";
|
||||||
|
public string Usage => "wink [@user]";
|
||||||
|
|
||||||
|
private static readonly HttpClient _http = new()
|
||||||
|
{
|
||||||
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
|
};
|
||||||
|
|
||||||
|
public async Task Execute(CommandContext ctx)
|
||||||
|
{
|
||||||
|
ConcurrentDictionary<long, Channel> channelCache = ctx.ChannelCache;
|
||||||
|
long channelId = ctx.ChannelId;
|
||||||
|
|
||||||
|
if (!channelCache.TryGetValue(channelId, out var channel)) return;
|
||||||
|
|
||||||
|
await channel.SendIsTyping();
|
||||||
|
|
||||||
|
string json;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
json = await _http.GetStringAsync("https://nekos.best/api/v2/wink");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not fetch a wink gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
using var doc = JsonDocument.Parse(json);
|
||||||
|
var results = doc.RootElement.GetProperty("results");
|
||||||
|
string gifUrl = results[0].GetProperty("url").GetString()!;
|
||||||
|
|
||||||
|
byte[] gifBytes;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
gifBytes = await _http.GetByteArrayAsync(gifUrl);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not download the wink gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int width = 0, height = 0;
|
||||||
|
if (gifBytes.Length >= 10)
|
||||||
|
{
|
||||||
|
width = gifBytes[6] | (gifBytes[7] << 8);
|
||||||
|
height = gifBytes[8] | (gifBytes[9] << 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
string cdnUrl;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var form = new MultipartFormDataContent();
|
||||||
|
using var fileContent = new ByteArrayContent(gifBytes);
|
||||||
|
fileContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("image/gif");
|
||||||
|
form.Add(fileContent, "file", "wink.gif");
|
||||||
|
|
||||||
|
var uploadResult = await ctx.Planet.Node.PostMultipartDataWithResponse<string>("upload/image", form);
|
||||||
|
if (!uploadResult.Success)
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not upload the wink gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cdnUrl = uploadResult.Data!;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, "Could not upload the wink gif. Try again later.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string? target = null;
|
||||||
|
if (ctx.Message.ReplyToId is not null)
|
||||||
|
{
|
||||||
|
var replied = await ctx.Message.FetchReplyMessageAsync();
|
||||||
|
if (replied is not null)
|
||||||
|
{
|
||||||
|
var author = await replied.FetchAuthorAsync();
|
||||||
|
if (author is not null)
|
||||||
|
target = author.Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (target is null && ctx.Args.Length > 0)
|
||||||
|
target = string.Join(" ", ctx.Args);
|
||||||
|
|
||||||
|
string sender = ctx.Member.Nickname ?? ctx.Member.User?.Name ?? "Unknown";
|
||||||
|
string text = target is not null
|
||||||
|
? $"{sender} winks at {target}! ;)"
|
||||||
|
: $"{sender} winks! ;)";
|
||||||
|
|
||||||
|
var attachment = new MessageAttachment(MessageAttachmentType.Image)
|
||||||
|
{
|
||||||
|
Location = cdnUrl,
|
||||||
|
MimeType = "image/gif",
|
||||||
|
FileName = "wink.gif",
|
||||||
|
Width = width,
|
||||||
|
Height = height
|
||||||
|
};
|
||||||
|
|
||||||
|
await MessageHelper.ReplyAsync(ctx, channel, text, [attachment]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ namespace SkyBot.Commands
|
|||||||
|
|
||||||
private static readonly HttpClient _http = new()
|
private static readonly HttpClient _http = new()
|
||||||
{
|
{
|
||||||
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0" } }
|
DefaultRequestHeaders = { { "User-Agent", "SkyBot/1.0 (https://skyjoshua.xyz, https://valour.gg)" } }
|
||||||
};
|
};
|
||||||
|
|
||||||
public async Task Execute(CommandContext ctx)
|
public async Task Execute(CommandContext ctx)
|
||||||
|
|||||||
Reference in New Issue
Block a user