Beispiel #1
0
                public async Task AddModule(ulong id, string name, int privileg, int posts = 0, int upvotes = 0, int downvotes = 0, int karma = -1)
                {
                    try
                    {
                        if (!Privileg.CheckById(Context.User.Id, Privileg.owner))
                        {
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("warning", "You are not my god!"), Colors.warning));

                            Log.Warning($"command - data user add - user:{Context.User.Id} channel:{Context.Channel.Id} privileg to low");
                            return;
                        }

                        Log.Information($"command - data user add - start user:{Context.User.Id} channel:{Context.Channel.Id} command:{Context.Message.Content}");

                        try
                        {
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("user", $"rows affected: {User.Add(new User(id, name, privileg, posts, upvotes, downvotes, karma))}"), Colors.information));
                        }
                        catch (Exception e)
                        {
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("error", e.Message), Colors.error));

                            throw e;
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error($"command - data user add - user:{Context.User.Id} channel:{Context.Channel.Id} error:{ex.Message}");
                    }
                }
Beispiel #2
0
            public async Task SetLeaderboardModule()
            {
                try
                {
                    if (!Privileg.CheckById(Context.User.Id, Privileg.moderator))
                    {
                        await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("warning", "You need to be at least moderator to use this command!"), Colors.warning));

                        Log.Warning($"command - set leaderboard - user:{Context.User.Id} channel:{Context.Channel.Id} privileg to low");
                        return;
                    }

                    Log.Information($"command - set leaderboard - start user:{Context.User.Id} channel:{Context.Channel.Id} command:{Context.Message.Content}");

                    var channel_event_list = Channel_Event.GetAllByChannelIdAndType(Context.Channel.Id, 'r');

                    if (channel_event_list != null)
                    {
                        foreach (var channel_event in channel_event_list)
                        {
                            Channel_Event.DeleteById(channel_event.id);
                        }
                    }

                    var message = await Context.Channel.SendMessageAsync(embed : Classes.Embed.GetLeaderboard());

                    Channel_Event.Add(new Channel_Event(1, Context.Channel.Id, 15, $"{message.Id}", 'r'));
                }
                catch (Exception ex)
                {
                    Log.Error($"command - set leaderboard - user:{Context.User.Id} channel:{Context.Channel.Id} error:{ex.Message}");
                }
            }
Beispiel #3
0
                public async Task AddModule(ulong vote, ulong channel, int aktiv = 1)
                {
                    try
                    {
                        if (!Privileg.CheckById(Context.User.Id, Privileg.owner))
                        {
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("warning", "You are not my god!"), Colors.warning));

                            Log.Warning($"command - data vote_channel add - user:{Context.User.Id} channel:{Context.Channel.Id} privileg to low");
                            return;
                        }

                        Log.Information($"command - data vote_channel add - start user:{Context.User.Id} channel:{Context.Channel.Id} command:{Context.Message.Content}");

                        try
                        {
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("vote_channel", $"rows affected: {Vote_Channel.Add(new Vote_Channel(aktiv, vote, channel))}"), Colors.information));
                        }
                        catch (Exception e)
                        {
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("error", e.Message), Colors.error));

                            throw e;
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error($"command - data vote_channel add - user:{Context.User.Id} channel:{Context.Channel.Id} error:{ex.Message}");
                    }
                }
Beispiel #4
0
        public async Task PlayModule(params string[] input)
        {
            try
            {
                if (!Privileg.CheckById(Context.User.Id, Privileg.owner))
                {
                    await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("warning", "You are not my god!"), Colors.warning));

                    Log.Warning($"command - play - user:{Context.User.Id} channel:{Context.Channel.Id} privileg to low");
                    return;
                }

                Log.Information($"command - play - start user:{Context.User.Id} channel:{Context.Channel.Id} command:{Context.Message.Content}");

                //join if not connected
                if (!audioClients.ContainsKey(Context.Guild.Id))
                {
                    var channel = (Context.User as IVoiceState).VoiceChannel;

                    audioClients.Add(Context.Guild.Id, new AudioClient(await channel.ConnectAsync(), Context.Channel, channel));
                }

                audioClients[Context.Guild.Id].Add(input);

                if (audioClients[Context.Guild.Id].playing == null)
                {
                    await audioClients[Context.Guild.Id].Start();
                }
            }
            catch (Exception ex)
            {
                Log.Error($"command - play - user:{Context.User.Id} channel:{Context.Channel.Id} error:{ex.Message}");
            }
        }
