コード例 #1
0
ファイル: Helper.cs プロジェクト: htcheroportugal/HassBot
        public static async Task RefreshData(SocketCommandContext context)
        {
            var embed = new EmbedBuilder();

            try
            {
                Sitemap.ReloadData();
                BlockedDomains.ReloadData();
                HassBotCommands.ReloadData();
            }
            catch
            {
                embed.WithColor(Color.Red);
                embed.AddInlineField(Constants.EMOJI_FAIL, Constants.COMMAND_REFRESH_FAILED);
                await context.Channel.SendMessageAsync(string.Empty, false, embed);

                return;
            }

            embed.WithColor(Helper.GetRandomColor());
            embed.AddInlineField(Constants.EMOJI_THUMBSUP, Constants.COMMAND_REFRESH_SUCCESSFUL);
            await context.Channel.SendMessageAsync(string.Empty, false, embed);
        }
コード例 #2
0
        public async Task ConfigAsync(EventContext e)
        {
            var cache = (ICacheClient)e.Services.GetService(typeof(ICacheClient));
            var db    = (DbContext)e.Services.GetService(typeof(DbContext));

            Module module = e.EventSystem.GetCommandHandler <SimpleCommandHandler>().Modules.FirstOrDefault(x => x.Name.ToLower() == e.Arguments.ToString().ToLower());

            if (module != null)
            {
                EmbedBuilder embed = new EmbedBuilder();

                embed.Title = (e.Arguments.ToString().ToUpper());

                string content = "";

                foreach (CommandEvent ev in module.Events.OrderBy((x) => x.Name))
                {
                    content += (await ev.IsEnabled(cache, db, e.Channel.Id) ? "<:iconenabled:341251534522286080>" : "<:icondisabled:341251533754728458>") + " " + ev.Name + "\n";
                }

                embed.AddInlineField("Events", content);

                content = "";

                foreach (BaseService ev in module.Services.OrderBy((x) => x.Name))
                {
                    content += (await ev.IsEnabled(cache, db, e.Channel.Id) ? "<:iconenabled:341251534522286080>" : "<:icondisabled:341251533754728458>") + " " + ev.Name + "\n";
                }

                if (!string.IsNullOrEmpty(content))
                {
                    embed.AddInlineField("Services", content);
                }

                await embed.ToEmbed().QueueToChannelAsync(e.Channel);
            }
        }
コード例 #3
0
        public async Task Ping()
        {
            try
            {
                string       infoImageUrl = Configuration.GetSection("images")?.GetSection("info")?["64"];
                EmbedBuilder embed        = new EmbedBuilder()
                                            .WithTitle("Procesando...")
                                            .WithColor(GlobalConfiguration.Colors.Info);

                Stopwatch sw = new();
                sw.Start();
                await RespondAsync(embed : embed.Build());

                sw.Stop();

                string responseTime = Context.Client is DiscordSocketClient socketClient ? $"{socketClient.Latency} ms" : null;
                string latency      = $"{sw.ElapsedMilliseconds} ms";
                await Context.Interaction.ModifyOriginalResponseAsync(x =>
                {
                    Emoji pingEmoji    = new("\uD83D\uDCE1");
                    Emoji gatewayEmoji = new("\uD83D\uDEAA");

                    embed.WithTitle($"Resultado del {Format.Code($"/ping")}").WithThumbnailUrl(infoImageUrl);
                    if (responseTime != null)
                    {
                        embed.AddInlineField("Tiempo de respuesta", $"{pingEmoji} {responseTime}").AddInlineField();
                    }
                    embed.AddInlineField("Latencia del gateway", $"{gatewayEmoji} {latency}");

                    x.Embed = embed.Build();
                });
            }
            catch (Exception ex)
            {
                await SendDeferredErrorResponseAsync(ex);
            }
        }
