예제 #1
0
        static void Main(string[] args)
        {
        var client = new DiscordClient();

        //Display all log messages in the console
        client.LogMessage += (s, e) => Console.WriteLine("[{e.Severity}] {e.Source}: {e.Message}");

        //Echo back any message received, provided it didn't come from the bot itself
        client.MessageReceived += async (s, e) =>
        {
            if (!e.Message.IsAuthor)
            await client.SendMessage(e.Channel, e.Message.Text);
        };

        //Convert our sync method to an async one and block the Main function until the bot disconnects
        client.Run(async () =>
        {
            while (true)
            {
                try
                {
                    await client.Connect(EMAIL, PASSWORD);
                    client.SetGame("Discord.Net);
                    break;
                }
                catch (Exception ex)
                {
                    client.LogMessage += (s, e) => Console.WriteLine(String.Concat("Login Failed", ex.Message));
                    await Task.Delay(client.Config.FailedReconnectDelay);
                }
            }
        });
        }
예제 #2
0
        public StormBot(string email, string password)
        {
            _email = email;
            _password = password;

            Client = new DiscordClient(config => { config.LogLevel = LogSeverity.Debug; });
        }
예제 #3
0
        static void Main(string[] args)
        {
        var client = new DiscordClient();

        //Display all log messages in the console
        client.LogMessage += (s, e) => Console.WriteLine("[{e.Severity}] {e.Source}: {e.Message}");

        //Echo back any message received, provided it didn't come from the bot itself
        client.MessageReceived += async (s, e) =>
        {
            if (!e.Message.IsAuthor)
            await client.SendMessage(e.Channel, e.Message.Text);
        };

        //Convert our sync method to an async one and block the Main function until the bot disconnects
        client.Run(async () =>
        {
            //Connect to the Discord server using our email and password
            await client.Connect(EMAIL, PASSWORD);
            client.SetGame(1);

            //If we are not a member of any server, use our invite code (made beforehand in the official Discord Client)
            /*
            if (!client.AllServers.Any())
            await client.AcceptInvite(client.GetInvite(TL_SOKU_INVITE_CODE));
             */
        });
        }
예제 #4
0
		internal Invite(DiscordClient client, string code, string xkcdPass, string serverId, string inviterId, string channelId)
			: base(client, code)
		{
			XkcdCode = xkcdPass;
			_server = new Reference<Server>(serverId, x =>
			{
				var server = _client.Servers[x];
				if (server == null)
				{
					server = _generatedServer = new Server(client, x);
					server.Cache();
				}
				return server;
			});
			_inviter = new Reference<User>(serverId, x =>
			{
				var inviter = _client.Users[x, _server.Id];
				if (inviter == null)
				{
					inviter = _generatedInviter = new User(client, x, _server.Id);
					inviter.Cache();
				}
				return inviter;
			});
			_channel = new Reference<Channel>(serverId, x =>
			{
				var channel = _client.Channels[x];
				if (channel == null)
				{
					channel = _generatedChannel = new Channel(client, x, _server.Id, null);
					channel.Cache();
				}
				return channel;
			});
		}
예제 #5
0
		internal Channel(DiscordClient client, string id, string serverId, string recipientId)
			: base(client, id)
		{
			_server = new Reference<Server>(serverId, 
				x => _client.Servers[x], 
				x => x.AddChannel(this), 
				x => x.RemoveChannel(this));
			_recipient = new Reference<User>(recipientId, 
				x => _client.Users.GetOrAdd(x, _server.Id), 
				x =>
				{
					Name = "@" + x.Name;
					if (_server.Id == null)
						x.GlobalUser.PrivateChannel = this;
				},
				x =>
				{
					if (_server.Id == null)
						x.GlobalUser.PrivateChannel = null;
                });
			_permissionOverwrites = _initialPermissionsOverwrites;
			_areMembersStale = true;

			//Local Cache
			_messages = new ConcurrentDictionary<string, Message>();
		}
예제 #6
0
        public void SendAudio(Discord.Audio.IAudioClient _vClient, Discord.DiscordClient _client, string filePath)
        {
            try
            {
                var channelCount = _client.GetService <AudioService>().Config.Channels;        // Get the number of AudioChannels our AudioService has been configured to use.
                var OutFormat    = new WaveFormat(48000, 16, channelCount);                    // Create a new Output Format, using the spec that Discord will accept, and with the number of channels that our client supports.
                using (var MP3Reader = new Mp3FileReader(filePath))                            // Create a new Disposable MP3FileReader, to read audio from the filePath parameter
                    using (var resampler = new MediaFoundationResampler(MP3Reader, OutFormat)) // Create a Disposable Resampler, which will convert the read MP3 data to PCM, using our Output Format
                    {
                        resampler.ResamplerQuality = 60;                                       // Set the quality of the resampler to 60, the highest quality
                        int    blockSize = OutFormat.AverageBytesPerSecond / 50;               // Establish the size of our AudioBuffer
                        byte[] buffer    = new byte[blockSize];
                        int    byteCount;

                        while ((byteCount = resampler.Read(buffer, 0, blockSize)) > 0) // Read audio into our buffer, and keep a loop open while data is present
                        {
                            if (byteCount < blockSize)
                            {
                                // Incomplete Frame
                                for (int i = byteCount; i < blockSize; i++)
                                {
                                    buffer[i] = 0;
                                }
                            }
                            audio.Send(buffer, 0, blockSize); // Send the buffer to Discord
                        }
                        audio.Wait();
                    }
            }
            catch
            {
            }
        }
예제 #7
0
        static void Main(string[] args)
        {
            Playlist = new List<string>();
            var inoriClient = new DiscordClient(x =>
            {
                x.AppName = "MilliaBot";
                x.MessageCacheSize = 0;
                x.UsePermissionsCache = true;
                x.EnablePreUpdateEvents = true;
                x.LogLevel = LogSeverity.Debug;
            })
                .UsingCommands(x =>
                {
                    x.AllowMentionPrefix = true;
                    x.HelpMode = HelpMode.Public;
                })
                .UsingModules();

            inoriClient.AddService<AudioService>(new AudioService(new AudioServiceConfigBuilder()
            {
                Channels = 2,
                EnableEncryption = false,
                EnableMultiserver = false,
                Bitrate = 96,
            }));

            //Display all log messages in the console
            inoriClient.Log.Message += (s, e) => Console.WriteLine($"[{e.Severity}] {e.Source}: {e.Message}");

            HandleMessage(inoriClient);

            //Convert our sync method to an async one and block the Main function until the bot disconnects
            Connect(inoriClient);
        }
예제 #8
0
        public void Install(ModuleManager manager)
        {
            _client = manager.Client;

            manager.CreateCommands("", group =>
            {
                group.CreateCommand("jobguide")
                    .Description("shows a link to class guides")
                    .Parameter("Job")
                    .Do(async e =>
                    {
                        if (e.Args.Length != 1 || string.IsNullOrEmpty(e.Args[0]))
                        {
                            await _client.SendMessage(e.Message.Channel, string.Format("Hi {0}, if you would like to see job guides, please say: !job guide [WHM/ DRK, e.t.c.]", e.Message.User));
                        }

                        var newsItems = await _botServices.News.GetOrAddNewsItems(new SyndicationSearchFields
                        {
                            Type = SyndicationType.JobGuides,
                            Url = GetJobGuideUrl(e.Args[0]),
                            Take = 3
                        });

                        for (int i = 0; i < newsItems.Count(); i++)
                        {
                            await _client.SendMessage(e.Message.Channel, string.Format("\n**{0}.** {1}", i + 1, newsItems.ElementAt(i).ToDiscordMessage()));
                        }
                    });
                });
        }
예제 #9
0
		internal User(string id, DiscordClient client)
		{
			Id = id;
			_client = client;
			LastActivity = DateTime.UtcNow;
			IsVerified = true;
        }
예제 #10
0
        void IModule.Install(ModuleManager manager)
        {
            _manager = manager;
            _client = _manager.Client;

            manager.CreateCommands("", group =>
            {
                //register skip command.
                group.CreateCommand("rainbow").
                     Parameter("nothing", ParameterType.Unparsed).
                     Description("Skips the current song in the music queue.").
                     Do(RainbowCommand);
            });

            _colors = new List<ColorDefinition>()
            {
                new ColorDefinition("Blue", Color.Blue),
                new ColorDefinition("Teal", Color.Teal),
                new ColorDefinition("Gold", Color.Gold),
                new ColorDefinition("Green", Color.Green),
                new ColorDefinition("Purple", Color.Purple),
                new ColorDefinition("Orange", Color.Orange),
                new ColorDefinition("Magenta", Color.Magenta),
                new ColorDefinition("Red", Color.Red),
                new ColorDefinition("DarkBlue", Color.DarkBlue),
                new ColorDefinition("DarkTeal", Color.DarkTeal),
                new ColorDefinition("DarkGold", Color.DarkGold),
                new ColorDefinition("DarkGreen", Color.DarkGreen),
                new ColorDefinition("DarkMagenta", Color.DarkMagenta),
                new ColorDefinition("DarkOrange", Color.DarkOrange),
                new ColorDefinition("DarkPurple", Color.DarkPurple),
                new ColorDefinition("DarkRed", Color.DarkRed),
            };
        }
예제 #11
0
        void IModule.Install(ModuleManager manager)
        {
            //Initiate variables
            _manager = manager;
            _client = manager.Client;

            //Message received
            _client.MessageReceived += async (s, e) =>
            {
                //Delete help requests
                if (e.Message.Text.StartsWith("!help"))
                    await e.Message.Delete();
            };

            //User banned
            _client.UserBanned += async (s, e) =>
            {
                await e.Server.DefaultChannel.SendMessage($"{e.User.Mention} ({e.User.NickOrName()}) was banned! :skull:");
            };

            //User joined
            _client.UserJoined += async (s, e) =>
            {
                await e.Server.DefaultChannel.SendMessage($"{e.User.Mention} has joined the server! Welcome! :smile: \r\nYou can use !help to know more about my functions! :kissing_heart:");
            };

            //User left
            _client.UserLeft += async (s, e) =>
            {
                await e.Server.DefaultChannel.SendMessage($"{e.User.NickOrName()} has left the server. :cry:");
                PointModule.DeleteUser(e.Server, e.User);
            };
        }
예제 #12
0
 public TwitchRelay(DiscordClient discord, string channel, string targetchannel, bool twoway = true)
 {
     sChannel = channel;
     sTargetChannel = targetchannel;
     discordclient = discord;
     bTwoWay = twoway;
 }
예제 #13
0
		internal Role(string id, string serverId, DiscordClient client)
		{
			Permissions = new PackedPermissions();
			Id = id;
			ServerId = serverId;
			_client = client;
		}
예제 #14
0
		internal Invite(DiscordClient client, string code, string xkcdPass, string serverId)
		{
			_client = client;
			Id = code;
			XkcdPass = xkcdPass;
			ServerId = serverId;
		}
예제 #15
0
		internal Channel(string id, string serverId, DiscordClient client)
		{
			Id = id;
			ServerId = serverId;
			IsPrivate = serverId == null;
			_client = client;
		}
예제 #16
0
    // Classes constructor
    public BotUser(Discord.DiscordClient Bot)
    {
        // Create a SaveModule named BotSaveModule to handle the saving / loading of user info data.
        Modules = new Modules();

        UsersInfo = Modules.SaveModule.LoadUserData();
    }
예제 #17
0
		internal static string ConvertToNames(DiscordClient client, Server server, string text)
		{
			text = _userRegex.Replace(text, new MatchEvaluator(e =>
			{
				string id = e.Value.Substring(2, e.Value.Length - 3);
				var user = client.Users[id, server?.Id];
				if (user != null)
					return '@' + user.Name;
				else //User not found
					return '@' + e.Value;
			}));
			if (server != null)
			{
				text = _channelRegex.Replace(text, new MatchEvaluator(e =>
				{
					string id = e.Value.Substring(2, e.Value.Length - 3);
					var channel = client.Channels[id];
					if (channel != null && channel.Server.Id == server.Id)
						return '#' + channel.Name;
					else //Channel not found
					return '#' + e.Value;
				}));
			}
			return text;
		}
예제 #18
0
        public void Install(ModuleManager manager)
        {
            _client = manager.Client;

            manager.CreateCommands("", group =>
            {
                group.CreateCommand("gear")
                    .Description("shows a link to gear and BiS information about a given job")
                    .Parameter("Job")
                    .Do(async e =>
                    {
                        await _client.SendMessage(e.Message.Channel, _botServices.Tools.GetUrlFromCommand(e));
                    });

                group.CreateCommand("garland")
                    .Description("shows a link to gathering information including node spawns")
                    .Do(async e =>
                    {
                        await _client.SendMessage(e.Message.Channel, _botServices.Tools.GetUrlFromCommand(e));
                    });

                group.CreateCommand("chocobo")
                    .Description("shows a link to the chocobo colour calculator")
                    .Do(async e =>
                    {
                        await _client.SendMessage(e.Message.Channel, _botServices.Tools.GetUrlFromCommand(e));
                    });

                group.CreateCommand("tripletriad")
                    .Description("shows a link to the Triple Triad deck manager")
                    .Do(async e =>
                    {
                        await _client.SendMessage(e.Message.Channel, _botServices.Tools.GetUrlFromCommand(e));
                    });

                group.CreateCommand("minions")
                    .Description("shows a link to a player's minion information")
                    .Parameter("Forename")
                    .Parameter("Surname")
                    .Parameter("Server")
                    .Do(async e =>
                    {
                        await _client.SendMessage(e.Message.Channel, _botServices.Tools.GetUrlFromCommand(e));
                    });

                group.CreateCommand("minicactpot")
                    .Description("shows a link to the minicactpot calculator")
                    .Do(async e =>
                    {
                        await _client.SendMessage(e.Message.Channel, _botServices.Tools.GetUrlFromCommand(e));
                    });

                group.CreateCommand("sightseeing")
                    .Description("shows a link to the sightseeing log helper")
                    .Do(async e =>
                    {
                        await _client.SendMessage(e.Message.Channel, _botServices.Tools.GetUrlFromCommand(e));
                    });
                });
        }
예제 #19
0
        static void Main(string[] args)
        {
            var inoriBot = new DiscordClient();

            //Display all log messages in the console
            inoriBot.LogMessage += (s, e) => Console.WriteLine($"[{e.Severity}] {e.Source}: {e.Message}");

            //Echo back any message received, provided it didn't come from the bot itself


            //Convert our sync method to an async one and block the Main function until the bot disconnects
            inoriBot.Run(async () =>
            {
                while (true)
                {
                    try
                    {
                        await inoriBot.Connect(EMAIL, PASSWORD);
                        await inoriBot.SetGame(1);
                        break;
                    }
                    catch (Exception ex)
                    {
                        inoriBot.LogMessage += (s, e) => Console.WriteLine(String.Concat("Login Failed", ex));
                        await Task.Delay(inoriBot.Config.FailedReconnectDelay);
                    }
                }
            });
        }
예제 #20
0
		internal Member(DiscordClient client, string userId, string serverId)
		{
			_client = client;
			UserId = userId;
			ServerId = serverId;
			Status = UserStatus.Offline;
			_permissions = new ConcurrentDictionary<string, PackedPermissions>();
        }
예제 #21
0
파일: Role.cs 프로젝트: Goobles/Discord.Net
		internal Role(DiscordClient client, string id, string serverId, bool isEveryone)
		{
			_client = client;
			Id = id;
			ServerId = serverId;
			Permissions = new PackedPermissions(true);
			IsEveryone = isEveryone;
        }
예제 #22
0
 private async void EchoMessage(DiscordClient client)
 {
     client.MessageReceived += async (s, e) =>
     {
         if (!e.Message.IsAuthor)
             await client.SendMessage(e.Channel, e.Message.Text);
     };
 }
예제 #23
0
        public void Install(ModuleManager manager)
        {
            _client = manager.Client;

            _client.UserJoined += async (s, e) => 
            {
                var buffer = string.Format("Welcome to '{0}', {1}\n\n", e.Server, Mention.User(e.User));
                buffer += _client.Commands().AllCommands.ToDiscordMessage();
                await _client.SendPrivateMessage(e.User, buffer);
                await _client.SendMessage(e.Server.DefaultChannel, string.Format("A wild {0} appears!", Mention.User(e.User)));
            };

            _client.UserLeft += async (s, e) => 
            {
                await _client.SendMessage(e.Server.DefaultChannel, string.Format("See you soon, {0}!", Mention.User(e.User)));
            };

            _client.ChannelUpdated += async (s, e) => 
            {
                if (_botServices.Server.ChannelTopicUpdated(e.Channel))
                {
                    await _client.SendMessage(e.Channel, string.Format("**Topic Updated**\n'{0}'", e.Channel.Topic));
                }
            };

            /*_client.UserPresenceUpdated += async (s, e) => 
            {
                if (_botServices.Server.UserHasReturned(e.Server, e.User))
                {
                    //await _client.SendMessage(e.Server.DefaultChannel, string.Format("Welcome back, {0}!", Mention.User(e.User)));
                }
            };*/

            _client.ChannelCreated += async (sender, e) =>
            {
                await _client.SendMessage(e.Server.DefaultChannel, string.Format("**New Channel Created**\n{0}", Mention.Channel(e.Channel)));
            };

            _client.MessageReceived += async (s, e) =>
            { 
                if (e.Message.IsAuthor)
                    return;

                var reply = _botServices.AI.GetReply(e.Message.Channel, e.Message);
                if(!string.IsNullOrEmpty(reply))
                {
                    await _client.SendMessage(e.Message.Channel, reply);
                }
            };

            _botServices.Ticker.OnTicked += async (s, e) => 
            {
                if (_botServices.Ticker.TicksElapsed(e.Ticks, 240))
                { 
                    await Announce(e);
                }
            };
        }
예제 #24
0
		internal Channel(DiscordClient client, string id, string serverId, string recipientId)
		{
			_client = client;
			Id = id;
			ServerId = serverId;
			RecipientId = recipientId;
			_messages = new ConcurrentDictionary<string, bool>();
			_areMembersStale = true;
        }
예제 #25
0
		public DiscordWebSocket(DiscordClient client, int timeout, int interval, bool isDebug)
		{
			_client = client;
            _timeout = timeout;
			_sendInterval = interval;
			_isDebug = isDebug;

			_sendQueue = new ConcurrentQueue<byte[]>();
		}
예제 #26
0
		public DiscordVoiceSocket(DiscordClient client, int timeout, int interval, bool isDebug)
			: base(client, timeout, interval, isDebug)
		{
			_connectWaitOnLogin = new ManualResetEventSlim(false);
#if !DNXCORE50
			_sendQueue = new ConcurrentQueue<Packet>();
			_encoder = new OpusEncoder(48000, 1, 20, Application.Audio);
#endif
		}
예제 #27
0
        public bool FinishLoading(DiscordClient client)
        {
            Channel channel = client.GetChannel(ChannelId);
            if (channel == null)
                return false;

            Channel = channel;
            return true;
        }
예제 #28
0
		//TODO: Add local members cache

		internal Role(DiscordClient client, string id, string serverId)
			: base(client, id)
		{
			_server = new Reference<Server>(serverId, x => _client.Servers[x], x => x.AddRole(this), x => x.RemoveRole(this));
			Permissions = new ServerPermissions(0);
			Permissions.Lock();
			Color = new Color(0);
			Color.Lock();
		}
예제 #29
0
		internal Server(string id, DiscordClient client)
		{
			Id = id;
			_client = client;
			_bans = new ConcurrentDictionary<string, bool>();
			_members = new AsyncCache<Membership, API.Models.MemberInfo>(
				(key, parentKey) =>
				{
					if (_client.IsDebugMode)
						_client.RaiseOnDebugMessage(DebugMessageType.Cache, $"Created user {key} in server {parentKey}.");
                    return new Membership(parentKey, key, _client);
				},
				(member, model) =>
				{
					if (model is API.Models.PresenceMemberInfo)
					{
						var extendedModel = model as API.Models.PresenceMemberInfo;
						member.Status = extendedModel.Status;
						member.GameId = extendedModel.GameId;
					}
					if (model is API.Models.VoiceMemberInfo)
					{
						var extendedModel = model as API.Models.VoiceMemberInfo;
						member.VoiceChannelId = extendedModel.ChannelId;
						member.IsDeafened = extendedModel.IsDeafened;
						member.IsMuted = extendedModel.IsMuted;
						if (extendedModel.IsSelfDeafened.HasValue)
							member.IsSelfDeafened = extendedModel.IsSelfDeafened.Value;
						if (extendedModel.IsSelfMuted.HasValue)
							member.IsSelfMuted = extendedModel.IsSelfMuted.Value;
						member.IsSuppressed = extendedModel.IsSuppressed;
						member.SessionId = extendedModel.SessionId;
						member.Token = extendedModel.Token;
					}
					if (model is API.Models.RoleMemberInfo)
					{
						var extendedModel = model as API.Models.RoleMemberInfo;
						member.RoleIds = extendedModel.Roles;
						if (extendedModel.JoinedAt.HasValue)
							member.JoinedAt = extendedModel.JoinedAt.Value;
					}
					if (model is API.Models.InitialMemberInfo)
					{
						var extendedModel = model as API.Models.InitialMemberInfo;
						member.IsDeafened = extendedModel.IsDeafened;
						member.IsMuted = extendedModel.IsMuted;
					}
					if (_client.IsDebugMode)
						_client.RaiseOnDebugMessage(DebugMessageType.Cache, $"Updated user {member.User?.Name} ({member.UserId}) in server {member.Server?.Name} ({member.ServerId}).");
				},
				(member) =>
				{
					if (_client.IsDebugMode)
						_client.RaiseOnDebugMessage(DebugMessageType.Cache, $"Destroyed user {member.User?.Name} ({member.UserId}) in server {member.Server?.Name} ({member.ServerId}).");
				}
			);
		}
예제 #30
0
파일: Voice.cs 프로젝트: Kusoneko/Nekobot
        internal static void Startup(DiscordClient c)
        {
            c.UsingAudio(x =>
            {
                x.Mode = AudioMode.Outgoing;
                x.EnableEncryption = true;
            });

            Music.Load(c);
        }
예제 #31
0
 public static void First(MessageEventArgs e, Discord.DiscordClient b)
 {
     bot                = b;
     battleship         = new BattleShip();
     battleship.playing = true;
     battleship.users   = new List <User>();
     battleship.teams1  = new List <User>();
     battleship.teams2  = new List <User>();
     e.Channel.SendMessage("Type /join if you want to play");
 }
예제 #32
0
        //connects the bot and then logs the chat
        public BauwsBot()
        {
            bot = new DiscordClient();

            bot.MessageReceived += Bot_MessageReceived;

            bot.Connect("*****@*****.**", "loveall4god123");

            bot.Wait();
        }
예제 #33
0
        public static void InitBot()
        {

            bot = new DiscordClient();

            bot.MessageReceived += Bot_MessagedReceived;

            bot.ExecuteAndWait(async () => {
                await bot.Connect(discordBotToken);
            });
        }
예제 #34
0
        public DiscordClient(Bot bot, DiscordToken token) : base(bot, token)
        {
            ID = token.myid;

            Discord.DiscordConfigBuilder b = new Discord.DiscordConfigBuilder();
            b.AppName = "Matbot";

            client = new Discord.DiscordClient(b);

            client.MessageReceived += C_MessageReceived;
            this.token              = token.Token;
        }
예제 #35
0
        static void Main(string[] args)
        {
            bot             = new Discord.DiscordClient();
            deletedmessages = new List <String>();
            storedmessages  = new List <MessageEventArgs>();

            bot.MessageReceived += bot_MessageReceived;
            bot.MessageDeleted  += bot_MessageDeleted;
            bot.UserJoined      += bot_UserJoined;
            bot.LoggedIn        += bot_LoggedIn;
            //bot.Connect("");
            bot.Wait();
        }
예제 #36
0
        public Bot()
        {
            try
            {
                r = new Random();


                discordBot = new DiscordClient(x =>
                {
                    x.AppName    = "IluvatarSuperBot";
                    x.LogLevel   = LogSeverity.Info;
                    x.LogHandler = Log;
                });

                discordBot.UsingCommands(x =>
                {
                    x.PrefixChar         = '~';
                    x.AllowMentionPrefix = true;
                    x.HelpMode           = HelpMode.Public;
                });

                discordBot.UsingPermissionLevels((u, c) => (int)GetPermissions(u, c));

                discordBot.UsingAudio(x =>
                {
                    x.Mode = AudioMode.Outgoing;
                });

                CreateCommand();

                discordBot.ExecuteAndWait(async() =>
                {
                    await discordBot.Connect(token);
                });
            }
            catch (Exception ex) { Console.WriteLine(ex); }
        }
예제 #37
0
 public static async Task <WelcomeScreen> ModifyWelcomeScreenAsync(this DiscordClient client, ulong guildId, WelcomeScreenProperties properties)
 {
     return((await client.HttpClient.PatchAsync($"/guilds/{guildId}/welcome-screen", properties))
            .Deserialize <WelcomeScreen>().SetClient(client));
 }
예제 #38
0
#pragma warning disable IDE1006
        private static Treturn modifyChannel <Treturn, TProperties>(this DiscordClient client, ulong channelId, TProperties properties) where TProperties : GuildChannelProperties where Treturn : GuildChannel
        {
            return(client.HttpClient.Patch($"/channels/{channelId}", properties).DeserializeEx <Treturn>().SetClient(client));
        }
예제 #39
0
 public static GuildMember GetGuildMember(this DiscordClient client, long guildId, long memberId)
 {
     return(client.HttpClient.Get($"/guilds/{guildId}/members/{memberId}")
            .Deserialize <GuildMember>());
 }
예제 #40
0
 /// <summary>
 /// Removes a permission overwrite from a channel
 /// </summary>
 /// <param name="channelId">ID of the channel</param>
 /// <param name="id">ID of the role or member affected by the overwrite</param>
 public static void RemovePermissionOverwrite(this DiscordClient client, ulong channelId, ulong id)
 {
     client.HttpClient.Delete($"/channels/{channelId}/permissions/{id}");
 }
예제 #41
0
 /// <summary>
 /// Creates an invite for a channel
 /// </summary>
 /// <param name="channelId">ID of the channel</param>
 /// <param name="properties">Options for creating the invite</param>
 /// <returns>The created invite</returns>
 public static DiscordInvite CreateInvite(this DiscordClient client, ulong channelId, InviteProperties properties = null)
 {
     return(client.CreateInviteAsync(channelId, properties).GetAwaiter().GetResult());
 }
예제 #42
0
 public static async Task <DiscordInvite> DeleteInviteAsync(this DiscordClient client, string invCode)
 {
     return((await client.HttpClient.DeleteAsync($"/invites/{invCode}"))
            .ParseDeterministic <DiscordInvite>().SetClient(client));
 }
예제 #43
0
 public static async Task <DiscordInvite> GetInviteAsync(this DiscordClient client, string invCode)
 {
     return((await client.HttpClient.GetAsync($"/invites/{invCode}?with_counts=true"))
            .ParseDeterministic <DiscordInvite>().SetClient(client));
 }
예제 #44
0
 /// <summary>
 /// Gets an invite
 /// </summary>
 public static DiscordInvite GetInvite(this DiscordClient client, string invCode)
 {
     return(client.GetInviteAsync(invCode).GetAwaiter().GetResult());
 }
예제 #45
0
 public static async Task <IReadOnlyList <GuildInvite> > GetGuildInvitesAsync(this DiscordClient client, ulong guildId)
 {
     return((await client.HttpClient.GetAsync($"/guilds/{guildId}/invites")).Deserialize <List <GuildInvite> >().SetClientsInList(client));
 }
예제 #46
0
 public static WelcomeScreen GetWelcomeScreen(this DiscordClient client, ulong guildId)
 {
     return(client.GetWelcomeScreenAsync(guildId).GetAwaiter().GetResult());
 }
예제 #47
0
 /// <summary>
 /// Modifies a guild channel
 /// </summary>
 /// <param name="channelId">ID of the channel</param>
 /// <param name="properties">Options for modifying the guild channel</param>
 /// <returns>The modified <see cref="GuildChannel"/></returns>
 public static GuildChannel ModifyGuildChannel(this DiscordClient client, ulong channelId, GuildChannelProperties properties)
 {
     return(client.modifyChannel <GuildChannel, GuildChannelProperties>(channelId, properties));
 }
예제 #48
0
 public static IReadOnlyList <GuildChannel> GetGuildChannels(this DiscordClient client, long guildId)
 {
     return(client.HttpClient.Get($"/guilds/{guildId}/channels")
            .Deserialize <IReadOnlyList <GuildChannel> >().SetClientsInList(client));
 }
예제 #49
0
 public static Guild CreateGuild(this DiscordClient client, GuildCreationProperties properties)
 {
     return(client.HttpClient.Post("/guilds", JsonConvert.SerializeObject(properties))
            .Deserialize <Guild>().SetClient(client));
 }
예제 #50
0
 /// <summary>
 /// Adds/edits a permission overwrite to a channel
 /// </summary>
 /// <param name="channelId">ID of the channel</param>
 /// <param name="overwrite">The permission overwrite to add/edit</param>
 public static void AddPermissionOverwrite(this DiscordClient client, ulong channelId, DiscordPermissionOverwrite overwrite)
 {
     client.HttpClient.Put($"/channels/{channelId}/permissions/{overwrite.Id}", overwrite);
 }
예제 #51
0
 public static Guild GetGuild(this DiscordClient client, long guildId)
 {
     return(client.HttpClient.Get("/guilds/" + guildId)
            .Deserialize <Guild>().SetClient(client));
 }
예제 #52
0
 /// <summary>
 /// Gets a guild's invites
 /// </summary>
 /// <param name="guildId">ID of the guild</param>
 public static IReadOnlyList <GuildInvite> GetGuildInvites(this DiscordClient client, ulong guildId)
 {
     return(client.GetGuildInvitesAsync(guildId).GetAwaiter().GetResult());
 }
예제 #53
0
 public static void UnbanGuildMember(this DiscordClient client, long guildId, long userId)
 {
     client.HttpClient.Delete($"/guilds/{guildId}/bans/{userId}");
 }
예제 #54
0
 /// <summary>
 /// Modifies a guild voice channel
 /// </summary>
 /// <param name="channelId">ID of the channel</param>
 /// <param name="properties">Options for modifying the channel</param>
 /// <returns>The modified <see cref="VoiceChannel"/></returns>
 public static VoiceChannel ModifyVoiceChannel(this DiscordClient client, ulong channelId, VoiceChannelProperties properties)
 {
     return(client.modifyChannel <VoiceChannel, VoiceChannelProperties>(channelId, properties));
 }
예제 #55
0
 public static IReadOnlyList <PartialGuild> GetClientGuilds(this DiscordClient client, int limit = 100, long afterId = 0)
 {
     return(client.HttpClient.Get($"/users/@me/guilds?limit={limit}&after={afterId}").Deserialize <IReadOnlyList <PartialGuild> >().SetClientsInList(client));
 }
예제 #56
0
 public Servers(DiscordClient client, object writerLock)
     : base(client, writerLock)
 {
 }
예제 #57
0
 public static void BanGuildMember(this DiscordClient client, long guildId, long userId, string reason = null, int deleteMessageDays = 0)
 {
     client.HttpClient.Put($"/guilds/{guildId}/bans/{userId}?delete-message-days={deleteMessageDays}&reason={reason}");
 }
예제 #58
0
 public static async Task <WelcomeScreen> GetWelcomeScreenAsync(this DiscordClient client, ulong guildId)
 {
     return((await client.HttpClient.GetAsync($"/guilds/{guildId}/welcome-screen"))
            .Deserialize <WelcomeScreen>().SetClient(client));
 }
예제 #59
0
 public static WelcomeScreen ModifyWelcomeScreen(this DiscordClient client, ulong guildId, WelcomeScreenProperties properties)
 {
     return(client.ModifyWelcomeScreenAsync(guildId, properties).GetAwaiter().GetResult());
 }
예제 #60
0
 /// <summary>
 /// Modifies a guild text channel
 /// </summary>
 /// <param name="channelId">ID of the channel</param>
 /// <param name="properties">Options for modifying the channel</param>
 /// <returns>The modified <see cref="TextChannel"/></returns>
 public static TextChannel ModifyTextChannel(this DiscordClient client, ulong channelId, TextChannelProperties properties)
 {
     return(client.modifyChannel <TextChannel, TextChannelProperties>(channelId, properties));
 }