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
GnomeChompski
Senior Member
Join Date: Jul 2012
Old 03-29-2018 , 16:47   Re: [ANY] Discord API (Send/Retrieve messages, list Guilds/Channels) UPDATE: 10/1/17
Reply With Quote #31

Is this alive still? the included test seems to do nothing. Messages won't sent/receive between the discord server and TF2 server.
__________________
GnomeChompski is offline
alphaearth
Senior Member
Join Date: Feb 2018
Location: Turkey
Old 04-21-2018 , 15:15   Re: [ANY] Discord API (Send/Retrieve messages, list Guilds/Channels) UPDATE: 10/1/17
Reply With Quote #32

I want to transfer the in-game chat to my discord channel to what channel i want
alphaearth is offline
ToasterKritz
Junior Member
Join Date: Mar 2018
Old 05-02-2018 , 01:01   Re: [ANY] Discord API (Send/Retrieve messages, list Guilds/Channels) UPDATE: 10/1/17
Reply With Quote #33

I've been trying to figure out if it is possible to give discord members a flag, however at the time it is very difficult to impossible, and webhooks is not the way to do it.
ToasterKritz is offline
Pala4
Senior Member
Join Date: Dec 2007
Old 05-25-2018 , 17:32   Re: [ANY] Discord API (Send/Retrieve messages, list Guilds/Channels) UPDATE: 10/1/17
Reply With Quote #34

Does it not work or it no longer works?

Spoiler
Pala4 is offline
StrikerMan780
AlliedModders Donor
Join Date: Jul 2009
Location: Canada
Old 06-23-2018 , 23:42   Re: [ANY] Discord API (Send/Retrieve messages, list Guilds/Channels) UPDATE: 10/1/17
Reply With Quote #35

Doesn't seem to work. The severely lacking documentation isn't helpful either.

EDIT: OK, it seems it does get guilds and channels, but Channel.IsText is broken, and so is Channel.GetID.

EDIT2: Updated to the code on GitHub. I can get messages from Discord to the server, but not the other way around. My bot also never shows as "online". When I try to send a message from the server to Discord, I get this message:
PHP Code:
L 06/24/2018 01:09:48: [discord_api.smx] [DISCORDCouldn't Send Message - Fail 0 400 
(Error 400 means Bad Request, btw.)

PHP Code:
#pragma semicolon 1

#define PLUGIN_VERSION "1.00"

#include <sourcemod>
#include <discord>

public Plugin myinfo = {
    
name "Relay for Discord",
    
author "StrikerTheHedgefox",
    
description "",
    
version PLUGIN_VERSION,
    
url ""
};

DiscordBot gBot null;
char channelID[256] = "FUCK";

public 
void OnPluginStart() {
    
//
}

public 
OnAllPluginsLoaded() {
    
gBot = new DiscordBot("KEY");
    
gBot.MessageCheckInterval 1.0;
    
gBot.GetGuilds(GuildList);
}

public 
void GuildList(DiscordBot botchar[] idchar[] namechar[] iconbool ownerint permissionsany data) {
    
//Retrieve all channels for the guild
    
PrintToChatAll("[DISCORD] Bot in guild: %s\n"name);
    
bot.GetGuildChannels(idChannelList);
}

public 
void ChannelList(DiscordBot botchar[] guildDiscordChannel Channelany data) {
    
//Verify that the channel is a text channel
    
    //Get name of channel
    
char name[32];
    
Channel.GetName(namesizeof(name));
    
PrintToChatAll("[DISCORD] Channel Name: %s\n"name);
        
    
//Compare name of channel to 'server-announcement'
    
if(StrEqual(name"server-relay"false)) {
        
//Start listening to channel
        
bot.StartListeningToChannel(ChannelOnMessage);
        
Channel.GetID(channelIDsizeof(channelID));
    }
}

public 
void OnMessage(DiscordBot botDiscordChannel channelDiscordMessage message)
{
    
//Received a message, print it out.
    
DiscordUser user message.GetAuthor();
    
char username[64];
    
user.GetUsername(usernamesizeof(username));
    
char messagecontent[255];
    
message.GetContent(messagecontentsizeof(messagecontent));
    
    
PrintToChatAll("\x0700FF00[\x07FFFF00Discord\x0700FF00] \x0700FFFF<\x07FFFFFF%s\x0700FFFF> \x07FFFFFF%s"usernamemessagecontent);
}

public 
Action:OnChatMessage(&clientHandle:recipientsString:name[], String:message[])
{
    if(!
StrEqual(channelID"FUCK"))
    {
        
char newString[255];
        
FormatEx(newStringsizeof(newString), "<%s> %s"namemessage);
        
gBot.SendMessageToChannelID(channelIDnewString);
    }


Last edited by StrikerMan780; 06-24-2018 at 02:12.
StrikerMan780 is offline
Bara
AlliedModders Donor
Join Date: Apr 2012
Location: Germany
Old 07-14-2018 , 09:29   Re: [ANY] Discord API (Send/Retrieve messages, list Guilds/Channels) UPDATE: 10/1/17
Reply With Quote #36

@StrikerMan780, do you followed this "How-To", especially step 4?
It works fine on my test server(s).
__________________
Discord (Bara#5006) | My Plugins (GitHub)
You like my work? Support is not a crime.
Bara is offline
ssandiss
Junior Member
Join Date: Jan 2018
Location: Sweden
Old 07-29-2018 , 15:30   Re: [ANY] Discord API (Send/Retrieve messages, list Guilds/Channels) UPDATE: 10/1/17
Reply With Quote #37

Does this plugin support custom messages with information from the Server.

For example.
Let's call the players following:

Player 1 = Steve
Admin 1 = Sandis

I do the command !calladmin in-game. Choose Steve And enter the reason "Own Reason", I put in "Player is disrespecting."
Is there a way to make the Discord message send like @WhateverRole <Player> has been reported by <ReporingPlayer> for <Reason>.

Currently there is no way to see if there is someone abusing the !calladmin system whilst getting the messages through your plugin.
Otherwise. Great plugin!
ssandiss is offline
Sahrechiiz
Junior Member
Join Date: Jun 2016
Old 08-04-2018 , 16:24   Re: [ANY] Discord API (Send/Retrieve messages, list Guilds/Channels) UPDATE: 10/1/17
Reply With Quote #38

Quote:
Originally Posted by Nextars View Post
where to put bot token in discord_Api.sp i can't find
same question
anyone care to answer plz ?
Sahrechiiz is offline
hmmmmm
Great Tester of Whatever
Join Date: Mar 2017
Location: ...
Old 08-04-2018 , 17:01   Re: [ANY] Discord API (Send/Retrieve messages, list Guilds/Channels) UPDATE: 10/1/17
Reply With Quote #39

Quote:
Originally Posted by Sahrechiiz View Post
same question
anyone care to answer plz ?
You don't put the bot token in the discord_api plugin, you put it in any plugins that use the API to interact with a discord bot.
hmmmmm is offline
Sahrechiiz
Junior Member
Join Date: Jun 2016
Old 08-07-2018 , 11:45   Re: [ANY] Discord API (Send/Retrieve messages, list Guilds/Channels) UPDATE: 10/1/17
Reply With Quote #40

Quote:
Originally Posted by hmmmmm View Post
You don't put the bot token in the discord_api plugin, you put it in any plugins that use the API to interact with a discord bot.
haha thx. I found that out after a while.
Sahrechiiz 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 15:53.


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