Beispiel #5
0
                public async Task GetModule(ulong id)
                {
                    try
                    {
                        if (!Privileg.CheckById(Context.User.Id, Privileg.admin))
                        {
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("warning", "You need to be at least admin to use this command!"), Colors.warning));

                            Log.Warning($"command - data user get - user:{Context.User.Id} channel:{Context.Channel.Id} privileg to low");
                            return;
                        }

                        Log.Information($"command - data user get - start user:{Context.User.Id} channel:{Context.Channel.Id} command:{Context.Message.Content}");

                        try
                        {
                            var item = User.GetById(id);
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder(User.header, item.ToString()), Colors.information, "user"));
                        }
                        catch (Exception e)
                        {
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("error", e.Message), Colors.error));

                            throw e;
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error($"command - data user get - user:{Context.User.Id} channel:{Context.Channel.Id} error:{ex.Message}");
                    }
                }
Beispiel #6
0
        public async Task QueueModule()
        {
            try
            {
                if (!Privileg.CheckById(Context.User.Id, Privileg.owner))
                {
                    await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("warning", "You are not my god!"), Colors.warning));

                    Log.Warning($"command - stop - user:{Context.User.Id} channel:{Context.Channel.Id} privileg to low");
                    return;
                }

                Log.Information($"command - stop - start user:{Context.User.Id} channel:{Context.Channel.Id} command:{Context.Message.Content}");

                string queueOutput = "";

                foreach (var video in audioClients[Context.Guild.Id].videoQueue)
                {
                    queueOutput = queueOutput + $"[{video.Title}]({video.Url})\n";
                }

                await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Program.Client.CurrentUser, Field.CreateFieldBuilder("queue", $"next 5 songs:\n{queueOutput}total {audioClients[Context.Guild.Id].videoQueue.Count + audioClients[Context.Guild.Id].IdQueue.Count} songs"), Colors.information));
            }
            catch (Exception ex)
            {
                Log.Error($"command - stop - user:{Context.User.Id} channel:{Context.Channel.Id} error:{ex.Message}");
            }
        }
Beispiel #7
0
                public async Task SetModule(ulong id, string what, string how)
                {
                    try
                    {
                        if (!Privileg.CheckById(Context.User.Id, Privileg.owner))
                        {
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("warning", "You are not my god!"), Colors.warning));

                            Log.Warning($"command - data event set - user:{Context.User.Id} channel:{Context.Channel.Id} privileg to low");
                            return;
                        }

                        Log.Information($"command - data event set - start user:{Context.User.Id} channel:{Context.Channel.Id} command:{Context.Message.Content}");

                        try
                        {
                            var item = Event.GetById(id);
                            item.what = what;
                            item.how  = how;

                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("event", $"rows affected: {Event.Edit(item)}"), Colors.information));
                        }
                        catch (Exception e)
                        {
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("error", e.Message), Colors.error));

                            throw e;
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error($"command - data event set - user:{Context.User.Id} channel:{Context.Channel.Id} error:{ex.Message}");
                    }
                }
