Raised This Month: $51 Target: $400
 12% 

[ANY] Discord API (Send/Retrieve messages, list Guilds/Channels) UPDATE: 10/1/17


Post New Thread Reply   
 
Thread Tools Display Modes
Facksy
Senior Member
Join Date: Apr 2017
Location: +2+2
Old 11-09-2018 , 13:42   Re: [ANY] Discord API (Send/Retrieve messages, list Guilds/Channels) UPDATE: 10/1/17
Reply With Quote #41

Hey guys, im trying to make a script which allow people with certain roles to relay message to the server.
For example, if a guy have the role "Root", it will send the message to the server but if he dont have it, it wont send. The problem is that I don't know how to check if some user has this role, I dont know how to get role of the message author, I tried to use message.GetAuthor().GetRoles() but it didnt work
__________________
My Steam I take private requests if related with TF2
My Plugins
Facksy is offline
Naydef
Senior Member
Join Date: Dec 2015
Location: Doom Town, Nevada
Old 02-10-2019 , 10:20   Re: [ANY] Discord API (Send/Retrieve messages, list Guilds/Channels) UPDATE: 10/1/17
Reply With Quote #42

Obviously this plugin is leaking tons of memory and causes server crashes in combination with plugins which use the API
Version: 0.1.103
Code:
L 02/10/2019 - 11:45:01: [SM] MEMORY LEAK DETECTED IN PLUGIN (file "discord_api.smx")
461414 	96246.456544 	L 02/10/2019 - 11:45:01: [SM] Unloading plugin to free 21886 handles.
461415 	96246.456767 	L 02/10/2019 - 11:45:01: [SM] Contact the author(s) of this plugin to correct this error.
461416 	96246.456951 	L 02/10/2019 - 11:45:01: --------------------------------------------------------------------------
461417 	96246.458203 	L 02/10/2019 - 11:45:01: Type	DataPack            |	Count	21
461418 	96246.458431 	L 02/10/2019 - 11:45:01: Type	Timer               |	Count	2
461419 	96246.458598 	L 02/10/2019 - 11:45:01: Type	PrivateFwd          |	Count	21749
461420 	96246.458749 	L 02/10/2019 - 11:45:01: Type	Trie                |	Count	3
461421 	96246.458889 	L 02/10/2019 - 11:45:01: Type	HTTPHandle          |	Count	39
461422 	96246.459024 	L 02/10/2019 - 11:45:01: Type	JanssonObject       |	Count	72
__________________
My plugins:
*None for now*


Steam:
naydef

Last edited by Naydef; 02-10-2019 at 10:21.
Naydef is offline
paulo_crash
AlliedModders Donor
Join Date: May 2016
Location: Brazil
Old 07-07-2019 , 12:26   Re: [ANY] Discord API (Send/Retrieve messages, list Guilds/Channels) UPDATE: 10/1/17
Reply With Quote #43

You could correct this error:
Code:
L 07/07/2019 - 12:52:16: [discord_api.smx] [DISCORD] Couldn't Send Webhook - Fail 0 400
This shows on the servers console:
Code:
BAD REQUEST

DATA RECE: {"attachments": ["0"]}

DATA SENT: {"username": "Map Notifications", "attachments": [{"color": "00FF3C", "title": "#1 - ZK Servidores [ COMPETITIVO ] @MGTHOST1.COM.BR", "thumb_url": "https://image.gametracker.com/images/maps/160x120/csgo/de_dust2.jpg", "fields": [{"value": "de_dust2", "short": true, "title": "Mapa Atual:"}, {"value": "1/12", "short": true, "title": "Players Online:"}, {"value": "steam://connect/185.50.105.218:27120", "short": true, "title": "Connect:"}]}]}

L 07/07/2019 - 21:18:05: [discord_api.smx] [DISCORD] Couldn't Send Webhook - Fail 0 400

Last edited by paulo_crash; 07-07-2019 at 20:20.
paulo_crash is offline
alphaearth
Senior Member
Join Date: Feb 2018
Location: Turkey
Old 11-13-2019 , 07:51   Re: [ANY] Discord API (Send/Retrieve messages, list Guilds/Channels) UPDATE: 10/1/17
Reply With Quote #44

L 11/13/2019 - 12:47:55: [DISCORD] Couldn't Send Webhook - Fail 0 0

Can you fix this error?
__________________
alphaearth is offline
OcC
Senior Member
Join Date: Mar 2012
Location: Romania
Old 11-21-2019 , 17:58   Re: [ANY] Discord API (Send/Retrieve messages, list Guilds/Channels) UPDATE: 10/1/17
Reply With Quote #45

14:29:55: [DISCORD] Couldn't Send Webhook - Fail 0 0
Fix ?
__________________

Last edited by OcC; 11-24-2019 at 07:33.
OcC is offline
Send a message via Yahoo to OcC
HiddenConn1
AlliedModders Donor
Join Date: Aug 2009
Location: Cambridge, UK
Old 02-10-2020 , 16:02   Re: [ANY] Discord API (Send/Retrieve messages, list Guilds/Channels) UPDATE: 10/1/17
Reply With Quote #46

Is this still being maintained or support being given?

I'm unable to compile the discord_api because it says "Could not find "discord_api.smx", please make sure you can access this file and retry." When I compile using command line in the folder correctly I get:
Quote:
C:\Users\kylei\Downloads\pstudio-0.8.3\scripting>compile discord_api.sp
//SourceMod Batch Compiler
// by the SourceMod Dev Team


