Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Extra libraries, Code snippets, applications etc. » Applications created with U++ » Bot library for discord, bombs example adapted.
Bot library for discord, bombs example adapted. [message #49999] Thu, 14 June 2018 22:11 Go to next message
jjacksonRIAB is currently offline  jjacksonRIAB
Messages: 219
Registered: June 2011
Experienced Member
https://github.com/BornTactical/DiscordUpp
It's far from full-featured, but I've had fun writing simple bots with it.
Re: Bot library for discord, bombs example adapted. [message #51566 is a reply to message #49999] Wed, 17 April 2019 11:29 Go to previous messageGo to next message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
Hello jjacksonRIAB,

Have tested it today, worked like charm ! I think I will use it to create a strong bot on my discord Smile !

thanks a lot for your Job !
Re: Bot library for discord, bombs example adapted. [message #51567 is a reply to message #51566] Wed, 17 April 2019 11:52 Go to previous messageGo to next message
jjacksonRIAB is currently offline  jjacksonRIAB
Messages: 219
Registered: June 2011
Experienced Member
Glad you found it useful. Very Happy
Re: Bot library for discord, bombs example adapted. [message #52668 is a reply to message #49999] Fri, 08 November 2019 13:39 Go to previous messageGo to next message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
Hello JjacksonRIAB,

I face a problem with your lib, when I use it on Linux it crash after few hours of running.

here is the crash message :
https://i.imgur.com/TWcAIOK.png

last line : "Erreur de segmentation" mean "segmentation error"

The code I use to produce this error is really simple :
#include <Core/Core.h>
#include "Discord.h"
using namespace Upp;

CONSOLE_APP_MAIN
{
	
	Discord bot(<botID>, <botToken>);
    
    bot.WhenMessageCreated = [&](ValueMap payload) {
        String channel  = payload["d"]["channel_id"];
        String content  = payload["d"]["content"];
        String userName = payload["d"]["username"];
        
        if(content.StartsWith("!hello")) {
            bot.CreateMessage(channel, "hello, world!");
        }
    };
    
    bot.Listen();
}


Have you any idea of how to fix this ?

Thanks in advance.
Re: Bot library for discord, bombs example adapted. [message #52670 is a reply to message #52668] Fri, 08 November 2019 14:33 Go to previous messageGo to next message
jjacksonRIAB is currently offline  jjacksonRIAB
Messages: 219
Registered: June 2011
Experienced Member
In Discord.h I'd add

Event<> BeforeSocketReceive,
        WhenDisconnected;

and I'd call it from Discord.cpp

else if(ws.IsClosed()) {
    LOG("Socket closed unexpectedly");
    LOG(ws.GetError());
    WhenDisconnected();
    return;
}

Hopefully then I could just subscribe to that event and run Listen() again.
bot.WhenMessageCreated = [&](ValueMap payload) {
    String channel  = payload["d"]["channel_id"];
    String content  = payload["d"]["content"];
    String userName = payload["d"]["username"];
        
    if(content.StartsWith("!hello")) {
        bot.CreateMessage(channel, "hello, world!");
    }
};

bot.WhenDisconnected = [] { 
    bot.Listen();
};


I think your connection is just being hard killed from Discord's end without the courtesy of a Resume event.
Re: Bot library for discord, bombs example adapted. [message #52695 is a reply to message #49999] Tue, 12 November 2019 09:48 Go to previous messageGo to next message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
Hello jjacksonRIAB,

Thanks for your help, I have try this fix but, Unfortunately the bot still crash after few day's of running. Since I compiled it in release mode I dont get any log and I got no idea of why it's crashing. I will dig up the case.

Do your bot crash after few day ? if no, what's your OS ?

Thank's in advance
Re: Bot library for discord, bombs example adapted. [message #52757 is a reply to message #52695] Tue, 19 November 2019 00:18 Go to previous message
jjacksonRIAB is currently offline  jjacksonRIAB
Messages: 219
Registered: June 2011
Experienced Member
Unfortunately I don't think I'll be able to assist in tracking this one down. My machine has some kind of hardware failure (I'm assuming a bad PSU) which causes it to spontaneously and randomly reboot. I'd be lucky if I could get a bot running for an entire day, let alone three, so my only option right now is guesswork.
Previous Topic: U++ SSH package and Turtle in action (Videos)
Next Topic: UltimateOpenGL [BETA] 3D engine
Goto Forum:
  


Current Time: Thu Mar 28 23:50:36 CET 2024

Total time taken to generate the page: 0.01062 seconds