Woops, didn't push correctly. Also added owner only commands now.
This commit is contained in:
@@ -13,6 +13,9 @@ using System.Text.RegularExpressions;
|
||||
using Discord.WebSocket;
|
||||
using NadekoBot.Services.Database;
|
||||
using NadekoBot.Services.Database.Models;
|
||||
using System.Net.Http;
|
||||
using ImageProcessorCore;
|
||||
using System.IO;
|
||||
|
||||
namespace NadekoBot.Modules.Administration
|
||||
{
|
||||
@@ -46,19 +49,21 @@ namespace NadekoBot.Modules.Administration
|
||||
_log.Warn(ex, "Delmsgoncmd errored...");
|
||||
}
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[OwnerOnly]
|
||||
public async Task Restart(IUserMessage umsg)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
|
||||
////todo owner only
|
||||
//[LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias]
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task Restart(IUserMessage umsg)
|
||||
//{
|
||||
// var channel = (ITextChannel)umsg.Channel;
|
||||
|
||||
// await channel.SendMessageAsync("`Restarting in 2 seconds...`");
|
||||
// await Task.Delay(2000);
|
||||
// System.Diagnostics.Process.Start(System.Reflection.Assembly.GetEntryAssembly().Location);
|
||||
// Environment.Exit(0);
|
||||
//}
|
||||
await channel.SendMessageAsync("`Restarting in 2 seconds...`");
|
||||
await Task.Delay(2000);
|
||||
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo {
|
||||
Arguments = "dotnet " + System.Reflection.Assembly.GetEntryAssembly().Location
|
||||
});
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
@@ -205,7 +210,7 @@ namespace NadekoBot.Modules.Administration
|
||||
var green = Convert.ToByte(rgb ? int.Parse(args[2]) : Convert.ToInt32(arg1.Substring(2, 2), 16));
|
||||
var blue = Convert.ToByte(rgb ? int.Parse(args[3]) : Convert.ToInt32(arg1.Substring(4, 2), 16));
|
||||
|
||||
await role.ModifyAsync(r => r.Color = new Color(red, green, blue).RawValue).ConfigureAwait(false);
|
||||
await role.ModifyAsync(r => r.Color = new Discord.Color(red, green, blue).RawValue).ConfigureAwait(false);
|
||||
await channel.SendMessageAsync($"Role {role.Name}'s color has been changed.").ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception)
|
||||
@@ -455,7 +460,7 @@ namespace NadekoBot.Modules.Administration
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
|
||||
var user = await channel.Guild.GetCurrentUserAsync();
|
||||
var user = channel.Guild.GetCurrentUser();
|
||||
|
||||
var enumerable = (await umsg.Channel.GetMessagesAsync()).Where(x => x.Author.Id == user.Id);
|
||||
await umsg.Channel.DeleteMessagesAsync(enumerable);
|
||||
@@ -483,6 +488,7 @@ namespace NadekoBot.Modules.Administration
|
||||
//prune @user [x]
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[RequirePermission(ChannelPermission.ManageMessages)]
|
||||
public async Task Prune(IUserMessage msg, IGuildUser user, int count = 100)
|
||||
{
|
||||
var channel = (ITextChannel)msg.Channel;
|
||||
@@ -490,149 +496,163 @@ namespace NadekoBot.Modules.Administration
|
||||
var enumerable = (await msg.Channel.GetMessagesAsync(limit: limit)).Where(m => m.Author == user);
|
||||
await msg.Channel.DeleteMessagesAsync(enumerable);
|
||||
}
|
||||
////todo owner only
|
||||
//[LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias]
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task Die(IUserMessage umsg)
|
||||
//{
|
||||
// var channel = (ITextChannel)umsg.Channel;
|
||||
|
||||
// await channel.SendMessageAsync("`Shutting down.`").ConfigureAwait(false);
|
||||
// await Task.Delay(2000).ConfigureAwait(false);
|
||||
// Environment.Exit(0);
|
||||
//}
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[OwnerOnly]
|
||||
public async Task Die(IUserMessage umsg)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
|
||||
////todo owner only
|
||||
//[LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias]
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task Setname(IUserMessage umsg, [Remainder] string newName = null)
|
||||
//{
|
||||
// var channel = (ITextChannel)umsg.Channel;
|
||||
await channel.SendMessageAsync("`Shutting down.`").ConfigureAwait(false);
|
||||
await Task.Delay(2000).ConfigureAwait(false);
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
//}
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[OwnerOnly]
|
||||
public async Task Setname(IUserMessage umsg, [Remainder] string newName)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
if (string.IsNullOrWhiteSpace(newName))
|
||||
return;
|
||||
|
||||
////todo owner only
|
||||
//[LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias]
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task NewAvatar(IUserMessage umsg, [Remainder] string img = null)
|
||||
//{
|
||||
// var channel = (ITextChannel)umsg.Channel;
|
||||
await NadekoBot.Client.GetCurrentUser().ModifyAsync(u => u.Username = newName).ConfigureAwait(false);
|
||||
|
||||
// if (string.IsNullOrWhiteSpace(img))
|
||||
// return;
|
||||
// // Gather user provided URL.
|
||||
// var avatarAddress = img;
|
||||
// var imageStream = await SearchHelper.GetResponseStreamAsync(avatarAddress).ConfigureAwait(false);
|
||||
// var image = System.Drawing.Image.FromStream(imageStream);
|
||||
// await client.CurrentUser.Edit("", avatar: image.ToStream()).ConfigureAwait(false);
|
||||
await channel.SendMessageAsync($"Successfully changed name to {newName}").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
// // Send confirm.
|
||||
// await channel.SendMessageAsync("New avatar set.").ConfigureAwait(false);
|
||||
//}
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[OwnerOnly]
|
||||
public async Task NewAvatar(IUserMessage umsg, [Remainder] string img = null)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
|
||||
////todo owner only
|
||||
//[LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias]
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task SetGame(IUserMessage umsg, [Remainder] string game = null)
|
||||
//{
|
||||
// var channel = (ITextChannel)umsg.Channel;
|
||||
if (string.IsNullOrWhiteSpace(img))
|
||||
return;
|
||||
|
||||
// game = game ?? "";
|
||||
using (var http = new HttpClient())
|
||||
{
|
||||
using (var sr = await http.GetStreamAsync(img))
|
||||
{
|
||||
var imgStream = new MemoryStream();
|
||||
await sr.CopyToAsync(imgStream);
|
||||
imgStream.Position = 0;
|
||||
|
||||
// client.SetGame(set_game);
|
||||
//}
|
||||
await NadekoBot.Client.GetCurrentUser().ModifyAsync(u => u.Avatar = imgStream).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
////todo owner only
|
||||
//[LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias]
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task Send(IUserMessage umsg, string where, [Remainder] string msg = null)
|
||||
//{
|
||||
// var channel = (ITextChannel)umsg.Channel;
|
||||
await channel.SendMessageAsync("New avatar set.").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
// if (string.IsNullOrWhiteSpace(msg))
|
||||
// return;
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[OwnerOnly]
|
||||
public async Task SetGame(IUserMessage umsg, [Remainder] string game = null)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
|
||||
// var ids = where.Split('|');
|
||||
// if (ids.Length != 2)
|
||||
// return;
|
||||
// var sid = ulong.Parse(ids[0]);
|
||||
// var server = NadekoBot.Client.Servers.Where(s => s.Id == sid).FirstOrDefault();
|
||||
game = game ?? "";
|
||||
|
||||
// if (server == null)
|
||||
// return;
|
||||
await NadekoBot.Client.GetCurrentUser().ModifyStatusAsync(u => u.Game = new Game(game)).ConfigureAwait(false);
|
||||
|
||||
// if (ids[1].ToUpperInvariant().StartsWith("C:"))
|
||||
// {
|
||||
// var cid = ulong.Parse(ids[1].Substring(2));
|
||||
// var channel = server.TextChannels.Where(c => c.Id == cid).FirstOrDefault();
|
||||
// if (channel == null)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
// await channel.SendMessageAsync(msg);
|
||||
// }
|
||||
// else if (ids[1].ToUpperInvariant().StartsWith("U:"))
|
||||
// {
|
||||
// var uid = ulong.Parse(ids[1].Substring(2));
|
||||
// var user = server.Users.Where(u => u.Id == uid).FirstOrDefault();
|
||||
// if (user == null)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
// await user.SendMessageAsync(msg);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// await channel.SendMessageAsync("`Invalid format.`");
|
||||
// }
|
||||
//}
|
||||
await channel.SendMessageAsync("New game set.").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
////todo owner only
|
||||
//[LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias]
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task Announce(IUserMessage umsg, [Remainder] string message)
|
||||
//{
|
||||
// var channel = (ITextChannel)umsg.Channel;
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[OwnerOnly]
|
||||
public async Task Send(IUserMessage umsg, string where, [Remainder] string msg = null)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
|
||||
// foreach (var ch in (await _client.GetGuildsAsync().ConfigureAwait(false)).Select(async g => await g.GetDefaultChannelAsync().ConfigureAwait(false)))
|
||||
// {
|
||||
// await channel.SendMessageAsync(message).ConfigureAwait(false);
|
||||
// }
|
||||
if (string.IsNullOrWhiteSpace(msg))
|
||||
return;
|
||||
|
||||
// await channel.SendMessageAsync(":ok:").ConfigureAwait(false);
|
||||
//}
|
||||
var ids = where.Split('|');
|
||||
if (ids.Length != 2)
|
||||
return;
|
||||
var sid = ulong.Parse(ids[0]);
|
||||
var server = NadekoBot.Client.GetGuilds().Where(s => s.Id == sid).FirstOrDefault();
|
||||
|
||||
////todo owner only
|
||||
//[LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias]
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task SaveChat(IUserMessage umsg, int cnt)
|
||||
//{
|
||||
// var channel = (ITextChannel)umsg.Channel;
|
||||
if (server == null)
|
||||
return;
|
||||
|
||||
// ulong? lastmsgId = null;
|
||||
// var sb = new StringBuilder();
|
||||
// var msgs = new List<IUserMessage>(cnt);
|
||||
// while (cnt > 0)
|
||||
// {
|
||||
// var dlcnt = cnt < 100 ? cnt : 100;
|
||||
// IReadOnlyCollection<IUserMessage> dledMsgs;
|
||||
// if (lastmsgId == null)
|
||||
// dledMsgs = await umsg.Channel.GetMessagesAsync(cnt).ConfigureAwait(false);
|
||||
// else
|
||||
// dledMsgs = await umsg.Channel.GetMessagesAsync(lastmsgId.Value, Direction.Before, dlcnt);
|
||||
if (ids[1].ToUpperInvariant().StartsWith("C:"))
|
||||
{
|
||||
var cid = ulong.Parse(ids[1].Substring(2));
|
||||
var ch = server.GetTextChannels().Where(c => c.Id == cid).FirstOrDefault();
|
||||
if (ch == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
await ch.SendMessageAsync(msg);
|
||||
}
|
||||
else if (ids[1].ToUpperInvariant().StartsWith("U:"))
|
||||
{
|
||||
var uid = ulong.Parse(ids[1].Substring(2));
|
||||
var user = server.GetUsers().Where(u => u.Id == uid).FirstOrDefault();
|
||||
if (user == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
await user.SendMessageAsync(msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
await channel.SendMessageAsync("`Invalid format.`");
|
||||
}
|
||||
}
|
||||
|
||||
// if (!dledMsgs.Any())
|
||||
// break;
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[OwnerOnly]
|
||||
public async Task Announce(IUserMessage umsg, [Remainder] string message)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
|
||||
// msgs.AddRange(dledMsgs);
|
||||
// lastmsgId = msgs[msgs.Count - 1].Id;
|
||||
// cnt -= 100;
|
||||
// }
|
||||
// var title = $"Chatlog-{channel.Guild.Name}/#{channel.Name}-{DateTime.Now}.txt";
|
||||
// await (umsg.Author as IGuildUser).SendFileAsync(
|
||||
// await JsonConvert.SerializeObject(new { Messages = msgs.Select(s => s.ToString()) }, Formatting.Indented).ToStream().ConfigureAwait(false),
|
||||
// title, title).ConfigureAwait(false);
|
||||
//}
|
||||
foreach (var ch in (await _client.GetGuildsAsync().ConfigureAwait(false)).Select(async g => await g.GetDefaultChannelAsync().ConfigureAwait(false)))
|
||||
{
|
||||
await channel.SendMessageAsync(message).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await channel.SendMessageAsync(":ok:").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[OwnerOnly]
|
||||
public async Task SaveChat(IUserMessage umsg, int cnt)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
|
||||
ulong? lastmsgId = null;
|
||||
var sb = new StringBuilder();
|
||||
var msgs = new List<IMessage>(cnt);
|
||||
while (cnt > 0)
|
||||
{
|
||||
var dlcnt = cnt < 100 ? cnt : 100;
|
||||
IReadOnlyCollection<IMessage> dledMsgs;
|
||||
if (lastmsgId == null)
|
||||
dledMsgs = await umsg.Channel.GetMessagesAsync(cnt).ConfigureAwait(false);
|
||||
else
|
||||
dledMsgs = await umsg.Channel.GetMessagesAsync(lastmsgId.Value, Direction.Before, dlcnt);
|
||||
|
||||
if (!dledMsgs.Any())
|
||||
break;
|
||||
|
||||
msgs.AddRange(dledMsgs);
|
||||
lastmsgId = msgs[msgs.Count - 1].Id;
|
||||
cnt -= 100;
|
||||
}
|
||||
var title = $"Chatlog-{channel.Guild.Name}/#{channel.Name}-{DateTime.Now}.txt";
|
||||
await (umsg.Author as IGuildUser).SendFileAsync(
|
||||
await JsonConvert.SerializeObject(new { Messages = msgs.Select(s => s.ToString()) }, Formatting.Indented).ToStream().ConfigureAwait(false),
|
||||
title, title).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
@@ -691,5 +711,17 @@ namespace NadekoBot.Modules.Administration
|
||||
|
||||
await channel.SendMessageAsync($"Successfuly added a new donator. Total donated amount from this user: {don.Amount} 👑").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[OwnerOnly]
|
||||
public async Task Leave(IUserMessage imsg, [Remainder] IGuild guild)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
await guild.LeaveAsync();
|
||||
|
||||
await channel.SendMessageAsync($"Left guild **{guild.Name}**\nId: `{guild.Id}`.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ using Discord.Commands;
|
||||
using Discord.WebSocket;
|
||||
using NadekoBot.Attributes;
|
||||
using NadekoBot.Extensions;
|
||||
using NadekoBot.Services;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
@@ -52,23 +53,23 @@ namespace NadekoBot.Modules.Administration
|
||||
|
||||
private string GetText(IGuild server, ITextChannel channel, IGuildUser user, IUserMessage message) =>
|
||||
$"**{server.Name} | {channel.Name}** `{user.Username}`: " + message.Content;
|
||||
|
||||
|
||||
public static readonly ConcurrentDictionary<int, HashSet<ITextChannel>> Subscribers = new ConcurrentDictionary<int, HashSet<ITextChannel>>();
|
||||
|
||||
////todo owner only
|
||||
//[LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias]
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task Scsc(IUserMessage msg)
|
||||
//{
|
||||
// var channel = (ITextChannel)msg.Channel;
|
||||
// var token = new NadekoRandom().Next();
|
||||
// var set = new HashSet<ITextChannel>();
|
||||
// if (Subscribers.TryAdd(token, set))
|
||||
// {
|
||||
// set.Add(channel);
|
||||
// await ((IGuildUser)msg.Author).SendMessageAsync("This is your CSC token:" + token.ToString()).ConfigureAwait(false);
|
||||
// }
|
||||
//}
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[OwnerOnly]
|
||||
public async Task Scsc(IUserMessage msg)
|
||||
{
|
||||
var channel = (ITextChannel)msg.Channel;
|
||||
var token = new NadekoRandom().Next();
|
||||
var set = new HashSet<ITextChannel>();
|
||||
if (Subscribers.TryAdd(token, set))
|
||||
{
|
||||
set.Add(channel);
|
||||
await ((IGuildUser)msg.Author).SendMessageAsync("This is your CSC token:" + token.ToString()).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
|
@@ -484,6 +484,7 @@ namespace NadekoBot.Modules.Administration
|
||||
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[OwnerOnly]
|
||||
public async Task LogServer(IUserMessage msg)
|
||||
{
|
||||
var channel = (ITextChannel)msg.Channel;
|
||||
@@ -506,6 +507,7 @@ namespace NadekoBot.Modules.Administration
|
||||
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[OwnerOnly]
|
||||
public async Task LogIgnore(IUserMessage imsg)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
@@ -529,6 +531,7 @@ namespace NadekoBot.Modules.Administration
|
||||
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[OwnerOnly]
|
||||
public async Task LogAdd(IUserMessage msg, [Remainder] string eventName)
|
||||
{
|
||||
var channel = (ITextChannel)msg.Channel;
|
||||
|
@@ -88,6 +88,7 @@ namespace NadekoBot.Modules.Administration
|
||||
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[OwnerOnly]
|
||||
public async Task RotatePlaying(IUserMessage umsg)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
@@ -108,6 +109,7 @@ namespace NadekoBot.Modules.Administration
|
||||
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[OwnerOnly]
|
||||
public async Task AddPlaying(IUserMessage umsg, [Remainder] string status)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
@@ -124,6 +126,7 @@ namespace NadekoBot.Modules.Administration
|
||||
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[OwnerOnly]
|
||||
public async Task ListPlaying(IUserMessage umsg)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
@@ -146,6 +149,7 @@ namespace NadekoBot.Modules.Administration
|
||||
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[OwnerOnly]
|
||||
public async Task RemovePlaying(IUserMessage umsg, int index)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
|
@@ -82,14 +82,15 @@ namespace NadekoBot.Modules.Gambling
|
||||
await channel.SendMessageAsync($"{umsg.Author.Mention} successfully sent {amount} {Gambling.CurrencyPluralName}s to {receiver.Mention}!").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
//todo owner only
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[OwnerOnly]
|
||||
public Task Award(IUserMessage umsg, long amount, [Remainder] IGuildUser usr) =>
|
||||
Award(umsg, amount, usr.Id);
|
||||
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[OwnerOnly]
|
||||
public async Task Award(IUserMessage umsg, long amount, [Remainder] ulong usrId)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
@@ -101,26 +102,35 @@ namespace NadekoBot.Modules.Gambling
|
||||
|
||||
await channel.SendMessageAsync($"{umsg.Author.Mention} successfully awarded {amount} {Gambling.CurrencyName}s to <@{usrId}>!").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[OwnerOnly]
|
||||
public async Task Take(IUserMessage umsg, long amount, [Remainder] IGuildUser user)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
if (amount <= 0)
|
||||
return;
|
||||
|
||||
////todo owner only
|
||||
//[LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias]
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public Task Take(IUserMessage umsg, long amount, [Remainder] IGuildUser user) =>
|
||||
// Take(umsg, amount, user.Id);
|
||||
await CurrencyHandler.RemoveCurrencyAsync(user, $"Taken by bot owner.({umsg.Author.Username}/{umsg.Author.Id})", amount, true).ConfigureAwait(false);
|
||||
|
||||
//todo owner only
|
||||
//[LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias]
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task Take(IUserMessage umsg, long amount, [Remainder] ulong usrId)
|
||||
//{
|
||||
// var channel = (ITextChannel)umsg.Channel;
|
||||
// if (amount <= 0)
|
||||
// return;
|
||||
await channel.SendMessageAsync($"{umsg.Author.Mention} successfully took {amount} {Gambling.CurrencyName}s from {user}!").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
// await CurrencyHandler.RemoveFlowers(usrId, $"Taken by bot owner.({umsg.Author.Username}/{umsg.Author.Id})", (int)amount).ConfigureAwait(false);
|
||||
|
||||
// await channel.SendMessageAsync($"{umsg.Author.Mention} successfully took {amount} {Gambling.CurrencyName}s from <@{usrId}>!").ConfigureAwait(false);
|
||||
//}
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[OwnerOnly]
|
||||
public async Task Take(IUserMessage umsg, long amount, [Remainder] ulong usrId)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
if (amount <= 0)
|
||||
return;
|
||||
|
||||
await CurrencyHandler.RemoveCurrencyAsync(usrId, $"Taken by bot owner.({umsg.Author.Username}/{umsg.Author.Id})", amount).ConfigureAwait(false);
|
||||
|
||||
await channel.SendMessageAsync($"{umsg.Author.Mention} successfully took {amount} {Gambling.CurrencyName}s from <@{usrId}>!").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
|
@@ -174,24 +174,25 @@ namespace NadekoBot.Modules.Games
|
||||
await channel.SendMessageAsync("No contest to stop on this channel.").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
////todo owner only
|
||||
//[LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias]
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task Typeadd(IUserMessage imsg, [Remainder] string text)
|
||||
//{
|
||||
// var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[OwnerOnly]
|
||||
public async Task Typeadd(IUserMessage imsg, [Remainder] string text)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
// using (var uow = DbHandler.UnitOfWork())
|
||||
// {
|
||||
// uow.TypingArticles.Add(new Services.Database.Models.TypingArticle
|
||||
// {
|
||||
// Author = imsg.Author.Username,
|
||||
// Text = text
|
||||
// });
|
||||
// }
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
uow.TypingArticles.Add(new Services.Database.Models.TypingArticle
|
||||
{
|
||||
Author = imsg.Author.Username,
|
||||
Text = text
|
||||
});
|
||||
}
|
||||
|
||||
// await channel.SendMessageAsync("Added new article for typing game.").ConfigureAwait(false);
|
||||
//}
|
||||
await channel.SendMessageAsync("Added new article for typing game.").ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -98,6 +98,7 @@ namespace NadekoBot.Modules.Help
|
||||
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[OwnerOnly]
|
||||
public async Task Hgit(IUserMessage umsg)
|
||||
{
|
||||
var helpstr = new StringBuilder();
|
||||
|
@@ -334,6 +334,7 @@ namespace NadekoBot.Modules.Music
|
||||
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[OwnerOnly]
|
||||
public async Task LocalPl(IUserMessage umsg, [Remainder] string directory)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
@@ -381,6 +382,7 @@ namespace NadekoBot.Modules.Music
|
||||
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[OwnerOnly]
|
||||
public async Task Local(IUserMessage umsg, [Remainder] string path)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
|
@@ -37,6 +37,28 @@ namespace NadekoBot.Modules.Permissions
|
||||
await channel.SendMessageAsync("I will " + (action.Value ? "now" : "no longer") + " show permission warnings.").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task PermRole(IUserMessage msg, [Remainder] IRole role = null)
|
||||
{
|
||||
var channel = (ITextChannel)msg.Channel;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
var config = uow.GuildConfigs.For(channel.Guild.Id);
|
||||
if (role == null)
|
||||
{
|
||||
await channel.SendMessageAsync($"Current permission role is **{config.PermissionRole}**.").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
config.PermissionRole = role.Name.Trim();
|
||||
await uow.CompleteAsync().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
await channel.SendMessageAsync($"Users now require **{role.Name}** role in order to edit permissions.").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task ListPerms(IUserMessage msg)
|
||||
@@ -186,7 +208,7 @@ namespace NadekoBot.Modules.Permissions
|
||||
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task UsrCmd(IUserMessage imsg, Command command, PermissionAction action, IGuildUser user)
|
||||
public async Task UsrCmd(IUserMessage imsg, Command command, PermissionAction action, [Remainder] IGuildUser user)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
@@ -209,7 +231,7 @@ namespace NadekoBot.Modules.Permissions
|
||||
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task UsrMdl(IUserMessage imsg, Module module, PermissionAction action, IGuildUser user)
|
||||
public async Task UsrMdl(IUserMessage imsg, Module module, PermissionAction action, [Remainder] IGuildUser user)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
@@ -232,7 +254,7 @@ namespace NadekoBot.Modules.Permissions
|
||||
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task RoleCmd(IUserMessage imsg, Command command, PermissionAction action, IRole role)
|
||||
public async Task RoleCmd(IUserMessage imsg, Command command, PermissionAction action, [Remainder] IRole role)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
@@ -255,7 +277,7 @@ namespace NadekoBot.Modules.Permissions
|
||||
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task RoleMdl(IUserMessage imsg, Module module, PermissionAction action, IRole role)
|
||||
public async Task RoleMdl(IUserMessage imsg, Module module, PermissionAction action, [Remainder] IRole role)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
@@ -278,7 +300,7 @@ namespace NadekoBot.Modules.Permissions
|
||||
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task ChnlCmd(IUserMessage imsg, Command command, PermissionAction action, ITextChannel chnl)
|
||||
public async Task ChnlCmd(IUserMessage imsg, Command command, PermissionAction action, [Remainder] ITextChannel chnl)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
try
|
||||
@@ -306,7 +328,7 @@ namespace NadekoBot.Modules.Permissions
|
||||
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task ChnlMdl(IUserMessage imsg, Module module, PermissionAction action, ITextChannel chnl)
|
||||
public async Task ChnlMdl(IUserMessage imsg, Module module, PermissionAction action, [Remainder] ITextChannel chnl)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
@@ -329,7 +351,7 @@ namespace NadekoBot.Modules.Permissions
|
||||
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task AllChnlMdls(IUserMessage imsg, PermissionAction action, ITextChannel chnl)
|
||||
public async Task AllChnlMdls(IUserMessage imsg, PermissionAction action, [Remainder] ITextChannel chnl)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
@@ -352,7 +374,7 @@ namespace NadekoBot.Modules.Permissions
|
||||
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task AllRoleMdls(IUserMessage imsg, PermissionAction action, IRole role)
|
||||
public async Task AllRoleMdls(IUserMessage imsg, PermissionAction action, [Remainder] IRole role)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
@@ -375,7 +397,7 @@ namespace NadekoBot.Modules.Permissions
|
||||
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task AllUsrMdls(IUserMessage imsg, PermissionAction action, IUser user)
|
||||
public async Task AllUsrMdls(IUserMessage imsg, PermissionAction action, [Remainder] IUser user)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
@@ -398,7 +420,7 @@ namespace NadekoBot.Modules.Permissions
|
||||
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task AllSrvrMdls(IUserMessage imsg, PermissionAction action, IUser user)
|
||||
public async Task AllSrvrMdls(IUserMessage imsg, PermissionAction action, [Remainder] IUser user)
|
||||
{
|
||||
var channel = (ITextChannel)imsg.Channel;
|
||||
|
||||
|
@@ -184,21 +184,23 @@ namespace NadekoBot.Modules.Utility
|
||||
await StartReminder(rem);
|
||||
}
|
||||
|
||||
////todo owner only
|
||||
//[LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias]
|
||||
//[RequireContext(ContextType.Guild)]
|
||||
//public async Task RemindTemplate(IUserMessage umsg, [Remainder] string arg)
|
||||
//{
|
||||
// var channel = (ITextChannel)umsg.Channel;
|
||||
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[OwnerOnly]
|
||||
public async Task RemindTemplate(IUserMessage umsg, [Remainder] string arg)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(arg))
|
||||
return;
|
||||
|
||||
// arg = arg?.Trim();
|
||||
// if (string.IsNullOrWhiteSpace(arg))
|
||||
// return;
|
||||
|
||||
// NadekoBot.Config.RemindMessageFormat = arg;
|
||||
// await channel.SendMessageAsync("`New remind message set.`");
|
||||
//}
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
uow.BotConfig.GetOrCreate().RemindMessageFormat = arg.Trim();
|
||||
await uow.CompleteAsync().ConfigureAwait(false);
|
||||
}
|
||||
await channel.SendMessageAsync("`New remind message set.`");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user