Beispiel #8
0
            public async Task DeleteModule(ulong guildID = 0)
            {
                try
                {
                    if (!Privileg.CheckById(Context.User.Id, Privileg.owner))
                    {
                        await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("warning", "You are not my god!"), Colors.warning));

                        Log.Warning($"command - admin delete - user:{Context.User.Id} channel:{Context.Channel.Id} privileg to low");
                        return;
                    }

                    if (guildID == 0)
                    {
                        await Program.Client.Rest.DeleteAllGlobalCommandsAsync();
                    }
                    else
                    {
                        var guild = Program.Client.GetGuild(guildID);
                        await guild.DeleteApplicationCommandsAsync();
                    }

                    await Context.Message.ReplyAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("info", "done!"), Colors.information));
                }
                catch (Exception ex)
                {
                    Log.Error($"command - !admin delete - user:{Context.Message.Author.Id} channel:{Context.Channel.Id} error:{ex.Message}");
                }
            }
Beispiel #9
0
        public async Task LeaveModule()
        {
            try
            {
                if (!Privileg.CheckById(Context.User.Id, Privileg.owner))
                {
                    await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("warning", "You are not my god!"), Colors.warning));

                    Log.Warning($"command - leave - user:{Context.User.Id} channel:{Context.Channel.Id} privileg to low");
                    return;
                }

                Log.Information($"command - leave - start user:{Context.User.Id} channel:{Context.Channel.Id} command:{Context.Message.Content}");

                audioClients[Context.Guild.Id].Stop();

                audioClients[Context.Guild.Id].CleanUp();

                //cleanup
                if (audioClients.ContainsKey(Context.Guild.Id))
                {
                    audioClients.Remove(Context.Guild.Id);
                }
            }
            catch (Exception ex)
            {
                Log.Error($"command - leave - user:{Context.User.Id} channel:{Context.Channel.Id} error:{ex.Message}");
            }
        }
Beispiel #10
0
            public async Task ServerModule()
            {
                try
                {
                    if (!Privileg.CheckById(Context.User.Id, Privileg.owner))
                    {
                        await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("warning", "You are not my god!"), Colors.warning));

                        Log.Warning($"command - get server - user:{Context.User.Id} channel:{Context.Channel.Id} privileg to low");
                        return;
                    }

                    Log.Information($"command - get server - start user:{Context.User.Id} channel:{Context.Channel.Id} command:{Context.Message.Content}");

                    List <EmbedFieldBuilder> fields = new List <EmbedFieldBuilder>();

                    foreach (var x in Context.Client.Guilds)
                    {
                        fields.Add(Field.CreateFieldBuilder(x.Name, x.Id.ToString()));
                    }

                    await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, fields, Colors.information, "server"));
                }
                catch (Exception ex)
                {
                    Log.Error($"command - get server - user:{Context.User.Id} channel:{Context.Channel.Id} error:{ex.Message}");
                }
            }
Beispiel #11
0
                public async Task DeleteModule(ulong id)
                {
                    try
                    {
                        if (!Privileg.CheckById(Context.User.Id, Privileg.owner))
                        {
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("warning", "You are not my god!"), Colors.warning));

                            Log.Warning($"command - data channel_event delete - user:{Context.User.Id} channel:{Context.Channel.Id} privileg to low");
                            return;
                        }

                        Log.Information($"command - data channel_event delete - start user:{Context.User.Id} channel:{Context.Channel.Id} command:{Context.Message.Content}");

                        try
                        {
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("channel_event", $"rows affected: {Channel_Event.DeleteById(id)}"), Colors.information));
                        }
                        catch (Exception e)
                        {
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("error", e.Message), Colors.error));

                            throw e;
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error($"command - data channel_event delete - user:{Context.User.Id} channel:{Context.Channel.Id} error:{ex.Message}");
                    }
                }
