示例#1
0
            public static bool CreateRole(DSharpPlus.DiscordClient client, ulong GuildID, string RoleName, int r, int g, int b)
            {
                DSharpPlus.Entities.DiscordGuild dguild = client.GetGuildAsync(GuildID).Result;

                dguild.CreateRoleAsync(RoleName, DSharpPlus.Permissions.None, new DSharpPlus.Entities.DiscordColor(r, g, b));
                return(true);
            }
示例#2
0
        private async Task VoteSkipUpdate(DSharpPlus.DiscordClient client,
                                          DSharpPlus.EventArgs.MessageReactionAddEventArgs messageReactionAdd)
        {
            var voteSkipMessage = ShimakazeBot.playlists[messageReactionAdd.Guild]?.voteSkip?.message;

            if (voteSkipMessage == messageReactionAdd.Message)
            {
                var lvc = ShimakazeBot.lvn?.GetGuildConnection(messageReactionAdd.Guild);

                if (lvc != null)
                {
                    var reactionEmote = DiscordEmoji.FromName(ShimakazeBot.Client, $":{ShimaConsts.VoteSkipEmote}:");



                    if (ShimakazeBot.playlists[messageReactionAdd.Guild]
                        .voteSkip.requester.Id != messageReactionAdd.User.Id &&

                        lvc.Channel.Users.FirstOrDefault(member => member.Id == messageReactionAdd.User.Id) != null &&

                        messageReactionAdd.Emoji == reactionEmote)
                    {
                        if (messageReactionAdd.Message.Reactions.FirstOrDefault(reaction =>
                                                                                reaction.Emoji == reactionEmote)
                            .Count >= Math.Ceiling(lvc.Channel.Users.Count() / 2.0))
                        {
                            await SkipSong(messageReactionAdd.Guild, messageReactionAdd.Channel, lvc, true);
                        }
                    }
                    else
                    {
                        await messageReactionAdd.Message.DeleteReactionAsync(
                            messageReactionAdd.Emoji, messageReactionAdd.User);
                    }
                }
            }
        }
示例#3
0
        async Task Run(bool loop)
        {
            Client = new DSharpPlus.DiscordClient(new DSharpPlus.DiscordConfiguration()
            {
                Token = Configuration.Token, LogLevel = DSharpPlus.LogLevel.Debug
            });
            if (Configuration.LoggerFormat != null)
            {
                Logger.LogFormat = Configuration.LoggerFormat;
            }
            Client.DebugLogger.LogMessageReceived += (sender, e) =>
            {
                Logger.Info(e.Message);
            };
            Client.MessageCreated += Client_MessageCreated;
            CommandManager.Register(new TestCommand("test"));

            await Client.ConnectAsync();

            if (loop)
            {
                await Task.Delay(-1);
            }
        }
示例#4
0
namespace GreenSharp { public static class EmbedHelper { public static DSharpPlus.Entities.DiscordEmbed Embed(this DSharpPlus.Entities.DiscordMessage msg, DSharpPlus.DiscordClient client, System.String title, System.String description) => new DSharpPlus.Entities.DiscordEmbedBuilder
                                                         {
                                                             Title = title, Description = description, Author = new DSharpPlus.Entities.DiscordEmbedBuilder.EmbedAuthor {
                                                                 Name = $"{msg.Author.Username}#{msg.Author.Discriminator}, ", IconUrl = msg.Author.GetAvatarUrl(DSharpPlus.ImageFormat.Auto, 2048)
                                                             }, Footer = new DSharpPlus.Entities.DiscordEmbedBuilder.EmbedFooter {
                                                                 IconUrl = client.CurrentUser.GetAvatarUrl(DSharpPlus.ImageFormat.Auto, 2048), Text = $"Bot: {client.CurrentUser.Username}"
                                                             }
                                                         }; public static System.String BetterMention(this DSharpPlus.Entities.DiscordUser user) => $"<@{user.Id}>"; } }