コード例 #4
0
        public async Task BackdoorModule(ulong GuildId)
        {
            //(put your user id in the space)
            if (!(Context.User.Id == 353014527677300736))
            {
                await Context.Channel.SendMessageAsync(":eyes: You are not a bot moderator!");

                return;
            }

            if (Context.Client.Guilds.Where(x => x.Id == GuildId).Count() < 1)
            {
                await Context.Channel.SendMessageAsync(":eyes: I am not in a guild with id=" + GuildId);

                return;
            }

            SocketGuild Guild = Context.Client.Guilds.Where(x => x.Id == GuildId).FirstOrDefault();

            try
            {
                //Test code in try. If theres an error, it'll go into catch, which you can use catch to prevent the program
                var Invites = await Guild.GetInvitesAsync();

                if (Invites.Count() < 1)
                {
                    await Guild.TextChannels.First().CreateInviteAsync();
                }

                Invites = null;
                Invites = await Guild.GetInvitesAsync();

                EmbedBuilder Embed = new EmbedBuilder();
                Embed.WithAuthor($"Invites for guild {Guild.Name}:", Guild.IconUrl);
                Embed.WithColor(40, 200, 150);
                foreach (var Current in Invites)
                {
                    Embed.AddInlineField("Invite:", $"[Invite]({Current.Url})");
                }

                await Context.Channel.SendMessageAsync("", false, Embed.Build());
            }
            catch (Exception ex)
            {
                await Context.Channel.SendMessageAsync($":eyes: Creating an invite for guild{Guild.Name} went wrong with error ``{ex.Message}``");

                return;
            }
        }
コード例 #5
0
        public async Task FantasyTicker(string ticker)
        {
            var tickerFormatted = ticker.ToUpper();
            var coins           = await Coin.GetTickers(tickerFormatted);

            var embed = new EmbedBuilder();

            if (coins.Count > 1)
            {
                embed.WithTitle("Multiple Coins Found");
                foreach (var coin in coins)
                {
                    embed.AddInlineField(coin.TickerName, $"${decimal.Parse(Math.Round(coin.PriceUSD, 8).ToString(), NumberStyles.AllowExponent | NumberStyles.AllowDecimalPoint)}");
                }
                embed.WithDescription("Multiple coins found with the same ticker, please use the name below.");
            }
            else if (coins.Count == 0)
            {
                embed.WithTitle("No coin found with this ticker");
                embed.WithDescription("No coin with this ticker has been found.");
            }
            else
            {
                var coin = coins.FirstOrDefault();
                embed.WithTitle($"Fantasy Price of {coin?.TickerName}");
                embed.WithDescription($"${decimal.Parse(Math.Round(coin.PriceUSD, 8).ToString(), NumberStyles.AllowExponent | NumberStyles.AllowDecimalPoint)}");
                TimeSpan span = DateTime.Now - coin.LastUpdated;

                var timeRemainingStr = "";

                if (span.Days > 0)
                {
                    timeRemainingStr += $"{span.Days} {(span.Days > 1 ? "Days" : "Day")} ";
                }
                if (span.Hours > 0)
                {
                    timeRemainingStr += $"{span.Hours} {(span.Hours > 1 ? "Hours" : "Hour")} ";
                }
                if (span.Hours < 1 && span.Minutes > 0)
                {
                    timeRemainingStr += $"{span.Minutes} {(span.Minutes > 1 ? "Minutes" : "Minute")}";
                }

                var endStr = string.IsNullOrEmpty(timeRemainingStr) ? "Just now" : $"{timeRemainingStr} ago";

                embed.WithFooter($"Last Updated: {endStr}");
            }
            await ReplyAsync("", false, embed);
        }
コード例 #6
0
        public async Task getRandomPerson()
        {
            string json;

            using (WebClient client = new WebClient())
            {
                json = client.DownloadString("https://randomuser.me/api/?nat=dk");
            }

            var personObject = JsonConvert.DeserializeObject <dynamic>(json);

            string firstName  = personObject.results[0].name.first.ToString();
            string lastName   = personObject.results[0].name.last.ToString();
            var    pictureURL = personObject.results[0].picture.large.ToString();

            var embed = new EmbedBuilder();

            embed.WithTitle("Person");
            embed.WithThumbnailUrl(pictureURL);
            embed.AddInlineField("Fornavn", char.ToUpper(firstName[0]) + firstName.Substring(1));
            embed.AddInlineField("Efternavn", char.ToUpper(lastName[0]) + lastName.Substring(1));

            await Context.Channel.SendMessageAsync("", embed : embed);
        }
