Skip to content

Commit

Permalink
format and documenting botway_dart library
Browse files Browse the repository at this point in the history
  • Loading branch information
abdfnx committed Jul 2, 2022
1 parent fa79297 commit 4b4abaf
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions packages/botway_dart/lib/src/botway_dart_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:convert';
import 'package:yaml/yaml.dart';
import 'package:path/path.dart' as p;

/// This is Botway class
class Botway {
get_bot_info(String value) {
if (File(".botway.yaml").existsSync()) {
Expand Down Expand Up @@ -30,10 +31,12 @@ class Botway {

dynamic get BotwayConfig => json.decode(BotwayConfigFile());

/// This function returns your bot token
Get_Token() {
return BotwayConfig["botway"]["bots"][get_bot_info("name")]["bot_token"];
}

/// This function returns your bot app id (or app token for `slack`)
Get_App_Id() {
String value = "bot_app_id";

Expand All @@ -44,19 +47,25 @@ class Botway {
return BotwayConfig["botway"]["bots"][get_bot_info("name")][value];
}

/// This function returns your guild id of a server
Get_Guild_Id(String server_name) {
if (get_bot_info("type") != "discord") {
throw Exception("ERROR: This function/feature is only working with discord bots");
throw Exception(
"ERROR: This function/feature is only working with discord bots");
} else {
return BotwayConfig["botway"]["bots"][get_bot_info("name")]["guilds"][server_name]["server_id"];
return BotwayConfig["botway"]["bots"][get_bot_info("name")]["guilds"]
[server_name]["server_id"];
}
}

/// This function returns the signing secret of your slack bot
Get_Signing_Secret() {
if (get_bot_info("type") != "slack") {
throw Exception("ERROR: This function/feature is only working with slack bots");
throw Exception(
"ERROR: This function/feature is only working with slack bots");
} else {
return BotwayConfig["botway"]["bots"][get_bot_info("name")]["signing_secret"];
return BotwayConfig["botway"]["bots"][get_bot_info("name")]
["signing_secret"];
}
}
}

0 comments on commit 4b4abaf

Please sign in to comment.