Exemple #1
0
        // Handles actions for when a guild deletes a role
        private Task ChannelDeleted(SocketChannel channel)
        {
            Formatter.GenerateLog(_logger, LogSeverity.Info, "Channel", "Channel Deleted: " + channel.Id);
            var serializedChannel = new DiscordChannel(channel).ToString();

            return(SendEvent("channel", "ChannelDeleted", "DNetBot.Channel.Deleted", serializedChannel));
        }
Exemple #2
0
        public async Task ChannelCreated(SocketChannel arg)
        {
            if (!(arg is IGuildChannel channel))
            {
                return;
            }
            if (!GetAuditLogEntry(channel.Guild, out var auditLog, Discord.ActionType.ChannelCreated))
            {
                return;
            }
            var description =
                $"Channel ❯ {{0}}\nResponsible User ❯ {auditLog.User.Mention}\nReason ❯ {auditLog.Reason ?? "none"}\nId ❯ {auditLog.Id}";

            switch (arg)
            {
            case ITextChannel textChannel:
                description = string.Format(description, textChannel.Mention);
                break;

            case IVoiceChannel voiceChannel:
                description = string.Format(description, voiceChannel.Name);
                break;
            }

            await SendLog(channel.Guild, "Channel Created", description);
        }
Exemple #3
0
        public async Task ListPlayers(SocketChannel channel)
        {
            if (!UserIsGameMater((SocketGuildUser)Context.User))
            {
                await ReplyAndDeleteAsync(":x: You are not the gamemaster. " + Context.User.Mention, timeout : new TimeSpan(0, 0, 15));

                return;
            }

            var game = _games.SingleOrDefault(x => x._RoomID == channel.Id);

            if (game == null)
            {
                return;
            }

            if (game.users.Count == 0)
            {
                await ReplyAndDeleteAsync($"No Playes has joined", timeout : new TimeSpan(0, 0, 15));

                return;
            }

            await ReplyAndDeleteAsync(
                $"Players({game.users.Count}/{game.MaxUsers}) \n" +
                "------------" + "\n" +
                String.Join("\n", game.users.Select(x => x.Username)), timeout : new TimeSpan(0, 0, 15));
        }
Exemple #4
0
        private Task _discordClient_ChannelDestroyed(SocketChannel channel)
        {
            var cmd = _services.GetService <ChannelDestroyedCommand>();

            cmd.Execute(channel.Id);
            return(Task.CompletedTask);
        }
Exemple #5
0
        /// <summary>
        /// Write our packet to "chan".  Consumes the packet as part of the
        /// write.
        ///
        /// The JDWP packet starts at offset 0 and ends at mBuffer.position().
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: void writeAndConsume(java.nio.channels.SocketChannel chan) throws java.io.IOException
        internal void writeAndConsume(SocketChannel chan)
        {
            int oldLimit;

            //Log.i("ddms", "writeAndConsume: pos=" + mBuffer.position()
            //    + ", limit=" + mBuffer.limit());

            Debug.Assert(mLength > 0);

            mBuffer.flip();             // limit<-posn, posn<-0
            oldLimit      = mBuffer.limit;
            mBuffer.limit = (mLength);
            while (mBuffer.position != mBuffer.limit)
            {
                chan.write(mBuffer);
            }
            // position should now be at end of packet
            Debug.Assert(mBuffer.position == mLength);

            mBuffer.limit = (oldLimit);
            mBuffer.compact();             // shift posn...limit, posn<-pending data

            //Log.i("ddms", "               : pos=" + mBuffer.position()
            //    + ", limit=" + mBuffer.limit());
        }
Exemple #6
0
        /// <summary>
        /// Write until all data in "data" is written, the optional length is reached,
        /// the timeout expires, or the connection fails. Returns "true" if all
        /// data was written. </summary>
        /// <param name="chan"> the opened socket to write to. </param>
        /// <param name="data"> the buffer to send. </param>
        /// <param name="length"> the length to write or -1 to send the whole buffer. </param>
        /// <param name="timeout"> The timeout value. A timeout of zero means "wait forever". </param>
        /// <exception cref="TimeoutException"> in case of timeout on the connection. </exception>
        /// <exception cref="IOException"> in case of I/O error on the connection. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: static void write(java.nio.channels.SocketChannel chan, byte[] data, int length, int timeout) throws TimeoutException, java.io.IOException
        internal static void write(SocketChannel chan, byte[] data, int length, int timeout)
        {
            ByteBuffer buf      = ByteBuffer.wrap(data, 0, length != -1 ? length : data.Length);
            int        numWaits = 0;

            while (buf.position != buf.limit)
            {
                int count;

                count = chan.write(buf);
                if (count < 0)
                {
                    Log.d("ddms", "write: channel EOF");
                    throw new IOException("channel EOF");
                }
                else if (count == 0)
                {
                    // TODO: need more accurate timeout?
                    if (timeout != 0 && numWaits * WAIT_TIME > timeout)
                    {
                        Log.d("ddms", "write: timeout");
                        throw new TimeoutException();
                    }
                    // non-blocking spin
                    Thread.Sleep(WAIT_TIME);
                    numWaits++;
                }
                else
                {
                    numWaits = 0;
                }
            }
        }
