Esempio n. 1
0
		/// <summary>
		/// Set the Volume of this Player
		/// </summary>
		/// <param name="volume">The Volume to set the player to, Volume may range from 0 to 1000. 100 is default.</param>
		/// <returns>Task</returns>
		public Task SetVolumeAsync(int volume)
			=> Node.SendAsync(new VolumePacket
			{
				OPCode = "volume",
				GuildID = GuildID.ToString(),
				Volume = volume
			});
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GuildTable"/> class.
 /// </summary>
 /// <param name="created">The initial value for the corresponding property.</param>
 /// <param name="iD">The initial value for the corresponding property.</param>
 /// <param name="name">The initial value for the corresponding property.</param>
 /// <param name="tag">The initial value for the corresponding property.</param>
 public GuildTable(DateTime @created, GuildID @iD, String @name, String @tag)
 {
     Created = @created;
     ID      = @iD;
     Name    = @name;
     Tag     = @tag;
 }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GuildMemberTable"/> class.
 /// </summary>
 /// <param name="characterID">The initial value for the corresponding property.</param>
 /// <param name="guildID">The initial value for the corresponding property.</param>
 /// <param name="joined">The initial value for the corresponding property.</param>
 /// <param name="rank">The initial value for the corresponding property.</param>
 public GuildMemberTable(CharacterID @characterID, GuildID @guildID, DateTime @joined, GuildRank @rank)
 {
     CharacterID = @characterID;
     GuildID     = @guildID;
     Joined      = @joined;
     Rank        = @rank;
 }
Esempio n. 4
0
        /// <summary>
        /// Tries to create a new guild.
        /// </summary>
        /// <param name="creator">The one trying to create the guild.</param>
        /// <param name="name">The name of the guild to create.</param>
        /// <param name="tag">The tag for the guild to create.</param>
        /// <returns>The created guild instance if successfully created, or null if the guild could not
        /// be created.</returns>
        protected override Guild InternalTryCreateGuild(IGuildMember creator, string name, string tag)
        {
            // Let the database assign the ID for us
            var dummyID = new GuildID(_dbController.ConnectionPool.AutoIncrementValue);

            // We want to insert the guild into the database first since if that query fails, we know that
            // we can't create the guild with the given values for whatever reason
            var  values = new GuildTable(iD: dummyID, name: name, tag: tag, created: DateTime.Now);
            long lastInsertedId;
            var  rowsAffected = _insertGuildQuery.ExecuteWithResult(values, out lastInsertedId);

            if (rowsAffected <= 0)
            {
                const string errmsg =
                    "Failed to create guild using values (name={0}, tag={1}) - insert query" +
                    " returned `{2}` rows affected. Most likely one of the values are not unique.";
                if (log.IsWarnEnabled)
                {
                    log.WarnFormat(errmsg, name, tag, rowsAffected);
                }
                return(null);
            }

            // Set the guild ID
            Debug.Assert(lastInsertedId <= int.MaxValue);
            Debug.Assert(lastInsertedId >= int.MinValue);
            values.ID = new GuildID((int)lastInsertedId);

            // Create the guild instance using the values we just inserted into the database
            return(new Guild(this, values));
        }
Esempio n. 5
0
		/// <summary>
		/// Seek to a position on this Player
		/// </summary>
		/// <param name="position">The position to seek to, in ms</param>
		/// <returns>Task</returns>
		public Task SeekAsync(long position)
			=> Node.SendAsync(new SeekPacket
			{
				OPCode = "seek",
				GuildID = GuildID.ToString(),
				Position = position
			});
Esempio n. 6
0
		/// <summary>
		/// Lets the Bot Leave the Current Connected Channel by sending an Packet to <see cref="LavalinkNode.DiscordSendFunction"/>
		/// </summary>
		/// <returns>Task</returns>
		public Task LeaveAsync()
			=> Node.DiscordSendFunction(GuildID, new UpdateVoiceStateDispatch
			{
				GuildId = GuildID.ToString(),
				ChannelId = null,
				SelfMute = false,
				SelfDeaf = false
			});
