Moved IDs to .env
This commit is contained in:
1 parent
5184d9bf8a
commit
9aaa0204b8
1 file changed
+35
-7
+35
-7
@@ -18,7 +18,10 @@ class Program
|
|||||||
{
|
{
|
||||||
var config = new DiscordSocketConfig()
|
var config = new DiscordSocketConfig()
|
||||||
{
|
{
|
||||||
GatewayIntents = GatewayIntents.AllUnprivileged | GatewayIntents.MessageContent | GatewayIntents.GuildVoiceStates,
|
GatewayIntents = GatewayIntents.AllUnprivileged
|
||||||
|
| GatewayIntents.MessageContent
|
||||||
|
| GatewayIntents.GuildVoiceStates,
|
||||||
|
|
||||||
EnableVoiceDaveEncryption = true
|
EnableVoiceDaveEncryption = true
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -31,7 +34,7 @@ class Program
|
|||||||
|
|
||||||
if (string.IsNullOrEmpty(token))
|
if (string.IsNullOrEmpty(token))
|
||||||
{
|
{
|
||||||
Console.WriteLine("[Error] Discord token is missing from the environment variables.");
|
Console.WriteLine("[Error] DISCORD_TOKEN is missing.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +46,7 @@ class Program
|
|||||||
|
|
||||||
private Task LogAsync(LogMessage message)
|
private Task LogAsync(LogMessage message)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"[Discord] {message.ToString()}");
|
Console.WriteLine($"[Discord] {message}");
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,7 +54,21 @@ class Program
|
|||||||
{
|
{
|
||||||
Console.WriteLine($"[Client] Connected successfully as {_client.CurrentUser}.");
|
Console.WriteLine($"[Client] Connected successfully as {_client.CurrentUser}.");
|
||||||
|
|
||||||
_ = _client.SetGameAsync("Among Us", "https://twitch.tv/mon_pseudo_twitch", ActivityType.Streaming);
|
var status = Environment.GetEnvironmentVariable("BOT_STATUS") ?? "Among Us";
|
||||||
|
var streamUrl = Environment.GetEnvironmentVariable("BOT_STREAM_URL");
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(streamUrl))
|
||||||
|
{
|
||||||
|
_ = _client.SetGameAsync(
|
||||||
|
status,
|
||||||
|
streamUrl,
|
||||||
|
ActivityType.Streaming
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_ = _client.SetGameAsync(status);
|
||||||
|
}
|
||||||
|
|
||||||
_ = Task.Run(async () =>
|
_ = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
@@ -59,10 +76,21 @@ class Program
|
|||||||
{
|
{
|
||||||
await Task.Delay(2000);
|
await Task.Delay(2000);
|
||||||
|
|
||||||
ulong guildId = 1536666691923353703;
|
var guildId = ulong.Parse(
|
||||||
ulong vocalId = 1540346109967208598;
|
Environment.GetEnvironmentVariable("GUILD_ID")
|
||||||
|
?? throw new InvalidOperationException("GUILD_ID is missing.")
|
||||||
|
);
|
||||||
|
|
||||||
await VocalManager.ConnectToVoiceChannelAsync(_client, guildId, vocalId);
|
var voiceId = ulong.Parse(
|
||||||
|
Environment.GetEnvironmentVariable("VOICE_CHANNEL_ID")
|
||||||
|
?? throw new InvalidOperationException("VOICE_CHANNEL_ID is missing.")
|
||||||
|
);
|
||||||
|
|
||||||
|
await VocalManager.ConnectToVoiceChannelAsync(
|
||||||
|
_client,
|
||||||
|
guildId,
|
||||||
|
voiceId
|
||||||
|
);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user