Skip to content

Retrieving Guilds

Deathknife edited this page Feb 18, 2017 · 1 revision

Retrieving Guilds

You can retrieve guilds the Bot as access to with the following:

DiscordBot.GetGuilds(DiscordGuildsRetrieve, DiscordGuildsRetrieveAll, any data);

You can pass INVALID_FUNCTION as a parameter if you do not wish to use one of the callbacks. Data is optional.


DiscordGuildsRetrieve

This callback is fired for every guild it retrieves.

(DiscordBot bot, char[] id, char[] name, char[] icon, bool owner, int permissions, any data);


DiscordGuildsRetrieveAll

This callback is fired once containing every guild.

(DiscordBot bot, ArrayList id, ArrayList name, ArrayList icon, ArrayList owner, ArrayList permissions, any data);

The ArrayList indexes are corresponding (i.e id[5] corresponds to name[5] etc...). ArrayLists will be closed by the main plugin after this event is fired. If you want to store it, you have to Clone it.


Example:

DiscordBot bot = new DiscordBot(BOT_TOKEN);
bot.GetGuilds(GuildList, GuildListAll, GetClientUserId(client));
public void GuildList(DiscordBot bot, char[] id, char[] name, char[] icon, bool owner, int permissions, any data) {
	int client = GetClientOfUserId(data);
	if(client > 0 && IsClientConnected(client) && IsClientInGame(client)) {
		PrintToConsole(client, "Guild [%s] [%s] [%s] [%i] [%i]", id, name, icon, owner, permissions);
	}
}
public void GuildListAll(DiscordBot bot, ArrayList Alid, ArrayList Alname, ArrayList Alicon, ArrayList Alowner, ArrayList Alpermissions, any data) {
	int client = GetClientOfUserId(data);
	if(client > 0 && IsClientConnected(client) && IsClientInGame(client)) {
		char id[32];
		char name[64];
		char icon[128];
		bool owner;
		int permissions;
		
		PrintToConsole(client, "Dumping Guilds from arraylist");
		
		for(int i = 0; i < Alid.Length; i++) {
			GetArrayString(Alid, i, id, sizeof(id));
			GetArrayString(Alname, i, name, sizeof(name));
			GetArrayString(Alicon, i, icon, sizeof(icon));
			owner = GetArrayCell(Alowner, i);
			permissions = GetArrayCell(Alpermissions, i);
			PrintToConsole(client, "Guild: [%s] [%s] [%s] [%i] [%i]", id, name, icon, owner, permissions);
		}
	}
}

Clone this wiki locally