1
1
using System . Linq ;
2
+ using System . Text ;
2
3
using System . Threading . Tasks ;
3
4
using Alderto . Bot . Extensions ;
4
5
using Alderto . Services ;
5
6
using Alderto . Services . Exceptions ;
7
+ using Discord ;
6
8
using Discord . Commands ;
7
9
using Microsoft . EntityFrameworkCore ;
8
10
9
11
namespace Alderto . Bot . Modules
10
12
{
11
- [ Group , Alias ( "GuildBank" , "GB" ) ]
13
+ [ Group , Alias ( "GuildBank" , "GB" , "GuildBanks" , "Banks" , "Bank" ) ]
12
14
public class GuildBankModule : ModuleBase < SocketCommandContext >
13
15
{
14
16
private readonly IGuildBankManager _guildBankManager ;
@@ -18,44 +20,24 @@ public GuildBankModule(IGuildBankManager guildBankManager)
18
20
_guildBankManager = guildBankManager ;
19
21
}
20
22
21
- //[Command("Give"), Alias("Add")]
22
- //public async Task Give(IGuildUser transactor, string bankName, string itemName, double quantity)
23
- //{
24
- // if (itemName == "$")
25
- // {
26
- // // Special case - currency donation.
27
- // await _guildBankManager.ModifyCurrencyCountAsync(Context.Guild.Id, bankName, Context.User.Id, transactor.Id, quantity);
28
- // }
29
- // else
30
- // {
31
- // await _guildBankManager.ModifyItemCountAsync(Context.Guild.Id, bankName, Context.User.Id, transactor.Id, itemName, quantity);
32
- // }
33
- //}
34
-
35
- //[Command("Take"), Alias("Remove")]
36
- //public async Task Take(IGuildUser transactor, string bankName, string itemName, double quantity)
37
- //{
38
- // if (itemName == "$")
39
- // {
40
- // // Special case - currency donation.
41
- // await _guildBankManager.ModifyCurrencyCountAsync(Context.Guild.Id, bankName, Context.User.Id, transactor.Id, -quantity);
42
- // }
43
- // else
44
- // {
45
- // await _guildBankManager.ModifyItemCountAsync(Context.Guild.Id, bankName, Context.User.Id, transactor.Id, itemName, -quantity);
46
- // }
47
- //}
23
+ [ Command ( "list" ) ]
24
+ public async Task List ( )
25
+ {
26
+ var banks = await _guildBankManager . GetGuildBanksAsync ( Context . Guild . Id ) ;
27
+ await this . ReplyEmbedAsync ( banks . Aggregate ( new StringBuilder ( ) , ( c , i ) => c . Append ( $ "**{ i . Name , 32 } **\n ") ) . ToString ( ) ) ;
28
+ }
48
29
49
- [ Command ( "Items" ) , Alias ( "List ") ]
30
+ [ Command ( "items " ) ]
50
31
public async Task Items ( string bankName )
51
32
{
52
33
var bank = await _guildBankManager . GetGuildBankAsync ( Context . Guild . Id , bankName ,
53
34
b => b . Include ( g => g . Contents ) ) ;
54
35
if ( bank == null )
55
36
throw new BankNotFoundException ( ) ;
56
37
57
- var res = bank . Contents . Aggregate ( seed : "" , ( current , item ) => current + $ "{ item . Name } { item . Description } \n ") ;
58
- await this . ReplySuccessEmbedAsync ( res ) ;
38
+ var res = bank . Contents . Aggregate ( new StringBuilder ( ) , ( current , item ) =>
39
+ current . Append ( $ "**{ item . Name } **\n { ( string . IsNullOrEmpty ( item . Description ) ? "N/A" : item . Description ) } \n *qty*: { item . Quantity } @ { item . Value } ea.\n \n ") ) ;
40
+ await this . ReplyEmbedAsync ( res . ToString ( ) ) ;
59
41
}
60
42
}
61
43
}
0 commit comments