Compare commits

..

10 Commits
4.0.0 ... 4.0.2

Author SHA1 Message Date
Kwoth
864a8fd7b6 Updated CHANGELOG.md 2022-03-03 23:22:12 +01:00
Kwoth
e7db631151 Fixed .rero issue which was introduced in 4.0 2022-03-03 22:32:28 +01:00
Kwoth
c7b312196e Added upgrade instructions to the docs 2022-03-03 10:15:17 +01:00
Kwoth
8cd7a50720 Updated guide to reflect the new changes to the installer 2022-03-03 03:09:59 +01:00
Kwoth
f82c4c7019 - Updated Changelog.md
- Fixed intent error message condition
2022-03-03 02:45:18 +01:00
Kwoth
03367c5ec4 Added usePrivilegedIntents to creds.yml as an option for users who don't have them enabled
Added an explanation on how to enable intents if the bot doesn't have them and fails to login
2022-03-03 02:31:32 +01:00
Kwoth
01cc6e52d5 Enabled client log everywhere which could hopefully print login errors 2022-03-03 01:42:22 +01:00
Kwoth
c903bc9003 Added one more log line to pinpoint the login hang 2022-03-03 01:33:05 +01:00
Kwoth
323699d103 Small change to Bot.cs to pinpoint the logging in hang issue 2022-03-03 01:13:49 +01:00
Kwoth
63ced029ab Updated CHANGELOG.md 2022-03-02 06:54:17 +01:00
10 changed files with 95 additions and 38 deletions

View File

@@ -5,6 +5,19 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
## Unreleased ## Unreleased
- More cool stuff coming soon
## [4.0.2] - 03.0.3.2022
- Fixed `.rero` not working due to a bug introduced in 4.0
## [4.0.1] - 03.03.2022
- Added `usePrivilegedIntents` to creds.yml if you don't have or don't want (?) to use them
- Added a human-readable, detailed error message if logging in fails due to missing privileged intents
## [4.0.0] - 02.03.2022
### Added ### Added
- Added `.deleteemptyservers` command - Added `.deleteemptyservers` command
- Added `.curtr <id>` which lets you see full information about one of your own transactions with the specified id - Added `.curtr <id>` which lets you see full information about one of your own transactions with the specified id

View File

