コード例 #1
0
ファイル: CommandHandler.cs プロジェクト: Foopy969/Suyabot
        private Embed GetVoiceLogEmbed(SocketUser user, SocketVoiceChannel oldChannel, SocketVoiceChannel newChannel)
        {
            EmbedBuilder embed = new EmbedBuilder
            {
                Color = Color.Purple,
            };

            if (newChannel == null)
            {
                embed.WithDescription($"{user.GetText()} has left `{oldChannel}`");
            }
            else if (oldChannel == null)
            {
                embed.WithDescription($"{user.GetText()} has joined `{newChannel}`");
            }
            else
            {
                embed.WithDescription($"{user.GetText()} has moved from `{oldChannel}` to `{newChannel}`");
            }
            return(embed.Build());
        }
コード例 #2
0
        public async Task Give(SocketUser target, int amount)
        {
            int userIndex   = Config.Profiles.FindIndex(x => x.UserID == Context.User.Id);
            int targetIndex = Config.Profiles.FindIndex(x => x.UserID == target.Id);

            if (userIndex == -1)
            {
                Extensions.Log("Error", $"Couldn't find profile for {Context.User.Username}");
                await Context.Channel.SendEmbedAsync($"Error", $"Couldn't find profile for {Context.User.GetText()}");

                return;
            }
            else if (targetIndex == -1)
            {
                Extensions.Log("Error", $"Couldn't find profile for {target.Username}");
                await Context.Channel.SendEmbedAsync($"Error", $"Couldn't find profile for {target.GetText()}");

                return;
            }
            else if (userIndex == targetIndex)
            {
                Extensions.Log("Error", $"Duplicate profile");
                await Context.Channel.SendEmbedAsync($"{Context.User.GetText()} gave him/herself money lmao");

                return;
            }
            else if (amount <= 0)
            {
                Extensions.Log("Error", $"Invalid amount");
                await Context.Channel.SendEmbedAsync($"Error", $"`{amount}` is not a valid amount");

                return;
            }
            else if (Config.Profiles[userIndex].Credit < amount)
            {
                Extensions.Log("Error", $"Invalid amount");
                await Context.Channel.SendEmbedAsync($"`{Context.User.GetText()}` you don't have anough credit");

                return;
            }

            Config.Profiles[userIndex].Credit   -= amount;
            Config.Profiles[targetIndex].Credit += amount;
            Config.Write(Config.ProfilesPath, Config.Profiles);

            await Context.Channel.SendEmbedAsync($"{Context.User.GetText()} gave `{amount}` credit to {target.GetText()}");

            return;
        }
コード例 #3
0
        public async Task Profile(SocketUser user = null)
        {
            user = user == null ? Context.User : user;
            int index = Config.Profiles.FindIndex(x => x.UserID == user.Id);

            if (index == -1)
            {
                Extensions.Log("Error", $"Couldn't find profile for {user.Username}");
                await Context.Channel.SendEmbedAsync($"Error", $"Couldn't find profile for {user.GetText()}");

                return;
            }

            Profile      profile = Config.Profiles[index];
            EmbedBuilder embed   = new EmbedBuilder
            {
                Color  = Color.Purple,
                Author = new EmbedAuthorBuilder
                {
                    IconUrl = user.GetAvatarUrl(),
                    Name    = user.Username
                }
            };

            embed.AddField("Level", profile.Level);
            embed.AddField("Credit", profile.Credit);
            embed.AddField("Exp", $"{profile.GetExpBar()} ({profile.Exp} / {profile.GetMaxExp()})");
            await Context.Channel.SendMessageAsync("", false, embed.Build());
        }