예제 #1
0
        public async Task InformationCommand()
        {
            var config = GuildConfig.GetOrCreateConfig(Context.Guild.Id);
            var embed  = new EmbedBuilder();

            embed.AddField("Version", Bot.Utilities.GetLocaleMsg("VersionString"));
            embed.AddField("Author", "<@168548441939509248>");
            embed.AddField("Language", "C# with Discord.Net");
            embed.AddField("Server", "https://discord.io/SIVA");
            embed.AddField("Servers", (Context.Client as DiscordSocketClient).Guilds.Count);
            embed.AddField("Invite Me", "https://bot.discord.io/SIVA");
            embed.AddField("Ping", (Context.Client as DiscordSocketClient).Latency);
            embed.AddField("Client ID", Program._client.CurrentUser.Id);
            embed.AddField("Invite my Nadeko", "https://bot.discord.io/snadeko");
            embed.WithThumbnailUrl("https://pbs.twimg.com/media/Cx0i4LOVQAIyLRU.png");
            embed.WithFooter(Bot.Utilities.GetFormattedLocaleMsg("CommandFooter", Context.User.Username));
            embed.WithColor(new Color(config.EmbedColour1, config.EmbedColour2, config.EmbedColour3));

            await Helpers.SendMessage(Context, embed);
        }
예제 #2
0
        public async Task SetBoolIntoConfig(bool setting)
        {
            var config = GuildConfig.GetGuildConfig(Context.Guild.Id) ?? GuildConfig.CreateGuildConfig(Context.Guild.Id);

            config.Antilink = setting;
            GuildConfig.SaveGuildConfig();
            var embed = new EmbedBuilder();

            embed.WithFooter(Bot.Utilities.GetFormattedLocaleMsg("CommandFooter", Context.User.Username));
            embed.WithColor(new Color(config.EmbedColour1, config.EmbedColour2, config.EmbedColour3));
            if (setting)
            {
                embed.WithDescription("Enabled Antilink for this server.");
            }
            if (setting == false)
            {
                embed.WithDescription("Disabled Antilink for this server.");
            }
            await ReplyAsync("", false, embed);
        }
예제 #3
0
        public async Task ExampleCommandAsync(CommandContext ctx, int limit)
        {
            var cfg = this._model.Configs.Find(ctx.Guild.Id);

            if (cfg is null)
            {
                cfg = new GuildConfig(ctx.Guild.Id);
                this._model.Add(cfg);
            }

            cfg.TriviaQuestionLimit = limit > 50 ? 50 : limit;
            if (cfg.TriviaQuestionLimit <= 0)
            {
                cfg.TriviaQuestionLimit = 1;
            }

            await this._model.SaveChangesAsync();

            await ctx.RespondAsync($"Set the question limit to {cfg.TriviaQuestionLimit}. The max questions per game can be no larger than 50.");
        }
예제 #4
0
        public async Task PPreview()
        {
            var guild = GuildConfig.GetServer(Context.Guild);
            var embed = new EmbedBuilder
            {
                Title        = Context.Guild.Name,
                Description  = guild.PartnerSetup.Message,
                ThumbnailUrl = Context.Guild.IconUrl,
                ImageUrl     = guild.PartnerSetup.ImageUrl,
                Color        = Color.Green,
                Footer       = new EmbedFooterBuilder
                {
                    Text = guild.PartnerSetup.showusercount
                        ? $"User Count: {((SocketGuild) Context.Guild).MemberCount}"
                        : null
                }
            };

            await ReplyAsync("", false, embed.Build());
        }