Beispiel #12
0
                public async Task SetModule(ulong id, int privileg, string name = "", int posts = 0, int upvotes = 0, int downvotes = 0, int karma = -1)
                {
                    try
                    {
                        if (!Privileg.CheckById(Context.User.Id, Privileg.owner))
                        {
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("warning", "You are not my god!"), Colors.warning));

                            Log.Warning($"command - data user set - user:{Context.User.Id} channel:{Context.Channel.Id} privileg to low");
                            return;
                        }

                        try
                        {
                            var item = User.GetById(id);

                            item.privileg = privileg;

                            if (name != "")
                            {
                                item.name = name;
                            }

                            if (posts != 0)
                            {
                                item.posts = posts;
                            }

                            if (upvotes != 0)
                            {
                                item.upvotes = upvotes;
                            }

                            if (downvotes != 0)
                            {
                                item.downvotes = downvotes;
                            }

                            if (karma != -1)
                            {
                                item.karma = karma;
                            }

                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("user", $"rows affected: {User.Edit(item)}"), Colors.information));
                        }
                        catch (Exception e)
                        {
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("error", e.Message), Colors.error));

                            throw e;
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error($"command - data user set - user:{Context.User.Id} channel:{Context.Channel.Id} error:{ex.Message}");
                    }
                }
Beispiel #13
0
                public async Task ResetRolesModule()
                {
                    try
                    {
                        if (!Privileg.CheckById(Context.User.Id, Privileg.admin))
                        {
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("warning", "You need to be at least admin to use this command!"), Colors.warning));

                            Log.Warning($"command - admin reset roles - user:{Context.User.Id} channel:{Context.Channel.Id} privileg to low");
                            return;
                        }

                        Log.Information($"command - admin reset roles - start user:{Context.User.Id} channel:{Context.Channel.Id} command:{Context.Message.Content}");

                        //code

                        var guild   = Context.Guild as IGuild;
                        var channel = Context.Channel as IGuildChannel;

                        List <IRole> exclutedRoles = new List <IRole>();

                        var Role = Classes.Role.GetById(6);
                        exclutedRoles.Add(channel.Guild.Roles.FirstOrDefault(x => x.Id == 573492166954057730));

                        Role = Classes.Role.GetById(6);
                        exclutedRoles.Add(channel.Guild.Roles.FirstOrDefault(x => x.Id == 778203675687387156));

                        Role = Classes.Role.GetById(6);
                        exclutedRoles.Add(channel.Guild.Roles.FirstOrDefault(x => x.Id == 356486959901835264));

                        Role = Classes.Role.GetById(6);
                        exclutedRoles.Add(channel.Guild.Roles.FirstOrDefault(x => x.Id == 780036990158110730));

                        List <IRole> roles = new List <IRole>();

                        foreach (var role in channel.Guild.Roles)
                        {
                            if (!role.Permissions.Administrator || !exclutedRoles.Contains(role))
                            {
                                roles.Add(role);
                            }
                        }

                        List <IRole> newRoles = new List <IRole>();

                        foreach (var role in roles)
                        {
                            await role.DeleteAsync();

                            newRoles.Add(await guild.CreateRoleAsync(role.Name, role.Permissions, role.Color, role.IsHoisted, null));
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error($"command - admin reset roles - user:{Context.User.Id} channel:{Context.Channel.Id} error:{ex.Message}");
                    }
                }
Beispiel #14
0
                public async Task SetModule(ulong id, int aktiv, ulong channel = 0, ulong Event = 0, string when = "", char type = ' ')
                {
                    try
                    {
                        if (!Privileg.CheckById(Context.User.Id, Privileg.owner))
                        {
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("warning", "You are not my god!"), Colors.warning));

                            Log.Warning($"command - data channel_event set - user:{Context.User.Id} channel:{Context.Channel.Id} privileg to low");
                            return;
                        }

                        Log.Information($"command - data channel_event set - start user:{Context.User.Id} channel:{Context.Channel.Id} command:{Context.Message.Content}");

                        try
                        {
                            var item = Channel_Event.GetById(id);
                            item.aktiv = aktiv;

                            if (channel != 0)
                            {
                                item.channel = channel;
                            }

                            if (Event != 0)
                            {
                                item.Event = Event;
                            }

                            if (when != "")
                            {
                                item.when = when;
                            }

                            if (type != ' ')
                            {
                                item.type = type;
                            }

                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("channel_event", $"rows affected: {Channel_Event.Edit(item)}"), Colors.information));
                        }
                        catch (Exception e)
                        {
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("error", e.Message), Colors.error));

                            throw e;
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error($"command - data channel_event set - user:{Context.User.Id} channel:{Context.Channel.Id} error:{ex.Message}");
                    }
                }
