コード例 #1
0
        private async Task WarnNicole(SocketCommandContext context)
        {
            foreach (var OwnerChannel in _ownerChannels)
            {
                IDMChannel ownerChannel = await OwnerChannel;

                if (ownerChannel.Recipient.Id != 191196558153220096)
                {
                    return;
                }

                //Var embed
                var embed = new EmbedBuilder().WithOkColour().WithTitle($"Potential Table Loss from [{context.User.Username}] | {context.User.Id}").WithDescription(context.Message.Content);

                var msg = await ownerChannel.BlankEmbedAsync(embed.Build());
            }
        }
コード例 #2
0
        private async Task DMHandling(SocketCommandContext context)
        {
            foreach (var OwnerChannel in _ownerChannels)
            {
                IDMChannel ownerChannel = await OwnerChannel;

                //Var embed
                var embed = new EmbedBuilder().WithOkColour().WithTitle($"DM from [{context.User.Username}] | {context.User.Id}").WithDescription(context.Message.Content);

                var msg = await ownerChannel.BlankEmbedAsync(embed.Build());

                //Delay
                await Task.Delay(500);

                //Msg ID
                embed = embed.WithFooter($"To delete this message, run the command: >fdmd {msg.Id}");

                //Sorted
                await msg.ModifyAsync(x => x.Embed = embed.Build());
            }
        }
コード例 #3
0
        public async Task PrivateRoll(string username, string roll, int modifier, string advantage, string reason)
        {
            //Is username a username
            username = username.Trim();

            if (username.StartsWith('@'))
            {
                username = username.Substring(1);
            }

            if (!Regex.IsMatch(username, @".*#\d{4}$"))
            {
                await Context.Channel.SendErrorAsync("Invalid target user.");

                return;
            }

            int index = username.LastIndexOf('#');

            string un   = username.Substring(0, index);
            string disc = username.Substring(index + 1);

            //Get DM
            IUser      targetUser = _client.GetUser(un, disc);
            IDMChannel dmchannel  = await targetUser.GetOrCreateDMChannelAsync();

            _logger.Log(roll, "DnD");
            roll = roll.Trim();
            if (!Regex.IsMatch(roll, @"\d[d]\d*"))
            {
                await Context.Channel.SendErrorAsync("Invalid dice string");

                return;
            }

            string[] sep   = roll.Split('d');
            int      count = Int32.Parse(sep[0]);
            int      dice  = Int32.Parse(sep[1]);

            if (count == 0)
            {
                return;
            }
            if (count > 50)
            {
                return;
            }

            List <int> rolls = new List <int>();

            if (advantage.ToLower().Equals("a") || advantage.ToLower().Equals("d"))
            {
                count = 2;
            }
            for (int i = 0; i < count; i++)
            {
                rolls.Add(_random.Next(dice) + 1);
            }

            string title = $"Rolling {rolls.Count}d{dice} {modifier.ToString("+0;-#")} | Rolled by: {Context.User.Username} / Sent to: {targetUser.Username}";

            if (advantage.ToLower().Equals("a"))
            {
                title += " | Rolling with advantage.";
            }
            if (advantage.ToLower().Equals("d"))
            {
                title += " | Rolling with disadvantage.";
            }

            var    embed = new EmbedBuilder().WithDnDColour().WithTitle(title);
            string desc  = "";

            foreach (int i in rolls)
            {
                desc += $"`{i}` ";
            }

            desc.TrimEnd();
            embed.AddField(efb => efb.WithName("Rolls").WithValue(desc).WithIsInline(true)).AddField(efb => efb.WithName("Modifier").WithValue(modifier.ToString("+0;-#")).WithIsInline(true));
            string finaltotal = "";

            if (advantage.ToLower().Equals("a"))
            {
                finaltotal += $"{rolls.Max() + modifier}";
            }
            else if (advantage.ToLower().Equals("d"))
            {
                finaltotal += $"{rolls.Min() + modifier}";
            }
            else
            {
                finaltotal += $"{rolls.Sum() + modifier}";
            }

            embed.AddField(efb => efb.WithName("Total").WithValue(finaltotal));

            if (reason != "")
            {
                embed.AddField(efb => efb.WithName("Reason").WithValue(reason));
            }

            await dmchannel.BlankEmbedAsync(embed.Build());

            await Context.Channel.BlankEmbedAsync(embed.Build());
        }