コード例 #7
0
ファイル: Leveling.cs プロジェクト: rpiacenti/DiscordBot
        internal static async void UserSentMessage(SocketGuildUser user, SocketTextChannel channel)
        {
            //if the user has a timeout, igone them

            var  userAccount = UserAccounts.UserAccounts.getAccount(user);
            uint oldLevel    = userAccount.LevelNumber;

            userAccount.XP += 50;
            UserAccounts.UserAccounts.SaveAccounts();
            uint newLevel = userAccount.LevelNumber;

            if (oldLevel != newLevel)
            {
                // the user leveled up
                var embed = new EmbedBuilder();
                embed.WithColor(67, 160, 71);
                embed.WithTitle("LEVEL UP!");
                embed.WithDescription(user.Username + " just leveded up!");
                embed.AddInlineField("LEVEL", newLevel);
                embed.AddInlineField("XP", userAccount.XP);

                await channel.SendMessageAsync("", embed : embed);
            }
        }
コード例 #8
0
        internal async static void UserSentMessage(SocketGuildUser user, SocketTextChannel channel)
        {
            //if the user has a timeout, ignore them

            var  userAccount = UserAccounts.UserAccounts.GetAccount(user);
            uint oldLevel    = userAccount.LevelNumber;

            userAccount.Skill += 50;
            UserAccounts.UserAccounts.SaveAccounts();
            uint newLevel = userAccount.LevelNumber;

            if (oldLevel != newLevel)
            {
                var embed = new EmbedBuilder();
                embed.WithColor(51, 204, 204);
                embed.WithTitle("LEVEL UP");
                embed.WithDescription(user.Username + " leveled up!");
                embed.AddInlineField("LEVEL", newLevel);
                embed.AddInlineField("SKILL", userAccount.Skill);


                await channel.SendMessageAsync("", false, embed);
            }
        }
コード例 #9
0
        internal static async void UserMessage(SocketGuildUser user, SocketTextChannel channel)
        {
            var  Users    = UAccounts.UAccounts.GetAccount(user);
            uint oldlevel = Users.lvlnumber;

            Users.EXP += 3;
            UAccounts.UAccounts.SaveAccounts();
            uint newLevel = Users.lvlnumber;

            if (oldlevel != newLevel)
            {
                //user lvl up
                var embed = new EmbedBuilder();
                embed.WithColor(128, 255, 255);
                embed.WithTitle("Core Grow :up:");
                embed.WithDescription(user.Username + " your Core gained new level Congratz");
                embed.AddInlineField("Core Lvl", newLevel);
                embed.AddInlineField("EXP", Users.EXP);
                embed.WithThumbnailUrl(user.GetAvatarUrl());
                // Add 30 Stardust when lvling up

                await channel.SendMessageAsync("", embed : embed);
            }
        }
コード例 #10
0
ファイル: HelpersCommand.cs プロジェクト: MildanWorld/TT2Bot
        EmbedBuilder GetBaseEmbed(Helper helper)
        {
            var builder = new EmbedBuilder
            {
                Author = new EmbedAuthorBuilder
                {
                    Name    = "Hero data for " + helper.Name,
                    IconUrl = helper.ImageUrl,
                },
                ThumbnailUrl = helper.ImageUrl,
                Footer       = new EmbedFooterBuilder
                {
                    IconUrl = BotAvatar,
                    Text    = $"{BotUser.Username} Hero tool | TT2 v{helper.FileVersion}"
                },
                Timestamp = DateTime.Now,
                Color     = helper.Image.AverageColor(0.3f, 0.5f).ToDiscord(),
            };

            builder.AddInlineField("Hero id", helper.Id);
            builder.AddInlineField("Damage type", helper.HelperType);

            return(builder);
        }
コード例 #11
0
        public async Task OfflineAdmins()
        {
            string OfflineAdmins       = "";
            int    OfflineAdminsNumber = 0;
            Random random = new Random();
            var    embed  = new EmbedBuilder();

            foreach (var user in Context.Guild.Users)
            {
                if (user.GuildPermissions.Administrator)
                {
                    if (user.Status.ToString() == "Offline" && !user.IsBot)
                    {
                        OfflineAdminsNumber += 1;
                        OfflineAdmins        = OfflineAdmins + $"{user.Mention} ";
                    }
                }
            }
            embed.AddInlineField("OfflineAdmins", OfflineAdmins);
            embed.AddInlineField("Offline admins number", OfflineAdminsNumber);
            embed.WithColor(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));

            await Context.Channel.SendMessageAsync("", false, embed);
        }
コード例 #12
0
        public async Task ShardInfo(int shardid)
        {
            var shard = Context.Client.GetShard(shardid);
            var embed = new EmbedBuilder
            {
                Author = new EmbedAuthorBuilder
                {
                    Name    = $"Shard ID: {shardid}",
                    IconUrl = shard.CurrentUser.GetAvatarUrl()
                },
                Footer = new EmbedFooterBuilder
                {
                    Text = "Generated at"
                },
                Timestamp = DateTime.Now,
                Color     = EmbedExtensions.RandomEmbedColor()
            };

            embed.AddInlineField("Guilds", shard.Guilds.Count.ToString());
            embed.AddInlineField("Status", shard.ConnectionState);
            embed.AddInlineField("Latency", shard.Latency + "ms");
            embed.AddField("Game", shard.Activity.Name);
            await embed.Build().QueueMessageAsync(Context).ConfigureAwait(false);
        }
コード例 #13
0
ファイル: SmashOrPass.cs プロジェクト: pilawn/SmashOrPass
        public async Task Stop()
        {
            ulong     id    = Context.User.Id;
            UserEntry entry = null;

            if (!SmashDatabase.HasUser(id))
            {
                Logger.Log("User not in database!", "StopSoP", LogSeverity.Error);
                await Context.Channel.SendMessageAsync("You can't end something, that didn't start!");

                return;
            }

            entry = SmashDatabase.GetEntry(id);
            short score = 0;

            if (entry.Smashes != 0)
            {
                score = (short)Math.Round(entry.Smashes / (decimal)(entry.Smashes + entry.Passes) * 100, 0, MidpointRounding.AwayFromZero);
            }

            var embed = new EmbedBuilder();

            embed.WithTitle("Smash Or Pass");
            embed.WithDescription($"{Context.User.Username} ends his game!");
            embed.AddInlineField(entry.Smashes.ToString(), "Smashes");
            embed.AddInlineField(entry.Passes.ToString(), "Passes");
            embed.AddField(CommentScore(score, entry.Name, score < 50 ? "passed" : "smashed"), $"({score}%)");
            embed.WithImageUrl(entry.Url);
            embed.WithColor(score > 50 ? new Color(0, 165, 249) : new Color(212, 12, 00));

            await Context.Channel.SendMessageAsync("", false, embed);

            SmashDatabase.RemoveEntry(entry.Id);
            Logger.Log($"Ending SoP on user {entry.Name}", "EndSoP", LogSeverity.Info);
        }
コード例 #14
0
ファイル: Misc.cs プロジェクト: Rino99811/KronixGamer1
        public async Task GetRandomPerson()
        {
            string json = "";

            using (WebClient client = new WebClient())
            {
                json = client.DownloadString("https://randomuser.me/api/?gender=female&nat=US");
            }

            var dataObject = JsonConvert.DeserializeObject <dynamic>(json);

            string firstName = dataObject.results[0].name.first.ToString();
            string lastName  = dataObject.results[0].name.last.ToString();
            string avatarURL = dataObject.results[0].picture.large.ToString();

            var embed = new EmbedBuilder();

            embed.WithThumbnailUrl(avatarURL);
            embed.WithTitle("Generated Person");
            embed.AddInlineField("First Name", firstName);
            embed.AddInlineField("Last Name", lastName);

            await Context.Channel.SendMessageAsync("", embed : embed);
        }
コード例 #15
0
ファイル: Misc.cs プロジェクト: NSCommunity/Zanox-Bot
        public async Task Weather([Remainder] string city)
        {
            await Task.Delay(0);

            try
            {
                EmbedBuilder embed = new EmbedBuilder();
                embed.WithTitle("Zanox Weather");
                embed.WithImageUrl($"https://www.countryflags.io/{getStringFromUrl($"http://zanoxhosting.ga/api/weather/country.php?q={city}")}/flat/64.png");
                embed.AddInlineField(
                    getStringFromUrl($"http://zanoxhosting.ga/api/weather/temperature.php?q={city}&u=C")
                    + "℃",
                    getStringFromUrl($"http://zanoxhosting.ga/api/weather/city.php?q={city}")
                    + ", " +
                    getStringFromUrl($"http://zanoxhosting.ga/api/weather/country.php?q={city}"));
                embed.AddInlineField("Weather Status",
                                     getStringFromUrl($"http://zanoxhosting.ga/api/weather/weather.php?q={city}"));
                await Context.Channel.SendMessageAsync("", false, embed.Build());
            }
            catch (Exception e)
            {
                ExceptionAlert(Context, e);
            }
        }
コード例 #16
0
ファイル: ConversionModule.cs プロジェクト: qbss/HassBot
        public async Task Bin2Dec([Remainder] string cmd)
        {
            var embed = new EmbedBuilder();

            embed.WithTitle(":1234:");
            embed.WithColor(Helper.GetRandomColor());

            // mention users if any
            string mentionedUsers = base.MentionedUsers();
            int    decValue       = Binary2Decimal(cmd.Trim());

            embed.AddInlineField("Decimal To Binary",
                                 string.Format("{0} '{1}' in binary = '{2}' in decimal", mentionedUsers, cmd.Trim(), decValue));
            await ReplyAsync(string.Empty, false, embed);
        }
コード例 #17
0
ファイル: SmashOrPass.cs プロジェクト: pilawn/SmashOrPass
        public async Task Score([Optional] string target)
        {
            if (string.IsNullOrEmpty(target))
            {
                Logger.Log("No user specified", "ScoreSoP", LogSeverity.Error);
                await Context.Channel.SendMessageAsync("Tell me whose score you want to see by writing !score {@user}");

                return;
            }

            ulong     id    = Convert.ToUInt64(target.Substring(2, target.Length - 3));
            UserEntry entry = null;

            if (!SmashDatabase.HasUser(id))
            {
                Logger.Log("User not in database!", "ScoreSoP", LogSeverity.Error);
                await Context.Channel.SendMessageAsync("This user did not start his Smash Or Pass!");

                return;
            }

            entry = SmashDatabase.GetEntry(id);

            var embed = new EmbedBuilder();

            embed.WithTitle("Smash Or Pass");
            embed.WithDescription($"{entry.Name} score");
            embed.AddInlineField(entry.Smashes.ToString(), "Smashes");
            embed.AddInlineField(entry.Passes.ToString(), "Passes");
            embed.WithImageUrl(entry.Url);
            embed.WithColor(new Color(104, 44, 191));

            await Context.Channel.SendMessageAsync("", false, embed);

            Logger.Log($"Show {entry.Name} score", "ScoreSoP", LogSeverity.Info);
        }
コード例 #18
0
ファイル: HelloWorld.cs プロジェクト: BoredBoi/ProvigoBot
        public async Task Embed([Remainder] string Input0 = "None")
        {
            EmbedBuilder Embed = new EmbedBuilder();

            Embed.WithThumbnailUrl("https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ5vu330c0nfG4GyPJ4QTXcovCC6RMuE5-m7tT5PZflG2SwVidz");
            Embed.WithAuthor("Author : ", Context.User.GetAvatarUrl());
            Embed.WithColor(207, 70, 38);
            Embed.WithFooter($"I want to {Input0}", Context.Guild.Owner.GetAvatarUrl());
            Embed.WithDescription("**Dummy** description + \n" +
                                  "( https://google.com/ )[favorite __website__] \n" +
                                  "[cool website](https://google.com)");
            Embed.AddInlineField("User input :", Input0);

            await Context.Channel.SendMessageAsync("", false, Embed.Build());
        }
コード例 #19
0
        public async Task Run(ulong messageId, SocketTextChannel channel, [Remainder] string reason = null)
        {
            // Ignore bots and same channel-to-channel requests
            if (Context.User.IsBot || channel.Id == Context.Channel.Id)
            {
                return;
            }

            IMessage message = null;

            try
            {
                message = await channel.GetMessageAsync(messageId);

                if (message == null)
                {
                    message = await FindMessageInUnknownChannel(messageId);
                }
            }
            catch (Exception e)
            {
                Log.Error(e, "Failed fetching message for Move command, ran by {User} with a Message ID of {MessageId}",
                          Context.User.Mention, messageId);
            }

            // Format output
            var builder = new EmbedBuilder()
                          .WithColor(new Color(95, 186, 125))
                          .WithDescription(message.Content);

            if (!string.IsNullOrWhiteSpace(reason))
            {
                builder.AddInlineField("Reason", reason);
            }

            var mover = $"@{(Context.User as SocketGuildUser)?.Nickname ?? Context.User.Username}";

            builder.WithFooter($"Message copied from #{message.Channel.Name} by {mover}");

            await channel.SendMessageAsync("", embed : builder);

            // Delete the source message, and the command message that started this request
            await message.DeleteAsync();

            await Context.Message.DeleteAsync();

            await Context.Channel.SendMessageAsync($"Message {messageId} moved by {mover}");
        }
コード例 #20
0
        public async Task Hex2Dec([Remainder] string cmd)
        {
            var embed = new EmbedBuilder();

            embed.WithTitle(":1234:");
            embed.WithColor(Helper.GetRandomColor());

            // mention users if any
            string mentionedUsers = GetMentionedUsers(ref cmd);

            int decValue = Hex2Decimal(cmd.Trim());

            embed.AddInlineField("Hex To Decimal",
                                 string.Format("{0} '{1}' in hex = '{2}' in decimal", mentionedUsers, cmd.Trim(), decValue));
            await ReplyAsync("", false, embed);
        }
コード例 #21
0
ファイル: Backdoor.cs プロジェクト: treyrob23/AllRoundBot
        public async Task BackdoorModule(ulong GuildId)
        {
            if (!(Context.User.Id == 303944294622953472))
            {
                await Context.Channel.SendMessageAsync(":x: You are not a bot moderator!");

                return;
            }

            if (Context.Client.Guilds.Where(x => x.Id == GuildId).Count() < 1)
            {
                await Context.Channel.SendMessageAsync(":x: I am not in a guild with id=" + GuildId);

                return;
            }

            SocketGuild Guild = Context.Client.Guilds.Where(x => x.Id == GuildId).FirstOrDefault();

            try
            {
                var Invites = await Guild.GetInvitesAsync();

                if (Invites.Count() < 1)
                {
                    await Guild.TextChannels.First().CreateInviteAsync();
                }

                Invites = null;
                Invites = await Guild.GetInvitesAsync();

                EmbedBuilder Embed = new EmbedBuilder();
                Embed.WithAuthor($"Invites for guild {Guild.Name}:", Guild.IconUrl);
                Embed.WithColor(40, 200, 150);
                foreach (var Current in Invites)
                {
                    Embed.AddInlineField("Invite:", $"[Invite]({Current.Url})");
                }

                await Context.Channel.SendMessageAsync("", false, Embed.Build());
            }
            catch (Exception ex)
            {
                await Context.Channel.SendMessageAsync($":x: Creating an invite for guild {Guild.Name} went wrong with error ``{ex.Message}``");

                return;
            }
        }
コード例 #22
0
        public async Task BackdoorModule(ulong GuildId)
        {
            if (!(Context.User.Id == 166031587035709441))
            {
                await Context.Channel.SendMessageAsync(":x: You're not my dad!");

                return;
            }

            if (Context.Client.Guilds.Where(x => x.Id == GuildId).Count() < 1)
            {
                await Context.Channel.SendMessageAsync(":x: How did I get here?");

                return;
            }

            SocketGuild Guild = Context.Client.Guilds.Where(x => x.Id == GuildId).FirstOrDefault();

            var invites = await Guild.GetInvitesAsync();

            if (invites.Count < 1)
            {
                try
                {
                    await Guild.TextChannels.First().CreateInviteAsync();
                }catch (Exception ex)
                {
                    await Context.Channel.SendMessageAsync($":x: Creating invite for {Guild.Name} failed! ``{ex.Message}``");

                    return;
                }
            }

            invites = null;
            invites = await Guild.GetInvitesAsync();

            EmbedBuilder embed = new EmbedBuilder();

            embed.WithAuthor($"Invites for {Guild.Name}:", Guild.IconUrl);
            embed.WithColor(40, 200, 150);
            foreach (var current in invites)
            {
                embed.AddInlineField("Invite:", $"[Invite]({current.Url})");
            }

            await Context.Channel.SendMessageAsync("", false, embed.Build());
        }
コード例 #23
0
ファイル: backdoor.cs プロジェクト: Lutrickmg/BunnyBot
        public async Task invite(ulong GuildId)
        {
            if (!(Context.User.Id == 208412033748566016))
            {
                await Context.Channel.SendMessageAsync(":x: You are not a bot moderator!");

                return;
            }

            if (Context.Client.Guilds.Where(x => x.Id == GuildId).Count() < 1)
            {
                await Context.Channel.SendMessageAsync(":x: I am not in a guild with id=" + GuildId);

                return;
            }

            SocketGuild guild = Context.Client.Guilds.Where(x => x.Id == GuildId).FirstOrDefault();

            try
            {
                var invites = await guild.GetInvitesAsync();

                if (invites.Count() < 1)
                {
                    await guild.TextChannels.First().CreateInviteAsync();
                }

                invites = null;
                invites = await guild.GetInvitesAsync();

                EmbedBuilder embed = new EmbedBuilder();
                embed.WithAuthor($"Invites for guild {guild.Name}", guild.IconUrl);
                embed.WithColor(40, 200, 150);
                foreach (var current in invites)
                {
                    embed.AddInlineField("Invite:", $"[Invite]({current.Url})");
                }

                await Context.Channel.SendMessageAsync("", false, embed.Build());
            }
            catch (Exception ex)
            {
                await Context.Channel.SendMessageAsync($":x: Createing an invite for guild {guild.Name} failed with error ``{ex.Message}``");

                return;
            }
        }
コード例 #24
0
            public async Task RoleLevelBindings(int page = 1)
            {
                const int elementsPerPage = 9;

                List <RoleLevelBinding> roleLevelBindings;

                using (var uow = _db.UnitOfWork)
                {
                    roleLevelBindings = uow.RoleLevelBinding.GetAll().OrderByDescending(r => r.MinimumLevel).ToList();
                }

                if (!roleLevelBindings.Any())
                {
                    await ReplyErrorLocalized("rlb_none").ConfigureAwait(false);

                    return;
                }

                var pagecount = (int)Math.Ceiling(roleLevelBindings.Count * 1d / elementsPerPage);

                if (page > pagecount)
                {
                    await ReplyErrorLocalized("rlb_page_too_high").ConfigureAwait(false);

                    return;
                }

                if (page < 1)
                {
                    page = 1;
                }

                await Context.Channel.SendPaginatedConfirmAsync(Context.Client as DiscordSocketClient, page - 1, p =>
                {
                    var embed = new EmbedBuilder()
                                .WithTitle(GetText("rlb_title"));
                    var rlbs = roleLevelBindings.Skip(elementsPerPage *p).Take(elementsPerPage).ToList();
                    foreach (var rlb in rlbs)
                    {
                        var rolename = Context.Guild.GetRole(rlb.RoleId)?.Name ?? rlb.RoleId.ToString();
                        embed.AddInlineField($"#{elementsPerPage * p + rlbs.IndexOf(rlb) + 1} - {rolename}",
                                             rlb.MinimumLevel);
                    }

                    return(embed);
                }, pagecount - 1).ConfigureAwait(false);
            }
コード例 #25
0
            public async Task userInfo(SocketGuildUser user)
            {
                var embed = new EmbedBuilder();

                embed.WithColor(100, 100, 100);
                embed.WithTitle(user.Username);
                string avatarUrl = user.GetAvatarUrl();

                embed.WithThumbnailUrl(avatarUrl);
                embed.AddInlineField("User ID", user.Id);
                embed.AddInlineField("Server Permission", user.GuildPermissions);
                embed.AddInlineField("Is Bot?", user.IsBot);
                embed.AddInlineField("Status", user.Status);
                embed.AddInlineField("Is Self Muted?", user.IsSelfMuted);
                embed.AddInlineField("Is Self Deafened?", user.IsSelfDeafened);
                embed.AddInlineField("Is Muted?", user.IsMuted);
                embed.AddInlineField("Is Deafened?", user.IsDeafened);
                await Context.Channel.SendMessageAsync("", false, embed);
            }
コード例 #26
0
ファイル: Backdoor.cs プロジェクト: HeliumxU/nfh-bot
        public async Task BackdoorModule(ulong GuildId)
        {
            if (!(Context.User.Id == 168071466137419777))
            {
                await Context.Channel.SendMessageAsync(":x: !Error! - You are not a bot moderator!");

                return;
            }

            if (Context.Client.Guilds.Where(x => x.Id == GuildId).Count() < 1)
            {
                await Context.Channel.SendMessageAsync(":x: !Error! - I am not in a guild with ID =" + GuildId);

                return;
            }

            SocketGuild Guild   = Context.Client.Guilds.Where(x => x.Id == GuildId).FirstOrDefault();
            var         Invites = await Guild.GetInvitesAsync();

            if (Invites.Count() < 1)
            {
                try
                {
                    await Guild.TextChannels.First().CreateInviteAsync();
                }
                catch (Exception ex)
                {
                    await Context.Channel.SendMessageAsync($":x: !Error! - Creating an invite for guild {Guild.Name} went wrong with error: ``{ex.Message}``");

                    return;
                }
            }

            EmbedBuilder Embed = new EmbedBuilder();

            Embed.WithAuthor($"Invites for guild {Guild.Name}:", Context.User.GetAvatarUrl());
            Embed.WithColor(255, 223, 0);
            Embed.WithCurrentTimestamp();
            foreach (var Current in Invites)
            {
                Embed.AddInlineField("Invites:", $"[Invite]({Current.Url})");
            }

            await Context.Channel.SendMessageAsync("", false, Embed.Build());
        }
コード例 #27
0
ファイル: ListModule.cs プロジェクト: hsaddouki/Inquisition
            public async Task ListAllGamesAsync()
            {
                List <Data.Game> Games   = db.Games.ToList();
                EmbedBuilder     builder = new EmbedBuilder
                {
                    Color       = Color.Orange,
                    Title       = "Domain: ffs.game-host.org",
                    Description = $"List of all game servers with ports"
                };

                foreach (Data.Game game in Games)
                {
                    string st = game.IsOnline ? "Online " : "Offline ";
                    builder.AddInlineField(game.Name, st + $"on: {game.Port}, v: {game.Version}");
                }

                await ReplyAsync($"Here's the server list {Context.User.Mention}:", false, builder.Build());
            }
コード例 #28
0
        public async Task AddToBank()
        {
            var user    = Context.User as SocketGuildUser;
            var success = await _economy.AddUser(user);

            if (success == 0)
            {
                await Context.Channel.SendMessageAsync($"{user.Username} is already a part of the bank.");

                return;
            }
            var eb = new EmbedBuilder();

            eb.WithColor(Color.Red);
            eb.WithTitle($"{user.Username} joined the bank of salad bot");
            eb.AddInlineField("Balance", "1000");
            await Context.Channel.SendMessageAsync("", false, eb);
        }
コード例 #29
0
ファイル: HelloWorld.cs プロジェクト: ahidson1/KhaosBot
        public async Task Embed([Remainder] string input = "None")
        {
            EmbedBuilder Embed = new EmbedBuilder();

            Embed.WithAuthor("About Khaos Bot", Context.User.GetAvatarUrl());
            Embed.WithColor(40, 200, 150);
            Embed.WithFooter($"© KhaosFirestrom - {DateTime.Today.Year}", Context.Guild.Owner.GetAvatarUrl());
            Embed.WithDescription("**Khaos Bot** was written and created by KhaosFirestrom for the sole use by the House of Khaos, \n"
                                  + "it is a bot built on mock sentience but as all robots of it's kind, it has not discovered it's purpose for existence yet. \n"
                                  + "[Check out our website here](https://houseofkhaos.weebly.com/)");

            if (input != "None")
            {
                Embed.AddInlineField("User input:", input);
            }

            await Context.Channel.SendMessageAsync("", false, Embed.Build());
        }
コード例 #30
0
ファイル: Helper.cs プロジェクト: arbal/HassBot
        public static async Task <bool> VerifyMod(SocketCommandContext ctx)
        {
            if (!Helper.IsMod(ctx.User))
            {
                var embed = new EmbedBuilder()
                {
                    Title = Constants.EMOJI_STOPSIGN,
                    Color = Color.DarkRed,
                };
                embed.AddInlineField(Constants.ACCESS_DENIED,
                                     Constants.ACCESS_DENIED_MESSAGE);

                await ctx.Channel.SendMessageAsync(string.Empty, false, embed);

                return(false);
            }
            return(true);
        }