Beispiel #15
0
                public async Task SetModule(ulong id, int aktiv, ulong vote = 0, ulong channel = 0)
                {
                    try
                    {
                        if (!Privileg.CheckById(Context.User.Id, Privileg.owner))
                        {
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("warning", "You are not my god!"), Colors.warning));

                            Log.Warning($"command - data vote_channel set - user:{Context.User.Id} channel:{Context.Channel.Id} privileg to low");
                            return;
                        }

                        Log.Information($"command - data vote_channel set - start user:{Context.User.Id} channel:{Context.Channel.Id} command:{Context.Message.Content}");

                        try
                        {
                            var item = Vote_Channel.GetById(id);
                            item.aktiv = aktiv;

                            if (vote != 0)
                            {
                                item.vote = vote;
                            }

                            if (channel != 0)
                            {
                                item.channel = channel;
                            }

                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("vote_channel", $"rows affected: {Vote_Channel.Edit(item)}"), Colors.information));
                        }
                        catch (Exception e)
                        {
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("error", e.Message), Colors.error));

                            throw e;
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error($"command - data vote_channel set - user:{Context.User.Id} channel:{Context.Channel.Id} error:{ex.Message}");
                    }
                }
Beispiel #16
0
            public async Task VersionModule()
            {
                try
                {
                    if (!Privileg.CheckById(Context.User.Id, Privileg.admin))
                    {
                        await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("warning", "You need to be at least admin to use this command!"), Colors.warning));

                        Log.Warning($"command - data version - user:{Context.User.Id} channel:{Context.Channel.Id} privileg to low");
                        return;
                    }

                    Log.Information($"command - data version - start user:{Context.User.Id} channel:{Context.Channel.Id} command:{Context.Message.Content}");

                    await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("version", Data.Version()), Colors.information));
                }
                catch (Exception ex)
                {
                    Log.Error($"command - data version - user:{Context.User.Id} channel:{Context.Channel.Id} error:{ex.Message}");
                }
            }
Beispiel #17
0
                public async Task GetAllModule()
                {
                    try
                    {
                        if (!Privileg.CheckById(Context.User.Id, Privileg.admin))
                        {
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("warning", "You need to be at least admin to use this command!"), Colors.warning));

                            Log.Warning($"command - data event getall - user:{Context.User.Id} channel:{Context.Channel.Id} privileg to low");
                            return;
                        }

                        Log.Information($"command - data event getall - start user:{Context.User.Id} channel:{Context.Channel.Id} command:{Context.Message.Content}");

                        try
                        {
                            var    list    = Event.GetAll();
                            string ausgabe = "";

                            foreach (var item in list)
                            {
                                ausgabe += item.ToString() + "\n";
                            }

                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder(Event.header, ausgabe), Colors.information, "event"));
                        }
                        catch (Exception e)
                        {
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("error", e.Message), Colors.error));

                            throw e;
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error($"command - data event getall - user:{Context.User.Id} channel:{Context.Channel.Id} error:{ex.Message}");
                    }
                }
Beispiel #18
0
                public async Task TimerDayModule()
                {
                    try
                    {
                        if (!Privileg.CheckById(Context.User.Id, Privileg.owner))
                        {
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("warning", "You are not my god!"), Colors.warning));

                            Log.Warning($"command - admin timer day - user:{Context.User.Id} channel:{Context.Channel.Id} privileg to low");
                            return;
                        }

                        Log.Information($"command - admin timer day - start user:{Context.User.Id} channel:{Context.Channel.Id} command:{Context.Message.Content}");

                        Repetitive_Timer.Daily_timer_Elapsed(null, null);

                        await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("info", "timer day done!"), Colors.information));
                    }
                    catch (Exception ex)
                    {
                        Log.Error($"command - admin timer day - user:{Context.User.Id} channel:{Context.Channel.Id} error:{ex.Message}");
                    }
                }
