@@ -33,8 +33,11 @@ public class Program
|
||||
// Discover all of the commands in this assembly and load them.
|
||||
await commands.LoadAssembly(Assembly.GetEntryAssembly());
|
||||
}
|
||||
public async Task HandleCommand(IMessage msg)
|
||||
public async Task HandleCommand(IMessage paramMessage)
|
||||
{
|
||||
// Cast paramMessage to an IUserMessage, return if the message was a System message.
|
||||
var msg = paramMessage as IUserMessage;
|
||||
if (msg == null) return;
|
||||
// Internal integer, marks where the command begins
|
||||
int argPos = 0;
|
||||
// Get the current user (used for Mention parsing)
|
||||
|
||||
@@ -2,6 +2,5 @@ public async Task SendMessageToChannel(ulong ChannelId)
|
||||
{
|
||||
var channel = await _client.GetChannelAsync(ChannelId) as IMessageChannel;
|
||||
await channel?.SendMessageAsync("aaaaaaaaahhh!!!")
|
||||
/* ^ This question mark is used to indicate that 'channel' may sometimes be null, and
|
||||
in cases that it is null, we will do nothing here. */
|
||||
/* ^ This question mark is used to indicate that 'channel' may sometimes be null, and in cases that it is null, we will do nothing here. */
|
||||
}
|
||||
@@ -6,10 +6,10 @@ public class AdminModule
|
||||
{
|
||||
// ~admin mod ban foxbot#0282
|
||||
[Command("ban")]
|
||||
public async Task Ban(IMessage msg, IGuildUser user) { }
|
||||
public async Task Ban(IUserMessage msg, IGuildUser user) { }
|
||||
}
|
||||
|
||||
// ~admin clean 100
|
||||
[Command("clean")]
|
||||
public async Task Clean(IMessage msg, int count = 100) { }
|
||||
public async Task Clean(IUserMessage msg, int count = 100) { }
|
||||
}
|
||||
@@ -3,7 +3,7 @@ private IAudioClient _audio;
|
||||
|
||||
// Create a Join command, that will join the parameter or the user's current voice channel
|
||||
[Command("join")]
|
||||
public async Task JoinChannel(IMessage msg,
|
||||
public async Task JoinChannel(IUserMessage msg,
|
||||
IVoiceChannel channel = null)
|
||||
{
|
||||
// Get the audio channel
|
||||
|
||||
@@ -7,7 +7,7 @@ public class Info
|
||||
{
|
||||
// ~say hello -> hello
|
||||
[Command("say"), Description("Echos a message.")]
|
||||
public async Task Say(IMessage msg,
|
||||
public async Task Say(IUserMessage msg,
|
||||
[Unparsed, Description("The text to echo")] string echo)
|
||||
{
|
||||
await msg.Channel.SendMessageAsync(echo);
|
||||
@@ -20,7 +20,7 @@ public class Sample
|
||||
{
|
||||
// ~sample square 20 ->
|
||||
[Command("square"), Description("Squares a number.")]
|
||||
public async Task Square(IMessage msg,
|
||||
public async Task Square(IUserMessage msg,
|
||||
[Description("The number to square.")] int num)
|
||||
{
|
||||
await msg.Channel.SendMessageAsync($"{num}^2 = {Math.Pow(num, 2)}");
|
||||
@@ -34,7 +34,7 @@ public class Sample
|
||||
// ~sample whois 96642168176807936 --> Khionu#8708
|
||||
[Command("userinfo"), Description("Returns info about the current user, or the user parameter, if one passed.")]
|
||||
[Alias("user", "whois")]
|
||||
public async Task UserInfo(IMessage msg,
|
||||
public async Task UserInfo(IUserMessage msg,
|
||||
[Description("The (optional) user to get info for")] IUser user = null)
|
||||
{
|
||||
var userInfo = user ?? await Program.Client.GetCurrentUserAsync();
|
||||
|
||||
@@ -3,9 +3,9 @@ public class InfoModule
|
||||
{
|
||||
// Constrain this command to Guilds
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Whois(IMessage msg, IGuildUser user) { }
|
||||
public async Task Whois(IUserMessage msg, IGuildUser user) { }
|
||||
|
||||
// Constrain this command to either Guilds or DMs
|
||||
[RequireContext(ContextType.Guild | ContextType.DM)]
|
||||
public async Task Info(IMessage msg) { }
|
||||
public async Task Info(IUserMessage msg) { }
|
||||
}
|
||||
@@ -8,7 +8,7 @@ public class RequireOwnerAttribute : PreconditionAttribute
|
||||
public readonly ulong OwnerId = 66078337084162048;
|
||||
|
||||
// Override the CheckPermissions method
|
||||
public override Task<PreconditionResult> CheckPermissions(IMessage context, Command executingCommand, object moduleInstance)
|
||||
public override Task<PreconditionResult> CheckPermissions(IUserMessage context, Command executingCommand, object moduleInstance)
|
||||
{
|
||||
// If the author of the message is '66078337084162048', return success; otherwise fail.
|
||||
return Task.FromResult(context.Author.Id == OwnerId ? PreconditionResult.FromSuccess() : PreconditionResult.FromError("You must be the owner of the bot."));
|
||||
|
||||
@@ -3,5 +3,5 @@ public class AdminModule
|
||||
{
|
||||
[Command("ban")]
|
||||
[RequirePermission(GuildPermission.BanMembers)]
|
||||
public async Task Ban(IMessage msg) { }
|
||||
public async Task Ban(IUserMessage msg) { }
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using Discord.Commands;
|
||||
|
||||
public class BooleanTypeReader : TypeReader
|
||||
{
|
||||
public override Task<TypeReaderResult> Read(IMessage context, string input)
|
||||
public override Task<TypeReaderResult> Read(IUserMessage context, string input)
|
||||
{
|
||||
bool result;
|
||||
if (bool.TryParse(input, out result))
|
||||
|
||||
Reference in New Issue
Block a user