Module, Command, PermissionAction typereaders, fixed HS (thanks to fearnlj01)
This commit is contained in:
35
src/NadekoBot/Modules/Permissions/PermissionAction.cs
Normal file
35
src/NadekoBot/Modules/Permissions/PermissionAction.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using Discord.Commands;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Discord;
|
||||
|
||||
namespace NadekoBot.Modules.Permissions
|
||||
{
|
||||
public class PermissionAction
|
||||
{
|
||||
public static PermissionAction Enable => new PermissionAction(true);
|
||||
public static PermissionAction Disable => new PermissionAction(false);
|
||||
|
||||
public bool Value { get; }
|
||||
|
||||
public PermissionAction(bool value)
|
||||
{
|
||||
this.Value = value;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null || GetType() != obj.GetType())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.Value == ((PermissionAction)obj).Value;
|
||||
}
|
||||
|
||||
public override int GetHashCode() => Value.GetHashCode();
|
||||
}
|
||||
}
|
39
src/NadekoBot/Modules/Permissions/Permissions.cs
Normal file
39
src/NadekoBot/Modules/Permissions/Permissions.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using NadekoBot.Attributes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
using Discord.WebSocket;
|
||||
using NadekoBot.Services;
|
||||
using Discord;
|
||||
|
||||
namespace NadekoBot.Modules.Permissions
|
||||
{
|
||||
[NadekoModule("Permissions", ";")]
|
||||
public class Permissions : DiscordModule
|
||||
{
|
||||
public Permissions(ILocalization loc, CommandService cmds, DiscordSocketClient client) : base(loc, cmds, client)
|
||||
{
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task UsrCmd(IUserMessage imsg, Command command, PermissionAction action, IGuildUser user)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
await channel.SendMessageAsync($"{command.Text} {action.Value} {user}");
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task UsrMdl(IUserMessage imsg, Module module, PermissionAction action, IGuildUser user)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
await channel.SendMessageAsync($"{module.Name} {action.Value} {user}");
|
||||
}
|
||||
}
|
||||
}
|
@@ -229,8 +229,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
var images = new List<Image>();
|
||||
if (items == null)
|
||||
throw new KeyNotFoundException("Cannot find a card by that name");
|
||||
var cnt = 0;
|
||||
foreach (var item in items.TakeWhile(item => cnt++ < 4).Where(item => item.HasValues && item["img"] != null))
|
||||
foreach (var item in items.Where(item => item.HasValues && item["img"] != null).Take(4))
|
||||
{
|
||||
using (var sr =await http.GetStreamAsync(item["img"].ToString()))
|
||||
{
|
||||
|
Reference in New Issue
Block a user