Esempio n. 7
0
		/// <summary>
		/// Lets the Bot Join a Channel by sending an Packet to <see cref="LavalinkNode.DiscordSendFunction"/>
		/// </summary>
		/// <param name="channelID">The ID of the Channel to join</param>
		/// <param name="mute">if the bot should be muted</param>
		/// <param name="deaf">if the bot should be deafen</param>
		/// <returns>Task</returns>
		public Task JoinAsync(long channelID, bool mute = false, bool deaf = false)
			=> Node.DiscordSendFunction(GuildID, new UpdateVoiceStateDispatch
			{
				GuildId = GuildID.ToString(),
				ChannelId = channelID.ToString(),
				SelfMute = mute,
				SelfDeaf = deaf
			});
Esempio n. 8
0
		/// <summary>
		/// Sends an VoiceUpdate to Lavalink for this Player
		/// </summary>
		/// <param name="sessionID">The SessionID of this VoiceUpdate</param>
		/// <param name="event">The VoiceServer event of this VoiceUpdate</param>
		/// <returns>Task</returns>
		public Task VoiceUpdateAsync(string sessionID, VoiceServerUpdatePayload @event)
			=> Node.SendAsync(new VoiceUpdatePacket
			{
				OPCode = "voiceUpdate",
				GuildID = GuildID.ToString(),
				UpdateEvent = @event,
				SessionID = sessionID
			});
Esempio n. 9
0
 public void Save()
 {
     using (var Session = DatabaseHandler.Store.OpenSession(DatabaseHandler.DBName))
     {
         Session.Store(this, GuildID.ToString());
         Session.SaveChanges();
     }
 }
Esempio n. 10
0
 /// <summary>
 /// Method to set the Volume
 /// </summary>
 /// <param name="volume"> the volume to set</param>
 /// <returns> Task resolving with void. </returns>
 public Task SetVolumeAsync(int volume)
 {
     return(_client.Websocket.SendMessageAsync(JsonConvert.SerializeObject(new VolumePacket
     {
         OPCode = "volume",
         GuildID = GuildID.ToString(),
         Volume = volume
     })));
 }
Esempio n. 11
0
 /// <summary>
 /// Method to Seek to a specified position.
 /// </summary>
 /// <param name="position"> position to seek to</param>
 /// <returns> Task resolving with void. </returns>
 public Task SeekAsync(int position)
 {
     return(_client.Websocket.SendMessageAsync(JsonConvert.SerializeObject(new SeekPacket
     {
         OPCode = "seek",
         GuildID = GuildID.ToString(),
         Position = position
     })));
 }
Esempio n. 12
0
 /// <summary>
 /// Method to call on Discord Voice Updates
 /// </summary>
 /// <param name="sessionID"> The SessionID </param>
 /// <param name="voiceEvent"> The VoiceEvent </param>
 /// <returns> Task resolving with void. </returns>
 public Task VoiceUpdateAsync(string sessionID, VoiceServerUpdate voiceEvent)
 {
     return(_client.Websocket.SendMessageAsync(JsonConvert.SerializeObject(new VoiceUpdatePacket
     {
         OPCode = "voiceUpdate",
         SessionID = sessionID,
         UpdateEvent = voiceEvent,
         GuildID = GuildID.ToString()
     })));
 }
Esempio n. 13
0
        // <summary>
        /// Method to stop the current track from the player
        /// <returns> Task resolving with void. </returns>
        public async Task StopAsync()
        {
            await _client.Websocket.SendMessageAsync(JsonConvert.SerializeObject(new StopPacket {
                OPCode  = "stop",
                Stop    = true,
                GuildID = GuildID.ToString()
            }));

            Status = Status.STOPPED;
        }
