コード例 #1
0
ファイル: BanPlayerCommand.cs プロジェクト: filipehb/UODisc
        public void Invoke(CommandHandler handler, CommandEventArgs args)
        {
            NetState[] states = NetState.Instances.ToArray();

            for (int i = 0; i < states.Length; i++)
            {
                if (states[i].IsDisposing || !states[i].Running || states[i].Mobile == null ||
                    !states[i].Mobile.Name.Equals(args.Parameters[0], StringComparison.CurrentCultureIgnoreCase))
                {
                    continue;
                }

                string reason = args.Parameters.Count > 1 ? args.Parameters[1] : "unspecified";

                states[i].Mobile.SendMessage($"You have been banned for: {reason}");
                states[i].Mobile.Account.Banned = true;
                states[i].Dispose();

                DClient.DiscordLog($"{args.User.Username} banned player {args.Parameters[0]} for reason: {reason}", LogLevel.Info);
                args.Channel.SendEmbedMessage($"Banned player {args.Parameters[0]} for reason: {reason}").ConfigureAwait(false);
                return;
            }

            args.Channel.SendEmbedMessage($"Player {args.Parameters[0]} not found").ConfigureAwait(false);
        }
コード例 #2
0
        public void Invoke(CommandHandler handler, CommandEventArgs args)
        {
            DClient.DiscordLog($"{args.User.Username} started a world save", LogLevel.Info);

            args.Channel.SendEmbedMessage("Saving the world...").ConfigureAwait(false).GetAwaiter().GetResult();
            World.Save();
            args.Channel.SendEmbedMessage("World was saved...").ConfigureAwait(false);
        }
コード例 #3
0
        public void Invoke(CommandHandler handler, CommandEventArgs args)
        {
            DiscordUserLink dul = DClient.UserManager[args.User.Id];

            if (dul != null && dul.Accounts != null && dul.Accounts.Length >= DClient.UserManager.AccountsPerIp)
            {
                args.Channel.SendEmbedMessage("You can't create more accounts").ConfigureAwait(false);
                return;
            }
            else if (dul == null)
            {
                dul = new DiscordUserLink(args.User.Id);
            }

            Account acc = new Account(args.Parameters[0], args.Parameters[1]);

            dul.AddAccount(acc);
            DClient.UserManager.AddOrUpdate(dul);

            args.Channel.SendEmbedMessage($"Created account:\n```\n{args.Parameters[0]}\n{args.Parameters[1]}\n```").ConfigureAwait(false);
            DClient.DiscordLog($"New account created: {args.Parameters[0]}", LogLevel.Info);
        }
コード例 #4
0
        public void Invoke(CommandHandler handler, CommandEventArgs args)
        {
            if (!int.TryParse(args.Parameters[0], out int hue))
            {
                HelpCommand.ShowHelp(args.Channel, this, "Unable to parse hue");
                return;
            }
            if (!bool.TryParse(args.Parameters[1], out bool hideUsername))
            {
                HelpCommand.ShowHelp(args.Channel, this, "Unable to parse hideUsername (true/false)");
                return;
            }

            string msg = args.ParameterString.Remove(0, args.Parameters[0].Length + args.Parameters[1].Length + 2);

            if (!hideUsername)
            {
                msg = $"{args.User.Username}: " + msg;
            }

            World.Broadcast(hue, false, msg);
            args.Channel.SendEmbedMessage("Sent message").ConfigureAwait(false);
            DClient.DiscordLog($"{args.User.Username} sent a world message (did hide username?: {hideUsername})", LogLevel.Info);
        }