コード例 #1
0
        private async Task OnJoinedGuild(SocketGuild arg)
        {
            await arg.DefaultChannel.TriggerTypingAsync();

            var builder = new EmbedBuilder()
                          .WithThumbnailUrl(arg.CurrentUser.GetAvatarUrl())
                          .WithTitle("Thanks for inviting me!")
                          .WithDescription("I'm still in training, please take care of me...\nType !help for a list of commands.")
                          .WithColor(new Color(33, 176, 252))
                          .WithCurrentTimestamp();
            var embed = builder.Build();
            await arg.DefaultChannel.SendMessageAsync(null, false, embed);

            //calls this method whenever bibs joins a new server so bibs doesn't do a die
            await _servers.ClearFilterAsync(arg.Id);

            await _servers.ClearRaidAsync(arg.Id);

            await _servers.ClearNoWeebAsync(arg.Id);

            await _servers.ClearHasLimitAsync(arg.Id);

            await _servers.ClearHasMarkovAsync(arg.Id);

            await _client.SetGameAsync($"over {_client.Guilds.Count} servers!", null, ActivityType.Watching);
        }
コード例 #2
0
ファイル: Moderation.cs プロジェクト: ribs351/Bibs_dotNET
        public async Task Raid()
        {
            var thirtyMinutes     = new TimeSpan(0, 30, 0);
            var fetchedServerRaid = await _servers.GetRaidAsync(Context.Guild.Id);

            try
            {
                await _servers.ModifyRaidAsync(Context.Guild.Id);

                await _serverHelper.SendLogAsync(Context.Guild, "Situation Log", $"{Context.User.Mention} activated Raid Mode! Prepare the defenses!");

                await Context.Channel.SendSuccessAsync("Raid Mode", $"Successfully sets the raid mode to {fetchedServerRaid.ToString()}");

                while (fetchedServerRaid == true)
                {
                    var invites = await Context.Guild.GetInvitesAsync();

                    foreach (var user in Context.Guild.Users)
                    {
                        if ((DateTime.Now - user.JoinedAt) < thirtyMinutes)
                        {
                            var channel = await user.GetOrCreateDMChannelAsync();

                            await channel.SendMessageAsync($"You've been kicked from {Context.Guild.Name} as a result of a raid that was detected. If you feel like you shouldn't have got kicked, please feel free to join back.");

                            await channel.SendMessageAsync(invites.Select(x => x.Url).FirstOrDefault());

                            await user.KickAsync();
                        }
                        else
                        {
                            continue;
                        }
                    }
                }
            }
            catch (Exception)
            {
                await _servers.ClearRaidAsync(Context.Guild.Id);

                await Context.Channel.SendErrorAsync("Error", "Something went wrong, please try again, if the bot is unresponsive, contact Ribs#8205 on discord.");
            }
        }