예제 #5
0
파일: Utils.cs 프로젝트: AlexbavGamer/SIVA
        public async Task SendFeedbackToDev([Remainder] string feedback)
        {
            var config = GuildConfig.GetOrCreateConfig(Context.Guild.Id);
            var embed  = new EmbedBuilder();

            embed.WithDescription(Bot.Internal.Utilities.GetFormattedLocaleMsg("FeedbackCommandText", feedback));
            embed.WithFooter(Bot.Internal.Utilities.GetFormattedLocaleMsg("CommandFooter", Context.User.Username));
            embed.WithColor(new Color(config.EmbedColour1, config.EmbedColour2, config.EmbedColour3));
            embed.WithTitle("Feedback to Greem");
            await ReplyAsync("", false, embed);

            var feedbackEmbed = new EmbedBuilder()
                                .WithDescription(feedback)
                                .WithTitle($"Feedback from {Context.User.Username}#{Context.User.DiscriminatorValue}")
                                .WithColor(Config.bot.DefaultEmbedColour);


            var channel = Program._client.GetGuild(405806471578648588).GetTextChannel(415182876326232064);
            await channel.SendMessageAsync("", false, feedbackEmbed);
        }
예제 #6
0
        public async Task LoadDareFromJson()
        {
            var config = GuildConfig.GetOrCreateConfig(Context.Guild.Id);

            if (!config.IsTodEnabled)
            {
                return;
            }
            var json      = TruthOrDareJson.LoadJson();
            var r         = new Random().Next(0, json.Dares.Count);
            var daresList = json.Dares.ToArray();
            var dare      = daresList[r];

            var embed = new EmbedBuilder()
                        .WithDescription(dare)
                        .WithColor(new Color(config.EmbedColour1, config.EmbedColour2, config.EmbedColour3))
                        .WithFooter(Bot.Utilities.GetFormattedLocaleMsg("CommandFooter", Context.User.Username));

            await ReplyAsync("", false, embed);
        }
예제 #7
0
        public async Task DisableSlashEnableTod(bool setting)
        {
            var config = GuildConfig.GetOrCreateConfig(Context.Guild.Id);

            config.IsTodEnabled = setting;
            GuildConfig.SaveGuildConfig();
            var embed = new EmbedBuilder()
                        .WithColor(new Color(config.EmbedColour1, config.EmbedColour2, config.EmbedColour3))
                        .WithFooter(Bot.Utilities.GetFormattedLocaleMsg("CommandFooter", Context.User.Username));

            if (setting)
            {
                embed.WithDescription("Enabled Truth or Dare for this server.");
            }
            if (setting == false)
            {
                embed.WithDescription("Disabled Truth or Dare for this server.");
            }
            await ReplyAsync("", false, embed);
        }
예제 #8
0
파일: Blacklist.cs 프로젝트: mturley/SIVA
        public static async Task CheckMessageForBlacklistedTerms(SocketMessage s)
        {
            var msg     = s as SocketUserMessage;
            var context = new SocketCommandContext(_client, msg);
            var config  = GuildConfig.GetGuildConfig(context.Guild.Id);

            if (msg == null || context.User.IsBot || config == null)
            {
                return;
            }
            foreach (var word in config.Blacklist)
            {
                if (msg.Content.Contains(word))
                {
                    await msg.DeleteAsync();

                    break;
                }
            }
        }
예제 #9
0
파일: Utils.cs 프로젝트: AlexbavGamer/SIVA
        public async Task ServerInformationCommand()
        {
            var config = GuildConfig.GetOrCreateConfig(Context.Guild.Id);
            var embed  = new EmbedBuilder();

            embed.WithTitle("Server Information");
            embed.AddField("Name", Context.Guild.Name);
            embed.AddField("Created", Context.Guild.CreatedAt.UtcDateTime);
            embed.AddField("Users", Context.Guild.Users.Count);
            embed.AddField("Text Channels", Context.Guild.TextChannels.Count);
            embed.AddField("Voice Channels", Context.Guild.VoiceChannels.Count);
            embed.AddField("Region", Context.Guild.VoiceRegionId);
            embed.WithThumbnailUrl(Context.Guild.IconUrl);
            embed.AddField("Roles", Context.Guild.Roles.Count);
            embed.AddField("Donator Guild", config.VerifiedGuild);
            embed.WithFooter(Bot.Internal.Utilities.GetFormattedLocaleMsg("CommandFooter", Context.User.Username));
            embed.WithColor(new Color(config.EmbedColour1, config.EmbedColour2, config.EmbedColour3));

            await ReplyAsync("", false, embed);
        }
