final github release
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using System.Collections.Concurrent;
|
||||
using SkyBot.Helpers;
|
||||
using SkyBot.Models;
|
||||
using Valour.Sdk.Client;
|
||||
using Valour.Sdk.Models;
|
||||
|
||||
namespace SkyBot.Commands
|
||||
@@ -15,8 +15,13 @@ namespace SkyBot.Commands
|
||||
|
||||
public async Task Execute(CommandContext ctx)
|
||||
{
|
||||
ConcurrentDictionary<long, Channel> channelCache = ctx.ChannelCache;
|
||||
long channelId = ctx.ChannelId;
|
||||
ValourClient Client = ctx.Client;
|
||||
ConcurrentDictionary<long, Channel> channelCache = ctx.ChannelCache;
|
||||
PlanetMember Member = ctx.Member;
|
||||
Message Message = ctx.Message;
|
||||
Planet Planet = ctx.Planet;
|
||||
long channelId = ctx.ChannelId;
|
||||
string[] Args = ctx.Args;
|
||||
|
||||
if (!channelCache.TryGetValue(channelId, out var channel)) return;
|
||||
|
||||
|
||||
72
SkyBot/Commands/Dev/React.cs
Normal file
72
SkyBot/Commands/Dev/React.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using System.Collections.Concurrent;
|
||||
using SkyBot.Helpers;
|
||||
using SkyBot.Models;
|
||||
using Valour.Sdk.Models;
|
||||
using Valour.Shared.Models;
|
||||
|
||||
namespace SkyBot.Commands
|
||||
{
|
||||
public class React : ICommand
|
||||
{
|
||||
public string Name => "react";
|
||||
public string[] Aliases => [];
|
||||
public string Description => "Send a message with a reaction at a set count.";
|
||||
public string Section => "Dev";
|
||||
public string Usage => "react <emoji> <amount> <message>";
|
||||
|
||||
public async Task Execute(CommandContext ctx)
|
||||
{
|
||||
ConcurrentDictionary<long, Channel> channelCache = ctx.ChannelCache;
|
||||
long channelId = ctx.ChannelId;
|
||||
|
||||
if (!channelCache.TryGetValue(channelId, out var channel)) return;
|
||||
|
||||
if (!PermissionHelper.IsOwner(ctx.Member))
|
||||
{
|
||||
await MessageHelper.ReplyAsync(ctx, channel, "This is a Dev only command.");
|
||||
return;
|
||||
}
|
||||
|
||||
string[] args = ctx.Args;
|
||||
|
||||
if (args.Length < 3)
|
||||
{
|
||||
await MessageHelper.ReplyAsync(ctx, channel, $"Usage: `{Config.Prefix}react <emoji> <amount> <message>`");
|
||||
return;
|
||||
}
|
||||
|
||||
string emoji = args[0];
|
||||
|
||||
if (!int.TryParse(args[1], out int amount) || amount < 1)
|
||||
{
|
||||
await MessageHelper.ReplyAsync(ctx, channel, "Amount must be a number between 1 and 100.");
|
||||
return;
|
||||
}
|
||||
|
||||
string content = string.Join(" ", args.Skip(2));
|
||||
|
||||
var reactions = Enumerable.Range(0, amount)
|
||||
.Select(_ => new MessageReaction
|
||||
{
|
||||
Emoji = emoji,
|
||||
AuthorUserId = ctx.Client.Me.Id,
|
||||
AuthorMemberId = ctx.Planet.MyMember?.Id,
|
||||
CreatedAt = DateTime.UtcNow
|
||||
})
|
||||
.ToList();
|
||||
|
||||
var msg = new Message(ctx.Client)
|
||||
{
|
||||
Content = content,
|
||||
ChannelId = channelId,
|
||||
PlanetId = ctx.Planet.Id,
|
||||
AuthorUserId = ctx.Client.Me.Id,
|
||||
AuthorMemberId = ctx.Planet.MyMember?.Id,
|
||||
Reactions = reactions,
|
||||
Fingerprint = Guid.NewGuid().ToString()
|
||||
};
|
||||
|
||||
await ctx.Client.MessageService.SendMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ namespace SkyBot.Commands
|
||||
if (!channelCache.TryGetValue(channelId, out var channel)) return;
|
||||
|
||||
string msg = @"Here is a link to a Bot Guide that SkyJoshua has made (WIP):
|
||||
https://github.com/SkyJoshua/Valour-Bot-Guide";
|
||||
https://git.skyjoshua.xyz/SkyJoshua/Valour-Bot-Guide";
|
||||
|
||||
await MessageHelper.ReplyAsync(ctx, channel, msg);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user