Beispiel #19
0
        public async Task ShuffleModule()
        {
            try
            {
                if (!Privileg.CheckById(Context.User.Id, Privileg.owner))
                {
                    await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("warning", "You are not my god!"), Colors.warning));

                    Log.Warning($"command - shuffle - user:{Context.User.Id} channel:{Context.Channel.Id} privileg to low");
                    return;
                }

                Log.Information($"command - shuffle - start user:{Context.User.Id} channel:{Context.Channel.Id} command:{Context.Message.Content}");

                audioClients[Context.Guild.Id].Shuffle();

                await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Program.Client.CurrentUser, Field.CreateFieldBuilder("audio", $"queue shuffled!"), Colors.information));
            }
            catch (Exception ex)
            {
                Log.Error($"command - shuffle - user:{Context.User.Id} channel:{Context.Channel.Id} error:{ex.Message}");
            }
        }
Beispiel #20
0
            public async Task SetBroadcastModule(int broadcast = 0)
            {
                try
                {
                    if (!Privileg.CheckById(Context.User.Id, Privileg.admin))
                    {
                        await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("warning", "You need to be at least admin to use this command!"), Colors.warning));

                        Log.Warning($"command - set broadcast - user:{Context.User.Id} channel:{Context.Channel.Id} privileg to low");
                        return;
                    }

                    Log.Information($"command - set broadcast - start user:{Context.User.Id} channel:{Context.Channel.Id} command:{Context.Message.Content}");

                    var channel = Channel.GetById(Context.Channel.Id);
                    channel.broadcast = broadcast;
                    Channel.Edit(channel);
                }
                catch (Exception ex)
                {
                    Log.Error($"command - set broadcast - user:{Context.User.Id} channel:{Context.Channel.Id} error:{ex.Message}");
                }
            }
Beispiel #21
0
        public async Task TestModule(ulong id = 0)
        {
            try
            {
                if (!Privileg.CheckById(Context.User.Id, Privileg.owner))
                {
                    await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("warning", "You are not my god!"), Colors.warning));

                    Log.Warning($"command - test - user:{Context.User.Id} channel:{Context.Channel.Id} privileg to low");
                    return;
                }

                Log.Information($"command - test - start user:{Context.User.Id} channel:{Context.Channel.Id} command:{Context.Message.Content}");

                //start test here

                //test end
            }
            catch (Exception ex)
            {
                Log.Error($"command - test - user:{Context.User.Id} channel:{Context.Channel.Id} error:{ex.Message}");
            }
        }
Beispiel #22
0
                public async Task RestartModule()
                {
                    try
                    {
                        if (!Privileg.CheckById(Context.User.Id, Privileg.owner))
                        {
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("warning", "You are not my god!"), Colors.warning));

                            Log.Warning($"command - admin timer restart - user:{Context.User.Id} channel:{Context.Channel.Id} privileg to low");
                            return;
                        }

                        Log.Information($"command - admin timer restart - start user:{Context.User.Id} channel:{Context.Channel.Id} command:{Context.Message.Content}");

                        Repetitive_Timer.SetUpDailyTimer(new TimeSpan(Convert.ToInt32(Global.GetByName("daily_timer_hour").value), 0, 0));
                        Repetitive_Timer.SetUpHourlyTimer(new TimeSpan(DateTime.Now.Hour + 1, 0, 0));

                        await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("info", "restart done!"), Colors.information));
                    }
                    catch (Exception ex)
                    {
                        Log.Error($"command - admin timer restart - user:{Context.User.Id} channel:{Context.Channel.Id} error:{ex.Message}");
                    }
                }
