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

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


Post New Thread Reply   
 
Thread Tools Display Modes
Trum
AlliedModders Donor
Join Date: Jan 2017
Old 08-15-2020 , 14:36   Re: [ANY] Discord API (Send/Retrieve messages, list Guilds/Channels) UPDATE: 10/1/17
Reply With Quote #51

What else do I need to send the message that I sent in my Discord channel to be sent in-game?

PHP Code:
#include <sourcemod>
#include <discord>

#pragma semicolon 1

#define BOT_TOKEN "mytoken"

DiscordBot gBot;

public 
void OnAllPluginsLoaded() {
    
gBot = new DiscordBot(BOT_TOKEN);
}

public 
void OnMessage(DiscordBot BotDiscordChannel ChannelDiscordMessage message) {
    
char sMessage[2048];
    
message.GetContent(sMessagesizeof(sMessage));
    
    
char sAuthor[128];
    
message.GetAuthor().GetUsername(sAuthorsizeof(sAuthor));
    
    
PrintToChatAll("[DISCORD] %s: %s"sAuthorsMessage);
    
    if(
StrEqual(sMessage"Ping"false)) {
        
gBot.SendMessage(Channel"Pong!");
    }

Trum is offline
Cruze
Veteran Member
Join Date: May 2017
Old 08-16-2020 , 01:36   Re: [ANY] Discord API (Send/Retrieve messages, list Guilds/Channels) UPDATE: 10/1/17
Reply With Quote #52

Quote:
Originally Posted by Trum View Post
What else do I need to send the message that I sent in my Discord channel to be sent in-game?

PHP Code:
#include <sourcemod>
#include <discord>

#pragma semicolon 1

#define BOT_TOKEN "mytoken"

DiscordBot gBot;

public 
void OnAllPluginsLoaded() {
    
gBot = new DiscordBot(BOT_TOKEN);
}

public 
void OnMessage(DiscordBot BotDiscordChannel ChannelDiscordMessage message) {
    
char sMessage[2048];
    
message.GetContent(sMessagesizeof(sMessage));
    
    
char sAuthor[128];
    
message.GetAuthor().GetUsername(sAuthorsizeof(sAuthor));
    
    
PrintToChatAll("[DISCORD] %s: %s"sAuthorsMessage);
    
    if(
StrEqual(sMessage"Ping"false)) {
        
gBot.SendMessage(Channel"Pong!");
    }

You haven't mentioned which channel bot should be active in
__________________
Taking paid private requests! Contact me
Cruze is offline
Trum
AlliedModders Donor
Join Date: Jan 2017
Old 08-16-2020 , 10:00   Re: [ANY] Discord API (Send/Retrieve messages, list Guilds/Channels) UPDATE: 10/1/17
Reply With Quote #53

Quote:
Originally Posted by Cruze View Post
You haven't mentioned which channel bot should be active in
Where do I provide what channel I want it sent in?
Trum is offline
Cruze
Veteran Member
Join Date: May 2017
Old 08-16-2020 , 14:00   Re: [ANY] Discord API (Send/Retrieve messages, list Guilds/Channels) UPDATE: 10/1/17
Reply With Quote #54

PHP Code:
#include <sourcemod>
#include <discord>

#pragma semicolon 1

#define BOT_TOKEN "mytoken"
#define CHANNEL_ID ""

DiscordBot gBot;

public 
void OnAllPluginsLoaded() {
    
gBot = new DiscordBot(BOT_TOKEN);
    
gBot.GetGuilds(GuildList_true);
}

public 
void GuildList(DiscordBot bawtchar[] idchar[] namechar[] iconbool ownerint permissions, const bool listen) {
    
gBot.GetGuildChannels(idChannelListINVALID_FUNCTIONlisten);
}

public 
void ChannelList(DiscordBot bawt, const char[] guildDiscordChannel Channel, const bool listen) {
    
char id[20];
    
Channel.GetID(idsizeof(id));
    if(
StrEqual(idCHANNEL_ID)) {
        if(
listen) {
            
gBot.StartListeningToChannel(ChannelOnMessage);
        }
    }
}

public 
void OnMessage(DiscordBot BotDiscordChannel ChannelDiscordMessage message) {
    
char sMessage[2048];
    
message.GetContent(sMessagesizeof(sMessage));
    
    
char sAuthor[128];
    
message.GetAuthor().GetUsername(sAuthorsizeof(sAuthor));
    
    
PrintToChatAll("[DISCORD] %s: %s"sAuthorsMessage);
    
    if(
StrEqual(sMessage"Ping"false)) {
        
gBot.SendMessage(Channel"Pong!");
    }

__________________
Taking paid private requests! Contact me
Cruze is offline
Trum
AlliedModders Donor
Join Date: Jan 2017
Old 08-21-2020 , 18:48   Re: [ANY] Discord API (Send/Retrieve messages, list Guilds/Channels) UPDATE: 10/1/17
Reply With Quote #55

Why am I getting Couldn't Send Webhook - Fail 0 400?

PHP Code:
#define "mywebhookurl"

char downloadURL[255];
Format(downloadURLsizeof(downloadURL), "https://website.com"g_sFileName);

DiscordWebHook hook = new DiscordWebHook(WEBHOOK);
hook.SlackMode false;

hook.SetContent(output2);

MessageEmbed Embed = new MessageEmbed();

Embed.SetColor("#91D18B");

Embed.SetAuthor("Click here to download the demo.");
Embed.SetAuthorLink(downloadURL);
Embed.SetAuthorIcon("https://website.com/image.png");

Embed.SetDescription("Server");

hook.Embed(Embed);

hook.Send();
delete hook
Solved: slack issue

Last edited by Trum; 08-30-2020 at 07:28. Reason: solved it
Trum is offline
Trum
AlliedModders Donor
Join Date: Jan 2017
Old 08-30-2020 , 06:34   Re: [ANY] Discord API (Send/Retrieve messages, list Guilds/Channels) UPDATE: 10/1/17
Reply With Quote #56

I'm trying to send a embed with a bot, but it says that argument 2 is a mismatch, why?

Code:
argument type mismatch (argument 2)
PHP Code:
#define BOT_TOKEN "mytoken"

DiscordBot gBot;

public 
void OnPluginStart() {
    
RegConsoleCmd("sm_sendmsg"Cmd_SendMsg);
}


public 
void OnAllPluginsLoaded() {
    
gBot = new DiscordBot(BOT_TOKEN);
}

public 
Action Cmd_Webhook(int clientint argc) {
    
MessageEmbed Embed = new MessageEmbed();
    
    
Embed.SetColor("#ff2222");
    
Embed.SetTitle("Testing WebHook");
    
Embed.AddField("Field1""Test1"true);
    
Embed.AddField("abc def""deef"true);

    
gBot.SendMessageToChannelID("743219950973616168"EmbedOnMessageSentGetClientUserId(client));
}

public 
void OnMessageSent(DiscordBot botchar[] channelDiscordMessage messageany data)
{
    
int client GetClientOfUserId(data);
    
ReplyToCommand(client"Message sent!");

Trum is offline
starcs
Member
Join Date: Nov 2018
Old 01-12-2021 , 10:14   Re: [ANY] Discord API (Send/Retrieve messages, list Guilds/Channels) UPDATE: 10/1/17
Reply With Quote #57

Any way to fix this?

__________________
Founder of ⭐ STRTEAM
starcs is offline
Truyn
Junior Member
Join Date: Mar 2019
Old 06-28-2021 , 13:37   Re: [ANY] Discord API (Send/Retrieve messages, list Guilds/Channels) UPDATE: 10/1/17
Reply With Quote #58

is there a version under Rest in pawn??
Truyn is offline
phantomx1
Junior Member
Join Date: Nov 2021
Location: Tampa, FL
Old 11-25-2021 , 01:01   Re: [ANY] Discord API (Send/Retrieve messages, list Guilds/Channels) UPDATE: 10/1/17
Reply With Quote #59

Any tips to fix this?

L 11/25/2021 - 00:00:17: [SM] Blaming: discord_api.smx
L 11/25/2021 - 00:00:17: [SM] Call stack trace:
L 11/25/2021 - 00:00:17: [SM] [0] SteamWorks_SetHTTPCallbacks
L 11/25/2021 - 00:00:17: [SM] [1] Line 76, discord/DiscordRequest.sp:iscordRequest.SetCallback s
L 11/25/2021 - 00:00:17: [SM] [2] Line 58, discord/SendWebHook.sp::SendWebHook
L 11/25/2021 - 00:00:17: [SM] [3] Line 84, discord/SendWebHook.sp::SendWebHookReceiveData
L 11/25/2021 - 00:00:18: [SM] Exception reported: Invalid Handle 0 (error: 4)
phantomx1 is offline
Pixon
New Member
Join Date: Jul 2022
Old 07-28-2022 , 11:30   Re: [ANY] Discord API (Send/Retrieve messages, list Guilds/Channels) UPDATE: 10/1/17
Reply With Quote #60

Hi,

I tried to install this plugin in order to make "csgotr_advanced_drop" plugin to work but im unable to make the plugin works :

L 07/28/2022 - 15:25:55: Error log file session closed.
L 07/28/2022 - 15:26:06: SourceMod error session started
L 07/28/2022 - 15:26:06: Info (map "de_mirage") (file "/home/csgoserver/serverfiles/csgo/addons/sourcemod/logs/errors_20220728.log")
L 07/28/2022 - 15:26:06: [SM] Unable to load plugin "csgotr-advanced_drop.smx": Could not find required plugin "discord-api"


I added the smx of discord-api but it doesn't work, I tried to compiled myself the discord-api.so to smx but I can't get it work :

discord_api.sp(6) : error 417: cannot read from file: "discord"
discord_api.sp( : error 417: cannot read from file: "smjansson"


other dependancies seem to be well installed but I can't get this one to work, would someone be able to help me ?
Pixon is offline
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

Forum Jump


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


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