Esempio n. 14
0
		/// <summary>
		/// Pauses this Player
		/// </summary>
		/// <returns>Task</returns>
		public async Task PauseAsync()
		{
			await Node.SendAsync(new PausePacket
			{
				OPCode = "pause",
				GuildID = GuildID.ToString(),
				Pause = true
			});
			Status = PlayerStatus.PAUSED;
		}
Esempio n. 15
0
		/// <summary>
		/// Resumes Playing on this Player
		/// </summary>
		/// <returns>Task</returns>
		public async Task ResumeAsync()
		{
			await Node.SendAsync(new PausePacket
			{
				OPCode = "pause",
				GuildID = GuildID.ToString(),
				Pause = false
			});
			Status = PlayerStatus.PLAYING;
		}
Esempio n. 16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GuildBase"/> class.
        /// </summary>
        /// <param name="guildManager">The <see cref="IGuildManager"/> managing this guild.</param>
        /// <param name="id">The unique ID of the guild.</param>
        /// <param name="name">The unique name of the guild.</param>
        /// <param name="tag">The guild's unique tag.</param>
        protected GuildBase(IGuildManager guildManager, GuildID id, string name, string tag)
        {
            _guildManager = guildManager;
            _id = id;
            _name = name;
            _tag = tag;

            // ReSharper disable DoNotCallOverridableMethodsInConstructor
            Save();
            // ReSharper restore DoNotCallOverridableMethodsInConstructor
        }