예제 #10
0
        public async Task KickUser(SocketGuildUser user, [Remainder] string reason = "")
        {
            var config = GuildConfig.GetOrCreateConfig(Context.Guild.Id);

            if (Helpers.UserHasRole(Context, config.ModRole))
            {
                await user.KickAsync(reason);

                var embed = Helpers.CreateEmbed(Context,
                                                Bot.Internal.Utilities.GetFormattedLocaleMsg("KickUserMsg", user.Mention, Context.User.Mention));

                await Helpers.SendMessage(Context, embed);
            }
            else
            {
                var e = Helpers.CreateEmbed(Context,
                                            Bot.Internal.Utilities.GetFormattedLocaleMsg("NotEnoughPermission", Context.User.Username));
                await Helpers.SendMessage(Context, e);
            }
        }
예제 #11
0
        public async Task RemoveStringFromBl([Remainder] string bl)
        {
            var config = GuildConfig.GetOrCreateConfig(Context.Guild.Id);
            var embed  = new EmbedBuilder();

            embed.WithColor(new Color(config.EmbedColour1, config.EmbedColour2, config.EmbedColour3));
            embed.WithFooter(Bot.Utilities.GetFormattedLocaleMsg("CommandFooter", Context.User.Username));
            if (!config.Blacklist.Contains(bl))
            {
                embed.WithDescription($"`{bl}` isn't present in the Blacklist.");
            }
            else
            {
                embed.WithDescription($"Removed {bl} from the Blacklist.");
                config.Blacklist.Remove(bl);
                GuildConfig.SaveGuildConfig();
            }

            await SendMessage(embed);
        }
예제 #12
0
        public async Task RemCustomCommand(string commandName)
        {
            var config = GuildConfig.GetGuildConfig(Context.Guild.Id);
            var embed  = new EmbedBuilder()
                         .WithColor(new Color(config.EmbedColour1, config.EmbedColour2, config.EmbedColour3))
                         .WithFooter(Bot.Utilities.GetFormattedLocaleMsg("CommandFooter", Context.User.Username));

            if (config.CustomCommands.Keys.Contains(commandName))
            {
                embed.WithDescription($"Removed **{commandName}** as a command!");
                config.CustomCommands.Remove(commandName);
                GuildConfig.SaveGuildConfig();
            }
            else
            {
                embed.WithDescription($"**{commandName}** isn't a command on this server.");
            }

            await SendMessage(embed);
        }
예제 #13
0
        public async Task ViewInventory(IUser user = null)
        {
            await Setupuser(Context.Guild, Context.User);

            if (user == null)
            {
                user = Context.User;
            }

            var guildobj = GuildConfig.GetServer(Context.Guild);
            var uprofile = guildobj.Gambling.Users.FirstOrDefault(x => x.userID == user.Id);

            if (uprofile == null)
            {
                await ReplyAsync("User has not been set up yet.");

                return;
            }

            if (!uprofile.Inventory.Any())
            {
                await ReplyAsync("User does not own anything.");

                return;
            }

            var embed  = new EmbedBuilder();
            var uitems = uprofile.Inventory
                         .Select(x => guildobj.Gambling.Store.ShowItems.FirstOrDefault(s => s.ItemID == x.ItemID))
                         .Where(x => x != null);

            foreach (var item in uitems)
            {
                var uitem = uprofile.Inventory.First(x => x.ItemID == item.ItemID);
                embed.AddField(item.ItemName, $"Quantity: {uitem.quantity}\n" +
                               $"{(item.HasDurability ? $"Durability: {uitem.Durability}\n" : "")}" +
                               $"Value: {item.cost}");
            }

            await ReplyAsync("", false, embed.Build());
        }
예제 #14
0
        private (ulong GuildId, TimeZoneInfo Timezone) GetTimzezoneTuple(GuildConfig x)
        {
            TimeZoneInfo tz;

            try
            {
                if (x.TimeZoneId == null)
                {
                    tz = null;
                }
                else
                {
                    tz = TimeZoneInfo.FindSystemTimeZoneById(x.TimeZoneId);
                }
            }
            catch
            {
                tz = null;
            }
            return(x.GuildId, Timezone : tz);
        }
예제 #15
0
        public static async Task DeleteSupportChannel(Cacheable <IUserMessage, ulong> cache, ISocketMessageChannel ch, SocketReaction s)
        {
            var channel = s.Channel as SocketGuildChannel;              //allow us to send a message
            var config  = GuildConfig.GetGuildConfig(channel.Guild.Id); //get the config so we can see the support channel name. (and embed colour)
            var embed   = new EmbedBuilder()                            //create the embedded message.
                          .WithColor(config.EmbedColour1, config.EmbedColour2, config.EmbedColour3)
                          .WithDescription($"Ticket marked as solved by {s.User.Value.Mention}! Closing in 45 seconds.")
                          .WithAuthor(s.User.Value);

            if (channel.Name.Contains($"{config.SupportChannelName}-{s.UserId}") && s.Emote.Equals(new Emoji("☑"))) //check if a user made the reaction in a support ticket,
            //check if the emote is `☑` and then delete the channel.
            {
                if (s.UserId != 320942091049893888 && s.UserId != 410547925597421571) //check if the id of the person who made the reaction is NOT SIVA-dev or SIVA public.
                {
                    await ch.SendMessageAsync("", false, embed);                      //send the embedded message defined above.

                    Thread.Sleep(45000);                                              //wait 45 seconds (45000ms)
                    await channel.DeleteAsync();                                      //delete the channel
                }
            }
        }
예제 #16
0
        public static async Task Goodbye(SocketGuildUser user)
        {
            var config = GuildConfig.GetGuildConfig(user.Guild.Id);

            if (config.WelcomeChannel != 0)
            {
                var a = config.LeavingMessage.Replace("{UserMention}", user.Mention);
                a = a.Replace("{ServerName}", user.Guild.Name);
                a = a.Replace("{UserName}", user.Username);
                a = a.Replace("{OwnerMention}", user.Guild.Owner.Mention);
                a = a.Replace("{UserTag}", user.DiscriminatorValue.ToString());

                var channel = user.Guild.GetTextChannel(config.WelcomeChannel);
                var embed   = new EmbedBuilder();
                embed.WithDescription(a);
                embed.WithColor(new Color(config.WelcomeColour1, config.WelcomeColour2, config.WelcomeColour3));
                embed.WithFooter($"Guild Owner: {user.Guild.Owner.Username}#{user.Guild.Owner.Discriminator}");
                embed.WithThumbnailUrl(user.Guild.IconUrl);
                await channel.SendMessageAsync("", false, embed);
            }
        }
예제 #17
0
        public async Task BanThenUnbanUser(SocketGuildUser user)
        {
            var config = GuildConfig.GetOrCreateConfig(Context.Guild.Id);

            if (Helpers.UserHasRole(Context, config.ModRole))
            {
                var embed = Helpers.CreateEmbed(Context,
                                                $"{Context.User.Mention} softbanned <@{user.Id}>, deleting the last 7 days of messages from that user.");
                await Helpers.SendMessage(Context, embed);

                await Context.Guild.AddBanAsync(user, 7);

                await Context.Guild.RemoveBanAsync(user);
            }
            else
            {
                var e = Helpers.CreateEmbed(Context,
                                            Bot.Internal.Utilities.GetFormattedLocaleMsg("NotEnoughPermission", Context.User.Username));
                await Helpers.SendMessage(Context, e);
            }
        }
예제 #18
0
        public async Task SetServerAdminRole(string roleName)
        {
            var config = GuildConfig.GetOrCreateConfig(Context.Guild.Id);
            var embed  = new EmbedBuilder()
                         .WithColor(new Color(config.EmbedColour1, config.EmbedColour2, config.EmbedColour3))
                         .WithFooter(Bot.Utilities.GetFormattedLocaleMsg("CommandFooter", Context.User.Username));
            var role = Context.Guild.Roles.FirstOrDefault(x => x.Name == roleName);

            if (role == null)
            {
                embed.WithDescription($"The role `{roleName}` doesn't exist on this server. Remember that this command is cAsE sEnSiTiVe.");
            }
            else
            {
                embed.WithDescription($"Set the Administrator role to **{roleName}** for this server!");
                config.AdminRole = role.Id;
                GuildConfig.SaveGuildConfig();
            }

            await SendMessage(embed);
        }