Beispiel #23
0
            public async Task StatsModule(ulong UserID = 0)
            {
                try
                {
                    Log.Information($"command - get stats - start user:{Context.User.Id} channel:{Context.Channel.Id} command:{Context.Message.Content}");

                    if (UserID != 0 && Privileg.CheckById(Context.User.Id, Privileg.admin))
                    {
                        Classes.User user = User.GetById(UserID);

                        if (user != null)
                        {
                            List <EmbedFieldBuilder> fields = new List <EmbedFieldBuilder>();

                            fields.Add(Field.CreateFieldBuilder(":+1: - upvotes", user.upvotes.ToString()));
                            fields.Add(Field.CreateFieldBuilder(":-1: - downvotes", user.downvotes.ToString()));
                            fields.Add(Field.CreateFieldBuilder(":notepad_spiral: - posts", user.posts.ToString()));

                            if (user.karma != -1)
                            {
                                fields.Add(Field.CreateFieldBuilder(":bar_chart: - karma", user.karma.ToString()));
                            }

                            var restUser = await Context.Client.Rest.GetUserAsync(UserID);

                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(restUser, fields, Colors.information, "stats"));
                        }
                        else
                        {
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("error", "User not found!"), Colors.error));

                            throw new Exception("User not found!");
                        }
                    }
                    else if (UserID != 0 && !Privileg.CheckById(Context.User.Id, Privileg.admin))
                    {
                        await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("warning", "You need to be at least admin to use this command!"), Colors.warning));

                        Log.Warning($"command - get stats - user:{Context.User.Id} channel:{Context.Channel.Id} privileg to low");
                    }
                    else
                    {
                        User user = User.GetById(Context.Message.Author.Id);

                        if (user != null)
                        {
                            List <EmbedFieldBuilder> fields = new List <EmbedFieldBuilder>();

                            fields.Add(Field.CreateFieldBuilder(":+1: - upvotes", user.upvotes.ToString()));
                            fields.Add(Field.CreateFieldBuilder(":-1: - downvotes", user.downvotes.ToString()));
                            fields.Add(Field.CreateFieldBuilder(":notepad_spiral: - posts", user.posts.ToString()));

                            if (user.karma != -1)
                            {
                                fields.Add(Field.CreateFieldBuilder(":bar_chart: - karma", user.karma.ToString()));
                            }

                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, fields, Colors.information, "stats"));
                        }
                        else
                        {
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("error", "User not found!"), Colors.error));

                            throw new Exception("User not found!");
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.Error($"command - get stats - user:{Context.User.Id} channel:{Context.Channel.Id} error:{ex.Message}");
                }
            }