Esempio n. 17
0
        public override int WriteTo(byte[] Buffer, int StartIndex = 0)
        {
            int cursor = StartIndex;

            Buffer[cursor] = (byte)CommandType;                     // Type     (1 byte)
            cursor++;

            cursor += GuildID.WriteTo(Buffer, cursor);              // GuildID (4/8 bytes)

            return(cursor - StartIndex);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="QueryArgs"/> struct.
 /// </summary>
 /// <param name="guildID">The guild ID.</param>
 /// <param name="charID">The char ID.</param>
 /// <param name="targetID">The target char ID.</param>
 /// <param name="eventID">The event ID.</param>
 /// <param name="arg0">The arg0.</param>
 /// <param name="arg1">The arg1.</param>
 /// <param name="arg2">The arg2.</param>
 public QueryArgs(GuildID guildID, CharacterID charID, CharacterID?targetID, byte eventID, string arg0, string arg1,
                  string arg2)
 {
     GuildID     = guildID;
     CharacterID = charID;
     TargetID    = targetID;
     EventID     = eventID;
     Arg0        = arg0;
     Arg1        = arg1;
     Arg2        = arg2;
 }
Esempio n. 19
0
		/// <summary>
		/// Destroys this Player and removes it from the Node
		/// </summary>
		/// <returns>Task</returns>
		public async Task DestroyAsync()
		{
			await Node.SendAsync(new PlayerPacket
			{
				OPCode = "destroy",
				GuildID = GuildID.ToString()
			});
			Status = PlayerStatus.ENDED;
			Node.Players.TryRemove(GuildID, out _);
			Node.VoiceServers.TryRemove(GuildID, out _);
			Node.VoiceStates.TryRemove(GuildID, out _);
		}
Esempio n. 20
0
		/// <summary>
		/// Starts to Play a Track on this Player
		/// </summary>
		/// <param name="track">The Track string to play</param>
		/// <param name="start">The Start time, defaults to 0</param>
		/// <param name="end">The End time, defaults to 0</param>
		/// <returns>Task</returns>
		public async Task PlayAsync(string track, int? start = 0, int? end = 0)
		{
			await Node.SendAsync(new PlayPacket
			{
				OPCode = "play",
				GuildID = GuildID.ToString(),
				Track = track,
				StartTime = start.ToString(),
				EndTime = end.ToString()
			});
			Status = PlayerStatus.PLAYING;
		}
Esempio n. 21
0
        /// <summary>
        /// Method to let the player start a track
        /// </summary>
        /// <param name="track"> Track instance of the track to play. </param>
        /// <param name="start"> optional: start time of the track</param>
        /// <param name="end"> optional: end time of the track</param>
        /// <returns> Task resolving with void. </returns>
        public async Task PlayAsync(Track track, int?start = 0, int?end = 0)
        {
            await _client.Websocket.SendMessageAsync(JsonConvert.SerializeObject(new PlayPacket {
                OPCode    = "play",
                GuildID   = GuildID.ToString(),
                Track     = track.TrackString,
                StartTime = start.ToString(),
                EndTime   = end.ToString()
            }));

            Status = Status.PLAYING;
        }
Esempio n. 22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GuildEventTable"/> class.
 /// </summary>
 /// <param name="arg0">The initial value for the corresponding property.</param>
 /// <param name="arg1">The initial value for the corresponding property.</param>
 /// <param name="arg2">The initial value for the corresponding property.</param>
 /// <param name="characterID">The initial value for the corresponding property.</param>
 /// <param name="created">The initial value for the corresponding property.</param>
 /// <param name="eventID">The initial value for the corresponding property.</param>
 /// <param name="guildID">The initial value for the corresponding property.</param>
 /// <param name="iD">The initial value for the corresponding property.</param>
 /// <param name="targetCharacterID">The initial value for the corresponding property.</param>
 public GuildEventTable(String @arg0, String @arg1, String @arg2, CharacterID @characterID, DateTime @created,
                        Byte @eventID, GuildID @guildID, Int32 @iD, CharacterID? @targetCharacterID)
 {
     Arg0              = @arg0;
     Arg1              = @arg1;
     Arg2              = @arg2;
     CharacterID       = @characterID;
     Created           = @created;
     EventID           = @eventID;
     GuildID           = @guildID;
     ID                = @iD;
     TargetCharacterID = @targetCharacterID;
 }
Esempio n. 23
0
        /// <summary>
        /// Method to pause/resume the player
        /// </summary>
        /// <param name="pause"> boolean </param>
        /// <returns> Task resolving with void. </returns>
        public async Task PauseAsync(bool pause = true)
        {
            await _client.Websocket.SendMessageAsync(JsonConvert.SerializeObject(new PausePacket {
                OPCode  = "pause",
                Pause   = pause,
                GuildID = GuildID.ToString()
            }));

            if (pause)
            {
                Status = Status.PAUSED;
            }
            else
            {
                Status = Status.PLAYING;
            }
        }
Esempio n. 24
0
        public override void CheckForFile()
        {
            // eg. "g_262726242036350976.xml"
            if (!File.Exists(BasePath + FileName))
            {
                GuildConfig config = new GuildConfig(GuildID.ToString());

                config.GuildID          = config.GuildID;
                config.DungeonCombatLog = "\u200B\n\u200B\n\u200B\n\u200B\n\u200B";

                config.Save();
            }
            else
            {
                GuildConfig config = Load() as GuildConfig;
                config.Save();
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="WorldStatsGuildUserChangeTable"/> class.
 /// </summary>
 /// <param name="guildID">The initial value for the corresponding property.</param>
 /// <param name="iD">The initial value for the corresponding property.</param>
 /// <param name="userID">The initial value for the corresponding property.</param>
 /// <param name="when">The initial value for the corresponding property.</param>
 public WorldStatsGuildUserChangeTable(GuildID? @guildID, UInt32 @iD, CharacterID @userID, DateTime @when)
 {
     GuildID = @guildID;
     ID = @iD;
     UserID = @userID;
     When = @when;
 }
Esempio n. 26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GuildEventTable"/> class.
 /// </summary>
 /// <param name="arg0">The initial value for the corresponding property.</param>
 /// <param name="arg1">The initial value for the corresponding property.</param>
 /// <param name="arg2">The initial value for the corresponding property.</param>
 /// <param name="characterID">The initial value for the corresponding property.</param>
 /// <param name="created">The initial value for the corresponding property.</param>
 /// <param name="eventID">The initial value for the corresponding property.</param>
 /// <param name="guildID">The initial value for the corresponding property.</param>
 /// <param name="iD">The initial value for the corresponding property.</param>
 /// <param name="targetCharacterID">The initial value for the corresponding property.</param>
 public GuildEventTable(String @arg0, String @arg1, String @arg2, CharacterID @characterID, DateTime @created,
                        Byte @eventID, GuildID @guildID, Int32 @iD, CharacterID? @targetCharacterID)
 {
     Arg0 = @arg0;
     Arg1 = @arg1;
     Arg2 = @arg2;
     CharacterID = @characterID;
     Created = @created;
     EventID = @eventID;
     GuildID = @guildID;
     ID = @iD;
     TargetCharacterID = @targetCharacterID;
 }
Esempio n. 27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QueryArgs"/> struct.
 /// </summary>
 /// <param name="characterID">The character ID.</param>
 /// <param name="guildID">The guild ID.</param>
 /// <param name="guildRank">The guild rank.</param>
 public QueryArgs(CharacterID characterID, GuildID guildID, GuildRank guildRank)
 {
     CharacterID = characterID;
     GuildID     = guildID;
     Rank        = guildRank;
 }
Esempio n. 28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EventCountersGuildTable"/> class.
 /// </summary>
 /// <param name="counter">The initial value for the corresponding property.</param>
 /// <param name="guildEventCounterId">The initial value for the corresponding property.</param>
 /// <param name="guildID">The initial value for the corresponding property.</param>
 public EventCountersGuildTable(Int64 @counter, Byte @guildEventCounterId, GuildID @guildID)
 {
     Counter = @counter;
     GuildEventCounterId = @guildEventCounterId;
     GuildID = @guildID;
 }
Esempio n. 29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QueryArgs"/> struct.
 /// </summary>
 /// <param name="id">The id.</param>
 /// <param name="value">The value.</param>
 public QueryArgs(GuildID id, string value)
 {
     ID    = id;
     Value = value;
 }
Esempio n. 30
0
		/// <summary>
		/// Stops the Player
		/// </summary>
		/// <returns>Task</returns>
		public Task StopAsync()
			=> Node.SendAsync(new PlayerPacket
			{
				OPCode = "stop",
				GuildID = GuildID.ToString()
			});
Esempio n. 31
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GuildTable"/> class.
 /// </summary>
 /// <param name="created">The initial value for the corresponding property.</param>
 /// <param name="iD">The initial value for the corresponding property.</param>
 /// <param name="name">The initial value for the corresponding property.</param>
 /// <param name="tag">The initial value for the corresponding property.</param>
 public GuildTable(DateTime @created, GuildID @iD, String @name, String @tag)
 {
     Created = @created;
     ID = @iD;
     Name = @name;
     Tag = @tag;
 }
Esempio n. 32
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GuildMemberTable"/> class.
 /// </summary>
 /// <param name="characterID">The initial value for the corresponding property.</param>
 /// <param name="guildID">The initial value for the corresponding property.</param>
 /// <param name="joined">The initial value for the corresponding property.</param>
 /// <param name="rank">The initial value for the corresponding property.</param>
 public GuildMemberTable(CharacterID @characterID, GuildID @guildID, DateTime @joined, GuildRank @rank)
 {
     CharacterID = @characterID;
     GuildID = @guildID;
     Joined = @joined;
     Rank = @rank;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="EventCountersGuildTable"/> class.
 /// </summary>
 /// <param name="counter">The initial value for the corresponding property.</param>
 /// <param name="guildEventCounterId">The initial value for the corresponding property.</param>
 /// <param name="guildID">The initial value for the corresponding property.</param>
 public EventCountersGuildTable(Int64 @counter, Byte @guildEventCounterId, GuildID @guildID)
 {
     Counter             = @counter;
     GuildEventCounterId = @guildEventCounterId;
     GuildID             = @guildID;
 }