SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 25/07/2020, 02:27 PM   #1
Dev86
Little Clucker
 
Dev86's Avatar
 
Join Date: Oct 2019
Posts: 7
Reputation: 6
Default [DCC V3] Dev86's Discord Command Processor (Dev86's fork of George's fork of inn0cent's DCC)

Dev86's Discord Command Processor

(Dev86's fork of George's fork of inn0cent's Discord Command Control)

What is DCC?
DCC is a command processor for discord bots in use with madd1nat0r's discord-connector plugin.

‏‏‎What did i change?
DCC V2 was made for the sake of it to be compatible with discord-connector version 0.3.2, but the library had flaws that made it hard to get the command sender's author due to it returning the author's username as a string instead of DCC_User. I modified it so that it returns the author as DCC_User instead. With this modification, it would make it easier to get the author's account information (role, permissions, etc.).
With this modification, i added 2 new functions that makes role checking and getting the discord user's name string easier.

Installation
First, prepare discord-connector. Please be guided by the following documentation: Discord Connector Plugin Installation Tutorial
After doing that, define the following before including the library.
Code:
// - You can get the ID's of these by enabling developer mode on discord, right click on the channel/server name and click on Copy ID.

#define DISCORD_CHANNEL_ID	"699723684042113075" // - Channel ID where commands are being sent
#define DISCORD_PREFIX		"~"                               // - symbol used before the command.
#define GUILD_ID			"699309687027269705" // - Server ID.
// - add more definitions for more roles or channels you may be using

#include <dccmd>
Usage
It has similar usage to most command processors.
PHP Code:
DCCMD:mycmd(DCC_User:userargs// - user will be the command author/sender, args will be the arguements/parameters, used for strtok/sscanf.
{
    
// - do stuff here
    
return 1;
}
/* ALIASES
    DISCORD:
    DC_CMD:
*/ 
Functions/Callbacks

OnDCCommandPerformed
PHP Code:
public OnDCCommandPerformed(args[], success
This is called when a command is detected. There are two possible success types (0 and 1), success is 0 when the command does not exist, and 1 is called when the command sent is a success and it does exist.
The following is an example usage, but is not recommended as it can be annoying and is abuseable.
PHP Code:
public OnDCCommandPerformed(args[], success)
{
    if(!
success) return SendDC(CHANNEL_ID"**[ERROR] Invalid command.");
    return 
1;

SendDiscordMessage

This callback is self explanatory, it is used to send a discord message as the discord bot. The bot makes use of y_va which makes you able to format it within the callback itself.

PHP Code:
SendDiscordMessage(channel[], const fmat[], va_args<>)
SendDC(channel[], const fmat[], va_args<>) // - Alias 
PHP Code:
DCCMD:whoami(DCC_User:userargs)
{
    
SendDiscordMessage(CHANNEL_ID"You are %s."GetDiscordName(user)); 
    return 
1;

UserHasRole
This function is used to check if a user has a certain role in the discord server.
PHP Code:
UserHasRole(DCC_User:userDCC_Role:role
PHP Code:
DCCMD:adminmessage(DCC_User:userargs)
{
    new 
DCC_Role:pAdmin;
    new 
message[256];
    
pAdmin DCC_FindRoleById(ROLE_ADMIN);
    if(!
UserHasRole(userpAdmin))
    {
        
// - I personally would not recommend this, but used it here for the sake of representation.
        
return SendDiscordMessage(CHANNEL_ID"**[ERROR]:** You do not have permission to use this command.");
    }
    if(
sscanf(args"s[256]"message))
    {
        return 
SendDiscordMessage(CHANNEL_ID"**[USAGE]:** /adminmessage [message]");
    }
    
SendDiscordMessage(CHANNEL_ID"**[ADMIN]:** %s"message);
    return 
1;

GetDiscordName
This function is used to make an easier way to return a discord user's name.
PHP Code:
 GetDiscordName(DCC_User:user); 
PHP Code:
DCCMD:whoami(DCC_User:userargs)
{
    
SendDiscordMessage(CHANNEL_ID"You are %s."GetDiscordName(user)); 
    return 
1;

Source Code

|

Credits & Dependencies


****** for YSI Library
madd1nat0r for discord-connector plugin & sscanf2
GeorgeLimit for DCC V2
Inn0cent for DCC
Dev86 is offline   Reply With Quote
Old 25/07/2020, 08:05 PM   #2
Chaprnks
Gangsta
 
Chaprnks's Avatar
 
Join Date: Sep 2007
Location: Soviet America
Posts: 603
Reputation: 69
Default Re: [DCC V3] Dev86's Discord Command Processor (Dev86's fork of George's fork of inn0cent's DCC)

Good to see someone updated this to work with the latest discord-connector. The couple latest updates on that plugin make 99% of includes using that plugin completely useless. Personally not a fan of plugins that always have constant "code breaking" changes, but thats besides the point.
__________________
Chaprnks is offline   Reply With Quote
Old 26/07/2020, 01:32 PM   #3
Dev86
Little Clucker
 
Dev86's Avatar
 
Join Date: Oct 2019
Posts: 7
Reputation: 6
Default Re: [DCC V3] Dev86's Discord Command Processor (Dev86's fork of George's fork of inn0cent's DCC)

Quote:
Originally Posted by Chaprnks View Post
Good to see someone updated this to work with the latest discord-connector. The couple latest updates on that plugin make 99% of includes using that plugin completely useless. Personally not a fan of plugins that always have constant "code breaking" changes, but thats besides the point.
Thank you, i'm also planning to make this more easier to use, i'm using the plugin and include to make an actual discord bot for my discord server without samp, i'll keep updating this to fit my needs and in hope to help in other people's stuff too.
Dev86 is offline   Reply With Quote
Old 26/07/2020, 03:40 PM   #4
GeorgeLimit
Big Clucker
 
GeorgeLimit's Avatar
 
Join Date: Mar 2018
Location: Jawa Timur, Indonesia
Posts: 166
Reputation: 0
Default Re: [DCC V3] Dev86's Discord Command Processor (Dev86's fork of George's fork of inn0cent's DCC)

__________________

Quote:
That is perfectly fine, I'm just pointing out where you made mistakes what does hearing "good job" get you? Absolutely nothing. You need to hear the problems otherwise you'll keep making the same mistakes
GeorgeLimit is offline   Reply With Quote
Old 29/07/2020, 02:33 PM   #5
XGreen
Huge Clucker
 
XGreen's Avatar
 
Join Date: May 2014
Location: Manila
Posts: 207
Reputation: 8
Default Re: [DCC V3] Dev86's Discord Command Processor (Dev86's fork of George's fork of inn0cent's DCC)

Great work! I'll use this! Thanks!
XGreen is online now   Reply With Quote
Old 02/08/2020, 08:34 AM   #6
Nyzenic
Big Clucker
 
Nyzenic's Avatar
 
Join Date: Sep 2017
Location: house
Posts: 86
Reputation: 51
Default Re: [DCC V3] Dev86's Discord Command Processor (Dev86's fork of George's fork of inn0cent's DCC)

nice include u have big pp now
__________________
discord: nize#5841
[FS/INC] Custom Player Nametags

not really into samp right now
Nyzenic is offline   Reply With Quote
Old 03/08/2020, 02:27 PM   #7
Krisna
Big Clucker
 
Krisna's Avatar
 
Join Date: Jan 2013
Location: Indonesia
Posts: 165
Reputation: 10
Default Re: [DCC V3] Dev86's Discord Command Processor (Dev86's fork of George's fork of inn0cent's DCC)

i'm still wondering the plugin support for webhook
__________________
leave samp, play osu!
Krisna is offline   Reply With Quote
Old 28/08/2020, 08:09 PM   #8
Volkof
Little Clucker
 
Join Date: Aug 2020
Posts: 1
Reputation: 0
Default Re: [DCC V3] Dev86's Discord Command Processor (Dev86's fork of George's fork of inn0cent's DCC)

Perdon, revivo post no me reconoce la ID de rol.
¿Que hago?
El code es
Quote:
DCCMD:kick(DCC_User:user, args)
{
new DCC_RoleAdmin;
pAdmin = DCC_FindRoleById("744056705310261288");
if(!UserHasRole(DCC_User:user, pAdmin))
{
// - I personally would not recommend this, but used it here for the sake of representation.
return SendDiscordMessage(DISCORD_CHANNEL_ID, "[ERROR]: You do not have permission to use this command.");
}
Volkof is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Plugin] SKY - Slice's fork of kurta999's fork of YSF Slice Plugin Development 163 13/07/2020 11:17 PM
Check the height of the fork of the forklift? danielpalade Scripting Help 1 21/05/2016 04:04 PM
Forklift fork Eloctro Scripting Help 3 06/07/2014 08:38 PM
command processor? RiChArD_A Scripting Help 3 23/01/2013 04:41 PM


All times are GMT. The time now is 07:55 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.