Exemple #1
0
        /// <summary>
        /// Creates a ts3 channel description with a selected discord channel id as json string
        /// </summary>
        /// <param name="serverConnectionHandlerID"></param>
        /// <param name="ts3ChannelID"></param>
        public void LinkDiscordChannel(ulong serverConnectionHandlerID, ulong ts3ChannelID)
        {
            var list           = ConnectionHandler.GetServerVoiceChannelList();
            ChannelConnector c = new ChannelConnector(list, callback);

            c.ShowDialog();
            void callback(ulong channelID)
            {
                var jsonString = Helpers.ChannelIDToJsonString(channelID);
                var err        = Functions.getChannelVariableAsString(serverConnectionHandlerID, ts3ChannelID, ChannelProperties.CHANNEL_DESCRIPTION, out var currentDescription);

                //first remove all channelIDs which were set before in the description
                currentDescription = Helpers.RemoveChannelID(currentDescription).TrimEnd(null);
                var newDescription = currentDescription + "\n" + jsonString;

                err = Functions.setChannelVariableAsString(serverConnectionHandlerID, ts3ChannelID, ChannelProperties.CHANNEL_DESCRIPTION, newDescription);
                err = Functions.flushChannelUpdates(serverConnectionHandlerID, ts3ChannelID, "");
                if (err != (uint)Ts3ErrorType.ERROR_ok)
                {
                    Logging.Log($"Failed to set ts3channeldescription. Code: {err}", LogLevel.LogLevel_ERROR);
                }
                else
                {
                    Logging.Log("Linked discord channel successfully");
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Creates a ts3 channel description with a selected discord channel id as json string
        /// </summary>
        /// <param name="serverConnectionHandlerID"></param>
        /// <param name="ts3ChannelID"></param>
        public void LinkDiscordChannel(ulong serverConnectionHandlerID, ulong ts3ChannelID)
        {
            var list           = ConnectionHandler.GetServerVoiceChannelList();
            ChannelConnector c = new ChannelConnector(list, callback);

            c.ShowDialog();
            void callback(ulong channelID)
            {
                var description = Helpers.ChannelIDToJsonString(channelID);
                var err         = Functions.setChannelVariableAsString(serverConnectionHandlerID, ts3ChannelID, ChannelProperties.CHANNEL_DESCRIPTION, description);

                err = Functions.flushChannelUpdates(serverConnectionHandlerID, ts3ChannelID, "");
                if (err != (uint)Ts3ErrorType.ERROR_ok)
                {
                    Logging.Log($"Failed to set ts3channeldescription. Code: {err}", LogLevel.LogLevel_ERROR);
                }
                else
                {
                    Logging.Log("Linked discord channel successfully");
                }
            }
        }