Merge pull request #2 from zeelorenc/master

Merge
This commit is contained in:
Dusan 2019-05-30 11:13:08 +02:00 committed by GitHub
commit 218d77d9f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 66 additions and 35 deletions

View File

@ -5,9 +5,13 @@
* Purpose: commands that can be used on the discord channel
*/
/* ** Error Checking ** */
#if defined DISCORD_DISABLED
#endinput
#endif
/* ** Includes ** */
#include < YSI\y_hooks >
#include < discord-command >
/* ** Commands ** */
DISCORD:commands( DCC_Channel: channel, DCC_User: author, params[ ] )
@ -162,7 +166,7 @@ thread OnPlayerDiscordStats( playerid, params[ ] )
cache_get_data( rows, fields );
if ( rows )
if ( rows )
{
iScore = cache_get_field_content_int( 0, "SCORE", dbHandle );
iKills = cache_get_field_content_int( 0, "KILLS", dbHandle );
@ -243,7 +247,7 @@ DISCORD:lastlogged( DCC_Channel: channel, DCC_User: author, params[ ] )
thread OnPlayerDiscordLastLogged( playerid, params[ ] )
{
new
rows, fields,
rows, fields,
time, Field[ 50 ]
;
cache_get_data( rows, fields );
@ -284,7 +288,7 @@ DISCORD:acmds( DCC_Channel: channel, DCC_User: author, params[ ] )
}
new
bool: hasExec, bool: hasDev, bool: hasCouncil,
bool: hasExec, bool: hasDev, bool: hasCouncil,
bool: hasLead, bool: hasSenior, bool: hasGeneral, bool: hasTrial;
DCC_HasGuildMemberRole( discordGuild, author, discordRoleExec, hasExec );
@ -294,7 +298,7 @@ DISCORD:acmds( DCC_Channel: channel, DCC_User: author, params[ ] )
DCC_HasGuildMemberRole( discordGuild, author, discordRoleSenior, hasSenior );
DCC_HasGuildMemberRole( discordGuild, author, discordRoleGeneral, hasGeneral );
DCC_HasGuildMemberRole( discordGuild, author, discordRoleTrial, hasTrial );
if ( hasExec || hasDev || hasCouncil || hasLead || hasSenior || hasGeneral || hasTrial )
{
DCC_SendChannelMessage( discordAdminChan, "**Commands:**\n**!kick** - Kicking a player from the server.\n**!mute** - Muting a player.\n**!unmute** - Un-muting a player.\n**!suspend** - Suspending a player.\
@ -313,7 +317,7 @@ DISCORD:warn( DCC_Channel: channel, DCC_User: author, params[ ] )
}
new
bool: hasExec, bool: hasDev, bool: hasCouncil,
bool: hasExec, bool: hasDev, bool: hasCouncil,
bool: hasLead, bool: hasSenior, bool: hasGeneral, bool: hasTrial;
DCC_HasGuildMemberRole( discordGuild, author, discordRoleExec, hasExec );
@ -323,7 +327,7 @@ DISCORD:warn( DCC_Channel: channel, DCC_User: author, params[ ] )
DCC_HasGuildMemberRole( discordGuild, author, discordRoleSenior, hasSenior );
DCC_HasGuildMemberRole( discordGuild, author, discordRoleGeneral, hasGeneral );
DCC_HasGuildMemberRole( discordGuild, author, discordRoleTrial, hasTrial );
if ( hasExec || hasDev || hasCouncil || hasLead || hasSenior || hasGeneral || hasTrial )
{
new pID, reason[50];
@ -356,7 +360,7 @@ DISCORD:jail( DCC_Channel: channel, DCC_User: author, params[ ] )
}
new
bool: hasExec, bool: hasDev, bool: hasCouncil,
bool: hasExec, bool: hasDev, bool: hasCouncil,
bool: hasLead, bool: hasSenior, bool: hasGeneral, bool: hasTrial;
DCC_HasGuildMemberRole( discordGuild, author, discordRoleExec, hasExec );
@ -366,7 +370,7 @@ DISCORD:jail( DCC_Channel: channel, DCC_User: author, params[ ] )
DCC_HasGuildMemberRole( discordGuild, author, discordRoleSenior, hasSenior );
DCC_HasGuildMemberRole( discordGuild, author, discordRoleGeneral, hasGeneral );
DCC_HasGuildMemberRole( discordGuild, author, discordRoleTrial, hasTrial );
if ( hasExec || hasDev || hasCouncil || hasLead || hasSenior || hasGeneral || hasTrial )
{
new pID, reason[50], Seconds;
@ -392,7 +396,7 @@ DISCORD:unjail( DCC_Channel: channel, DCC_User: author, params[ ] )
}
new
bool: hasExec, bool: hasDev, bool: hasCouncil,
bool: hasExec, bool: hasDev, bool: hasCouncil,
bool: hasLead, bool: hasSenior, bool: hasGeneral, bool: hasTrial;
DCC_HasGuildMemberRole( discordGuild, author, discordRoleExec, hasExec );
@ -402,7 +406,7 @@ DISCORD:unjail( DCC_Channel: channel, DCC_User: author, params[ ] )
DCC_HasGuildMemberRole( discordGuild, author, discordRoleSenior, hasSenior );
DCC_HasGuildMemberRole( discordGuild, author, discordRoleGeneral, hasGeneral );
DCC_HasGuildMemberRole( discordGuild, author, discordRoleTrial, hasTrial );
if ( hasExec || hasDev || hasCouncil || hasLead || hasSenior || hasGeneral || hasTrial )
{
new
@ -430,7 +434,7 @@ DISCORD:ans( DCC_Channel: channel, DCC_User: author, params[ ] )
}
new
bool: hasExec, bool: hasDev, bool: hasCouncil,
bool: hasExec, bool: hasDev, bool: hasCouncil,
bool: hasLead, bool: hasSenior, bool: hasGeneral, bool: hasTrial;
DCC_HasGuildMemberRole( discordGuild, author, discordRoleExec, hasExec );
@ -440,7 +444,7 @@ DISCORD:ans( DCC_Channel: channel, DCC_User: author, params[ ] )
DCC_HasGuildMemberRole( discordGuild, author, discordRoleSenior, hasSenior );
DCC_HasGuildMemberRole( discordGuild, author, discordRoleGeneral, hasGeneral );
DCC_HasGuildMemberRole( discordGuild, author, discordRoleTrial, hasTrial );
if ( hasExec || hasDev || hasCouncil || hasLead || hasSenior || hasGeneral || hasTrial )
{
new
@ -470,7 +474,7 @@ DISCORD:kick( DCC_Channel: channel, DCC_User: author, params[ ] )
}
new
bool: hasExec, bool: hasDev, bool: hasCouncil,
bool: hasExec, bool: hasDev, bool: hasCouncil,
bool: hasLead, bool: hasSenior, bool: hasGeneral;
DCC_HasGuildMemberRole( discordGuild, author, discordRoleExec, hasExec );
@ -479,7 +483,7 @@ DISCORD:kick( DCC_Channel: channel, DCC_User: author, params[ ] )
DCC_HasGuildMemberRole( discordGuild, author, discordRoleLead, hasLead );
DCC_HasGuildMemberRole( discordGuild, author, discordRoleSenior, hasSenior );
DCC_HasGuildMemberRole( discordGuild, author, discordRoleGeneral, hasGeneral );
if ( hasExec || hasDev || hasCouncil || hasLead || hasSenior || hasGeneral )
{
new pID, reason[64];
@ -505,7 +509,7 @@ DISCORD:mute( DCC_Channel: channel, DCC_User: author, params[ ] )
}
new
bool: hasExec, bool: hasDev, bool: hasCouncil,
bool: hasExec, bool: hasDev, bool: hasCouncil,
bool: hasLead, bool: hasSenior, bool: hasGeneral;
DCC_HasGuildMemberRole( discordGuild, author, discordRoleExec, hasExec );
@ -514,7 +518,7 @@ DISCORD:mute( DCC_Channel: channel, DCC_User: author, params[ ] )
DCC_HasGuildMemberRole( discordGuild, author, discordRoleLead, hasLead );
DCC_HasGuildMemberRole( discordGuild, author, discordRoleSenior, hasSenior );
DCC_HasGuildMemberRole( discordGuild, author, discordRoleGeneral, hasGeneral );
if ( hasExec || hasDev || hasCouncil || hasLead || hasSenior || hasGeneral )
{
new pID, seconds, reason[ 32 ];
@ -544,7 +548,7 @@ DISCORD:unmute( DCC_Channel: channel, DCC_User: author, params[ ] )
}
new
bool: hasExec, bool: hasDev, bool: hasCouncil,
bool: hasExec, bool: hasDev, bool: hasCouncil,
bool: hasLead, bool: hasSenior, bool: hasGeneral;
DCC_HasGuildMemberRole( discordGuild, author, discordRoleExec, hasExec );
@ -553,7 +557,7 @@ DISCORD:unmute( DCC_Channel: channel, DCC_User: author, params[ ] )
DCC_HasGuildMemberRole( discordGuild, author, discordRoleLead, hasLead );
DCC_HasGuildMemberRole( discordGuild, author, discordRoleSenior, hasSenior );
DCC_HasGuildMemberRole( discordGuild, author, discordRoleGeneral, hasGeneral );
if ( hasExec || hasDev || hasCouncil || hasLead || hasSenior || hasGeneral )
{
new pID;
@ -581,7 +585,7 @@ DISCORD:suspend( DCC_Channel: channel, DCC_User: author, params[ ] )
}
new
bool: hasExec, bool: hasDev, bool: hasCouncil,
bool: hasExec, bool: hasDev, bool: hasCouncil,
bool: hasLead, bool: hasSenior, bool: hasGeneral;
DCC_HasGuildMemberRole( discordGuild, author, discordRoleExec, hasExec );
@ -590,7 +594,7 @@ DISCORD:suspend( DCC_Channel: channel, DCC_User: author, params[ ] )
DCC_HasGuildMemberRole( discordGuild, author, discordRoleLead, hasLead );
DCC_HasGuildMemberRole( discordGuild, author, discordRoleSenior, hasSenior );
DCC_HasGuildMemberRole( discordGuild, author, discordRoleGeneral, hasGeneral );
if ( hasExec || hasDev || hasCouncil || hasLead || hasSenior || hasGeneral )
{
new pID, reason[50], hours, days;
@ -621,7 +625,7 @@ DISCORD:ban( DCC_Channel: channel, DCC_User: author, params[ ] )
}
new
bool: hasExec, bool: hasDev, bool: hasCouncil,
bool: hasExec, bool: hasDev, bool: hasCouncil,
bool: hasLead, bool: hasSenior;
DCC_HasGuildMemberRole( discordGuild, author, discordRoleExec, hasExec );
@ -629,7 +633,7 @@ DISCORD:ban( DCC_Channel: channel, DCC_User: author, params[ ] )
DCC_HasGuildMemberRole( discordGuild, author, discordRoleCouncil, hasCouncil );
DCC_HasGuildMemberRole( discordGuild, author, discordRoleLead, hasLead );
DCC_HasGuildMemberRole( discordGuild, author, discordRoleSenior, hasSenior );
if ( hasExec || hasDev || hasCouncil || hasLead || hasSenior )
{
new pID, reason[64];
@ -655,7 +659,7 @@ DISCORD:getip( DCC_Channel: channel, DCC_User: author, params[ ] )
}
new
bool: hasExec, bool: hasDev, bool: hasCouncil,
bool: hasExec, bool: hasDev, bool: hasCouncil,
bool: hasLead, bool: hasSenior;
DCC_HasGuildMemberRole( discordGuild, author, discordRoleExec, hasExec );
@ -663,7 +667,7 @@ DISCORD:getip( DCC_Channel: channel, DCC_User: author, params[ ] )
DCC_HasGuildMemberRole( discordGuild, author, discordRoleCouncil, hasCouncil );
DCC_HasGuildMemberRole( discordGuild, author, discordRoleLead, hasLead );
DCC_HasGuildMemberRole( discordGuild, author, discordRoleSenior, hasSenior );
if ( hasExec || hasDev || hasCouncil || hasLead || hasSenior )
{
new pID;

View File

@ -5,11 +5,24 @@
* Purpose: discord implementation in-game
*/
//#define DISCORD_DISABLED // !!!! DISABLED BY DEFAULT !!!!
/* ** Enable or disable discord ** */
// #define DISCORD_DISABLED // !!!! DISABLED BY DEFAULT !!!!
/* ** Includes ** */
#include < YSI\y_hooks >
#include < discord-connector >
#tryinclude < discord-connector >
#tryinclude < discord-command >
/* ** Disable if discord connector not enabled ** */
#if !defined dcconnector_included && !defined DISCORD_DISABLED
#warning "Discord is disabled as the connector is not found. (https://github.com/maddinat0r/samp-discord-connector)"
#define DISCORD_DISABLED
#endif
#if !defined _discordcmd_included && !defined DISCORD_DISABLED
#warning "Discord is disabled as the command handler is not found. (https://github.com/AliLogic/discord-command)"
#define DISCORD_DISABLED
#endif
/* ** Definitions ** */
/* Guild */
@ -56,23 +69,33 @@ new stock
DCC_Role: discordRoleMember
;
stock DCC_SendChannelMessageFormatted( DCC_Channel: channel, const format[ ], va_args< > ) {
return DCC_SendChannelMessage( channel, va_return( format, va_start< 2 > ) );
}
/* ** Error Checking ** */
#if defined DISCORD_DISABLED
stock DCC_SendChannelMessage( DCC_Channel: channel, const message[ ] ) {
stock TMP_DCC_SendChannelMessage( DCC_Channel: channel, const message[ ] ) {
#pragma unused channel
#pragma unused message
return 1;
}
#if defined _ALS_DCC_SendChannelMessage
#undef DCC_SendChannelMessage
#else
#define _ALS_DCC_SendChannelMessage
#endif
#define DCC_SendChannelMessage TMP_DCC_SendChannelMessage
stock DCC_SendUserMessage( DCC_User: author, const message[ ] )
{
#pragma unused author
#pragma unused message
return 1;
}
stock DCC_SendChannelMessageFormatted( DCC_Channel: channel, const format[ ], va_args< > ) {
#pragma unused channel
#pragma unused format
return 1;
}
#endinput
#endif
@ -114,7 +137,7 @@ stock ReturnDiscordName( DCC_User: author ) {
stock discordLevelToString( DCC_User: author )
{
static
szRank[ 15 ],
szRank[ 15 ],
bool: hasExec, bool: hasDev, bool: hasCouncil, bool: hasLead, bool: hasSenior,
bool: hasGeneral, bool: hasTrial, bool: hasSupport, bool: hasVIP, bool: hasMember;
@ -153,7 +176,7 @@ stock DCC_SendUserUsage( DCC_User: author, const message[ ] )
return DCC_SendChannelMessage( discordCmdsChan, szBigString );
}
public OnDiscordCommandPerformed(DCC_Channel: channel, DCC_User: author, bool: success)
public OnDiscordCommandPerformed(DCC_Channel: channel, DCC_User: author, bool: success)
{
if (!success) {
return DCC_SendChannelMessage(channel, "**[ERROR]** You have entered an invalid command. To display the command list type !commands.");
@ -162,8 +185,12 @@ public OnDiscordCommandPerformed(DCC_Channel: channel, DCC_User: author, bool: s
return 1;
}
public DCC_OnGuildMemberAdd(DCC_Guild:guild, DCC_User:user)
public DCC_OnGuildMemberAdd(DCC_Guild:guild, DCC_User:user)
{
DCC_SendUserUsage(user, "Hey there! I am **Stephanie**, i am here to help you out!\nUse **!commands** to see all commands i offer.\nYou need to have **member** role trough to use them, so first verify your account!");
return 1;
}
stock DCC_SendChannelMessageFormatted( DCC_Channel: channel, const format[ ], va_args< > ) {
return DCC_SendChannelMessage( channel, va_return( format, va_start< 2 > ) );
}