Donators commands, removed message cache
This commit is contained in:
parent
afe929430a
commit
4668985d26
@ -20,6 +20,7 @@ namespace NadekoBot.Classes {
|
|||||||
_conn.CreateTable<TypingArticle>();
|
_conn.CreateTable<TypingArticle>();
|
||||||
_conn.CreateTable<CurrencyState>();
|
_conn.CreateTable<CurrencyState>();
|
||||||
_conn.CreateTable<CurrencyTransaction>();
|
_conn.CreateTable<CurrencyTransaction>();
|
||||||
|
_conn.CreateTable<Donator>();
|
||||||
_conn.Execute(Queries.TransactionTriggerQuery);
|
_conn.Execute(Queries.TransactionTriggerQuery);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
13
NadekoBot/Classes/_DataModels/Donator.cs
Normal file
13
NadekoBot/Classes/_DataModels/Donator.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace NadekoBot.Classes._DataModels {
|
||||||
|
class Donator : IDataModel {
|
||||||
|
public long UserId { get; set; }
|
||||||
|
public string UserName { get; set; }
|
||||||
|
public int Amount { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -562,6 +562,43 @@ namespace NadekoBot.Modules {
|
|||||||
return;
|
return;
|
||||||
await Task.Run(() => NadekoBot.client.MessageQueue.Clear());
|
await Task.Run(() => NadekoBot.client.MessageQueue.Clear());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
cgb.CreateCommand(".donators")
|
||||||
|
.Description("List of lovely people who donated to keep this project alive.")
|
||||||
|
.Do(async e => {
|
||||||
|
await Task.Run(async () => {
|
||||||
|
var rows = Classes.DBHandler.Instance.GetAllRows<Donator>();
|
||||||
|
var donatorsOrdered = rows.OrderBy(d => d.Amount);
|
||||||
|
string str = $"`Total number of people who donated is {donatorsOrdered.Count()}`\n";
|
||||||
|
foreach (var don in donatorsOrdered) {
|
||||||
|
str += don.UserName;
|
||||||
|
}
|
||||||
|
await e.Channel.SendMessage(str);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
//THIS IS INTENTED TO BE USED ONLY BY THE ORIGINAL BOT OWNER
|
||||||
|
cgb.CreateCommand(".adddon")
|
||||||
|
.Description("Add a donator to the database.")
|
||||||
|
.Parameter("donator")
|
||||||
|
.Parameter("amount")
|
||||||
|
.Do(e => {
|
||||||
|
try {
|
||||||
|
if (NadekoBot.OwnerID != e.User.Id)
|
||||||
|
return;
|
||||||
|
var donator = e.Server.FindUsers(e.GetArg("donator")).FirstOrDefault();
|
||||||
|
var amount = int.Parse(e.GetArg("amount"));
|
||||||
|
Classes.DBHandler.Instance.InsertData(new Donator {
|
||||||
|
Amount = amount,
|
||||||
|
UserName = donator.Name,
|
||||||
|
UserId = (long)e.User.Id
|
||||||
|
});
|
||||||
|
e.Channel.SendMessage("Successfuly added a new donator. 👑");
|
||||||
|
} catch (Exception ex) {
|
||||||
|
Console.WriteLine(ex);
|
||||||
|
Console.WriteLine("---------------\nInner error:\n" + ex.InnerException);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
/*cgb.CreateCommand(".voicetext")
|
/*cgb.CreateCommand(".voicetext")
|
||||||
.Description("Enabled or disabled voice to text channel connection. Only people in a certain voice channel will see ")
|
.Description("Enabled or disabled voice to text channel connection. Only people in a certain voice channel will see ")
|
||||||
|
@ -276,7 +276,7 @@ namespace NadekoBot.Modules {
|
|||||||
.Do(async e => {
|
.Do(async e => {
|
||||||
|
|
||||||
Message msg = null;
|
Message msg = null;
|
||||||
var msgs = e.Channel.Messages
|
var msgs = (await e.Channel.DownloadMessages(100))
|
||||||
.Where(m => m.MentionedUsers.Contains(e.User))
|
.Where(m => m.MentionedUsers.Contains(e.User))
|
||||||
.OrderByDescending(m => m.Timestamp);
|
.OrderByDescending(m => m.Timestamp);
|
||||||
if (msgs.Count() > 0)
|
if (msgs.Count() > 0)
|
||||||
|
@ -61,7 +61,9 @@ namespace NadekoBot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//create new discord client
|
//create new discord client
|
||||||
client = new DiscordClient();
|
client = new DiscordClient(new DiscordConfig {
|
||||||
|
MessageCacheSize = 0
|
||||||
|
});
|
||||||
|
|
||||||
//create a command service
|
//create a command service
|
||||||
var commandService = new CommandService(new CommandServiceConfig {
|
var commandService = new CommandService(new CommandServiceConfig {
|
||||||
|
@ -139,6 +139,7 @@
|
|||||||
<Compile Include="Classes\_DataModels\CommandModel.cs" />
|
<Compile Include="Classes\_DataModels\CommandModel.cs" />
|
||||||
<Compile Include="Classes\_DataModels\CurrencyStateModel.cs" />
|
<Compile Include="Classes\_DataModels\CurrencyStateModel.cs" />
|
||||||
<Compile Include="Classes\_DataModels\CurrencyTransactionModel.cs" />
|
<Compile Include="Classes\_DataModels\CurrencyTransactionModel.cs" />
|
||||||
|
<Compile Include="Classes\_DataModels\Donator.cs" />
|
||||||
<Compile Include="Classes\_DataModels\IDataModel.cs" />
|
<Compile Include="Classes\_DataModels\IDataModel.cs" />
|
||||||
<Compile Include="Classes\_DataModels\RequestModel.cs" />
|
<Compile Include="Classes\_DataModels\RequestModel.cs" />
|
||||||
<Compile Include="Classes\_DataModels\StatsModel.cs" />
|
<Compile Include="Classes\_DataModels\StatsModel.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user