@@ -26,14 +26,24 @@ It is recommended that you use **Ubuntu 20.04**, as there have been nearly no pr
## Linux From Source ## Linux From Source
Open Terminal (if you're on an installation with a window manager) and navigate to the location where you want to install the bot (for example `cd ~`) ##### Migration from v3 -> v4
Follow the following few steps only if you're migrating from v3. If not, skip to installation instructions.
Use the new installer script: `cd ~ && wget -N https://gitlab.com/Kwoth/nadeko-bash-installer/-/raw/v4/linuxAIO.sh && bash linuxAIO.sh`
> - Install prerequisites (type `1` and press `enter`)
> - Download (type `2` and press `enter`)
> - Run (type `3` and press `enter`)
> - Done
##### Installation Instructions ##### Installation Instructions
1. Download and run the **new** installer script `cd ~ && wget -N https://gitlab.com/Kwoth/nadeko-bash-installer/-/raw/master/linuxAIO.sh && bash linuxAIO.sh` Open Terminal (if you're on an installation with a window manager) and navigate to the location where you want to install the bot (for example `cd ~`)
1. Download and run the **new** installer script `cd ~ && wget -N https://gitlab.com/Kwoth/nadeko-bash-installer/-/raw/v4/linuxAIO.sh && bash linuxAIO.sh`
2. Install prerequisites (type `1` and press enter) 2. Install prerequisites (type `1` and press enter)
3. Download the bot (type `2` and press enter) 3. Download the bot (type `2` and press enter)
4. Exit the installer (type `5` and press enter) 4. Exit the installer (type `6` and press enter)
5. Copy the creds.yml template `cp nadekobot/output/creds_example.yml nadekobot/output/creds.yml` 5. Copy the creds.yml template `cp nadekobot/output/creds_example.yml nadekobot/output/creds.yml`
6. Open `nadekobot/output/creds.yml` with your favorite text editor. We will use nano here 6. Open `nadekobot/output/creds.yml` with your favorite text editor. We will use nano here
- `nano nadekobot/output/creds.yml` - `nano nadekobot/output/creds.yml`
@@ -42,12 +52,13 @@ Open Terminal (if you're on an installation with a window manager) and navigate
- `CTRL` + `X` - `CTRL` + `X`
- `Y` - `Y`
- `Enter` - `Enter`
8. Run the bot (type `3` and press enter) 8. Run the installer script again `cd ~ && wget -N https://gitlab.com/Kwoth/nadeko-bash-installer/-/raw/v4/linuxAIO.sh && bash linuxAIO.sh`
9. Run the bot (type `3` and press enter)
##### Source Update Instructions ##### Source Update Instructions
1. ⚠ Stop the bot ⚠ 1. ⚠ Stop the bot ⚠
2. Update and run the **new** installer script `cd ~ && wget -N https://gitlab.com/Kwoth/nadeko-bash-installer/-/raw/master/linuxAIO.sh && bash linuxAIO.sh` 2. Update and run the **new** installer script `cd ~ && wget -N https://gitlab.com/Kwoth/nadeko-bash-installer/-/raw/v4/linuxAIO.sh && bash linuxAIO.sh`
3. Update the bot (type `2` and press enter) 3. Update the bot (type `2` and press enter)
4. Run the bot (type `3` and press enter) 4. Run the bot (type `3` and press enter)
5. 🎉 5. 🎉

View File

@@ -31,7 +31,7 @@ sudo ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
##### Installation Instructions ##### Installation Instructions
1. Download and run the **new** installer script `cd ~ && wget -N https://gitlab.com/Kwoth/nadeko-bash-installer/-/raw/master/linuxAIO.sh && bash linuxAIO.sh` 1. Download and run the **new** installer script `cd ~ && wget -N https://gitlab.com/Kwoth/nadeko-bash-installer/-/raw/v4/linuxAIO.sh && bash linuxAIO.sh`
2. Install prerequisites (type `1` and press enter) 2. Install prerequisites (type `1` and press enter)
3. Download the bot (type `2` and press enter) 3. Download the bot (type `2` and press enter)
4. Exit the installer in order to set up your `creds.yml` 4. Exit the installer in order to set up your `creds.yml`
@@ -49,7 +49,7 @@ sudo ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
##### Update Instructions ##### Update Instructions
1. ⚠ Stop the bot 1. ⚠ Stop the bot
2. Update and run the **new** installer script `cd ~ && wget -N https://gitlab.com/Kwoth/nadeko-bash-installer/-/raw/master/linuxAIO.sh && bash linuxAIO.sh` 2. Update and run the **new** installer script `cd ~ && wget -N https://gitlab.com/Kwoth/nadeko-bash-installer/-/raw/v4/linuxAIO.sh && bash linuxAIO.sh`
3. Update the bot (type `2` and press enter) 3. Update the bot (type `2` and press enter)
4. Run the bot (type `3` and press enter) 4. Run the bot (type `3` and press enter)
5. 🎉 5. 🎉

View File

@@ -53,6 +53,9 @@ public sealed class Bot
50; 50;
#endif #endif
if(!_creds.UsePrivilegedIntents)
Log.Warning("You are not using privileged intents. Some features will not work properly");
Client = new(new() Client = new(new()
{ {
MessageCacheSize = messageCacheSize, MessageCacheSize = messageCacheSize,
@@ -63,8 +66,10 @@ public sealed class Bot
AlwaysDownloadUsers = false, AlwaysDownloadUsers = false,
AlwaysResolveStickers = false, AlwaysResolveStickers = false,
AlwaysDownloadDefaultStickers = false, AlwaysDownloadDefaultStickers = false,
GatewayIntents = GatewayIntents.All, GatewayIntents = _creds.UsePrivilegedIntents
LogGatewayIntentWarnings = false ? GatewayIntents.All
: GatewayIntents.AllUnprivileged,
LogGatewayIntentWarnings = false,
}); });
_commandService = new(new() _commandService = new(new()
@@ -75,9 +80,7 @@ public sealed class Bot
// _interactionService = new(Client.Rest); // _interactionService = new(Client.Rest);
#if GLOBAL_NADEKO || DEBUG
Client.Log += Client_Log; Client.Log += Client_Log;
#endif
} }
@@ -216,30 +219,28 @@ public sealed class Bot
private async Task LoginAsync(string token) private async Task LoginAsync(string token)
{ {
var clientReady = new TaskCompletionSource<bool>(); var clientReady = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
Task SetClientReady() async Task SetClientReady()
{ {
_ = Task.Run(async () => clientReady.TrySetResult(true);
try
{ {
clientReady.TrySetResult(true); foreach (var chan in await Client.GetDMChannelsAsync())
try await chan.CloseAsync();
{ }
foreach (var chan in await Client.GetDMChannelsAsync()) catch
await chan.CloseAsync(); {
} // ignored
catch }
{
// ignored
}
});
return Task.CompletedTask;
} }
//connect //connect
Log.Information("Shard {ShardId} logging in ...", Client.ShardId); Log.Information("Shard {ShardId} logging in ...", Client.ShardId);
try try
{ {
Client.Ready += SetClientReady;
await Client.LoginAsync(TokenType.Bot, token); await Client.LoginAsync(TokenType.Bot, token);
await Client.StartAsync(); await Client.StartAsync();
} }
@@ -254,8 +255,7 @@ public sealed class Bot
Helpers.ReadErrorAndExit(4); Helpers.ReadErrorAndExit(4);
} }
Client.Ready += SetClientReady; await clientReady.Task.ConfigureAwait(false);
await clientReady.Task;
Client.Ready -= SetClientReady; Client.Ready -= SetClientReady;
Client.JoinedGuild += Client_JoinedGuild; Client.JoinedGuild += Client_JoinedGuild;
@@ -341,7 +341,33 @@ public sealed class Bot
private Task Client_Log(LogMessage arg) private Task Client_Log(LogMessage arg)
{ {
if (arg.Exception is not null) if (arg.Message?.Contains("unknown dispatch", StringComparison.InvariantCultureIgnoreCase) ?? false)
return Task.CompletedTask;
if (arg.Exception is { InnerException: WebSocketClosedException { CloseCode: 4014 } })
{
Log.Error(@"
Login failed.
*** Please enable privileged intents ***
Certain Nadeko features require Discord's privileged gateway intents.
These include greeting and goodbye messages, as well as creating the Owner message channels for DM forwarding.
How to enable privileged intents:
1. Head over to the Discord Developer Portal https://discord.com/developers/applications/
2. Select your Application.
3. Click on `Bot` in the left side navigation panel, and scroll down to the intents section.
4. Enable both intents.
5. Restart your bot.
Read this only if your bot is in 100 or more servers:
You'll need to apply to use the intents with Discord, but for small selfhosts, all that is required is enabling the intents in the developer portal.
Yes, this is a new thing from Discord, as of October 2020. No, there's nothing we can do about it. Yes, we're aware it worked before.
While waiting for your bot to be accepted, you can change the 'usePrivilegedIntents' inside your creds.yml to 'false', although this will break many of the nadeko's features");
}
else if (arg.Exception is not null)
Log.Warning(arg.Exception, "{ErrorSource} | {ErrorMessage}", arg.Source, arg.Message); Log.Warning(arg.Exception, "{ErrorSource} | {ErrorMessage}", arg.Source, arg.Message);
else else
Log.Warning("{ErrorSource} | {ErrorMessage}", arg.Source, arg.Message); Log.Warning("{ErrorSource} | {ErrorMessage}", arg.Source, arg.Message);

View File

@@ -15,6 +15,9 @@ public sealed class Creds : IBotCredentials
**DO NOT ADD PEOPLE YOU DON'T TRUST**")] **DO NOT ADD PEOPLE YOU DON'T TRUST**")]
public ICollection<ulong> OwnerIds { get; set; } public ICollection<ulong> OwnerIds { get; set; }
[Comment("Keep this on 'true' unless you're sure your bot shouldn't use privileged intents or you're waiting to be accepted")]
public bool UsePrivilegedIntents { get; set; }
[Comment(@"The number of shards that the bot will running on. [Comment(@"The number of shards that the bot will running on.
Leave at 1 if you don't know what you're doing.")] Leave at 1 if you don't know what you're doing.")]
public int TotalShards { get; set; } public int TotalShards { get; set; }
@@ -96,8 +99,9 @@ Windows default
public Creds() public Creds()
{ {
Version = 3; Version = 4;
Token = string.Empty; Token = string.Empty;
UsePrivilegedIntents = true;
OwnerIds = new List<ulong>(); OwnerIds = new List<ulong>();
TotalShards = 1; TotalShards = 1;
GoogleApiKey = string.Empty; GoogleApiKey = string.Empty;

View File

@@ -6,6 +6,7 @@ public interface IBotCredentials
string Token { get; } string Token { get; }
string GoogleApiKey { get; } string GoogleApiKey { get; }
ICollection<ulong> OwnerIds { get; } ICollection<ulong> OwnerIds { get; }
bool UsePrivilegedIntents { get; }
string RapidApiKey { get; } string RapidApiKey { get; }
Creds.DbOptions Db { get; } Creds.DbOptions Db { get; }

View File

@@ -27,7 +27,7 @@ public partial class Administration
if (input.Length % 2 != 0 || target is null) if (input.Length % 2 != 0 || target is null)
return; return;
var all = await input.Chunk(input.Length / 2) var all = await input.Chunk(2)
.Select(async x => .Select(async x =>
{ {
var inputRoleStr = x.First(); var inputRoleStr = x.First();

View File

@@ -165,9 +165,9 @@ public sealed class BotCredsProvider : IBotCredsProvider
if (File.Exists(CREDS_FILE_NAME)) if (File.Exists(CREDS_FILE_NAME))
{ {
var creds = Yaml.Deserializer.Deserialize<Creds>(File.ReadAllText(CREDS_FILE_NAME)); var creds = Yaml.Deserializer.Deserialize<Creds>(File.ReadAllText(CREDS_FILE_NAME));
if (creds.Version <= 2) if (creds.Version <= 3)
{ {
creds.Version = 3; creds.Version = 4;
File.WriteAllText(CREDS_FILE_NAME, Yaml.Serializer.Serialize(creds)); File.WriteAllText(CREDS_FILE_NAME, Yaml.Serializer.Serialize(creds));
} }
} }

View File

@@ -7,7 +7,7 @@ namespace NadekoBot.Services;
public class StatsService : IStatsService, IReadyExecutor, INService, IDisposable public class StatsService : IStatsService, IReadyExecutor, INService, IDisposable
{ {
public const string BOT_VERSION = "4.0.0"; public const string BOT_VERSION = "4.0.1";
public string Author public string Author
=> "Kwoth#2452"; => "Kwoth#2452";

View File

@@ -1,10 +1,12 @@
# DO NOT CHANGE # DO NOT CHANGE
version: 3 version: 4
# Bot token. Do not share with anyone ever -> https://discordapp.com/developers/applications/ # Bot token. Do not share with anyone ever -> https://discordapp.com/developers/applications/
token: '' token: ''
# List of Ids of the users who have bot owner permissions # List of Ids of the users who have bot owner permissions
# **DO NOT ADD PEOPLE YOU DON'T TRUST** # **DO NOT ADD PEOPLE YOU DON'T TRUST**
ownerIds: [] ownerIds: []
# Keep this on 'true' unless you're sure your bot shouldn't use privileged intents or you're waiting to be accepted
usePrivilegedIntents: true
# The number of shards that the bot will running on. # The number of shards that the bot will running on.
# Leave at 1 if you don't know what you're doing. # Leave at 1 if you don't know what you're doing.
totalShards: 1 totalShards: 1