예제 #1
0
        public async Task Send([Summary("The user to send currency to.")] SocketGuildUser mention = null, [Summary("The amount to send."), Remainder] int amount = 1)
        {
            if (Xml.CommandAllowed("send", Context))
            {
                //Check that the post author has money
                bool hasMoney       = false;
                int  originalAmount = 0;
                foreach (var pair in UserSettings.Currency.Get(Context.Guild.Id))
                {
                    if (pair.Item1 == Context.Message.Author.Id.ToString())
                    {
                        originalAmount = pair.Item2;
                    }
                }

                if (originalAmount >= amount)
                {
                    hasMoney = true;
                }


                if (hasMoney)
                {
                    UserSettings.Currency.Remove(Context.Guild.Id, Context.Message.Author.Id, amount);
                    UserSettings.Currency.Add(Context.Guild.Id, mention.Id, amount);

                    var botlog = await Context.Guild.GetTextChannelAsync(UserSettings.Channels.BotLogsId(Context.Guild.Id));

                    var embed = Embeds.Send((SocketGuildUser)Context.Message.Author, mention.Username, amount);
                    await botlog.SendMessageAsync("", embed : embed).ConfigureAwait(false);

                    await Context.Channel.SendMessageAsync("", embed : embed).ConfigureAwait(false);
                }
                else
                {
                    await Context.Channel.SendMessageAsync($"You don't have enough {UserSettings.BotOptions.GetString("CurrencyName", Context.Guild.Id)}!");
                }
            }
        }