예제 #19
0
            public async Task SetServerEmitterAsync(CommandContext context)
            {
                GuildConfig config = await guildConfig.FindOrCreateConfigAsync(context.Guild.Id);

                if (config.ApiLogin is null)
                {
                    await context.RespondAsync("Please set API Credentials first.");

                    return;
                }

                await _emitterClient.SetEmitterAsync(new()
                {
                    DisplayName = context.Guild.Name,
                    EmitterType = EmitterType.Server,
                    Snowflake   = context.Guild.Id
                }, await _apiAuthService.GetOrUpdateAuthTokenAsync(context.Guild.Id));

                await context.RespondAsync("Emitter successfully set :",
                                           Utilities.BuildEmitterEmbed(await _emitterClient.GetEmitterAsync(await _apiAuthService.GetOrUpdateAuthTokenAsync(context.Guild.Id))));
            }
예제 #20
0
        public async Task AddRuleAsync([Summary("The rule to add")][Remainder] string rule)
        {
            if (rule.IsEmpty())
            {
                await ReplyAsync("Please enter a rule").ConfigureAwait(false);

                return;
            }

            GuildConfig config = await GetOrCreatConfigAsync(Context.Guild.Id).ConfigureAwait(false);

            if (config.Rules == null)
            {
                config.Rules = new List <string>();
            }
            config.Rules.Add(rule);
            dbContext.GuildConfigs.Update(config);
            await dbContext.SaveChangesAsync().ConfigureAwait(false);

            await ReplyAndDeleteAsync("Rule added").ConfigureAwait(false);
        }
예제 #21
0
        public override BaseHelpFormatter WithSubcommands(IEnumerable <Command> subcommands)
        {
            var guild = this._database.Find <GuildConfig>(this.GuildId);

            if (guild is null)
            {
                guild = new GuildConfig(this.GuildId)
                {
                    Prefix = Prefix,
                };
                this._database.Add(guild);
                this._database.SaveChanges();
            }

            HashSet <string> disabledCommands = new();

            disabledCommands.UnionWith(guild.DisabledCommands);

            if (DiscordBot.Bot is not null)
            {
                foreach (var module in DiscordBot.Bot.CommandGroups)
                {
                    if (guild.DisabledModules.Contains(module.Key))
                    {
                        disabledCommands.UnionWith(module.Value.Select(x => x.Name.ToLower()));
                    }
                }
            }

            disabledCommands.ExceptWith(guild.ActivatedCommands);

            var cmdList = subcommands.Where(x => !disabledCommands.Contains(x.Name.ToLower()));

            this.EmbedBuilder.AddField(this.Command != null ? "Subcommands" : "Commands", string.Join(", ",
                                                                                                      cmdList.Select(x => {
                return(Formatter.InlineCode(x.Name));
            })), false);

            return(this);
        }
예제 #22
0
        public async Task Tagadd(string tagname, [Remainder] string tagmessage)
        {
            var tg = new Tagging
            {
                Tagname = tagname,
                Content = tagmessage,
                Creator = Context.User.Id
            };
            var file    = Path.Combine(AppContext.BaseDirectory, $"setup/server/{Context.Guild.Id}.json");
            var jsononb = JsonConvert.DeserializeObject <GuildConfig>(File.ReadAllText(file));

            try
            {
                var d = GuildConfig.Load(Context.Guild.Id).Dict;
                foreach (var tagging in d)
                {
                    if (tagging.Tagname == tagname)
                    {
                        await ReplyAsync(
                            $"**{tagname}** is already a tag in this server, if you want to edit it, please delete it first, then add the new tag");

                        return;
                    }
                }
                d.Add(tg);
                jsononb.Dict = d;
                var output = JsonConvert.SerializeObject(jsononb, Formatting.Indented);
                File.WriteAllText(file, output);
                await ReplyAsync("Tags List Updated");
            }
            catch
            {
                var d = new List <Tagging> {
                    tg
                };
                jsononb.Dict = d;
                var output = JsonConvert.SerializeObject(jsononb, Formatting.Indented);
                File.WriteAllText(file, output);
            }
        }