Skip to content

ExampleCode.2.2

Luckshya edited this page Jul 9, 2020 · 1 revision
class CDiscordGuild {
	ID = null;
	Name = null;
	OwnerID = null;
	Region = null;
	Roles = null;
	Members = null;
	Channels = null;
	
	function constructor(guild) {
		ID = guild.ID;
		Name = guild.Name;
		OwnerID = guild.OwnerID;
		Region = guild.Region;
		Roles = {};
		Members = {};
		Channels = {};
		
		foreach(roleID, role in guild.RolesTable) {
			Roles.rawset(roleID, CDiscordRole(role));
		}
		
		foreach(memberID, member in guild.MembersTable) {
			Members.rawset(memberID, CDiscordMember(member));
		}
		
		foreach(channelID, channel in guild.ChannelsTable) {
			Channels.rawset(channelID, CDiscordChannel(channel));
		}
	}
}

class CDiscordChannel {
	ID = null;
	ServerID = null;
	Position = null;
	Name = null;
	Topic = null;
	IsNSFW = null;
	Recipients = null;
	OwnerID = null;
	ParentID = null;
	Type = null;
	
	function constructor(channel) {
		ID = channel.ID;
		ServerID = channel.ServerID;
		Position = channel.Position;
		Name = channel.Name;
		Topic = channel.Topic;
		IsNSFW = channel.IsNSFW;
		Recipients = {};
		OwnerID = channel.OwnerID;
		ParentID = channel.ParentID;
		Type = channel.Type;
		
		foreach(recipientID, recipient in channel.RecipientsTable) {
			Recipients.rawset(recipientID, CDiscordUser(recipient));
		}
	}
}

class CDiscordMember {
	ID = null;
	User = null;
	Nick = null;
	Roles = null;
	JoinedAt = null;
	IsDeaf = null;
	IsMute = null;
	
	function constructor(member) {
		ID = member.ID;
		User = CDiscordUser(member.User);
		Nick = member.Nick;
		Roles = member.Roles;
		JoinedAt = member.JoinedAt;
		IsDeaf = member.IsDeaf;
		IsMute = member.IsMute;
	}
}

class CDiscordUser {
	ID = null;
	Username = null;
	Discriminator = null;
	IsBot = null;
	Mfa_enabled = null;
	Verified = null;
	Email = null;
	
	function constructor(user) {
		ID = user.ID;
		Username = user.Username;
		Discriminator = user.Discriminator;
		IsBot = user.IsBot;
		Mfa_enabled = user.Mfa_enabled;
		Verified = user.Verified;
		Email = user.Email;
	}
}

class CDiscordRole {
	ID = null;
	Name = null;
	Color = null;
	Hoist = null;
	Position = null;
	
	function constructor(role) {
		ID = role.ID;
		Name = role.Name;
		Color = role.Color;
		Hoist = role.Hoist;
		Position = role.Position;
	}
}
Clone this wiki locally