public async Task ReplyToAsync(Message message, string content, bool isPublic) { if (message is null) { throw new ArgumentNullException(nameof(message)); } currentChannel = !isPublic && !_isPrivateChannel ? message.MessageObject is SocketCommandContext Context ? await Context.User.CreateDMChannelAsync().ConfigureAwait(false) : _channel : _channel; await WriteToAsync(content).ConfigureAwait(false); }
static async Task LewdSX(string chan, Discord.IMessageChannel c) { string result = Helpers.GetRestClient("https://lewdchan.com").Execute(new RestRequest($"{chan}/src/list.php", Method.GET)).Content; List <string> list = result.Split(new[] { Environment.NewLine }, StringSplitOptions.None).ToList(); Regex re = new Regex(@"([^\s]+(\.(jpg|jpeg|png|gif|bmp)))"); foreach (Match m in re.Matches(result)) { list.Add(m.Value); } await c.SendMessageAsync($"https://lewdchan.com/{chan}/src/{list[new Random().Next(0, list.Count())]}"); }
public async void Dispose() { await AudioClient.StopAsync(); FFMPEGProcess = null; DiscordOutStream = null; Videos = null; RadioTimer = null; CurrentSong = ""; MessageClient = null; AudioClient = null; }
public Poll(Discord.IMessageChannel channel, int minutes, string question, string[] options) { completed = false; this.minutes = minutes; this.question = question; this.options = options; pollChannel = channel; startTime = Var.CurrentDate(); votes = new int[options.Count()]; for (int i = 0; i < votes.Count(); i++) { votes[i] = 0; } endTimer = new Timer(new TimerCallback(End), null, 1000 * 60 * minutes, Timeout.Infinite); }
public async Task <bool> AddFriendRequestAsync(Discord.IMessageChannel chan, Profile author, Profile target) { if (_friendRequests.Any(x => x.Value.author == author && x.Value.destinator == target)) { return(false); } var textChan = (Discord.ITextChannel)chan; if (target.GetId() == Program.p.client.CurrentUser.Id) { var sMsg = await chan.SendMessageAsync(Sentences.FriendAccepted(textChan.Guild, target.GetUsername() + "#" + target.GetDiscriminator(), author.GetUsername() + "#" + author.GetDiscriminator())); await sMsg.AddReactionAsync(new Discord.Emoji("✅")); await target.AddFriendAsync(author, sMsg); return(true); } var msg = await chan.SendMessageAsync(Sentences.FriendRequest(textChan.Guild, target.GetUsername() + "#" + target.GetDiscriminator(), author.GetUsername() + "#" + author.GetDiscriminator())); _friendRequests.Add(msg.Id, new FriendRequest { author = author, destinator = target }); await msg.AddReactionAsync(new Discord.Emoji("✅")); await msg.AddReactionAsync(new Discord.Emoji("❌")); _ = Task.Run(async() => { await Task.Delay(600000); // 10 minutes if (_friendRequests.ContainsKey(msg.Id)) { _friendRequests.Remove(msg.Id); await msg.DeleteAsync(); } }); return(true); }
public DiscordMessageChannel(Discord.IMessageChannel channel, bool isPrivate) { _channel = channel; currentChannel = _channel; _isPrivateChannel = isPrivate; }
public SlateBotControllerLifecycleStates OnMessageReadyToSend(Commands.Response message, Discord.IMessageChannel destination) { lifecycle.ErrorLogger.LogError(new Error(ErrorCode.NotSendingMessage, ErrorSeverity.Debug, $"{nameof(SlateBotControllerConnectedReceivingOnlyState)} {nameof(OnMessageReadyToSend)} dest {destination.Id} message {message}")); return(StateId); }
public SlateBotControllerLifecycleStates OnMessageReadyToSend(Commands.Response message, Discord.IMessageChannel destination) { lifecycle.ErrorLogger.LogError(new Error(ErrorCode.UnexpectedEvent, ErrorSeverity.Information, $"{nameof(SlateBotControllerDisconnectedState)} {nameof(OnMessageReadyToSend)}: Storing message.")); lifecycle.StorePendingMessage(message, destination); return(StateId); }