Exemple #7
0
 private async Task ChannelCreated(SocketChannel channel)
 {
     if (channel is SocketTextChannel)
     {
         await(channel as SocketTextChannel).SendMessageAsync("A wild channel appears");
     }
 }
Exemple #8
0
        private async Task DiscordReady()
        {
            SocketChannel socketChannel = _discordClient.GetChannel(_configurationManager.DiscordChannelIdOut);

            _outputMessageChannel = socketChannel as ISocketMessageChannel;
            await Console.Out.WriteLineAsync("DiscordOutputChannel : " + _outputMessageChannel?.Name);
        }
        private async Task ChannelUpdated(SocketChannel before, SocketChannel after)
        {
            var beforeChannel = before as SocketTextChannel;
            var afterChannel  = after as SocketTextChannel;

            if (beforeChannel == null || afterChannel == null)
            {
                _logger.LogWarning($"before or after channels not vald text channels");
                return;
            }

            var channel = afterChannel.Guild.DefaultChannel;

            _config.Reload(channel.Guild.Id);
            if (!_config.Enabled)
            {
                return;
            }

            if (afterChannel.Topic != beforeChannel.Topic)
            {
                _logger.LogInformation($"Topic changed to { afterChannel.Topic}");

                await channel.SendMessageAsync($"Topic changed to { afterChannel.Topic}", true);
            }

            if (afterChannel.Name != afterChannel.Name)
            {
                _logger.LogInformation($"Channel name changed to { afterChannel.Name}");

                await channel.SendMessageAsync($"Channel name changed to { afterChannel.Name}", true);
            }
        }
