Merge remote-tracking branch 'refs/remotes/Kwoth/1.0' into 1.0-fearnlj01
This commit is contained in:
commit
719ae5da69
@ -121,22 +121,6 @@ namespace NadekoBot.Modules.Administration
|
|||||||
await channel.SendMessageAsync($"{imsg.Author.Mention} :ok: `Permissions for this server are reset`");
|
await channel.SendMessageAsync($"{imsg.Author.Mention} :ok: `Permissions for this server are reset`");
|
||||||
}
|
}
|
||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
|
||||||
[RequireContext(ContextType.Guild)]
|
|
||||||
[OwnerOnly]
|
|
||||||
public async Task Restart(IUserMessage umsg)
|
|
||||||
{
|
|
||||||
var channel = (ITextChannel)umsg.Channel;
|
|
||||||
|
|
||||||
await channel.SendMessageAsync("`Restarting in 2 seconds...`").ConfigureAwait(false);
|
|
||||||
await Task.Delay(2000).ConfigureAwait(false);
|
|
||||||
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo
|
|
||||||
{
|
|
||||||
Arguments = "dotnet " + System.Reflection.Assembly.GetEntryAssembly().Location
|
|
||||||
});
|
|
||||||
Environment.Exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
[RequirePermission(GuildPermission.Administrator)]
|
[RequirePermission(GuildPermission.Administrator)]
|
||||||
@ -306,11 +290,6 @@ namespace NadekoBot.Modules.Administration
|
|||||||
await channel.SendMessageAsync("You can't use this command on users with a role higher or equal to yours in the role hierarchy.");
|
await channel.SendMessageAsync("You can't use this command on users with a role higher or equal to yours in the role hierarchy.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (umsg.Author.Id != user.Guild.OwnerId && user.Roles.Max().Position >= ((IGuildUser)umsg.Author).Roles.Max().Position)
|
|
||||||
{
|
|
||||||
await channel.SendMessageAsync("You can't use this command on users with a role higher or equal to yours in the role hierarchy.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await (await user.CreateDMChannelAsync()).SendMessageAsync($"**You have been BANNED from `{channel.Guild.Name}` server.**\n" +
|
await (await user.CreateDMChannelAsync()).SendMessageAsync($"**You have been BANNED from `{channel.Guild.Name}` server.**\n" +
|
||||||
@ -340,7 +319,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
msg = "No reason provided.";
|
msg = "No reason provided.";
|
||||||
}
|
}
|
||||||
if (umsg.Author.Id != user.Guild.OwnerId && user.Roles.Max().Position >= ((IGuildUser)umsg.Author).Roles.Max().Position)
|
if (umsg.Author.Id != user.Guild.OwnerId && user.Roles.Select(r => r.Position).Max() >= ((IGuildUser)umsg.Author).Roles.Select(r => r.Position).Max())
|
||||||
{
|
{
|
||||||
await channel.SendMessageAsync("You can't use this command on users with a role higher or equal to yours in the role hierarchy.");
|
await channel.SendMessageAsync("You can't use this command on users with a role higher or equal to yours in the role hierarchy.");
|
||||||
return;
|
return;
|
||||||
|
@ -70,7 +70,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
var beforeVch = before.VoiceChannel;
|
var beforeVch = before.VoiceChannel;
|
||||||
if (beforeVch != null)
|
if (beforeVch != null)
|
||||||
{
|
{
|
||||||
var textChannel = guild.GetTextChannels().Where(t => t.Name == GetChannelName(beforeVch.Name)).FirstOrDefault();
|
var textChannel = guild.GetTextChannels().Where(t => t.Name == GetChannelName(beforeVch.Name).ToLowerInvariant()).FirstOrDefault();
|
||||||
if (textChannel != null)
|
if (textChannel != null)
|
||||||
await textChannel.AddPermissionOverwriteAsync(user,
|
await textChannel.AddPermissionOverwriteAsync(user,
|
||||||
new OverwritePermissions(readMessages: PermValue.Deny,
|
new OverwritePermissions(readMessages: PermValue.Deny,
|
||||||
@ -80,11 +80,11 @@ namespace NadekoBot.Modules.Administration
|
|||||||
if (afterVch != null && guild.AFKChannelId != afterVch.Id)
|
if (afterVch != null && guild.AFKChannelId != afterVch.Id)
|
||||||
{
|
{
|
||||||
var textChannel = guild.GetTextChannels()
|
var textChannel = guild.GetTextChannels()
|
||||||
.Where(t => t.Name == GetChannelName(afterVch.Name))
|
.Where(t => t.Name == GetChannelName(afterVch.Name).ToLowerInvariant())
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
if (textChannel == null)
|
if (textChannel == null)
|
||||||
{
|
{
|
||||||
textChannel = (await guild.CreateTextChannelAsync(GetChannelName(afterVch.Name)).ConfigureAwait(false));
|
textChannel = (await guild.CreateTextChannelAsync(GetChannelName(afterVch.Name).ToLowerInvariant()).ConfigureAwait(false));
|
||||||
await textChannel.AddPermissionOverwriteAsync(guild.EveryoneRole,
|
await textChannel.AddPermissionOverwriteAsync(guild.EveryoneRole,
|
||||||
new OverwritePermissions(readMessages: PermValue.Deny,
|
new OverwritePermissions(readMessages: PermValue.Deny,
|
||||||
sendMessages: PermValue.Deny)).ConfigureAwait(false);
|
sendMessages: PermValue.Deny)).ConfigureAwait(false);
|
||||||
@ -117,9 +117,19 @@ namespace NadekoBot.Modules.Administration
|
|||||||
var botUser = guild.GetCurrentUser();
|
var botUser = guild.GetCurrentUser();
|
||||||
if (!botUser.GuildPermissions.ManageRoles || !botUser.GuildPermissions.ManageChannels)
|
if (!botUser.GuildPermissions.ManageRoles || !botUser.GuildPermissions.ManageChannels)
|
||||||
{
|
{
|
||||||
await channel.SendMessageAsync(":anger: `I require manage roles and manage channels permissions to enable this feature.`");
|
await channel.SendMessageAsync(":anger: `I require atleast manage roles and manage channels permissions to enable this feature (preffered Administration permission).`");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!botUser.GuildPermissions.Administrator)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await channel.SendMessageAsync(":warning: `You are enabling this feature and I do not have ADMINISTRATOR permissions, " +
|
||||||
|
"this may cause some issues, and you will have to clean up text channels yourself afterwards.`");
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
bool isEnabled;
|
bool isEnabled;
|
||||||
@ -156,14 +166,14 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
var channel = (ITextChannel)msg.Channel;
|
var channel = (ITextChannel)msg.Channel;
|
||||||
var guild = channel.Guild;
|
var guild = channel.Guild;
|
||||||
if (!guild.GetCurrentUser().GuildPermissions.ManageChannels)
|
if (!guild.GetCurrentUser().GuildPermissions.Administrator)
|
||||||
{
|
{
|
||||||
await channel.SendMessageAsync("`I have insufficient permission to do that.`").ConfigureAwait(false);
|
await channel.SendMessageAsync("`I need Administrator permission to do that.`").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var allTxtChannels = guild.GetTextChannels().Where(c => c.Name.EndsWith("-voice"));
|
var allTxtChannels = guild.GetTextChannels().Where(c => c.Name.EndsWith("-voice"));
|
||||||
var validTxtChannelNames = guild.GetVoiceChannels().Select(c => GetChannelName(c.Name));
|
var validTxtChannelNames = guild.GetVoiceChannels().Select(c => GetChannelName(c.Name).ToLowerInvariant());
|
||||||
|
|
||||||
var invalidTxtChannels = allTxtChannels.Where(c => !validTxtChannelNames.Contains(c.Name));
|
var invalidTxtChannels = allTxtChannels.Where(c => !validTxtChannelNames.Contains(c.Name));
|
||||||
|
|
||||||
|
@ -188,7 +188,9 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
{
|
{
|
||||||
actionQueue.Enqueue(() =>
|
actionQueue.Enqueue(() =>
|
||||||
{
|
{
|
||||||
playlist.Shuffle();
|
var oldPlaylist = playlist.ToArray();
|
||||||
|
playlist.Clear();
|
||||||
|
playlist.AddRange(oldPlaylist.Shuffle());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ namespace NadekoBot.Services.Impl
|
|||||||
|
|
||||||
public DB Db { get; }
|
public DB Db { get; }
|
||||||
public int TotalShards { get; }
|
public int TotalShards { get; }
|
||||||
|
public string CarbonKey { get; }
|
||||||
|
|
||||||
public BotCredentials()
|
public BotCredentials()
|
||||||
{
|
{
|
||||||
@ -48,6 +49,7 @@ namespace NadekoBot.Services.Impl
|
|||||||
BotId = cm.BotId ?? cm.ClientId;
|
BotId = cm.BotId ?? cm.ClientId;
|
||||||
ClientId = cm.ClientId;
|
ClientId = cm.ClientId;
|
||||||
SoundCloudClientId = cm.SoundCloudClientId;
|
SoundCloudClientId = cm.SoundCloudClientId;
|
||||||
|
CarbonKey = cm.CarbonKey;
|
||||||
if (cm.Db == null)
|
if (cm.Db == null)
|
||||||
Db = new DB("sqlite", "");
|
Db = new DB("sqlite", "");
|
||||||
else
|
else
|
||||||
@ -72,6 +74,7 @@ namespace NadekoBot.Services.Impl
|
|||||||
public string MashapeKey { get; set; } = "";
|
public string MashapeKey { get; set; } = "";
|
||||||
public string OsuApiKey { get; set; } = "";
|
public string OsuApiKey { get; set; } = "";
|
||||||
public string SoundCloudClientId { get; set; } = "";
|
public string SoundCloudClientId { get; set; } = "";
|
||||||
|
public string CarbonKey { get; set; } = "";
|
||||||
public DB Db { get; set; }
|
public DB Db { get; set; }
|
||||||
public int TotalShards { get; set; } = 1;
|
public int TotalShards { get; set; } = 1;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,9 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net.Http;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace NadekoBot.Services.Impl
|
namespace NadekoBot.Services.Impl
|
||||||
@ -21,6 +23,8 @@ namespace NadekoBot.Services.Impl
|
|||||||
|
|
||||||
public string Heap => Math.Round((double)GC.GetTotalMemory(false) / 1.MiB(), 2).ToString();
|
public string Heap => Math.Round((double)GC.GetTotalMemory(false) / 1.MiB(), 2).ToString();
|
||||||
|
|
||||||
|
Timer carbonitexTimer { get; }
|
||||||
|
|
||||||
|
|
||||||
public StatsService(ShardedDiscordClient client, CommandHandler cmdHandler)
|
public StatsService(ShardedDiscordClient client, CommandHandler cmdHandler)
|
||||||
{
|
{
|
||||||
@ -32,6 +36,29 @@ namespace NadekoBot.Services.Impl
|
|||||||
cmdHandler.CommandExecuted += (_, e) => commandsRan++;
|
cmdHandler.CommandExecuted += (_, e) => commandsRan++;
|
||||||
|
|
||||||
this.client.Disconnected += _ => Reset();
|
this.client.Disconnected += _ => Reset();
|
||||||
|
|
||||||
|
this.carbonitexTimer = new Timer(async (state) =>
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(NadekoBot.Credentials.CarbonKey))
|
||||||
|
return;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var http = new HttpClient())
|
||||||
|
{
|
||||||
|
using (var content = new FormUrlEncodedContent(
|
||||||
|
new Dictionary<string, string> {
|
||||||
|
{ "servercount", this.client.GetGuilds().Count.ToString() },
|
||||||
|
{ "key", NadekoBot.Credentials.CarbonKey }}))
|
||||||
|
{
|
||||||
|
content.Headers.Clear();
|
||||||
|
content.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
|
||||||
|
|
||||||
|
var res = await http.PostAsync("https://www.carbonitex.net/discord/data/botdata.php", content).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}, null, TimeSpan.FromHours(1), TimeSpan.FromHours(1));
|
||||||
}
|
}
|
||||||
public async Task<string> Print()
|
public async Task<string> Print()
|
||||||
{
|
{
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
"MashapeKey": "",
|
"MashapeKey": "",
|
||||||
"OsuApiKey": "",
|
"OsuApiKey": "",
|
||||||
"SoundCloudClientId": "",
|
"SoundCloudClientId": "",
|
||||||
|
"CarbonKey": "",
|
||||||
"Db": null,
|
"Db": null,
|
||||||
"TotalShards": 1
|
"TotalShards": 1
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user