public void DeleteChannel(DiscordChannel channel) { if (Unavailable) throw new Exception("Server is currently unavailable!"); string url = Endpoints.BaseAPI + Endpoints.Channels + $"/{channel.ID}"; WebWrapper.Delete(url, DiscordClient.token); }
public DiscordChannel CreateChannel(string ChannelName, bool voice) { if (Unavailable) throw new Exception("Server is currently unavailable!"); string url = Endpoints.BaseAPI + Endpoints.Guilds + $"/{this.ID}" + Endpoints.Channels; var reqJson = JsonConvert.SerializeObject(new { name = ChannelName, type = voice ? "voice" : "text" }); var result = JObject.Parse(WebWrapper.Post(url, DiscordClient.token, reqJson)); if (result != null) { DiscordChannel dc = new DiscordChannel { Name = result["name"].ToString(), ID = result["id"].ToString(), Type = result["type"].ToObject<ChannelType>(), Private = result["is_private"].ToObject<bool>() }; if (!result["topic"].IsNullOrEmpty()) { dc.Topic = result["topic"].ToString(); } if (dc.Type == ChannelType.Voice && !result["bitrate"].IsNullOrEmpty()) { dc.Bitrate = result["bitrate"].ToObject<int>(); } this.Channels.Add(dc); return dc; } return null; }
public abstract void ExecuteCommand(DiscordChannel channel, DiscordMember member);
public LuigibotDiscordChannel(DiscordChannel channel) { RawChannel = channel; }
public DiscordChannel CreateChannel(string ChannelName, bool voice) { string url = Endpoints.BaseAPI + Endpoints.Guilds + $"/{this.id}" + Endpoints.Channels; var reqJson = JsonConvert.SerializeObject(new { name = ChannelName, type = voice ? "voice" : "text" }); var result = JObject.Parse(WebWrapper.Post(url, DiscordClient.token, reqJson)); if (result != null) { DiscordChannel dc = new DiscordChannel { Name = result["name"].ToString(), ID = result["id"].ToString(), Type = result["type"].ToObject<ChannelType>(), Private = result["is_private"].ToObject<bool>(), Topic = result["topic"].ToString() }; this.channels.Add(dc); return dc; } return null; }
public void DeleteChannel(DiscordChannel channel) { string url = Endpoints.BaseAPI + Endpoints.Channels + $"/{channel.ID}"; WebWrapper.Delete(url, DiscordClient.token); }
public int ExecuteOnMessageCommand(string rawCommandText, DiscordChannel channel, DiscordMember author) { string[] split = rawCommandText.Split(new char[] { ' ' }); //splits into args and stuff try { var command = __commands.Find(x => x.CommandName == split[0]); if (command != null && command.Parent != null) //if it's a generic command without a parent then don't bother doing this. { lock(__modules) { if (__modules[command.Parent] == false) { throw new ModuleNotEnabledException($"The specified module {command.Parent.Name} is not enabled.", command.Parent); } } } if(command != null) { command.Args.Clear(); if (command.ArgCount > 0) { string[] argsSplit = rawCommandText.Split(new char[] { ' ' }, command.ArgCount + 1); //adds all the arguments for (int i = 1; i < argsSplit.Length; i++) command.AddArgument(argsSplit[i]); } //finally, executes it command.ExecuteCommand(channel, author); return 0; } } catch(UnauthorizedAccessException uaex) { throw uaex; //no permission } catch(Exception ex) { throw ex; } return 1; }
public DiscordChannel ShallowCopy() { DiscordChannel channel = (DiscordChannel)this.MemberwiseClone(); return(channel); }