New lib, created some mock class for editing
The class would allow you to edit users LINQ-style , i just need to convince voltana to make this happen
This commit is contained in:
parent
537595694a
commit
fcb59b15ad
@ -13,10 +13,10 @@ namespace NadekoBot
|
||||
{
|
||||
public class Trivia : DiscordCommand
|
||||
{
|
||||
public static Dictionary<long, TriviaGame> runningTrivias;
|
||||
public static Dictionary<ulong, TriviaGame> runningTrivias;
|
||||
|
||||
public Trivia() : base() {
|
||||
runningTrivias = new Dictionary<long, TriviaGame>();
|
||||
runningTrivias = new Dictionary<ulong, TriviaGame>();
|
||||
}
|
||||
|
||||
public static TriviaGame StartNewGame(CommandEventArgs e) {
|
||||
@ -29,7 +29,7 @@ namespace NadekoBot
|
||||
return tg;
|
||||
}
|
||||
|
||||
public TriviaQuestion GetCurrentQuestion(long serverId) => runningTrivias[serverId].currentQuestion;
|
||||
public TriviaQuestion GetCurrentQuestion(ulong serverId) => runningTrivias[serverId].currentQuestion;
|
||||
|
||||
public override Func<CommandEventArgs, Task> DoFunc() => async e =>
|
||||
{
|
||||
@ -103,12 +103,12 @@ namespace NadekoBot
|
||||
public class TriviaGame {
|
||||
|
||||
private DiscordClient client;
|
||||
private long _serverId;
|
||||
private long _channellId;
|
||||
private ulong _serverId;
|
||||
private ulong _channellId;
|
||||
|
||||
public long ChannelId => _channellId;
|
||||
public ulong ChannelId => _channellId;
|
||||
|
||||
private Dictionary<long, int> users;
|
||||
private Dictionary<ulong, int> users;
|
||||
|
||||
public List<string> oldQuestions;
|
||||
|
||||
@ -121,7 +121,7 @@ namespace NadekoBot
|
||||
private bool isQuit = false;
|
||||
|
||||
public TriviaGame(CommandEventArgs starter, DiscordClient client) {
|
||||
this.users = new Dictionary<long, int>();
|
||||
this.users = new Dictionary<ulong, int>();
|
||||
this.client = client;
|
||||
this._serverId = starter.Server.Id;
|
||||
this._channellId= starter.Channel.Id;
|
||||
@ -196,7 +196,7 @@ namespace NadekoBot
|
||||
|
||||
if (currentQuestion == null || isQuit)
|
||||
{
|
||||
await ch.Send("Trivia bot stopping. :\\\n" + GetLeaderboard());
|
||||
ch.Send("Trivia bot stopping. :\\\n" + GetLeaderboard());
|
||||
FinishGame();
|
||||
return;
|
||||
}
|
||||
|
@ -6,13 +6,12 @@
|
||||
public string Password;
|
||||
public string BotMention;
|
||||
public string GoogleAPIKey;
|
||||
public long OwnerID;
|
||||
public ulong OwnerID;
|
||||
public bool Crawl;
|
||||
public string ParseID;
|
||||
public string ParseKey;
|
||||
}
|
||||
|
||||
class AnimeResult
|
||||
public class AnimeResult
|
||||
{
|
||||
public int id;
|
||||
public string airing_status;
|
||||
@ -29,7 +28,6 @@
|
||||
"\n`Synopsis:` " + description.Substring(0, description.Length > 500 ? 500 : description.Length) + "..." +
|
||||
"\n`img:` " + image_url_lge;
|
||||
}
|
||||
|
||||
class MangaResult
|
||||
{
|
||||
public int id;
|
||||
|
@ -7,11 +7,11 @@ namespace NadekoBot
|
||||
{
|
||||
class CopyCommand : DiscordCommand
|
||||
{
|
||||
private List<long> CopiedUsers;
|
||||
private List<ulong> CopiedUsers;
|
||||
|
||||
public CopyCommand() : base()
|
||||
{
|
||||
CopiedUsers = new List<long>();
|
||||
CopiedUsers = new List<ulong>();
|
||||
client.MessageReceived += Client_MessageReceived;
|
||||
}
|
||||
|
||||
|
@ -241,10 +241,14 @@ namespace NadekoBot.Modules
|
||||
.Parameter("user",Discord.Commands.ParameterType.Required)
|
||||
.Do(async e =>
|
||||
{
|
||||
if (e.Message.MentionedUsers.Any())
|
||||
await e.Send( "Id of the user " + e.Message.MentionedUsers.First().Mention + " is " + e.Message.MentionedUsers.First().Id);
|
||||
else
|
||||
await e.Send( "You must mention a user.");
|
||||
var usr = client.FindUsers(e.Channel, e.GetArg("user")).FirstOrDefault();
|
||||
if (usr == null)
|
||||
{
|
||||
await e.Send("You must mention a user.");
|
||||
return;
|
||||
}
|
||||
|
||||
await e.Send( "Id of the user " + usr.Name + " is " + usr.Id);
|
||||
});
|
||||
|
||||
cgb.CreateCommand(".cid").Alias(".channelid")
|
||||
|
@ -94,7 +94,7 @@ namespace NadekoBot.Modules
|
||||
}
|
||||
}
|
||||
|
||||
private PokeType GetType(long id) {
|
||||
private PokeType GetType(ulong id) {
|
||||
var remainder = id % 10;
|
||||
if (remainder < 3)
|
||||
return PokeType.WATER;
|
||||
|
@ -22,6 +22,81 @@ namespace NadekoBot.Modules
|
||||
|
||||
}
|
||||
|
||||
class EditUserBuilder {
|
||||
|
||||
public Discord.DiscordClient Client { get; set; }
|
||||
public Discord.User User { get; set; }
|
||||
private bool? ShouldMute { get; set; }
|
||||
private bool? ShouldDeaf { get; set; }
|
||||
private Discord.Channel TargetVoiceChannel { get; set; }
|
||||
private Dictionary<Discord.EditMode, IEnumerable<Discord.Role>> TargetRoles { get; set; }
|
||||
|
||||
|
||||
public EditUserBuilder(Discord.User user, Discord.DiscordClient client = null) {
|
||||
this.User = user;
|
||||
this.Client = client;
|
||||
TargetRoles = new Dictionary<Discord.EditMode, IEnumerable<Discord.Role>>();
|
||||
}
|
||||
|
||||
public EditUserBuilder Mute(bool mute = true) {
|
||||
ShouldMute = mute;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EditUserBuilder Deaf(bool mute = true)
|
||||
{
|
||||
ShouldDeaf = mute;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EditUserBuilder VoiceChannel(Discord.Channel voiceChannel = null)
|
||||
{
|
||||
TargetVoiceChannel = voiceChannel;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EditUserBuilder Roles(IEnumerable<Discord.Role> roles, Discord.EditMode mode)
|
||||
{
|
||||
if (TargetRoles.Keys.Contains(mode))
|
||||
{
|
||||
TargetRoles[mode] = TargetRoles[mode].Concat(roles);
|
||||
}
|
||||
else
|
||||
{
|
||||
TargetRoles[mode] = roles;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public async Task Apply() {
|
||||
if (Client == null || User == null) return; //throw exception?
|
||||
await Client.EditUser(User, ShouldMute, ShouldDeaf, TargetVoiceChannel);
|
||||
foreach (var mode in TargetRoles.Keys) {
|
||||
await Client.EditUser(User, null, null, null, TargetRoles[mode], mode);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
public EditUserBuilder SetUser(Discord.User user)
|
||||
{
|
||||
this.User = user;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EditUserBuilder SetClient(Discord.DiscordClient client)
|
||||
{
|
||||
this.Client = client;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EditUserBuilder DoWhen(Func<EditUserBuilder, EditUserBuilder> func, Func<bool> predicate) {
|
||||
if (predicate())
|
||||
return func(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void Install(ModuleManager manager)
|
||||
{
|
||||
var client = NadekoBot.client;
|
||||
|
@ -15,7 +15,7 @@ namespace NadekoBot
|
||||
// public static StatsCollector stats_collector;
|
||||
public static string botMention;
|
||||
public static string GoogleAPIKey;
|
||||
public static long OwnerID;
|
||||
public static ulong OwnerID;
|
||||
|
||||
static void Main()
|
||||
{
|
||||
|
@ -48,18 +48,6 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Discord.Net">
|
||||
<HintPath>E:\Ostalo\Discord.Net\src\Discord.Net.Modules.Net45\bin\Debug\Discord.Net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Discord.Net.Audio">
|
||||
<HintPath>E:\Ostalo\Discord.Net\src\Discord.Net.Audio.Net5\bin\Debug\Discord.Net.Audio.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Discord.Net.Commands">
|
||||
<HintPath>E:\Ostalo\Discord.Net\src\Discord.Net.Modules.Net45\bin\Debug\Discord.Net.Commands.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Discord.Net.Modules">
|
||||
<HintPath>E:\Ostalo\Discord.Net\src\Discord.Net.Modules.Net45\bin\Debug\Discord.Net.Modules.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="libvideo, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\VideoLibrary.1.3.1\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\libvideo.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
@ -138,6 +126,24 @@
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="E:\Ostalo\Discord.Net\src\Discord.Net.Audio.Net5\Discord.Net.Audio.csproj">
|
||||
<Project>{7bfef748-b934-4621-9b11-6302e3a9f6b3}</Project>
|
||||
<Name>Discord.Net.Audio</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="E:\Ostalo\Discord.Net\src\Discord.Net.Commands.Net45\Discord.Net.Commands.csproj">
|
||||
<Project>{1b5603b4-6f8f-4289-b945-7baae523d740}</Project>
|
||||
<Name>Discord.Net.Commands</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="E:\Ostalo\Discord.Net\src\Discord.Net.Modules.Net45\Discord.Net.Modules.csproj">
|
||||
<Project>{3091164f-66ae-4543-a63d-167c1116241d}</Project>
|
||||
<Name>Discord.Net.Modules</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="E:\Ostalo\Discord.Net\src\Discord.Net.Net45\Discord.Net.csproj">
|
||||
<Project>{8d71a857-879a-4a10-859e-5ff824ed6688}</Project>
|
||||
<Name>Discord.Net</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
@ -154,8 +154,8 @@ namespace NadekoBot
|
||||
{
|
||||
if (i == requestNumber) {
|
||||
var txt = reqObj.Get<string>("Request");
|
||||
var id = reqObj.Get<long>("UserId");
|
||||
var sid = reqObj.Get<long>("ServerId");
|
||||
var id = reqObj.Get<ulong>("UserId");
|
||||
var sid = reqObj.Get<ulong>("ServerId");
|
||||
reqObj.DeleteAsync();
|
||||
return new ResolveRequestObject { Id = id, Text = txt, ServerId=sid };
|
||||
}
|
||||
@ -165,8 +165,8 @@ namespace NadekoBot
|
||||
}
|
||||
|
||||
public class ResolveRequestObject {
|
||||
public long Id;
|
||||
public long ServerId;
|
||||
public ulong Id;
|
||||
public ulong ServerId;
|
||||
public string Text;
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user