コード例 #1
0
        public async Task UserJoinServer(SocketGuildUser arg)
        {
            var guildData  = _config.CurrentValue.GuildData;
            var raidLeader = _discordContext.GetUserNickname(guildData.GuildRaidLeadreId);

            var raidLeaderName = string.Equals(raidLeader, guildData.GuildRaidLeaderName, StringComparison.OrdinalIgnoreCase)
                ? raidLeader
                : $"{raidLeader} ({guildData.GuildRaidLeaderName})";

            var defaultRole = _discord.GetGuild(_config.CurrentValue.MyGuildId)
                              .GetRole(_config.CurrentValue.DefaultUserRole);

            var sb = new StringBuilder();

            sb.AppendLine($"Witaj na Discordzie gildi {guildData.GuildName.Decorate(Decorator.Bold)}");
            sb.AppendLine("Jak chcesz dowiedzieć się więcej zapraszamy na stronę gildii lub do kontaktu z Oficerami");
            sb.AppendLine(guildData.GuildUrl);
            sb.AppendLine(string.Empty);
            sb.AppendLine("Do mówienia na kanale raidowym wymagane jest Push-to-talk".Decorate(Decorator.Underline));
            sb.AppendLine("W przypadku jakichkolwiek pytań zachęcamy do kontaktu :)");
            sb.AppendLine(string.Empty);
            sb.AppendLine($"W razie pytań odnośnie raidów zachęcam do kontaktu z Raid Leaderem - {raidLeaderName}");
            sb.AppendLine(string.Empty);
            sb.AppendLine(string.Empty);
            sb.AppendLine($"{"Jeżeli chcesz poznać funkcję bota zapraszam do wykorzystania komendy".Decorate(Decorator.Italics)} {"!pomoc".Decorate(Decorator.Bold)}");

            await arg.AddRoleAsync(defaultRole);

            await arg.SendMessageAsync(sb.ToString());
        }
コード例 #2
0
        public async Task SendPassToAll()
        {
            var loginCell    = _config.CurrentValue.RaidbotsAccountData.LoginCellAddress;
            var passwordCell = _config.CurrentValue.RaidbotsAccountData.PasswordCellAddress;
            var allowedRole  = _config.CurrentValue.RaidbotsAccountData.AllowerRoleId;

            var login = await _googleService.ReadCellAsync(loginCell);

            var password = await _googleService.ReadCellAsync(passwordCell);

            foreach (var usr in _discord.GetGuild(_config.CurrentValue.MyGuildId).Users.Where(x => x.Roles.Any(y => y.Id == allowedRole)))
            {
                var container = new EmbedFieldBuilder
                {
                    IsInline = true,
                    Name     = "Dane logowania:",
                    Value    = $"{("Login: "******"Hasło: ".Decorate(Decorator.Bold))}{password.Decorate(Decorator.Inline_code)}"
                };

                var emb = new EmbedBuilder
                {
                    Color = Color.Blue,
                    Url   = @"https://www.raidbots.com/auth",
                    Title = $"Konto do raidbotsów"
                };

                var footer = new EmbedFooterBuilder
                {
                    Text = $"[{DateTime.Now:yyyy-MM-dd  HH:mm:ss}]"
                };

                emb.Footer = footer;
                emb.AddField(container);

                try
                {
                    await usr.SendMessageAsync(string.Empty, false, emb.Build());

                    await Context.Channel.SendMessageAsync($"Wysłano wiadomość z danymi dostępowymi do: {_discordContext.GetUserNickname(usr.Id)}");
                }
                catch (Discord.Net.HttpException ex)
                {
                    if (ex.DiscordCode == 50007)
                    {
                        await Context.Channel.SendMessageAsync($"Użytkownik nie zezwala na DM: {_discordContext.GetUserNickname(usr.Id)}");
                    }
                    else
                    {
                        await Context.Channel.SendMessageAsync($"Błąd doscorda: {_discordContext.GetUserNickname(usr.Id)} ([{ex.DiscordCode}] - {ex.Message})");
                    }
                }
                catch (Exception ex)
                {
                    await Context.Channel.SendMessageAsync($"Błąd bota: {_discordContext.GetUserNickname(usr.Id)} ({ex.Message})");
                }
            }
        }
コード例 #3
0
        public async Task CountFlasks(string fightId, int count)
        {
            var data = await _warcraftLogsService.GetFullFight(fightId);

            if (data != null)
            {
                var fightDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
                fightDateTime = fightDateTime.AddMilliseconds(data.Start).ToLocalTime();

                SubstractFlasks(data.Friendlies, count, fightDateTime);
                AddReaction(fightId);

                var counter = 1;
                var sb      = new StringBuilder();
                foreach (var friendly in data.Friendlies)
                {
                    sb.AppendLine($"{counter++}. {friendly.Name.Decorate(Decorator.Bold)}  ({friendly.Type.Decorate(Decorator.Italics)})");
                }

                sb.AppendLine(string.Empty);
                sb.AppendLine($"Odejmuje {count.ToString().Decorate(Decorator.Bold)} {count.FlaskGrammaVariety()}");

                foreach (var msg in sb.ToString().DiscordMessageSplit())
                {
                    await Context.Channel.SendMessageAsync(msg);
                }

                var nick = _discordContext.GetUserNickname(Context.User.Id);
                await _discordContext.GetChannel(_config.CurrentValue.FlaskChannelId).SendMessageAsync($"Podliczono raid z {fightDateTime.ToString("yyyy-MM-dd".Decorate(Decorator.Bold))} przez użytkownika {nick.Decorate(Decorator.Bold)}");
            }
            else
            {
                await _logger.WriteLog($"Logs {fightId} doesn't exist");

                await Context.Channel.SendMessageAsync($"Logi o Id {fightId} nie istnieją!");
            }
        }