Exemple #10
0
        public async Task AddChannelMentionAsync(SocketChannel Channel, int Weight, [Remainder] string Remainder = null)
        {
            if (RainBorg.Operators.Contains(Context.Message.Author.Id))
            {
                try
                {
                    if (!RainBorg.UserPools.ContainsKey(Channel.Id) && Weight > 0)
                    {
                        RainBorg.UserPools.Add(Channel.Id, new List <ulong>());
                        for (int i = 0; i < Weight; i++)
                        {
                            RainBorg.ChannelWeight.Add(Channel.Id);
                        }
                        await Config.Save();

                        if (RainBorg.entranceMessage != "")
                        {
                            await(Context.Client.GetChannel(Channel.Id) as SocketTextChannel).SendMessageAsync(RainBorg.entranceMessage);
                        }
                        try
                        {
                            // Add reaction to message
                            IEmote emote = Context.Guild.Emotes.First(e => e.Name == RainBorg.successReact);
                            await Context.Message.AddReactionAsync(emote);
                        }
                        catch
                        {
                            await Context.Message.AddReactionAsync(new Emoji("👌"));
                        }
                    }
                }
                catch { }
            }
        }
        private async Task OnChannelDeleted(SocketChannel arg)
        {
            // TODO: Prevent abuse of constant deletions of our stuff
            await ChannelHandler.OnChannelDeleted(arg);

            BattleContext.OnChannelDeleted(arg);
        }
        private static Task Client_ChannelUpdated(SocketChannel arg1, SocketChannel arg2)
        {
            SocketGuildChannel old     = arg1 as SocketGuildChannel;
            SocketGuildChannel updated = arg2 as SocketGuildChannel;

            if (old != null && updated != null)
            {
                if (TryGetLogChannel(old.Guild, DiscordEventType.ChannelUpdated, out SocketTextChannel logChannel, out EmbedBuilder embed))
                {
                    StringBuilder description = new StringBuilder();
                    ChannelUpdated(old, updated, ref description);
                    if (old is SocketTextChannel textOld && updated is SocketTextChannel textUpdated)
                    {
                        ChannelUpdated(textOld, textUpdated, ref description);
                    }
                    else if (old is SocketVoiceChannel voiceOld && updated is SocketVoiceChannel voiceUpdated)
                    {
                        ChannelUpdated(voiceOld, voiceUpdated, ref description);
                    }
                    if (description.Length > 0)
                    {
                        embed.Title       = $"#{updated} updated";
                        embed.Description = description.ToString();
                        return(logChannel.SendEmbedAsync(embed));
                    }
                }
Exemple #13
0
        private async Task _client_ChannelCreated(SocketChannel sChannel)
        {
            var guild    = ((SocketGuildChannel)sChannel).Guild;
            var guildobj = DatabaseHandler.GetGuild(guild.Id);

            if (!guildobj.EventLogger.Settings.channelcreated)
            {
                return;
            }
            if (guildobj.EventLogger.LogEvents)
            {
                var embed = new EmbedBuilder
                {
                    Title       = "Channel Created",
                    Description = ((SocketGuildChannel)sChannel)?.Name,
                    Color       = Color.Green,
                    Footer      = new EmbedFooterBuilder
                    {
                        Text = $"{DateTime.UtcNow.ToString(CultureInfo.InvariantCulture)} UTC TIME"
                    }
                };
                //await guildobj.EventLog(embed, guild);
                await LogEvent(guildobj, guild, embed);
            }
        }
Exemple #14
0
        private async Task _client_ChannelUpdated(SocketChannel s1, SocketChannel s2)
        {
            var ChannelBefore = s1 as SocketGuildChannel;
            var ChannelAfter  = s2 as SocketGuildChannel;
            var guildobj      = DatabaseHandler.GetGuild(ChannelAfter.Guild.Id);

            if (!guildobj.EventLogger.Settings.channelupdated)
            {
                return;
            }
            if (guildobj.EventLogger.LogEvents)
            {
                if (ChannelBefore.Position != ChannelAfter.Position)
                {
                    return;
                }
                var embed = new EmbedBuilder
                {
                    Title       = "Channel Updated",
                    Description = ChannelAfter.Name,
                    Color       = Color.Blue,
                    Footer      = new EmbedFooterBuilder
                    {
                        Text = $"{DateTime.UtcNow.ToString(CultureInfo.InvariantCulture)} UTC TIME"
                    }
                };
                //await guildobj.EventLog(embed, ChannelAfter.Guild);
                await LogEvent(guildobj, ChannelAfter.Guild, embed);
            }
        }
Exemple #15
0
        /// <summary>
        /// Runs a log service on the <seealso cref="Device"/>, and provides its output to the <seealso cref="LogReceiver"/>.
        /// <p/>This call is blocking until <seealso cref="LogReceiver#isCancelled()"/> returns true. </summary>
        /// <param name="adbSockAddr"> the socket address to connect to adb </param>
        /// <param name="device"> the Device on which to run the service </param>
        /// <param name="logName"> the name of the log file to output </param>
        /// <param name="rcvr"> the <seealso cref="LogReceiver"/> to receive the log output </param>
        /// <exception cref="TimeoutException"> in case of timeout on the connection. </exception>
        /// <exception cref="AdbCommandRejectedException"> if adb rejects the command </exception>
        /// <exception cref="IOException"> in case of I/O error on the connection. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static void runLogService(java.net.InetSocketAddress adbSockAddr, Device device, String logName, com.android.ddmlib.log.LogReceiver rcvr) throws TimeoutException, AdbCommandRejectedException, java.io.IOException
        public static void runLogService(EndPoint adbSockAddr, Device device, string logName, LogReceiver rcvr)
        {
            SocketChannel adbChan = null;

            try
            {
                adbChan = SocketChannel.open(adbSockAddr);
                adbChan.configureBlocking(false);

                // if the device is not -1, then we first tell adb we're looking to talk
                // to a specific device
                setDevice(adbChan, device);

                var request = formAdbRequest("log:" + logName);
                write(adbChan, request);

                AdbResponse resp = readAdbResponse(adbChan, false);                 // readDiagString
                if (resp.okay == false)
                {
                    throw new AdbCommandRejectedException(resp.message);
                }

                var        data = new byte[16384];
                ByteBuffer buf  = ByteBuffer.wrap(data);
                while (true)
                {
                    int count;

                    if (rcvr != null && rcvr.cancelled)
                    {
                        break;
                    }

                    count = adbChan.read(buf);
                    if (count < 0)
                    {
                        break;
                    }
                    else if (count == 0)
                    {
                        Thread.Sleep(WAIT_TIME * 5);
                    }
                    else
                    {
                        if (rcvr != null)
                        {
                            rcvr.parseNewData(buf.array(), buf.arrayOffset(), buf.position);
                        }
                        buf.rewind();
                    }
                }
            }
            finally
            {
                if (adbChan != null)
                {
                    adbChan.close();
                }
            }
        }
Exemple #16
0
        private static Task OnChannelUpdated(SocketChannel before, SocketChannel after)
        {
            if (before is SocketGuildChannel guildBefore && after is SocketGuildChannel guildAfter)
            {
                if (guildBefore.Name != guildAfter.Name)
                {
                    Core.Log.Write(Core.Log.Type.CHANNEL, $"{guildBefore.GetPath()} changed name to {guildAfter.Name}.");
                }
                if (guildBefore.Position != guildAfter.Position)
                {
                    Core.Log.Write(Core.Log.Type.CHANNEL, $"{guildBefore.GetPath()} changed position from {guildBefore.Position} to {guildAfter.Position}.");
                }
            }

            if (before.Users.Count != after.Users.Count)
            {
                int difference = before.Users.Count - after.Users.Count;
                if (difference < 0)
                {
                    Core.Log.Write(Core.Log.Type.CHANNEL, "Channel " + before.GetPath() + " gained " + difference + " new users.");
                }
                else
                {
                    Core.Log.Write(Core.Log.Type.CHANNEL, "Channel " + before.GetPath() + " lost " + -difference + " users.");
                }
            }
            else
            {
                Core.Log.Write(Core.Log.Type.CHANNEL, "Channel " + before.GetPath() + " has changed.");
            }
            return(Task.CompletedTask);
        }
Exemple #17
0
        /// <summary>
        /// Remove a port forwarding between a local and a remote port. </summary>
        /// <param name="adbSockAddr"> the socket address to connect to adb </param>
        /// <param name="device"> the device on which to remove the port fowarding </param>
        /// <param name="localPort"> the local port of the forward </param>
        /// <param name="remotePort"> the remote port. </param>
        /// <exception cref="TimeoutException"> in case of timeout on the connection. </exception>
        /// <exception cref="AdbCommandRejectedException"> if adb rejects the command </exception>
        /// <exception cref="IOException"> in case of I/O error on the connection. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static void removeForward(java.net.InetSocketAddress adbSockAddr, Device device, int localPort, int remotePort) throws TimeoutException, AdbCommandRejectedException, java.io.IOException
        public static void removeForward(EndPoint adbSockAddr, Device device, int localPort, int remotePort)
        {
            SocketChannel adbChan = null;

            try
            {
                adbChan = SocketChannel.open(adbSockAddr);
                adbChan.configureBlocking(false);

                var request = formAdbRequest(string.Format("host-serial:{0}:killforward:tcp:{1:D};tcp:{2:D}", device.serialNumber, localPort, remotePort));                 //$NON-NLS-1$

                write(adbChan, request);

                AdbResponse resp = readAdbResponse(adbChan, false);                 // readDiagString
                if (resp.okay == false)
                {
                    Log.w("remove-forward", "Error creating forward: " + resp.message);
                    throw new AdbCommandRejectedException(resp.message);
                }
            }
            finally
            {
                if (adbChan != null)
                {
                    adbChan.close();
                }
            }
        }
        private Task RemoveChannelFromMap(SocketChannel channel)
        {
            string foundLang = string.Empty;

            foreach (var pair in _channelPairs)
            {
                if (pair.Value?.TranslationChannel == null || pair.Value?.StandardLangChanel == null)
                {
                    _logger.LogWarning("invalid channel pair detected");
                    continue;
                }

                if (channel.Id == pair.Value.StandardLangChanel.Id || channel.Id == pair.Value.TranslationChannel.Id)
                {
                    foundLang = pair.Key;
                }
            }

            if (foundLang != string.Empty)
            {
                _logger.LogDebug($"One of the channels in a pair were deleted, removing pair '{foundLang}' from map");
                _channelPairs.TryRemove(foundLang, out _);
            }

            return(Task.CompletedTask);
        }
Exemple #19
0
        /// <summary>
        /// Reboot the device.
        /// </summary>
        /// <param name="into"> what to reboot into (recovery, bootloader).  Or null to just reboot. </param>
        /// <exception cref="TimeoutException"> in case of timeout on the connection. </exception>
        /// <exception cref="AdbCommandRejectedException"> if adb rejects the command </exception>
        /// <exception cref="IOException"> in case of I/O error on the connection. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static void reboot(String into, java.net.InetSocketAddress adbSockAddr, Device device) throws TimeoutException, AdbCommandRejectedException, java.io.IOException
        public static void reboot(string into, EndPoint adbSockAddr, Device device)
        {
            byte[] request;
            if (into == null)
            {
                request = formAdbRequest("reboot:");                 //$NON-NLS-1$
            }
            else
            {
                request = formAdbRequest("reboot:" + into);                 //$NON-NLS-1$
            }

            SocketChannel adbChan = null;

            try
            {
                adbChan = SocketChannel.open(adbSockAddr);
                adbChan.configureBlocking(false);

                // if the device is not -1, then we first tell adb we're looking to talk
                // to a specific device
                setDevice(adbChan, device);

                write(adbChan, request);
            }
            finally
            {
                if (adbChan != null)
                {
                    adbChan.close();
                }
            }
        }
Exemple #20
0
        private Task Client_ChannelCreated(SocketChannel channel)
        {
            ChannelCreated++;

            if (channel is SocketGuildChannel gChannel)
            {
                var config = TryGetConfig(gChannel.Guild.Id);
                if (config == null || !config.Enabled || config.ChannelId == 0 || !config.ChannelCreated)
                {
                    return(Task.CompletedTask);
                }

                if (channel is SocketTextChannel tChannel)
                {
                    LogEvent(config, "Text Channel Created", $"Name: {tChannel.Name}\n" +
                             $"Topic: {tChannel.Topic ?? "N/A"}\n" +
                             $"NSFW: {tChannel.IsNsfw}\n" +
                             $"SlowModeInterval: {tChannel.SlowModeInterval}\n" +
                             $"Category: {tChannel.Category?.Name ?? "N/A"}\n" +
                             $"Position: {tChannel.Position}\n" +
                             $"Permissions: {PermissionList(gChannel, tChannel.PermissionOverwrites.ToList())}", EventClass.EventType.ChannelCreated, Color.Green);
                }
                else if (channel is SocketVoiceChannel vChannel)
                {
                    LogEvent(config, "Voice Channel Created", $"Name: {vChannel.Name}\n" +
                             $"Category: {vChannel.Category?.Name ?? "N/A"}\n" +
                             $"User Limit: {(vChannel.UserLimit == null ? "N/A" : vChannel.UserLimit.ToString())}\n" +
                             $"BitRate: {vChannel.Bitrate}\n" +
                             $"Position: {vChannel.Position}\n" +
                             $"Permissions: {PermissionList(gChannel, vChannel.PermissionOverwrites.ToList())}", EventClass.EventType.ChannelCreated, Color.Green);
                }
            }
            return(Task.CompletedTask);
        }
Exemple #21
0
 private async Task UpdateCommandHandlerConfigAsync(SocketChannel oldHandlerSource, SocketChannel newHandlerSource)
 {
     if ((oldHandlerSource is IDMChannel) && (newHandlerSource is IDMChannel))
     {
         await UpdateCommandHandlerAsync(oldHandlerSource, newHandlerSource, (oldHandlerSource as IDMChannel).Recipient.Id, (newHandlerSource as IDMChannel).Recipient.Id);
     }
 }
Exemple #22
0
        private static async Task DiscordClient_ChannelUpdated(SocketChannel arg1, SocketChannel arg2)
        {
            var oldChannel = arg1 as Discord.WebSocket.SocketGuildChannel;
            var newChannel = arg2 as Discord.WebSocket.SocketGuildChannel;

            if (null != oldChannel && null != newChannel)
            {
                if (oldChannel.Name != newChannel.Name)
                {
                    Activity act = new Activity();
                    act.Type = ActivityTypes.ConversationUpdate;
                    var channelData = new Newtonsoft.Json.Linq.JObject();
                    channelData["eventType"]    = "GroupNameChanged";
                    channelData["groupName"]    = oldChannel.Guild.Name + "#" + oldChannel.Name;
                    channelData["groupNewName"] = newChannel.Guild.Name + "#" + newChannel.Name;
                    channelData["isGroup"]      = act.Conversation.IsGroup;
                    channelData["channelId"]    = _theChannelName;
                    var conversationId = Program.GetBotConversationId(oldChannel.Id);
                    if (string.Empty != conversationId)
                    {
                        Log.OutputLine("DiscordApp group name has been changed...");
                        var resp = _directlineClinet.Conversations.PostActivity(conversationId, act);
                        Log.OutputLine("Direct response " + resp.Id);
                    }
                }
            }
        }
Exemple #23
0
		/// <summary>
		/// Starts the connection of the console. </summary>
		/// <returns> true if success. </returns>
		private bool start()
		{

			DnsEndPoint socketAddr;
			try
			{
				socketAddr = new DnsEndPoint(HOST, mPort);
			}
			catch (ArgumentException)
			{
				return false;
			}

			try
			{
				mSocketChannel = SocketChannel.open(socketAddr);
			}
			catch (IOException)
			{
				return false;
			}

			// read some stuff from it
			readLines();

			return true;
		}
Exemple #24
0
    public IRemoteUser SendFriendResult(long user, bool answer)
    {
        string data;

        using (HttpClient web = new())
        {
            web.DefaultRequestHeaders.Add("token", Token);
            data = web.PostAsync($"https://{Domain}/Luski/api/{API_Ver}/FriendRequestResult", new StringContent(JsonRequest.FriendRequestResult(user, answer))).Result.Content.ReadAsStringAsync().Result;
        }

        IncomingHTTP?json = JsonSerializer.Deserialize(data, IncomingHTTPContext.Default.IncomingHTTP);

        if (json?.error is null && json?.data is not null)
        {
            if (answer)
            {
                string?temp = json.data.ToString();
                if (!string.IsNullOrEmpty(temp))
                {
                    FriendRequestResult?FRR = JsonSerializer.Deserialize <FriendRequestResult>(temp);
                    if (FRR is not null && FRR.channel is not null)
                    {
                        SocketChannel chan = SocketChannel.GetChannel((long)FRR.channel);
                        _ = chan.StartKeyProcessAsync();
                        chans.Add(chan);
                    }
                }
            }
        }
Exemple #25
0
        public Task ChannelDestroyed(SocketChannel e)
        {
            SocketGuildChannel channel = e as SocketGuildChannel;

            FileSystem.RemoveSettle(channel.Guild.Id);
            return(Task.CompletedTask);
        }
Exemple #26
0
        private async Task DetailedLogsForChannel(SocketChannel socketChannel, string action, Color color)
        {
            if (!(socketChannel is SocketTextChannel) && !(socketChannel is SocketVoiceChannel))
            {
                return;
            }
            string      channelType;
            string      channelName;
            SocketGuild guild;

            if (socketChannel is SocketTextChannel)
            {
                channelType = "Text Channel";
                channelName = (socketChannel as SocketTextChannel).Name;
                guild       = (socketChannel as SocketTextChannel).Guild;
            }
            else
            {
                channelType = "Voice Channel";
                channelName = (socketChannel as SocketVoiceChannel).Name;
                guild       = (socketChannel as SocketVoiceChannel).Guild;
            }
            SocketChannel channel = socketChannel as SocketTextChannel;
            await Logger.DetailedLog(guild, "Action", action, channelType, channelName, socketChannel.Id, color);
        }
        public void AbortClose(SocketChannel channel)
        {
            // TODO: Do we need to handle expection like JVM?

            channel.Socket.LingerState = new LingerOption(true, 0);
            channel.Close();
        }
Exemple #28
0
 private async Task DiscordShardedClientOnChannelUpdated(SocketChannel arg1, SocketChannel arg2)
 {
     if (ChannelUpdated != null)
     {
         await ChannelUpdated.Invoke(this, arg1, arg2).ConfigureAwait(false);
     }
 }
Exemple #29
0
        public Task OnChannelDestroyedAsync(SocketChannel socketChannel)
        {
            SocketGuildChannel channel = socketChannel as SocketGuildChannel;

            _logger.LogInformation($"Channel destroyed: {channel.Name} in {channel.Guild.Name}");
            return(Task.CompletedTask);
        }
Exemple #30
0
        public static async Task GetGrubs()
        {
            SocketChannel channel = _client.GetChannel(627615133115482149);

            Modules.Global.Messages = await(channel as ISocketMessageChannel).GetMessagesAsync(1000).FlattenAsync();
            Console.WriteLine();
        }