Beispiel #24
0
            public async Task AddModule(string name, ulong guildID = 0)
            {
                if (!Privileg.CheckById(Context.User.Id, Privileg.owner))
                {
                    await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("warning", "You are not my god!"), Colors.warning));

                    Log.Warning($"command - admin add - user:{Context.User.Id} channel:{Context.Channel.Id} privileg to low");
                    return;
                }

                try
                {
                    List <SlashCommandBuilder> slashCommands = new List <SlashCommandBuilder>();

                    var command = new SlashCommandBuilder();

                    //help
                    {
                        command.WithName("help");
                        command.WithDescription("displays all bots commands");

                        command.AddOption("type", ApplicationCommandOptionType.String, "type of help", false, false, false, null, new ApplicationCommandOptionChoiceProperties {
                            Name = "data", Value = "data"
                        });

                        slashCommands.Add(command);
                    }

                    //get
                    {
                        command = new SlashCommandBuilder();
                        command.WithName("get");
                        command.WithDescription("get various things");

                        var options = new List <ApplicationCommandOptionChoiceProperties>();
                        options.Add(new ApplicationCommandOptionChoiceProperties {
                            Name = "stats", Value = "stats"
                        });
                        options.Add(new ApplicationCommandOptionChoiceProperties {
                            Name = "leaderboard", Value = "leaderboard"
                        });

                        command.AddOption("what", ApplicationCommandOptionType.String, "what to get", true, false, false, null, options.ToArray());

                        slashCommands.Add(command);
                    }

                    //play
                    {
                        command = new SlashCommandBuilder();
                        command.WithName("play");
                        command.WithDescription("play music from youtube");
                        command.AddOption("what", ApplicationCommandOptionType.String, "what to play", required: false);

                        slashCommands.Add(command);
                    }

                    //stop
                    {
                        command = new SlashCommandBuilder();
                        command.WithName("stop");
                        command.WithDescription("stop music");

                        slashCommands.Add(command);
                    }

                    //skip
                    {
                        command = new SlashCommandBuilder();
                        command.WithName("skip");
                        command.WithDescription("skip music track");

                        slashCommands.Add(command);
                    }

                    //leave
                    {
                        command = new SlashCommandBuilder();
                        command.WithName("leave");
                        command.WithDescription("leave the connected voice channel");

                        slashCommands.Add(command);
                    }

                    //shuffle
                    {
                        command = new SlashCommandBuilder();
                        command.WithName("shuffle");
                        command.WithDescription("shuffle music queue");

                        slashCommands.Add(command);
                    }

                    //queue
                    {
                        command = new SlashCommandBuilder();
                        command.WithName("queue");
                        command.WithDescription("list the 5 next music tracks");

                        slashCommands.Add(command);
                    }

                    foreach (var slashCommand in slashCommands)
                    {
                        if (guildID != 0)
                        {
                            if (slashCommand.Name == name)
                            {
                                await Program.Client.Rest.CreateGuildCommand(slashCommand.Build(), guildID);
                            }
                        }
                        else
                        {
                            if (slashCommand.Name == name)
                            {
                                await Program.Client.Rest.CreateGlobalCommand(slashCommand.Build());
                            }
                        }
                    }

                    await Context.Message.ReplyAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("info", "done!"), Colors.information));
                }
                catch (ApplicationCommandException ex)
                {
                    var json = JsonConvert.SerializeObject(ex.Error, Formatting.Indented);
                    await Context.Message.ReplyAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("error", json), Colors.error));
                }
                catch (Exception ex)
                {
                    Log.Error($"command - !admin get - user:{Context.Message.Author.Id} channel:{Context.Channel.Id} error:{ex.Message}");
                }
            }
Beispiel #25
0
            public async Task GetModule()
            {
                if (!Privileg.CheckById(Context.User.Id, Privileg.owner))
                {
                    await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("warning", "You are not my god!"), Colors.warning));

                    Log.Warning($"command - admin get - user:{Context.User.Id} channel:{Context.Channel.Id} privileg to low");
                    return;
                }

                try
                {
                    var commands = await Program.Client.Rest.GetGlobalApplicationCommands();

                    List <EmbedFieldBuilder> fields = new List <EmbedFieldBuilder>();

                    string output = "";

                    foreach (var command in commands)
                    {
                        output = output + command.Name + "\n";
                    }

                    if (output != "")
                    {
                        fields.Add(Field.CreateFieldBuilder("global slash commands", output));
                    }
                    else
                    {
                        fields.Add(Field.CreateFieldBuilder("global slash commands", "NULL"));
                    }

                    foreach (var server in Program.Client.Guilds)
                    {
                        try
                        {
                            var commands2 = await Program.Client.Rest.GetGuildApplicationCommands(server.Id);

                            output = "";

                            foreach (var command in commands2)
                            {
                                output = output + command.Name + "\n";
                            }

                            if (output != "")
                            {
                                fields.Add(Field.CreateFieldBuilder(server.Name, output));
                            }
                            else
                            {
                                fields.Add(Field.CreateFieldBuilder(server.Name, "NULL"));
                            }
                        }
                        catch
                        {
                        }
                    }

                    await Context.Message.ReplyAsync(embed : Classes.Embed.New(Context.Message.Author, fields, Colors.information));
                }
                catch (Exception ex)
                {
                    Log.Error($"command - !admin get - user:{Context.Message.Author.Id} channel:{Context.Channel.Id} error:{ex.Message}");
                }
            }