//// discord_api.sp
//
// C:\Users\kylei\Downloads\pstudio-0.8.3\scripting\include\smjansson.inc(66) : error 173: 'in' is a newly reserved keyword that may be used in the future; use a different name as an identifier
// discord_api.sp(146) : warning 203: symbol is never used: "JsonObjectGetInt"
//
// 1 Error.
//
// Compilation Time: 0.67 sec
// ----------------------------------------

Press enter to exit ...
__________________
HiddenConn1 is offline
Tonblader
Senior Member
Join Date: Jul 2011
Location: Peru
Old 04-24-2020 , 16:24   Re: [ANY] Discord API (Send/Retrieve messages, list Guilds/Channels) UPDATE: 10/1/17
Reply With Quote #47

Quote:
Originally Posted by HiddenConn1 View Post
Is this still being maintained or support being given?

I'm unable to compile the discord_api because it says "Could not find "discord_api.smx", please make sure you can access this file and retry." When I compile using command line in the folder correctly I get:
Use this version of smjansson.inc
https://forums.alliedmods.net/showpo...6&postcount=50

by the way, does anyone know why I can't compile the files:

GetGuildChannels.sp
GetGuilds.sp
ListenToChannel.sp
SendMessage.sp

Quote:
Originally Posted by BasicPawn Compiler
Compiling source started!
Compiling failed! Compiler can not be found!
EDIT: does not need to compile, it is specified in discord_api.sp
Apparently I can't get any errors thrown at me, could it be that I did something wrong about getting my bot's token?

Last edited by Tonblader; 04-24-2020 at 17:04.
Tonblader is offline
Trum
AlliedModders Donor
Join Date: Jan 2017
Old 08-12-2020 , 18:10   Re: [ANY] Discord API (Send/Retrieve messages, list Guilds/Channels) UPDATE: 10/1/17
Reply With Quote #48

I'm trying to compile the example plugin but I get errors I don't know how to fix:
Code:
dctest.sp(24) : error 172: methodmap 'DiscordWebHook' does not have a constructor
dctest.sp(24) : warning 213: tag mismatch
dctest.sp(25) : error 105: cannot find method or property DiscordWebHook.SetUsername
dctest.sp(26) : error 105: cannot find method or property DiscordWebHook.SlackMode
dctest.sp(26) : warning 213: tag mismatch
dctest.sp(27) : error 105: cannot find method or property DiscordWebHook.SetContent
dctest.sp(28) : error 105: cannot find method or property DiscordWebHook.Send
Why am I getting those errors with this code?
PHP Code:
#pragma semicolon 1

#define PLUGIN_VERSION "1.10"

#include <sourcemod>
#include <discord>

#define WEBHOOK "mywebhookurl"

public Plugin myinfo 
{
    
name "Discord Test",
    
author "Deathknife",
    
description "",
    
version PLUGIN_VERSION,
    
url ""
};

public 
void OnPluginStart() {
    
RegConsoleCmd("sm_webhooktest"Cmd_Webhook);
}

public 
Action Cmd_Webhook(int clientint argc) {
    
DiscordWebHook hook = new DiscordWebHook(WEBHOOK);
    
hook.SetUsername("Testing");
    
hook.SlackMode false;
    
hook.SetContent("Testing 1 2 3");
    
hook.Send();
    
delete hook;

I have placed the discord.inc inside the /include/ folder, then compiling my plugin but I get those errors.

Have I missed something?
Trum is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 08-12-2020 , 22:17   Re: [ANY] Discord API (Send/Retrieve messages, list Guilds/Channels) UPDATE: 10/1/17
Reply With Quote #49

Quote:
Originally Posted by Trum View Post
I'm trying to compile the example plugin but I get errors I don't know how to fix:
Code:
dctest.sp(24) : error 172: methodmap 'DiscordWebHook' does not have a constructor
dctest.sp(24) : warning 213: tag mismatch
dctest.sp(25) : error 105: cannot find method or property DiscordWebHook.SetUsername
dctest.sp(26) : error 105: cannot find method or property DiscordWebHook.SlackMode
dctest.sp(26) : warning 213: tag mismatch
dctest.sp(27) : error 105: cannot find method or property DiscordWebHook.SetContent
dctest.sp(28) : error 105: cannot find method or property DiscordWebHook.Send
Why am I getting those errors with this code?
PHP Code:
#pragma semicolon 1

#define PLUGIN_VERSION "1.10"

#include <sourcemod>
#include <discord>

#define WEBHOOK "mywebhookurl"

public Plugin myinfo 
{
    
name "Discord Test",
    
author "Deathknife",
    
description "",
    
version PLUGIN_VERSION,
    
url ""
};

public 
void OnPluginStart() {
    
RegConsoleCmd("sm_webhooktest"Cmd_Webhook);
}

public 
Action Cmd_Webhook(int clientint argc) {
    
DiscordWebHook hook = new DiscordWebHook(WEBHOOK);
    
hook.SetUsername("Testing");
    
hook.SlackMode false;
    
hook.SetContent("Testing 1 2 3");
    
hook.Send();
    
delete hook;

I have placed the discord.inc inside the /include/ folder, then compiling my plugin but I get those errors.

Have I missed something?
are you using the correct include? not the include from zipcore's discord
do you have all the include files? https://github.com/Deathknife/source...master/include

don't use the attachment here its outdated
__________________
8guawong is offline
Trum
AlliedModders Donor
Join Date: Jan 2017
Old 08-13-2020 , 04:59   Re: [ANY] Discord API (Send/Retrieve messages, list Guilds/Channels) UPDATE: 10/1/17
Reply With Quote #50

Ah, I totally forgot those in /include/discord/, thanks!
Trum is offline
Reply



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

Forum Jump


All times are GMT -4. The time now is 01:40.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode