Make modchannel command easier and some random stuff
This commit is contained in:
parent
2eca82e899
commit
75c699e25b
4 changed files with 12 additions and 18 deletions
|
@ -123,16 +123,10 @@ namespace Geekbot.net.Commands
|
|||
[Command("modchannel", RunMode = RunMode.Async)]
|
||||
[Remarks(CommandCategories.Admin)]
|
||||
[Summary("Set a channel for moderation purposes")]
|
||||
public async Task selectModChannel([Summary("ChannelId")] ulong channelId)
|
||||
public async Task selectModChannel([Summary("#Channel")] ISocketMessageChannel channel)
|
||||
{
|
||||
try
|
||||
{
|
||||
var channel = (ISocketMessageChannel)_client.GetChannel(channelId);
|
||||
if (string.IsNullOrEmpty(channel.Name))
|
||||
{
|
||||
await ReplyAsync("I couldn't find that channel...");
|
||||
return;
|
||||
}
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine("Successfully saved mod channel, you can now do the following");
|
||||
sb.AppendLine("- `!admin showleave true` - send message to mod channel when someone leaves");
|
||||
|
@ -152,7 +146,7 @@ namespace Geekbot.net.Commands
|
|||
[Summary("Notify modchannel when someone leaves")]
|
||||
public async Task showLeave([Summary("true/false")] bool enabled)
|
||||
{
|
||||
var modChannelId = (ulong)_redis.HashGet($"{Context.Guild.Id}:Settings", "ModChannel");
|
||||
var modChannelId = ulong.Parse(_redis.HashGet($"{Context.Guild.Id}:Settings", "ModChannel"));
|
||||
try
|
||||
{
|
||||
var modChannel = (ISocketMessageChannel) _client.GetChannel(modChannelId);
|
||||
|
@ -179,7 +173,7 @@ namespace Geekbot.net.Commands
|
|||
[Summary("Notify modchannel when someone deletes a message")]
|
||||
public async Task showDelete([Summary("true/false")] bool enabled)
|
||||
{
|
||||
var modChannelId = (ulong)_redis.HashGet($"{Context.Guild.Id}:Settings", "ModChannel");
|
||||
var modChannelId = ulong.Parse(_redis.HashGet($"{Context.Guild.Id}:Settings", "ModChannel"));
|
||||
try
|
||||
{
|
||||
var modChannel = (ISocketMessageChannel) _client.GetChannel(modChannelId);
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace Geekbot.net.Commands
|
|||
}
|
||||
if (guildUser.RoleIds.Contains(roleId))
|
||||
{
|
||||
guildUser.RemoveRoleAsync(role);
|
||||
await guildUser.RemoveRoleAsync(role);
|
||||
await ReplyAsync($"Removed you from {role.Name}");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -105,10 +105,10 @@ namespace Geekbot.net
|
|||
var sendLeftEnabled = _redis.HashGet($"{user.Guild.Id}:Settings", "ShowLeave");
|
||||
if (sendLeftEnabled.ToString() == "1")
|
||||
{
|
||||
var modChannel = _redis.HashGet($"{user.Guild.Id}:Settings", "ModChannel");
|
||||
if (!string.IsNullOrEmpty(modChannel))
|
||||
var modChannel = ulong.Parse(_redis.HashGet($"{user.Guild.Id}:Settings", "ModChannel"));
|
||||
if (!string.IsNullOrEmpty(modChannel.ToString()))
|
||||
{
|
||||
var modChannelSocket = (ISocketMessageChannel) await _client.GetChannelAsync((ulong)modChannel);
|
||||
var modChannelSocket = (ISocketMessageChannel) await _client.GetChannelAsync(modChannel);
|
||||
await modChannelSocket.SendMessageAsync($"{user.Username}#{user.Discriminator} left the server");
|
||||
}
|
||||
}
|
||||
|
@ -132,15 +132,15 @@ namespace Geekbot.net
|
|||
var sendLeftEnabled = _redis.HashGet($"{guild.Id}:Settings", "ShowDelete");
|
||||
if (sendLeftEnabled.ToString() == "1")
|
||||
{
|
||||
var modChannel = _redis.HashGet($"{guild.Id}:Settings", "ModChannel");
|
||||
if (!string.IsNullOrEmpty(modChannel))
|
||||
var modChannel = ulong.Parse(_redis.HashGet($"{guild.Id}:Settings", "ModChannel"));
|
||||
if (!string.IsNullOrEmpty(modChannel.ToString()) && modChannel != channel.Id)
|
||||
{
|
||||
var modChannelSocket = (ISocketMessageChannel) await _client.GetChannelAsync((ulong)modChannel);
|
||||
var modChannelSocket = (ISocketMessageChannel) await _client.GetChannelAsync(modChannel);
|
||||
var sb = new StringBuilder();
|
||||
if (message.Value != null)
|
||||
{
|
||||
sb.AppendLine(
|
||||
$"{message.Value.Author.Username}#{message.Value.Author.Discriminator} deleted the following message from <#{channel.Id}>");
|
||||
$"The following message from {message.Value.Author.Username}#{message.Value.Author.Discriminator} was deleted in <#{channel.Id}>");
|
||||
sb.AppendLine(message.Value.Content);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -182,7 +182,7 @@ namespace Geekbot.net
|
|||
return true;
|
||||
}
|
||||
|
||||
private async Task startWebApi()
|
||||
private void startWebApi()
|
||||
{
|
||||
logger.Information("[API] Starting Webserver");
|
||||
var webApiUrl = new Uri("http://localhost:12995");
|
||||
|
|
Loading…
Reference in a new issue