-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replace pointers for channels and interaction options
- Loading branch information
Showing
19 changed files
with
164 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#pragma once | ||
|
||
#include <variant> | ||
|
||
#include "Channel.h" | ||
#include "DMChannel.h" | ||
#include "GuildChannel.h" | ||
#include "VoiceChannel.h" | ||
|
||
namespace DiscordCPP { | ||
using ChannelVariant = std::variant<DMChannel, VoiceChannel, GuildChannel, Channel>; | ||
|
||
class ChannelHelper { | ||
public: | ||
DLL_EXPORT static ChannelVariant channel_from_json(Discord* client, const json& data, const std::string& token) { | ||
switch (data.at("type").get<int>()) { | ||
case Channel::Type::GUILD_TEXT: | ||
case Channel::Type::GUILD_NEWS: | ||
return GuildChannel(data, token); | ||
case Channel::Type::GUILD_VOICE: | ||
return VoiceChannel(client, data, token); | ||
case Channel::Type::DM: | ||
case Channel::Type::GROUP_DM: | ||
return DMChannel(data, token); | ||
default: | ||
return Channel(data, token); | ||
} | ||
} | ||
|
||
DLL_EXPORT static std::string get_channel_id(const ChannelVariant& channel) { | ||
return std::visit([](auto& c) { return c.get_id(); }, channel); | ||
} | ||
}; | ||
} // namespace DiscordCPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.